diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-12-15 18:02:47 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-12-15 18:02:47 +0100 |
commit | e633df17dd72703a541c46d829096dfe40b75e50 (patch) | |
tree | c8514b0a05fed2e0e359d479c934cbd9ae504abf /src/Hakyll/Web/Pandoc.hs | |
parent | 3f42c9cd6f45bb306d622f3ffa175e2a8b0910e1 (diff) | |
download | hakyll-e633df17dd72703a541c46d829096dfe40b75e50.tar.gz |
Rename pageCompiler to pandocCompiler
Diffstat (limited to 'src/Hakyll/Web/Pandoc.hs')
-rw-r--r-- | src/Hakyll/Web/Pandoc.hs | 35 |
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 |