aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs7
-rw-r--r--src/Text/Pandoc/Writers/RST.hs9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 70d1f0c91..bebb88a76 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -52,11 +52,13 @@ pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
pandocToMarkdown opts (Pandoc meta blocks) = do
let before = writerIncludeBefore opts
let after = writerIncludeAfter opts
+ let header = writerHeader opts
let before' = if null before then empty else text before
let after' = if null after then empty else text after
+ let header' = if null header then empty else text header
metaBlock <- metaToMarkdown opts meta
let head' = if writerStandalone opts
- then metaBlock $+$ text (writerHeader opts)
+ then metaBlock $+$ header'
else empty
let headerBlocks = filter isHeaderBlock blocks
let toc = if writerTableOfContents opts
@@ -104,11 +106,12 @@ escapeString = escapeStringUsing markdownEscapes
-- | Convert bibliographic information into Markdown header.
metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
+metaToMarkdown _ (Meta [] [] []) = return empty
metaToMarkdown opts (Meta title authors date) = do
title' <- titleToMarkdown opts title
authors' <- authorsToMarkdown authors
date' <- dateToMarkdown date
- return $ title' $+$ authors' $+$ date'
+ return $ title' $+$ authors' $+$ date' $+$ text ""
titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
titleToMarkdown _ [] = return empty
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 91826cbcd..728c78712 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -59,12 +59,14 @@ pandocToRST :: Pandoc -> State WriterState Doc
pandocToRST (Pandoc meta blocks) = do
opts <- get >>= (return . stOptions)
let before = writerIncludeBefore opts
- let after = writerIncludeAfter opts
+ after = writerIncludeAfter opts
+ header = writerHeader opts
before' = if null before then empty else text before
after' = if null after then empty else text after
+ header' = if null header then empty else text header
metaBlock <- metaToRST opts meta
let head' = if (writerStandalone opts)
- then metaBlock $+$ text (writerHeader opts)
+ then metaBlock $+$ header'
else empty
body <- blockListToRST blocks
includes <- get >>= (return . concat . stIncludes)
@@ -129,6 +131,7 @@ escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
-- | Convert bibliographic information into RST header.
metaToRST :: WriterOptions -> Meta -> State WriterState Doc
+metaToRST _ (Meta [] [] []) = return empty
metaToRST opts (Meta title authors date) = do
title' <- titleToRST title
authors' <- authorsToRST authors
@@ -136,7 +139,7 @@ metaToRST opts (Meta title authors date) = do
let toc = if writerTableOfContents opts
then text "" $+$ text ".. contents::"
else empty
- return $ title' $+$ authors' $+$ date' $+$ toc
+ return $ title' $+$ authors' $+$ date' $+$ toc $+$ text ""
titleToRST :: [Inline] -> State WriterState Doc
titleToRST [] = return empty