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
This commit is contained in:
parent
a03331a3b4
commit
dcedb2f712
2 changed files with 11 additions and 5 deletions
|
@ -52,11 +52,13 @@ pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
|
||||||
pandocToMarkdown opts (Pandoc meta blocks) = do
|
pandocToMarkdown opts (Pandoc meta blocks) = do
|
||||||
let before = writerIncludeBefore opts
|
let before = writerIncludeBefore opts
|
||||||
let after = writerIncludeAfter opts
|
let after = writerIncludeAfter opts
|
||||||
|
let header = writerHeader opts
|
||||||
let before' = if null before then empty else text before
|
let before' = if null before then empty else text before
|
||||||
let after' = if null after then empty else text after
|
let after' = if null after then empty else text after
|
||||||
|
let header' = if null header then empty else text header
|
||||||
metaBlock <- metaToMarkdown opts meta
|
metaBlock <- metaToMarkdown opts meta
|
||||||
let head' = if writerStandalone opts
|
let head' = if writerStandalone opts
|
||||||
then metaBlock $+$ text (writerHeader opts)
|
then metaBlock $+$ header'
|
||||||
else empty
|
else empty
|
||||||
let headerBlocks = filter isHeaderBlock blocks
|
let headerBlocks = filter isHeaderBlock blocks
|
||||||
let toc = if writerTableOfContents opts
|
let toc = if writerTableOfContents opts
|
||||||
|
@ -104,11 +106,12 @@ escapeString = escapeStringUsing markdownEscapes
|
||||||
|
|
||||||
-- | Convert bibliographic information into Markdown header.
|
-- | Convert bibliographic information into Markdown header.
|
||||||
metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
|
metaToMarkdown :: WriterOptions -> Meta -> State WriterState Doc
|
||||||
|
metaToMarkdown _ (Meta [] [] []) = return empty
|
||||||
metaToMarkdown opts (Meta title authors date) = do
|
metaToMarkdown opts (Meta title authors date) = do
|
||||||
title' <- titleToMarkdown opts title
|
title' <- titleToMarkdown opts title
|
||||||
authors' <- authorsToMarkdown authors
|
authors' <- authorsToMarkdown authors
|
||||||
date' <- dateToMarkdown date
|
date' <- dateToMarkdown date
|
||||||
return $ title' $+$ authors' $+$ date'
|
return $ title' $+$ authors' $+$ date' $+$ text ""
|
||||||
|
|
||||||
titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
|
titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
|
||||||
titleToMarkdown _ [] = return empty
|
titleToMarkdown _ [] = return empty
|
||||||
|
|
|
@ -59,12 +59,14 @@ pandocToRST :: Pandoc -> State WriterState Doc
|
||||||
pandocToRST (Pandoc meta blocks) = do
|
pandocToRST (Pandoc meta blocks) = do
|
||||||
opts <- get >>= (return . stOptions)
|
opts <- get >>= (return . stOptions)
|
||||||
let before = writerIncludeBefore opts
|
let before = writerIncludeBefore opts
|
||||||
let after = writerIncludeAfter opts
|
after = writerIncludeAfter opts
|
||||||
|
header = writerHeader opts
|
||||||
before' = if null before then empty else text before
|
before' = if null before then empty else text before
|
||||||
after' = if null after then empty else text after
|
after' = if null after then empty else text after
|
||||||
|
header' = if null header then empty else text header
|
||||||
metaBlock <- metaToRST opts meta
|
metaBlock <- metaToRST opts meta
|
||||||
let head' = if (writerStandalone opts)
|
let head' = if (writerStandalone opts)
|
||||||
then metaBlock $+$ text (writerHeader opts)
|
then metaBlock $+$ header'
|
||||||
else empty
|
else empty
|
||||||
body <- blockListToRST blocks
|
body <- blockListToRST blocks
|
||||||
includes <- get >>= (return . concat . stIncludes)
|
includes <- get >>= (return . concat . stIncludes)
|
||||||
|
@ -129,6 +131,7 @@ escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
|
||||||
|
|
||||||
-- | Convert bibliographic information into RST header.
|
-- | Convert bibliographic information into RST header.
|
||||||
metaToRST :: WriterOptions -> Meta -> State WriterState Doc
|
metaToRST :: WriterOptions -> Meta -> State WriterState Doc
|
||||||
|
metaToRST _ (Meta [] [] []) = return empty
|
||||||
metaToRST opts (Meta title authors date) = do
|
metaToRST opts (Meta title authors date) = do
|
||||||
title' <- titleToRST title
|
title' <- titleToRST title
|
||||||
authors' <- authorsToRST authors
|
authors' <- authorsToRST authors
|
||||||
|
@ -136,7 +139,7 @@ metaToRST opts (Meta title authors date) = do
|
||||||
let toc = if writerTableOfContents opts
|
let toc = if writerTableOfContents opts
|
||||||
then text "" $+$ text ".. contents::"
|
then text "" $+$ text ".. contents::"
|
||||||
else empty
|
else empty
|
||||||
return $ title' $+$ authors' $+$ date' $+$ toc
|
return $ title' $+$ authors' $+$ date' $+$ toc $+$ text ""
|
||||||
|
|
||||||
titleToRST :: [Inline] -> State WriterState Doc
|
titleToRST :: [Inline] -> State WriterState Doc
|
||||||
titleToRST [] = return empty
|
titleToRST [] = return empty
|
||||||
|
|
Loading…
Add table
Reference in a new issue