summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Pandoc.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-12-15 18:02:47 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-12-15 18:02:47 +0100
commite633df17dd72703a541c46d829096dfe40b75e50 (patch)
treec8514b0a05fed2e0e359d479c934cbd9ae504abf /src/Hakyll/Web/Pandoc.hs
parent3f42c9cd6f45bb306d622f3ffa175e2a8b0910e1 (diff)
downloadhakyll-e633df17dd72703a541c46d829096dfe40b75e50.tar.gz
Rename pageCompiler to pandocCompiler
Diffstat (limited to 'src/Hakyll/Web/Pandoc.hs')
-rw-r--r--src/Hakyll/Web/Pandoc.hs35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs
index c2319dc..82784be 100644
--- a/src/Hakyll/Web/Pandoc.hs
+++ b/src/Hakyll/Web/Pandoc.hs
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------------
--- | Module exporting convenientpandoc bindings
+-- | Module exporting convenient pandoc bindings
module Hakyll.Web.Pandoc
( -- * The basic building blocks
readPandoc
@@ -9,6 +9,11 @@ module Hakyll.Web.Pandoc
, renderPandoc
, renderPandocWith
+ -- * Derived compilers
+ , pandocCompiler
+ , pandocCompilerWith
+ , pandocCompilerWithTransform
+
-- * Default options
, defaultHakyllParserState
, defaultHakyllWriterOptions
@@ -16,10 +21,12 @@ module Hakyll.Web.Pandoc
--------------------------------------------------------------------------------
+import Control.Applicative ((<$>))
import Text.Pandoc
--------------------------------------------------------------------------------
+import Hakyll.Core.Compiler
import Hakyll.Core.Item
import Hakyll.Web.Pandoc.FileType
@@ -79,6 +86,32 @@ renderPandocWith state options = writePandocWith options . readPandocWith state
--------------------------------------------------------------------------------
+-- | Read a page render using pandoc
+pandocCompiler :: Compiler (Item String)
+pandocCompiler =
+ pandocCompilerWith defaultHakyllParserState defaultHakyllWriterOptions
+
+
+--------------------------------------------------------------------------------
+-- | A version of 'pandocCompiler' which allows you to specify your own pandoc
+-- options
+pandocCompilerWith :: ParserState -> WriterOptions -> Compiler (Item String)
+pandocCompilerWith state options = pandocCompilerWithTransform state options id
+
+
+--------------------------------------------------------------------------------
+-- | An extension of 'pandocCompilerWith' which allows you to specify a custom
+-- pandoc transformation for the content
+pandocCompilerWithTransform :: ParserState -> WriterOptions
+ -> (Pandoc -> Pandoc)
+ -> Compiler (Item String)
+pandocCompilerWithTransform state options f = cached cacheName $
+ writePandocWith options . fmap f . readPandocWith state <$> getResourceBody
+ where
+ cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"
+
+
+--------------------------------------------------------------------------------
-- | The default reader options for pandoc parsing in hakyll
defaultHakyllParserState :: ParserState
defaultHakyllParserState = defaultParserState