summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Frumin <difrumin@gmail.com>2014-01-24 14:55:32 +0400
committerDaniil Frumin <difrumin@gmail.com>2014-01-24 14:55:32 +0400
commit8a29542ee663a613427a1dee7a882ad974fed12c (patch)
tree6476cc510a7ea75ac9e089f5ecd9795ee1ee56b9 /src
parentbc360a3f4654d0d32c00c408c170aaede24f1b17 (diff)
downloadhakyll-8a29542ee663a613427a1dee7a882ad974fed12c.tar.gz
Added the `pandocCompilerWithTransformM` function
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Pandoc.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs
index 5a4f4f5..450a575 100644
--- a/src/Hakyll/Web/Pandoc.hs
+++ b/src/Hakyll/Web/Pandoc.hs
@@ -13,6 +13,7 @@ module Hakyll.Web.Pandoc
, pandocCompiler
, pandocCompilerWith
, pandocCompilerWithTransform
+ , pandocCompilerWithTransformM
-- * Default options
, defaultHakyllReaderOptions
@@ -23,6 +24,7 @@ module Hakyll.Web.Pandoc
--------------------------------------------------------------------------------
import Control.Applicative ((<$>))
import qualified Data.Set as S
+import Data.Traversable (traverse)
import Text.Pandoc
@@ -113,6 +115,20 @@ pandocCompilerWithTransform ropt wopt f = cached cacheName $
where
cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
+--------------------------------------------------------------------------------
+-- | Similar to 'pandocCompilerWithTransform', but the transformation
+-- function is monadic. This is useful when you want the pandoc
+-- tranfromation to use the 'Compiler' information such as routes,
+-- metadata, etc
+pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
+ -> (Pandoc -> Compiler Pandoc)
+ -> Compiler (Item String)
+pandocCompilerWithTransformM ropt wopt f = cached cacheName $
+ writePandocWith wopt <$>
+ (traverse f
+ =<< readPandocWith ropt <$> getResourceBody)
+ where
+ cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
--------------------------------------------------------------------------------
-- | The default reader options for pandoc parsing in hakyll