diff options
Diffstat (limited to 'src/Text/Pandoc/Writers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 266336968..25fe561da 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -60,17 +60,25 @@ pandocToMarkdown opts (Pandoc meta blocks) = do then tableOfContents opts headerBlocks else empty body <- blockListToMarkdown opts blocks + let before = if null (writerIncludeBefore opts) + then empty + else text $ writerIncludeBefore opts + let after = if null (writerIncludeAfter opts) + then empty + else text $ writerIncludeAfter opts (notes, _) <- get notes' <- notesToMarkdown opts (reverse notes) (_, refs) <- get -- note that the notes may contain refs refs' <- keyTableToMarkdown opts (reverse refs) + let main = render $ before $+$ body $+$ text "" $+$ notes' $+$ text "" $+$ refs' $+$ after let context = writerVariables opts ++ [ ("toc", render toc) - , ("body", render $ body $+$ text "" $+$ notes' $+$ - text "" $+$ refs') + , ("body", main) , ("titleblock", render head') ] - return $ renderTemplate context $ writerTemplate opts + if writerStandalone opts + then return $ renderTemplate context $ writerTemplate opts + else return main -- | Return markdown representation of reference key table. keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc |