module Hakyll.Web.Pandoc
(
readPandoc
, readPandocWith
, writePandoc
, writePandocWith
, pageReadPandoc
, pageReadPandocWith
, pageRenderPandoc
, pageRenderPandocWith
, defaultHakyllParserState
, defaultHakyllWriterOptions
) where
import Prelude hiding (id)
import Control.Applicative ((<$>))
import Control.Arrow ((>>^), (&&&))
import Control.Category (id)
import Text.Pandoc
import Hakyll.Core.Compiler
import Hakyll.Web.Pandoc.FileType
import Hakyll.Web.Page.Internal
readPandoc :: FileType
-> String
-> Pandoc
readPandoc = readPandocWith defaultHakyllParserState
readPandocWith :: ParserState
-> FileType
-> String
-> Pandoc
readPandocWith state fileType' = case fileType' of
Html -> readHtml state
LaTeX -> readLaTeX state
LiterateHaskell t -> readPandocWith state {stateLiterateHaskell = True} t
Markdown -> readMarkdown state
Rst -> readRST state
t -> error $
"Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
writePandoc :: Pandoc
-> String
writePandoc = writePandocWith defaultHakyllWriterOptions
writePandocWith :: WriterOptions
-> Pandoc
-> String
writePandocWith = writeHtmlString
pageReadPandoc :: Compiler (Page String) (Page Pandoc)
pageReadPandoc = pageReadPandocWith defaultHakyllParserState
pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
pageReadPandocWith state =
id &&& getFileType >>^ pageReadPandocWith'
where
pageReadPandocWith' (p, t) = readPandocWith state t <$> p
pageRenderPandoc :: Compiler (Page String) (Page String)
pageRenderPandoc =
pageRenderPandocWith defaultHakyllParserState defaultHakyllWriterOptions
pageRenderPandocWith :: ParserState
-> WriterOptions
-> Compiler (Page String) (Page String)
pageRenderPandocWith state options =
pageReadPandocWith state >>^ fmap (writePandocWith options)
defaultHakyllParserState :: ParserState
defaultHakyllParserState = defaultParserState
{
stateSmart = True
}
defaultHakyllWriterOptions :: WriterOptions
defaultHakyllWriterOptions = defaultWriterOptions
{
writerLiterateHaskell = True
}