@@ -1,25 +1,31 @@
11-- | Module exporting pandoc bindings
22--
33module Hakyll.Web.Pandoc
4− ( readPandoc
4+ ( -- * The basic building blocks
5+ readPandoc
56 , readPandocWith
67 , writePandoc
78 , writePandocWith
8− , targetReadPandoc
9− , targetReadPandocWith
10− , targetRenderPandoc
11− , targetRenderPandocWith
9+
10+ -- * Functions working on pages/targets
11+ , pageReadPandoc
12+ , pageReadPandocWith
13+ , pageRenderPandoc
14+ , pageRenderPandocWith
15+
16+ -- * Default options
1217 , defaultParserState
1318 , defaultWriterOptions
1419 ) where
1520
16−import Control.Applicative ((<$>), (<*>))
21+import Control.Applicative ((<$>))
1722
1823import Text.Pandoc (Pandoc)
1924import qualified Text.Pandoc as P
2025
21−import Hakyll.Web.FileType
2226import Hakyll.Core.Target
27+import Hakyll.Web.FileType
28+import Hakyll.Web.Page
2329
2430-- | Read a string using pandoc, with the default options
2531--
@@ -58,26 +64,30 @@ writePandocWith = P.writeHtmlString
5864
5965-- | Read the resource using pandoc
6066--
61−targetReadPandoc :: TargetM a Pandoc
62−targetReadPandoc = targetReadPandocWith defaultParserState
67+pageReadPandoc :: Page String -> TargetM a (Page Pandoc)
68+pageReadPandoc = pageReadPandocWith defaultParserState
6369
6470-- | Read the resource using pandoc
6571--
66−targetReadPandocWith :: P.ParserState -> TargetM a Pandoc
67−targetReadPandocWith state =
68− readPandocWith state <$> getFileType <*> getResourceString
72+pageReadPandocWith :: P.ParserState -> Page String -> TargetM a (Page Pandoc)
73+pageReadPandocWith state page = do
74+ fileType' <- getFileType
75+ return $ readPandocWith state fileType' <$> page
6976
7077-- | Render the resource using pandoc
7178--
72−targetRenderPandoc :: TargetM a String
73−targetRenderPandoc =
74− targetRenderPandocWith defaultParserState defaultWriterOptions
79+pageRenderPandoc :: Page String -> TargetM a (Page String)
80+pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
7581
7682-- | Render the resource using pandoc
7783--
78−targetRenderPandocWith :: P.ParserState -> P.WriterOptions -> TargetM a String
79−targetRenderPandocWith state options =
80− writePandocWith options <$> targetReadPandocWith state
84+pageRenderPandocWith :: P.ParserState
85+ -> P.WriterOptions
86+ -> Page String
87+ -> TargetM a (Page String)
88+pageRenderPandocWith state options page = do
89+ pandoc <- pageReadPandocWith state page
90+ return $ writePandocWith options <$> pandoc
8191
8292-- | The default reader options for pandoc parsing in hakyll
8393--