From 8a29542ee663a613427a1dee7a882ad974fed12c Mon Sep 17 00:00:00 2001 From: Daniil Frumin Date: Fri, 24 Jan 2014 14:55:32 +0400 Subject: [PATCH 1/2] Added the `pandocCompilerWithTransformM` function --- src/Hakyll/Web/Pandoc.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 From 84ba953ed39a4733031f4da0019ed05699975efc Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 26 Jan 2014 10:14:04 +0300 Subject: [PATCH 2/2] Typo in Pandoc.hs --- src/Hakyll/Web/Pandoc.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs index 450a575..77f06c9 100644 --- a/src/Hakyll/Web/Pandoc.hs +++ b/src/Hakyll/Web/Pandoc.hs @@ -118,7 +118,7 @@ pandocCompilerWithTransform ropt wopt f = cached cacheName $ -------------------------------------------------------------------------------- -- | 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, +-- transformation to use the 'Compiler' information such as routes, -- metadata, etc pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions -> (Pandoc -> Compiler Pandoc)