on master help sign in
Update to use Pandoc 1.14
commiteb4ea434a6b98f252ff82fface9cd9107ddc43ed authorJasper Van der Jeugt <m@jaspervdj.be> dateFri 29 May 2015, 11:52 (11 years ago) parent3728288
5 files changed+33−16
hakyll.cabal+3−3 src/Hakyll/Web/Pandoc.hs+21−10 src/Hakyll/Web/Pandoc/Biblio.hs+2−2 tests/Hakyll/Core/Runtime/Tests.hs+1−1 web/releases.markdown+6
hakyll.cabal+3−3
@@ -1,5 +1,5 @@
11Name: hakyll
2−Version: 4.6.9.0
2+Version: 4.7.0.0
33
44Synopsis: A static website compiler library
55Description:
@@ -158,7 +158,7 @@ Library
158158 network-uri >= 2.6 && < 2.7,
159159 old-locale >= 1.0 && < 1.1,
160160 old-time >= 1.0 && < 1.2,
161− pandoc >= 1.12.4 && < 1.14,
161+ pandoc >= 1.14 && < 1.15,
162162 pandoc-citeproc >= 0.4 && < 0.8,
163163 parsec >= 3.0 && < 3.2,
164164 process >= 1.0 && < 1.3,
@@ -246,7 +246,7 @@ Test-suite hakyll-tests
246246 network-uri >= 2.6 && < 2.7,
247247 old-locale >= 1.0 && < 1.1,
248248 old-time >= 1.0 && < 1.2,
249− pandoc >= 1.12.4 && < 1.14,
249+ pandoc >= 1.14 && < 1.15,
250250 pandoc-citeproc >= 0.4 && < 0.8,
251251 parsec >= 3.0 && < 3.2,
252252 process >= 1.0 && < 1.3,
src/Hakyll/Web/Pandoc.hs+21−10
@@ -26,6 +26,7 @@ import Control.Applicative ((<$>))
2626import qualified Data.Set as S
2727import Data.Traversable (traverse)
2828import Text.Pandoc
29+import Text.Pandoc.Error (PandocError (..))
2930
3031
3132--------------------------------------------------------------------------------
@@ -36,17 +37,25 @@ import Hakyll.Web.Pandoc.FileType
3637
3738--------------------------------------------------------------------------------
3839-- | Read a string using pandoc, with the default options
39−readPandoc :: Item String -- ^ String to read
40− -> Item Pandoc -- ^ Resulting document
40+readPandoc
41+ :: Item String -- ^ String to read
42+ -> Compiler (Item Pandoc) -- ^ Resulting document
4143readPandoc = readPandocWith defaultHakyllReaderOptions
4244
4345
4446--------------------------------------------------------------------------------
4547-- | Read a string using pandoc, with the supplied options
46−readPandocWith :: ReaderOptions -- ^ Parser options
47− -> Item String -- ^ String to read
48− -> Item Pandoc -- ^ Resulting document
49−readPandocWith ropt item = fmap (reader ropt (itemFileType item)) item
48+readPandocWith
49+ :: ReaderOptions -- ^ Parser options
50+ -> Item String -- ^ String to read
51+ -> Compiler (Item Pandoc) -- ^ Resulting document
52+readPandocWith ropt item =
53+ case traverse (reader ropt (itemFileType item)) item of
54+ Left (ParseFailure err) -> fail $
55+ "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
56+ Left (ParsecError _ err) -> fail $
57+ "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
58+ Right item' -> return item'
5059 where
5160 reader ro t = case t of
5261 DocBook -> readDocBook ro
@@ -81,15 +90,17 @@ writePandocWith wopt = fmap $ writeHtmlString wopt
8190
8291--------------------------------------------------------------------------------
8392-- | Render the resource using pandoc
84−renderPandoc :: Item String -> Item String
93+renderPandoc :: Item String -> Compiler (Item String)
8594renderPandoc =
8695 renderPandocWith defaultHakyllReaderOptions defaultHakyllWriterOptions
8796
8897
8998--------------------------------------------------------------------------------
9099-- | Render the resource using pandoc
91−renderPandocWith :: ReaderOptions -> WriterOptions -> Item String -> Item String
92−renderPandocWith ropt wopt = writePandocWith wopt . readPandocWith ropt
100+renderPandocWith
101+ :: ReaderOptions -> WriterOptions -> Item String -> Compiler (Item String)
102+renderPandocWith ropt wopt item =
103+ writePandocWith wopt <$> readPandocWith ropt item
93104
94105
95106--------------------------------------------------------------------------------
@@ -128,7 +139,7 @@ pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
128139 -> Compiler (Item String)
129140pandocCompilerWithTransformM ropt wopt f =
130141 writePandocWith wopt <$>
131− (traverse f =<< readPandocWith ropt <$> getResourceBody)
142+ (traverse f =<< readPandocWith ropt =<< getResourceBody)
132143
133144
134145--------------------------------------------------------------------------------
src/Hakyll/Web/Pandoc/Biblio.hs+2−2
@@ -100,8 +100,8 @@ readPandocBiblio ropt csl biblio item = do
100100 -- actual page. If we don't do this, pandoc won't even consider them
101101 -- citations!
102102 let Biblio refs = itemBody biblio
103− pandoc = itemBody $ readPandocWith ropt item
104− pandoc' = processCites style refs pandoc
103+ pandoc <- itemBody <$> readPandocWith ropt item
104+ let pandoc' = processCites style refs pandoc
105105
106106 return $ fmap (const pandoc') item
107107
tests/Hakyll/Core/Runtime/Tests.hs+1−1
@@ -39,7 +39,7 @@ case01 = do
3939 compile $ do
4040 getResourceBody
4141 >>= saveSnapshot "raw"
42− >>= return . renderPandoc
42+ >>= renderPandoc
4343
4444 create ["bodies.txt"] $ do
4545 route idRoute
web/releases.markdown+6
@@ -4,6 +4,12 @@ title: Releases
44
55# Releases
66
7+## Hakyll 4.7.0.0
8+
9+- Bump pandoc to 1.14. This will break a lot of sites: since the pandoc parser
10+ might now return an error message, it is ran inside the `Compiler` monad where
11+ we can nicely handle the error.
12+
713## Hakyll 4.6.9.0
814
915- Let caller decide exit (fix by Erik Dominikus)