hakyll
hakyll copied to clipboard
Hakyll only supports `PandocPure` `PandocMonad`
In readPandocWith, runPure is used so pandoc is run in PandocPure. PandocPure doesn't support all pandoc functionality (in particular, I needed PandocIO so that pandoc would honor org mode includes).
Options I can imagine:
- Add functionality to support running
pandocin IO (unsafeCompiler . runIOseems to Just Work.) - Document this behavior. It was definitely confusing for me when
hakyll'spandocbehavior silently differed from directly runningpandoc(pandocfrom the CLI defaults toPandocIO) - Examine log messages in
CommonStateand print them or even crash if they're present
Has this been addressed in newer versions? If not did you get a workaround for this?
I import Text.Pandoc myself and wrap everything up with an unsafeCompiler:
-- Run pandoc in IO instead of purely so that we can work with org mode file includes
readPandocWith ::
ReaderOptions -- ^ Parser options
-> Item String -- ^ String to read
-> Compiler (Item Pandoc) -- ^ Resulting document
readPandocWith ropt item =
unsafeCompiler $
runIO (traverse (reader ropt (itemFileType item)) (fmap T.pack item)) >>= \case
Left err ->
fail $ "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
Right item' -> return item'
where
reader ro t =
case t of
DocBook -> readDocBook ro
Html -> readHtml ro
LaTeX -> readLaTeX ro
LiterateHaskell t' -> reader (addExt ro Ext_literate_haskell) t'
Markdown -> readMarkdown ro
MediaWiki -> readMediaWiki ro
OrgMode -> readOrg ro
Rst -> readRST ro
Textile -> readTextile ro
_ ->
error $
"Hakyll.Web.readPandocWith: I don't know how to read a file of " ++
"the type " ++ show t ++ " for: " ++ show (itemIdentifier item)
addExt ro e =
ro {readerExtensions = enableExtension e $ readerExtensions ro}