diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-13 20:41:26 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-13 20:41:26 +0100 |
commit | 0da0dd469de6f3c7439099900676deb8a667bbe6 (patch) | |
tree | 4f9ccb9ec621ac70591d0bed62176df4d35a54b9 /src/Text/Hakyll/Pandoc.hs | |
parent | 18ec821d02e007dd1a1db983daf504407e70732e (diff) | |
download | hakyll-0da0dd469de6f3c7439099900676deb8a667bbe6.tar.gz |
Experimental changes for a re-write
Diffstat (limited to 'src/Text/Hakyll/Pandoc.hs')
-rw-r--r-- | src/Text/Hakyll/Pandoc.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Text/Hakyll/Pandoc.hs b/src/Text/Hakyll/Pandoc.hs index c0dec77..af4be62 100644 --- a/src/Text/Hakyll/Pandoc.hs +++ b/src/Text/Hakyll/Pandoc.hs @@ -17,6 +17,30 @@ import Text.Hakyll.HakyllMonad import Text.Hakyll.HakyllAction import Text.Hakyll.Context +-- | Reader function for plain text +-- +readText :: ParserState -> String -> Pandoc +readText _ = Pandoc (Meta [] [] []) . return . Plain . return . Str + +-- | Get a read function for a given extension. +-- +readPandoc :: HakyllAction (FileType, String) Pandoc +readPandoc = createHakyllAction $ \(fileType, inp) -> do + parserState <- askHakyll pandocParserState + return $ readFunction fileType (readOptions parserState fileType) inp + where + readFunction ReStructuredText = readRST + readFunction LaTeX = readLaTeX + readFunction Markdown = readMarkdown + readFunction LiterateHaskellMarkdown = readMarkdown + readFunction Html = readHtml + readFunction Text = readText + readFunction t = error $ "Cannot render " ++ show t + + readOptions options LiterateHaskellMarkdown = options + { stateLiterateHaskell = True } + readOptions options _ = options + -- | Get a render function for a given extension. -- getRenderFunction :: HakyllAction FileType (String -> String) @@ -39,6 +63,13 @@ getRenderFunction = createHakyllAction $ \fileType -> case fileType of { stateLiterateHaskell = True } readOptions options _ = options +-- | Get a render action +-- +renderPandoc :: HakyllAction Pandoc String +renderPandoc = createHakyllAction $ \p -> do + writerOptions <- askHakyll pandocWriterOptions + return $ writeHtmlString writerOptions p + -- | An action that renders the list of page sections to a context using pandoc -- renderAction :: HakyllAction [PageSection] Context |