git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug with header spacing in Markdown and RST writers.
dcedb2ffiddlosopher
src/Text/Pandoc/Writers/Markdown.hs+5−2
@@ -52,11 +52,13 @@ pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
52pandocToMarkdown opts (Pandoc meta blocks) = do
52pandocToMarkdown opts (Pandoc meta blocks) = do
53 let before = writerIncludeBefore opts
53 let before = writerIncludeBefore opts
54 let after = writerIncludeAfter opts
54 let after = writerIncludeAfter opts
55+ let header = writerHeader opts
55 let before' = if null before then empty else text before
56 let before' = if null before then empty else text before
56 let after' = if null after then empty else text after
57 let after' = if null after then empty else text after
58+ let header' = if null header then empty else text header
57 metaBlock <- metaToMarkdown opts meta
59 metaBlock <- metaToMarkdown opts meta
58 let head' = if writerStandalone opts
60 let head' = if writerStandalone opts
59− then metaBlock $+$ text (writerHeader opts)
61+ then metaBlock $+$ header'
60 else empty
62 else empty
61 let headerBlocks = filter isHeaderBlock blocks
63 let headerBlocks = filter isHeaderBlock blocks
62 let toc = if writerTableOfContents opts
64 let toc = if writerTableOfContents opts
@@ -104,11 +106,12 @@ escapeString = escapeStringUsing markdownEscapes
104
106
105-- | Convert bibliographic information into Markdown header.
107-- | Convert bibliographic information into Markdown header.
106metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
108metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
109+metaToMarkdown _ (Meta [] [] []) = return empty
107metaToMarkdown opts (Meta title authors date) = do
110metaToMarkdown opts (Meta title authors date) = do
108 title' <- titleToMarkdown opts title
111 title' <- titleToMarkdown opts title
109 authors' <- authorsToMarkdown authors
112 authors' <- authorsToMarkdown authors
110 date' <- dateToMarkdown date
113 date' <- dateToMarkdown date
111− return $ title' $+$ authors' $+$ date'
114+ return $ title' $+$ authors' $+$ date' $+$ text ""
112
115
113titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
116titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
114titleToMarkdown _ [] = return empty
117titleToMarkdown _ [] = return empty
src/Text/Pandoc/Writers/RST.hs+6−3
@@ -59,12 +59,14 @@ pandocToRST :: Pandoc -> State WriterState Doc
59pandocToRST (Pandoc meta blocks) = do
59pandocToRST (Pandoc meta blocks) = do
60 opts <- get >>= (return . stOptions)
60 opts <- get >>= (return . stOptions)
61 let before = writerIncludeBefore opts
61 let before = writerIncludeBefore opts
62− let after = writerIncludeAfter opts
62+ after = writerIncludeAfter opts
63+ header = writerHeader opts
63 before' = if null before then empty else text before
64 before' = if null before then empty else text before
64 after' = if null after then empty else text after
65 after' = if null after then empty else text after
66+ header' = if null header then empty else text header
65 metaBlock <- metaToRST opts meta
67 metaBlock <- metaToRST opts meta
66 let head' = if (writerStandalone opts)
68 let head' = if (writerStandalone opts)
67− then metaBlock $+$ text (writerHeader opts)
69+ then metaBlock $+$ header'
68 else empty
70 else empty
69 body <- blockListToRST blocks
71 body <- blockListToRST blocks
70 includes <- get >>= (return . concat . stIncludes)
72 includes <- get >>= (return . concat . stIncludes)
@@ -129,6 +131,7 @@ escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
129
131
130-- | Convert bibliographic information into RST header.
132-- | Convert bibliographic information into RST header.
131metaToRST :: WriterOptions -> Meta -> State WriterState Doc
133metaToRST :: WriterOptions -> Meta -> State WriterState Doc
134+metaToRST _ (Meta [] [] []) = return empty
132metaToRST opts (Meta title authors date) = do
135metaToRST opts (Meta title authors date) = do
133 title' <- titleToRST title
136 title' <- titleToRST title
134 authors' <- authorsToRST authors
137 authors' <- authorsToRST authors
@@ -136,7 +139,7 @@ metaToRST opts (Meta title authors date) = do
136 let toc = if writerTableOfContents opts
139 let toc = if writerTableOfContents opts
137 then text "" $+$ text ".. contents::"
140 then text "" $+$ text ".. contents::"
138 else empty
141 else empty
139− return $ title' $+$ authors' $+$ date' $+$ toc
142+ return $ title' $+$ authors' $+$ date' $+$ toc $+$ text ""
140
143
141titleToRST :: [Inline] -> State WriterState Doc
144titleToRST :: [Inline] -> State WriterState Doc
142titleToRST [] = return empty
145titleToRST [] = return empty