on master help sign in
Update to use Pandoc 1.14
eb4ea43Jasper Van der Jeugt
hakyll.cabal+3−3
@@ -1,5 +1,5 @@
1Name: hakyll
1Name: hakyll
2−Version: 4.6.9.0
2+Version: 4.7.0.0
3
3
4Synopsis: A static website compiler library
4Synopsis: A static website compiler library
5Description:
5Description:
@@ -158,7 +158,7 @@ Library
158 network-uri >= 2.6 && < 2.7,
158 network-uri >= 2.6 && < 2.7,
159 old-locale >= 1.0 && < 1.1,
159 old-locale >= 1.0 && < 1.1,
160 old-time >= 1.0 && < 1.2,
160 old-time >= 1.0 && < 1.2,
161− pandoc >= 1.12.4 && < 1.14,
161+ pandoc >= 1.14 && < 1.15,
162 pandoc-citeproc >= 0.4 && < 0.8,
162 pandoc-citeproc >= 0.4 && < 0.8,
163 parsec >= 3.0 && < 3.2,
163 parsec >= 3.0 && < 3.2,
164 process >= 1.0 && < 1.3,
164 process >= 1.0 && < 1.3,
@@ -246,7 +246,7 @@ Test-suite hakyll-tests
246 network-uri >= 2.6 && < 2.7,
246 network-uri >= 2.6 && < 2.7,
247 old-locale >= 1.0 && < 1.1,
247 old-locale >= 1.0 && < 1.1,
248 old-time >= 1.0 && < 1.2,
248 old-time >= 1.0 && < 1.2,
249− pandoc >= 1.12.4 && < 1.14,
249+ pandoc >= 1.14 && < 1.15,
250 pandoc-citeproc >= 0.4 && < 0.8,
250 pandoc-citeproc >= 0.4 && < 0.8,
251 parsec >= 3.0 && < 3.2,
251 parsec >= 3.0 && < 3.2,
252 process >= 1.0 && < 1.3,
252 process >= 1.0 && < 1.3,
src/Hakyll/Web/Pandoc.hs+21−10
@@ -26,6 +26,7 @@ import Control.Applicative ((<$>))
26import qualified Data.Set as S
26import qualified Data.Set as S
27import Data.Traversable (traverse)
27import Data.Traversable (traverse)
28import Text.Pandoc
28import Text.Pandoc
29+import Text.Pandoc.Error (PandocError (..))
29
30
30
31
31--------------------------------------------------------------------------------
32--------------------------------------------------------------------------------
@@ -36,17 +37,25 @@ import Hakyll.Web.Pandoc.FileType
36
37
37--------------------------------------------------------------------------------
38--------------------------------------------------------------------------------
38-- | Read a string using pandoc, with the default options
39-- | Read a string using pandoc, with the default options
40+readPandoc
39−readPandoc :: Item String -- ^ String to read
41+ :: Item String -- ^ String to read
40− -> Item Pandoc -- ^ Resulting document
42+ -> Compiler (Item Pandoc) -- ^ Resulting document
41readPandoc = readPandocWith defaultHakyllReaderOptions
43readPandoc = readPandocWith defaultHakyllReaderOptions
42
44
43
45
44--------------------------------------------------------------------------------
46--------------------------------------------------------------------------------
45-- | Read a string using pandoc, with the supplied options
47-- | Read a string using pandoc, with the supplied options
48+readPandocWith
46−readPandocWith :: ReaderOptions -- ^ Parser options
49+ :: ReaderOptions -- ^ Parser options
47− -> Item String -- ^ String to read
50+ -> Item String -- ^ String to read
48− -> Item Pandoc -- ^ Resulting document
51+ -> Compiler (Item Pandoc) -- ^ Resulting document
52+readPandocWith ropt item =
49−readPandocWith ropt item = fmap (reader ropt (itemFileType item)) 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'
50 where
59 where
51 reader ro t = case t of
60 reader ro t = case t of
52 DocBook -> readDocBook ro
61 DocBook -> readDocBook ro
@@ -81,15 +90,17 @@ writePandocWith wopt = fmap $ writeHtmlString wopt
81
90
82--------------------------------------------------------------------------------
91--------------------------------------------------------------------------------
83-- | Render the resource using pandoc
92-- | Render the resource using pandoc
84−renderPandoc :: Item String -> Item String
93+renderPandoc :: Item String -> Compiler (Item String)
85renderPandoc =
94renderPandoc =
86 renderPandocWith defaultHakyllReaderOptions defaultHakyllWriterOptions
95 renderPandocWith defaultHakyllReaderOptions defaultHakyllWriterOptions
87
96
88
97
89--------------------------------------------------------------------------------
98--------------------------------------------------------------------------------
90-- | Render the resource using pandoc
99-- | Render the resource using pandoc
100+renderPandocWith
91−renderPandocWith :: ReaderOptions -> WriterOptions -> Item String -> Item String
101+ :: ReaderOptions -> WriterOptions -> Item String -> Compiler (Item String)
102+renderPandocWith ropt wopt item =
92−renderPandocWith ropt wopt = writePandocWith wopt . readPandocWith ropt
103+ writePandocWith wopt <$> readPandocWith ropt item
93
104
94
105
95--------------------------------------------------------------------------------
106--------------------------------------------------------------------------------
@@ -128,7 +139,7 @@ pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
128 -> Compiler (Item String)
139 -> Compiler (Item String)
129pandocCompilerWithTransformM ropt wopt f =
140pandocCompilerWithTransformM ropt wopt f =
130 writePandocWith wopt <$>
141 writePandocWith wopt <$>
131− (traverse f =<< readPandocWith ropt <$> getResourceBody)
142+ (traverse f =<< readPandocWith ropt =<< getResourceBody)
132
143
133
144
134--------------------------------------------------------------------------------
145--------------------------------------------------------------------------------
src/Hakyll/Web/Pandoc/Biblio.hs+2−2
@@ -100,8 +100,8 @@ readPandocBiblio ropt csl biblio item = do
100 -- actual page. If we don't do this, pandoc won't even consider them
100 -- actual page. If we don't do this, pandoc won't even consider them
101 -- citations!
101 -- citations!
102 let Biblio refs = itemBody biblio
102 let Biblio refs = itemBody biblio
103− pandoc = itemBody $ readPandocWith ropt item
103+ pandoc <- itemBody <$> readPandocWith ropt item
104− pandoc' = processCites style refs pandoc
104+ let pandoc' = processCites style refs pandoc
105
105
106 return $ fmap (const pandoc') item
106 return $ fmap (const pandoc') item
107
107
tests/Hakyll/Core/Runtime/Tests.hs+1−1
@@ -39,7 +39,7 @@ case01 = do
39 compile $ do
39 compile $ do
40 getResourceBody
40 getResourceBody
41 >>= saveSnapshot "raw"
41 >>= saveSnapshot "raw"
42− >>= return . renderPandoc
42+ >>= renderPandoc
43
43
44 create ["bodies.txt"] $ do
44 create ["bodies.txt"] $ do
45 route idRoute
45 route idRoute
web/releases.markdown+6
@@ -4,6 +4,12 @@ title: Releases
4
4
5# Releases
5# Releases
6
6
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+
7## Hakyll 4.6.9.0
13## Hakyll 4.6.9.0
8
14
9- Let caller decide exit (fix by Erik Dominikus)
15- Let caller decide exit (fix by Erik Dominikus)