on master help sign in
Add pageCompilerWithPandoc
commit7ff2d79c53f710c8f726488c00f4a61cfa7e28b2 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 29 May 2011, 08:27 (15 years ago) parent6ab5943
1 file changed+17−6
src/Hakyll/Web/Page.hs+17−6
src/Hakyll/Web/Page.hs+17−6
@@ -54,6 +54,7 @@ module Hakyll.Web.Page
5454 , readPageCompiler
5555 , pageCompiler
5656 , pageCompilerWith
57+ , pageCompilerWithPandoc
5758 , addDefaultFields
5859 , sortByBaseName
5960 ) where
@@ -66,7 +67,7 @@ import qualified Data.Map as M
6667import Data.List (sortBy)
6768import Data.Ord (comparing)
6869
69−import Text.Pandoc (ParserState, WriterOptions)
70+import Text.Pandoc (Pandoc, ParserState, WriterOptions)
7071
7172import Hakyll.Core.Identifier
7273import Hakyll.Core.Compiler
@@ -91,16 +92,26 @@ readPageCompiler = getResourceString >>^ readPage
9192-- | Read a page, add default fields, substitute fields and render using pandoc
9293--
9394pageCompiler :: Compiler Resource (Page String)
94−pageCompiler = cached "Hakyll.Web.Page.pageCompiler" $
95− readPageCompiler >>> addDefaultFields >>> arr applySelf >>> pageRenderPandoc
95+pageCompiler =
96+ pageCompilerWith defaultHakyllParserState defaultHakyllWriterOptions
9697
9798-- | A version of 'pageCompiler' which allows you to specify your own pandoc
9899-- options
99100--
100−pageCompilerWith :: ParserState -> WriterOptions -> Compiler Resource (Page String)
101−pageCompilerWith state options = cached "pageCompilerWith" $
101+pageCompilerWith :: ParserState -> WriterOptions
102+ -> Compiler Resource (Page String)
103+pageCompilerWith state options = pageCompilerWithPandoc state options id
104+
105+-- | An extension of 'pageCompilerWith' which allows you to specify a custom
106+-- pandoc transformer for the content
107+--
108+pageCompilerWithPandoc :: ParserState -> WriterOptions
109+ -> (Pandoc -> Pandoc)
110+ -> Compiler Resource (Page String)
111+pageCompilerWithPandoc state options f = cached "pageCompilerWithPandoc" $
102112 readPageCompiler >>> addDefaultFields >>> arr applySelf
103− >>> pageRenderPandocWith state options
113+ >>> pageReadPandocWith state
114+ >>> arr (fmap (writePandocWith options . f))
104115
105116-- | Add a number of default metadata fields to a page. These fields include:
106117--