summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2015-05-29 11:52:36 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2015-05-29 11:52:36 +0200
commiteb4ea434a6b98f252ff82fface9cd9107ddc43ed (patch)
tree71eeb88efd7d3c144b70a0eae2b23807f24cdc3a
parent3728288f53fbd2ec32eaef6459c474f455541471 (diff)
downloadhakyll-eb4ea434a6b98f252ff82fface9cd9107ddc43ed.tar.gz
Update to use Pandoc 1.14
-rw-r--r--hakyll.cabal6
-rw-r--r--src/Hakyll/Web/Pandoc.hs31
-rw-r--r--src/Hakyll/Web/Pandoc/Biblio.hs4
-rw-r--r--tests/Hakyll/Core/Runtime/Tests.hs2
-rw-r--r--web/releases.markdown6
5 files changed, 33 insertions, 16 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index dd92d02..ea7c879 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -1,5 +1,5 @@
Name: hakyll
-Version: 4.6.9.0
+Version: 4.7.0.0
Synopsis: A static website compiler library
Description:
@@ -158,7 +158,7 @@ Library
network-uri >= 2.6 && < 2.7,
old-locale >= 1.0 && < 1.1,
old-time >= 1.0 && < 1.2,
- pandoc >= 1.12.4 && < 1.14,
+ pandoc >= 1.14 && < 1.15,
pandoc-citeproc >= 0.4 && < 0.8,
parsec >= 3.0 && < 3.2,
process >= 1.0 && < 1.3,
@@ -246,7 +246,7 @@ Test-suite hakyll-tests
network-uri >= 2.6 && < 2.7,
old-locale >= 1.0 && < 1.1,
old-time >= 1.0 && < 1.2,
- pandoc >= 1.12.4 && < 1.14,
+ pandoc >= 1.14 && < 1.15,
pandoc-citeproc >= 0.4 && < 0.8,
parsec >= 3.0 && < 3.2,
process >= 1.0 && < 1.3,
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs
index a1b8903..d9287de 100644
--- a/src/Hakyll/Web/Pandoc.hs
+++ b/src/Hakyll/Web/Pandoc.hs
@@ -26,6 +26,7 @@ import Control.Applicative ((<$>))
import qualified Data.Set as S
import Data.Traversable (traverse)
import Text.Pandoc
+import Text.Pandoc.Error (PandocError (..))
--------------------------------------------------------------------------------
@@ -36,17 +37,25 @@ import Hakyll.Web.Pandoc.FileType
--------------------------------------------------------------------------------
-- | Read a string using pandoc, with the default options
-readPandoc :: Item String -- ^ String to read
- -> Item Pandoc -- ^ Resulting document
+readPandoc
+ :: Item String -- ^ String to read
+ -> Compiler (Item Pandoc) -- ^ Resulting document
readPandoc = readPandocWith defaultHakyllReaderOptions
--------------------------------------------------------------------------------
-- | Read a string using pandoc, with the supplied options
-readPandocWith :: ReaderOptions -- ^ Parser options
- -> Item String -- ^ String to read
- -> Item Pandoc -- ^ Resulting document
-readPandocWith ropt item = fmap (reader ropt (itemFileType item)) item
+readPandocWith
+ :: ReaderOptions -- ^ Parser options
+ -> Item String -- ^ String to read
+ -> Compiler (Item Pandoc) -- ^ Resulting document
+readPandocWith ropt item =
+ case traverse (reader ropt (itemFileType item)) item of
+ Left (ParseFailure err) -> fail $
+ "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
+ Left (ParsecError _ err) -> fail $
+ "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
+ Right item' -> return item'
where
reader ro t = case t of
DocBook -> readDocBook ro
@@ -81,15 +90,17 @@ writePandocWith wopt = fmap $ writeHtmlString wopt
--------------------------------------------------------------------------------
-- | Render the resource using pandoc
-renderPandoc :: Item String -> Item String
+renderPandoc :: Item String -> Compiler (Item String)
renderPandoc =
renderPandocWith defaultHakyllReaderOptions defaultHakyllWriterOptions
--------------------------------------------------------------------------------
-- | Render the resource using pandoc
-renderPandocWith :: ReaderOptions -> WriterOptions -> Item String -> Item String
-renderPandocWith ropt wopt = writePandocWith wopt . readPandocWith ropt
+renderPandocWith
+ :: ReaderOptions -> WriterOptions -> Item String -> Compiler (Item String)
+renderPandocWith ropt wopt item =
+ writePandocWith wopt <$> readPandocWith ropt item
--------------------------------------------------------------------------------
@@ -128,7 +139,7 @@ pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
-> Compiler (Item String)
pandocCompilerWithTransformM ropt wopt f =
writePandocWith wopt <$>
- (traverse f =<< readPandocWith ropt <$> getResourceBody)
+ (traverse f =<< readPandocWith ropt =<< getResourceBody)
--------------------------------------------------------------------------------
diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs
index c8f075d..a4df630 100644
--- a/src/Hakyll/Web/Pandoc/Biblio.hs
+++ b/src/Hakyll/Web/Pandoc/Biblio.hs
@@ -100,8 +100,8 @@ readPandocBiblio ropt csl biblio item = do
-- actual page. If we don't do this, pandoc won't even consider them
-- citations!
let Biblio refs = itemBody biblio
- pandoc = itemBody $ readPandocWith ropt item
- pandoc' = processCites style refs pandoc
+ pandoc <- itemBody <$> readPandocWith ropt item
+ let pandoc' = processCites style refs pandoc
return $ fmap (const pandoc') item
diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs
index 73a3c6b..1ef77ca 100644
--- a/tests/Hakyll/Core/Runtime/Tests.hs
+++ b/tests/Hakyll/Core/Runtime/Tests.hs
@@ -39,7 +39,7 @@ case01 = do
compile $ do
getResourceBody
>>= saveSnapshot "raw"
- >>= return . renderPandoc
+ >>= renderPandoc
create ["bodies.txt"] $ do
route idRoute
diff --git a/web/releases.markdown b/web/releases.markdown
index 7f82068..cf9e248 100644
--- a/web/releases.markdown
+++ b/web/releases.markdown
@@ -4,6 +4,12 @@ title: Releases
# Releases
+## Hakyll 4.7.0.0
+
+- Bump pandoc to 1.14. This will break a lot of sites: since the pandoc parser
+ might now return an error message, it is ran inside the `Compiler` monad where
+ we can nicely handle the error.
+
## Hakyll 4.6.9.0
- Let caller decide exit (fix by Erik Dominikus)