Merge pull request #215 from co-dan/pandoc-transf
Added the `pandocCompilerWithTransformM` function
This commit is contained in:
commit
ca20400712
1 changed files with 16 additions and 0 deletions
|
@ -13,6 +13,7 @@ module Hakyll.Web.Pandoc
|
||||||
, pandocCompiler
|
, pandocCompiler
|
||||||
, pandocCompilerWith
|
, pandocCompilerWith
|
||||||
, pandocCompilerWithTransform
|
, pandocCompilerWithTransform
|
||||||
|
, pandocCompilerWithTransformM
|
||||||
|
|
||||||
-- * Default options
|
-- * Default options
|
||||||
, defaultHakyllReaderOptions
|
, defaultHakyllReaderOptions
|
||||||
|
@ -23,6 +24,7 @@ module Hakyll.Web.Pandoc
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
import Data.Traversable (traverse)
|
||||||
import Text.Pandoc
|
import Text.Pandoc
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,6 +115,20 @@ pandocCompilerWithTransform ropt wopt f = cached cacheName $
|
||||||
where
|
where
|
||||||
cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
|
cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- | Similar to 'pandocCompilerWithTransform', but the transformation
|
||||||
|
-- function is monadic. This is useful when you want the pandoc
|
||||||
|
-- transformation 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
|
-- | The default reader options for pandoc parsing in hakyll
|
||||||
|
|
Loading…
Reference in a new issue