@@ -1,25 +1,31 @@
1-- | Module exporting pandoc bindings
1-- | Module exporting pandoc bindings
3module Hakyll.Web.Pandoc
3module Hakyll.Web.Pandoc
4+ ( -- * The basic building blocks
4− ( readPandoc
5+ readPandoc
5 , readPandocWith
6 , readPandocWith
6 , writePandoc
7 , writePandoc
7 , writePandocWith
8 , writePandocWith
9− , targetReadPandocWith
10+ -- * Functions working on pages/targets
10− , targetRenderPandoc
11+ , pageReadPandoc
11− , targetRenderPandocWith
12+ , pageReadPandocWith
14+ , pageRenderPandocWith
12 , defaultParserState
17 , defaultParserState
13 , defaultWriterOptions
18 , defaultWriterOptions
16−import Control.Applicative ((<$>), (<*>))
21+import Control.Applicative ((<$>))
18import Text.Pandoc (Pandoc)
23import Text.Pandoc (Pandoc)
19import qualified Text.Pandoc as P
24import qualified Text.Pandoc as P
21−import Hakyll.Web.FileType
22import Hakyll.Core.Target
26import Hakyll.Core.Target
27+import Hakyll.Web.FileType
28+import Hakyll.Web.Page
24-- | Read a string using pandoc, with the default options
30-- | Read a string using pandoc, with the default options
@@ -58,26 +64,30 @@ writePandocWith = P.writeHtmlString
59-- | Read the resource using pandoc
65-- | Read the resource using pandoc
61−targetReadPandoc :: TargetM a Pandoc
67+pageReadPandoc :: Page String -> TargetM a (Page Pandoc)
62−targetReadPandoc = targetReadPandocWith defaultParserState
68+pageReadPandoc = pageReadPandocWith defaultParserState
64-- | Read the resource using pandoc
70-- | Read the resource using pandoc
66−targetReadPandocWith :: P.ParserState -> TargetM a Pandoc
72+pageReadPandocWith :: P.ParserState -> Page String -> TargetM a (Page Pandoc)
67−targetReadPandocWith state =
73+pageReadPandocWith state page = do
74+ fileType' <- getFileType
68− readPandocWith state <$> getFileType <*> getResourceString
75+ return $ readPandocWith state fileType' <$> page
70-- | Render the resource using pandoc
77-- | Render the resource using pandoc
72−targetRenderPandoc :: TargetM a String
79+pageRenderPandoc :: Page String -> TargetM a (Page String)
74− targetRenderPandocWith defaultParserState defaultWriterOptions
80+pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
76-- | Render the resource using pandoc
82-- | Render the resource using pandoc
78−targetRenderPandocWith :: P.ParserState -> P.WriterOptions -> TargetM a String
84+pageRenderPandocWith :: P.ParserState
79−targetRenderPandocWith state options =
85+ -> P.WriterOptions
87+ -> TargetM a (Page String)
88+pageRenderPandocWith state options page = do
89+ pandoc <- pageReadPandocWith state page
80− writePandocWith options <$> targetReadPandocWith state
90+ return $ writePandocWith options <$> pandoc
82-- | The default reader options for pandoc parsing in hakyll
92-- | The default reader options for pandoc parsing in hakyll