diff options
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 13 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index f119598a6..6782cc14e 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -52,7 +52,14 @@ writeLaTeX options document = pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do - main <- liftM render $ blockListToLaTeX blocks + body <- blockListToLaTeX blocks + let before = if null (writerIncludeBefore options) + then empty + else text $ writerIncludeBefore options + let after = if null (writerIncludeAfter options) + then empty + else text $ writerIncludeAfter options + let main = render $ before $$ body $$ after titletext <- liftM render $ inlineListToLaTeX title authorsText <- mapM (liftM render . inlineListToLaTeX) authors dateText <- liftM render $ inlineListToLaTeX date @@ -62,7 +69,9 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do , ("title", titletext) , ("authors", intercalate "\\\\" authorsText) , ("date", dateText) ] - return $ renderTemplate context $ writerTemplate options + return $ if writerStandalone options + then renderTemplate context $ writerTemplate options + else main -- escape things as needed for LaTeX 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 |