diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2014-01-28 01:59:40 -0800 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2014-01-28 01:59:40 -0800 |
commit | ca20400712d2b740672d70fbd64b7cec788393ce (patch) | |
tree | dbf5564a084c2e98bf19346a2b84341587901dc4 | |
parent | 63107a6f75335cabe828751d2bef4704667cad76 (diff) | |
parent | 84ba953ed39a4733031f4da0019ed05699975efc (diff) | |
download | hakyll-ca20400712d2b740672d70fbd64b7cec788393ce.tar.gz |
Merge pull request #215 from co-dan/pandoc-transf
Added the `pandocCompilerWithTransformM` function
-rw-r--r-- | src/Hakyll/Web/Pandoc.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs index 5a4f4f5..77f06c9 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 +-- 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 |