diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2015-05-29 11:52:36 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2015-05-29 11:52:36 +0200 |
commit | eb4ea434a6b98f252ff82fface9cd9107ddc43ed (patch) | |
tree | 71eeb88efd7d3c144b70a0eae2b23807f24cdc3a /src | |
parent | 3728288f53fbd2ec32eaef6459c474f455541471 (diff) | |
download | hakyll-eb4ea434a6b98f252ff82fface9cd9107ddc43ed.tar.gz |
Update to use Pandoc 1.14
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Web/Pandoc.hs | 31 | ||||
-rw-r--r-- | src/Hakyll/Web/Pandoc/Biblio.hs | 4 |
2 files changed, 23 insertions, 12 deletions
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 |