Safe Haskell | None |
---|---|
Language | Haskell98 |
Heist.Splices.Markdown
Description
The "markdown" splice formats markdown content as HTML and inserts it into the document.
If the file attribute is present the contents of the tag is ignored and the file specified is converted to HTML.
Otherwise the non-markup children of the tag are processed as markdown and converted to HTML.
This splice requires that the "pandoc" executable is in your path.
You can add custom pandoc splice with pandocSplice
. It is not limited to
markdown input, and can process anything pandoc can.
For example you can create a page with generated table of contents, using heist template as pandoc template.
<!-- _wrap.tpl --> <html> <head> <title> <pageTitle/> </title> </head> <div class="nav"> <pageToc/> </div> <apply-content/> </html>
And pandoc template, which would bind pageTitle
and pageToc
splices and
applies "_wrap" template.
<!-- _pandoc.tpl --> <apply template="_wrap.tpl"> <bind tag="pageTitle"> $title$</bind> <bind tag="pageToc"> $toc$</bind> $body$ </apply>
Bind splice pandoc splice. Set it to not wrap in div, or it will break html from _wrap.tpl
splices = "docmarkdown" ## pandocSplice opts where opts = setPandocArgs ["-S", "--no-wrap", "--toc" , "--standalone" , "--template", "_pandoc.tpl" , "--html5"] $ setPandocWrapDiv Nothing $ defaultPandocOptions
And then use it to render your markdown file
<!-- apidocs.tpl --> <DOCTYPE html> <html lang="en"> <head> <link href="/static/css/site.css rel="stylesheet"> </head> <body> <apply template="_navbar.tpl" /> <docmarkdown file="apidocs.md"/> </body>
Synopsis
- data PandocMissingException
- data MarkdownException
- data NoMarkdownFileException
- markdownTag :: Text
- markdownSplice :: MonadIO m => Splice m
- pandocSplice :: MonadIO m => PandocOptions -> Splice m
- data PandocOptions
- defaultPandocOptions :: PandocOptions
- setPandocExecutable :: FilePath -> PandocOptions -> PandocOptions
- setPandocArgs :: [String] -> PandocOptions -> PandocOptions
- setPandocBaseDir :: Maybe FilePath -> PandocOptions -> PandocOptions
- setPandocWrapDiv :: Maybe Text -> PandocOptions -> PandocOptions
- pandocExecutable :: Functor f => (FilePath -> f FilePath) -> PandocOptions -> f PandocOptions
- pandocArgs :: Functor f => ([String] -> f [String]) -> PandocOptions -> f PandocOptions
- pandocBaseDir :: Functor f => (Maybe FilePath -> f (Maybe FilePath)) -> PandocOptions -> f PandocOptions
- pandocWrapDiv :: Functor f => (Maybe Text -> f (Maybe Text)) -> PandocOptions -> f PandocOptions
Exceptions
data PandocMissingException #
Instances
Show PandocMissingException # | |
Defined in Heist.Splices.Markdown Methods showsPrec :: Int -> PandocMissingException -> ShowS # show :: PandocMissingException -> String # showList :: [PandocMissingException] -> ShowS # | |
Exception PandocMissingException # | |
Defined in Heist.Splices.Markdown |
data MarkdownException #
Instances
Show MarkdownException # | |
Defined in Heist.Splices.Markdown Methods showsPrec :: Int -> MarkdownException -> ShowS # show :: MarkdownException -> String # showList :: [MarkdownException] -> ShowS # | |
Exception MarkdownException # | |
Defined in Heist.Splices.Markdown Methods toException :: MarkdownException -> SomeException # |
data NoMarkdownFileException #
Instances
Show NoMarkdownFileException # | |
Defined in Heist.Splices.Markdown Methods showsPrec :: Int -> NoMarkdownFileException -> ShowS # show :: NoMarkdownFileException -> String # showList :: [NoMarkdownFileException] -> ShowS # | |
Exception NoMarkdownFileException # | |
Defined in Heist.Splices.Markdown |
Markdown Splice
markdownTag :: Text #
Default name for the markdown splice.
markdownSplice :: MonadIO m => Splice m #
Default markdown splice with executable "pandoc"
Generic pandoc splice
pandocSplice :: MonadIO m => PandocOptions -> Splice m #
Implementation of the markdown splice.
Pandoc Options
data PandocOptions #
Instances
Eq PandocOptions # | |
Defined in Heist.Splices.Markdown Methods (==) :: PandocOptions -> PandocOptions -> Bool # (/=) :: PandocOptions -> PandocOptions -> Bool # | |
Ord PandocOptions # | |
Defined in Heist.Splices.Markdown Methods compare :: PandocOptions -> PandocOptions -> Ordering # (<) :: PandocOptions -> PandocOptions -> Bool # (<=) :: PandocOptions -> PandocOptions -> Bool # (>) :: PandocOptions -> PandocOptions -> Bool # (>=) :: PandocOptions -> PandocOptions -> Bool # max :: PandocOptions -> PandocOptions -> PandocOptions # min :: PandocOptions -> PandocOptions -> PandocOptions # | |
Show PandocOptions # | |
Defined in Heist.Splices.Markdown Methods showsPrec :: Int -> PandocOptions -> ShowS # show :: PandocOptions -> String # showList :: [PandocOptions] -> ShowS # |
defaultPandocOptions :: PandocOptions #
Default options
setPandocExecutable :: FilePath -> PandocOptions -> PandocOptions #
Name of pandoc executable
setPandocArgs :: [String] -> PandocOptions -> PandocOptions #
Arguments passed to pandoc
setPandocBaseDir :: Maybe FilePath -> PandocOptions -> PandocOptions #
Base directory for input files, defaults to current template dir
setPandocWrapDiv :: Maybe Text -> PandocOptions -> PandocOptions #
Wrap pandoc output in div with class. Appends node attributes to div and appends class to ones specified on node.
Lens for PandocOptions
pandocExecutable :: Functor f => (FilePath -> f FilePath) -> PandocOptions -> f PandocOptions #
pandocArgs :: Functor f => ([String] -> f [String]) -> PandocOptions -> f PandocOptions #
pandocBaseDir :: Functor f => (Maybe FilePath -> f (Maybe FilePath)) -> PandocOptions -> f PandocOptions #
pandocWrapDiv :: Functor f => (Maybe Text -> f (Maybe Text)) -> PandocOptions -> f PandocOptions #