git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug with header spacing in Markdown and RST writers.

A null header (Meta [] [] []) should not cause a blank line at the beginning of output. But a blank line is needed between a non-null header and the main text. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1536 788f1e2b-df1e-0410-8736-df70ead52e1b

commitdcedb2f71243197f34c241b28b8ae76c2f1422c6 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 7 Feb 2009, 19:20 (18 years ago) parenta03331a
2 files changed+11−5
src/Text/Pandoc/Writers/Markdown.hs+5−2 src/Text/Pandoc/Writers/RST.hs+6−3
src/Text/Pandoc/Writers/Markdown.hs+5−2
@@ -52,11 +52,13 @@ pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
5252pandocToMarkdown opts (Pandoc meta blocks) = do
5353 let before = writerIncludeBefore opts
5454 let after = writerIncludeAfter opts
55+ let header = writerHeader opts
5556 let before' = if null before then empty else text before
5657 let after' = if null after then empty else text after
58+ let header' = if null header then empty else text header
5759 metaBlock <- metaToMarkdown opts meta
5860 let head' = if writerStandalone opts
59− then metaBlock $+$ text (writerHeader opts)
61+ then metaBlock $+$ header'
6062 else empty
6163 let headerBlocks = filter isHeaderBlock blocks
6264 let toc = if writerTableOfContents opts
@@ -104,11 +106,12 @@ escapeString = escapeStringUsing markdownEscapes
104106
105107-- | Convert bibliographic information into Markdown header.
106108metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
109+metaToMarkdown _ (Meta [] [] []) = return empty
107110metaToMarkdown opts (Meta title authors date) = do
108111 title' <- titleToMarkdown opts title
109112 authors' <- authorsToMarkdown authors
110113 date' <- dateToMarkdown date
111− return $ title' $+$ authors' $+$ date'
114+ return $ title' $+$ authors' $+$ date' $+$ text ""
112115
113116titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
114117titleToMarkdown _ [] = return empty
src/Text/Pandoc/Writers/RST.hs+6−3
@@ -59,12 +59,14 @@ pandocToRST :: Pandoc -> State WriterState Doc
5959pandocToRST (Pandoc meta blocks) = do
6060 opts <- get >>= (return . stOptions)
6161 let before = writerIncludeBefore opts
62− let after = writerIncludeAfter opts
62+ after = writerIncludeAfter opts
63+ header = writerHeader opts
6364 before' = if null before then empty else text before
6465 after' = if null after then empty else text after
66+ header' = if null header then empty else text header
6567 metaBlock <- metaToRST opts meta
6668 let head' = if (writerStandalone opts)
67− then metaBlock $+$ text (writerHeader opts)
69+ then metaBlock $+$ header'
6870 else empty
6971 body <- blockListToRST blocks
7072 includes <- get >>= (return . concat . stIncludes)
@@ -129,6 +131,7 @@ escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
129131
130132-- | Convert bibliographic information into RST header.
131133metaToRST :: WriterOptions -> Meta -> State WriterState Doc
134+metaToRST _ (Meta [] [] []) = return empty
132135metaToRST opts (Meta title authors date) = do
133136 title' <- titleToRST title
134137 authors' <- authorsToRST authors
@@ -136,7 +139,7 @@ metaToRST opts (Meta title authors date) = do
136139 let toc = if writerTableOfContents opts
137140 then text "" $+$ text ".. contents::"
138141 else empty
139− return $ title' $+$ authors' $+$ date' $+$ toc
142+ return $ title' $+$ authors' $+$ date' $+$ toc $+$ text ""
140143
141144titleToRST :: [Inline] -> State WriterState Doc
142145titleToRST [] = return empty