@@ -13,6 +13,7 @@ module Hakyll.Web.Pandoc
13 , pandocCompiler
13 , pandocCompiler
14 , pandocCompilerWith
14 , pandocCompilerWith
15 , pandocCompilerWithTransform
15 , pandocCompilerWithTransform
16+ , pandocCompilerWithTransformM
17 -- * Default options
18 -- * Default options
18 , defaultHakyllReaderOptions
19 , defaultHakyllReaderOptions
@@ -23,6 +24,7 @@ module Hakyll.Web.Pandoc
23--------------------------------------------------------------------------------
24--------------------------------------------------------------------------------
24import Control.Applicative ((<$>))
25import Control.Applicative ((<$>))
25import qualified Data.Set as S
26import qualified Data.Set as S
27+import Data.Traversable (traverse)
26import Text.Pandoc
28import Text.Pandoc
@@ -113,6 +115,20 @@ pandocCompilerWithTransform ropt wopt f = cached cacheName $
114 cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
116 cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
118+--------------------------------------------------------------------------------
119+-- | Similar to 'pandocCompilerWithTransform', but the transformation
120+-- function is monadic. This is useful when you want the pandoc
121+-- tranfromation to use the 'Compiler' information such as routes,
123+pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
124+ -> (Pandoc -> Compiler Pandoc)
125+ -> Compiler (Item String)
126+pandocCompilerWithTransformM ropt wopt f = cached cacheName $
127+ writePandocWith wopt <$>
129+ =<< readPandocWith ropt <$> getResourceBody)
131+ cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
117--------------------------------------------------------------------------------
133--------------------------------------------------------------------------------
118-- | The default reader options for pandoc parsing in hakyll
134-- | The default reader options for pandoc parsing in hakyll