@@ -1,5 +1,5 @@
1-- | A module for dealing with @Page@s. This module is mostly internally used.
1-- | A module for dealing with @Page@s. This module is mostly internally used.
2−module Text.Hakyll.Internal.Page
2+module Text.Hakyll.Internal.Page
@@ -20,28 +20,15 @@ import Text.Hakyll.Util (trim)
20import Text.Hakyll.Internal.Cache
20import Text.Hakyll.Internal.Cache
21import Text.Hakyll.Internal.FileType
21import Text.Hakyll.Internal.FileType
23−-- | The default reader options for pandoc parsing.
24−readerOptions :: ParserState
25−readerOptions = defaultParserState
26− { -- The following option causes pandoc to read smart typography, a nice
31−-- | The default writer options for pandoc rendering.
32−writerOptions :: WriterOptions
33−writerOptions = defaultWriterOptions
34− { -- This option causes literate haskell to be written using '>' marks in
35− -- html, which I think is a good default.
36− writerLiterateHaskell = True
39-- | Get a render function for a given extension.
23-- | Get a render function for a given extension.
40−getRenderFunction :: FileType -> (String -> String)
24+getRenderFunction :: FileType -> Hakyll (String -> String)
41−getRenderFunction Html = id
25+getRenderFunction Html = return id
42−getRenderFunction Text = id
26+getRenderFunction Text = return id
27+getRenderFunction fileType = do
28+ parserState <- askHakyll pandocParserState
29+ writerOptions <- askHakyll pandocWriterOptions
43−getRenderFunction fileType = writeHtmlString writerOptions
30+ return $ writeHtmlString writerOptions
44− . readFunction fileType (readOptions fileType)
31+ . readFunction fileType (readOptions parserState fileType)
46 readFunction ReStructuredText = readRST
33 readFunction ReStructuredText = readRST
47 readFunction LaTeX = readLaTeX
34 readFunction LaTeX = readLaTeX
@@ -49,9 +36,9 @@ getRenderFunction fileType = writeHtmlString writerOptions
49 readFunction LiterateHaskellMarkdown = readMarkdown
36 readFunction LiterateHaskellMarkdown = readMarkdown
50 readFunction t = error $ "Cannot render " ++ show t
37 readFunction t = error $ "Cannot render " ++ show t
52− readOptions LiterateHaskellMarkdown =
39+ readOptions options LiterateHaskellMarkdown = options
53− readerOptions { stateLiterateHaskell = True }
40+ { stateLiterateHaskell = True }
54− readOptions _ = readerOptions
41+ readOptions options _ = options
56-- | Split a page into sections.
43-- | Split a page into sections.
57splitAtDelimiters :: [String] -> State (Maybe String) [[String]]
44splitAtDelimiters :: [String] -> State (Maybe String) [[String]]
@@ -103,8 +90,8 @@ readSection renderFunction isFirst ls
103-- has a @.markdown@ extension, it will be rendered using pandoc.
90-- has a @.markdown@ extension, it will be rendered using pandoc.
104readPageFromFile :: FilePath -> Hakyll Context
91readPageFromFile :: FilePath -> Hakyll Context
105readPageFromFile path = do
92readPageFromFile path = do
106− let renderFunction = getRenderFunction $ getFileType path
93+ renderFunction <- getRenderFunction $ getFileType path
107− sectionFunctions = map (readSection renderFunction)
94+ let sectionFunctions = map (readSection renderFunction)
108 (True : repeat False)
95 (True : repeat False)
110 -- Read file.
97 -- Read file.