Made spacing at end of output more consistent.

Previously some of the writers added spurious whitespace.
This has been removed, resolving Issue #232.

NOTE: If your application combines pandoc's output with other
text, for example in a template, you may need to add spacing.
For example, a pandoc-generated markdown file will not have
a blank line after the final block element.  If you are inserting
it into another markdown file, you will need to make sure there
is a blank line between it and the next block element.
This commit is contained in:
John MacFarlane 2010-07-20 12:42:12 -07:00
parent 465a4a6699
commit feb70b6e93
50 changed files with 10 additions and 67 deletions

View file

@ -64,7 +64,7 @@ pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do
then return ""
else liftM render $ inlineListToConTeXt date
body <- blockListToConTeXt blocks
let main = render body
let main = render $ body $$ text ""
let context = writerVariables options ++
[ ("toc", if writerTableOfContents options then "yes" else "")
, ("body", main)

View file

@ -63,7 +63,7 @@ pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
body <- blockListToMan opts blocks
notes <- liftM stNotes get
notes' <- notesToMan opts (reverse notes)
let main = render $ body $$ notes'
let main = render $ body $$ notes' $$ text ""
hasTables <- liftM stHasTables get
let context = writerVariables opts ++
[ ("body", main)

View file

@ -96,7 +96,7 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
notes' <- notesToMarkdown opts (reverse $ stNotes st)
st' <- get -- note that the notes may contain refs
refs' <- refsToMarkdown opts (reverse $ stRefs st')
let main = render $ body $+$ text "" $+$ notes' $+$ text "" $+$ refs'
let main = render $ foldl ($+$) empty $ [body, notes', refs']
let context = writerVariables opts ++
[ ("toc", render toc)
, ("body", main)

View file

@ -70,7 +70,7 @@ pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
refs <- liftM (reverse . stLinks) get >>= refsToRST
pics <- liftM (reverse . stImages) get >>= pictRefsToRST
hasMath <- liftM stHasMath get
let main = render $ body $+$ notes $+$ text "" $+$ refs $+$ pics
let main = render $ foldl ($+$) empty $ [body, notes, refs, pics]
let context = writerVariables opts ++
[ ("body", main)
, ("title", render title)

View file

@ -833,5 +833,5 @@ main = do
writerOutput <- writer writerOptions doc''
if outputFile == "-"
then B.putStrLn writerOutput
then B.putStr writerOutput
else B.writeFile outputFile writerOutput

View file

@ -25,4 +25,3 @@ $for(include-after)$
$include-after$
$endfor$
</article>

View file

@ -344,4 +344,3 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
, Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)."]
, CodeBlock ("",[],[]) " { <code> }"
, Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines."] ]

View file

@ -375,4 +375,3 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
[ [ Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]] ]
]
, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."] ]

View file

@ -36,4 +36,4 @@
><p
>foo bar</p
></blockquote
>
>

View file

@ -66,4 +66,3 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
>
</body>
</html>

View file

@ -66,4 +66,3 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
>
</body>
</html>

View file

@ -35,4 +35,3 @@ foo bar
\end{quote}
\end{document}

View file

@ -37,4 +37,3 @@ foo bar
\end{quote}
\end{document}

View file

@ -16,6 +16,3 @@ and one arrow on the second item of the pair).
Block quote:
> foo bar

View file

@ -17,6 +17,3 @@ and one arrow on the second item of the pair).
Block quote:
> foo bar

View file

@ -8,4 +8,3 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
, BlockQuote
[ Para [Str "foo",Space,Str "bar"] ]
]

View file

@ -22,5 +22,3 @@ Block quote:
foo bar

View file

@ -20,5 +20,3 @@ Block quote:
foo bar

View file

@ -40,4 +40,3 @@ Pandoc (Meta {docTitle = [Str "Title",Space,Str "spanning",Space,Str "multiple",
, OrderedList (3,Example,TwoParens)
[ [ Plain [Str "Third",Space,Str "example",Str "."] ]
] ]

View file

@ -309,4 +309,3 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
[ [ Plain [Str "b"] ]
, [ Plain [Str "b",Space,Str "2"] ]
, [ Plain [Str "b",Space,Str "2"] ] ] ], [ Plain [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"] ] ] ] ]

View file

@ -316,4 +316,3 @@
</div>
</body>
</html>

View file

@ -517,4 +517,3 @@
</div>
</body>
</html>

View file

@ -14,4 +14,4 @@
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
></li
></ul
>
>

View file

@ -33,4 +33,3 @@ STUFF INSERTED
STUFF INSERTED
</body>
</html>

View file

@ -116,4 +116,3 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
, [ Plain [Str "row"] ]
, [ Plain [Str "5.0"] ]
, [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ] ]

View file

@ -399,4 +399,4 @@
</td>
</tr>
</tbody>
</informaltable>
</informaltable>

View file

@ -298,4 +298,4 @@
></tr
></tbody
></table
>
>

View file

@ -175,4 +175,3 @@ Second
\\
\end{tabular}
\end{center}

View file

@ -74,6 +74,3 @@ Multiline table without column headers:
the blank line between
rows.
----------- ---------- ------------ --------------------------

View file

@ -209,4 +209,3 @@ Multiline table without column headers:
</tr>
</tbody>
</table>

View file

@ -113,4 +113,3 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
, [ Plain [Str "row"] ]
, [ Plain [Str "5",Str ".",Str "0"] ]
, [ Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."] ] ] ] ]

View file

@ -381,4 +381,4 @@
<text:p text:style-name="Table_20_Contents">Here's another one. Note the blank line between rows.</text:p>
</table:table-cell>
</table:table-row>
</table:table>
</table:table>

View file

@ -74,6 +74,3 @@ Multiline table without column headers:
the blank line between
rows.
----------- ---------- ------------ --------------------------

View file

@ -88,5 +88,3 @@ Multiline table without column headers:
| | | | the blank line between |
| | | | rows. |
+-------------+------------+--------------+----------------------------+

View file

@ -357,4 +357,3 @@
}
\intbl\row}
{\pard \ql \f0 \sa180 \li0 \fi0 \par}

View file

@ -156,4 +156,3 @@ Second
@tab 5.0
@tab Here's another one. Note the blank line between rows.
@end multitable

View file

@ -415,4 +415,3 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
[ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
]
, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]

View file

@ -906,4 +906,3 @@ This paragraph should not be part of the note, as it is not
indented.
\stoptext

View file

@ -1462,5 +1462,3 @@ or here: &lt;http://example.com/&gt;
</para>
</section>
</article>

View file

@ -1163,4 +1163,3 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'<code>'+e+'</code>'+'<\/'+
>
</body>
</html>

View file

@ -864,4 +864,3 @@ This paragraph should not be part of the note, as it is not
indented.
\end{document}

View file

@ -798,4 +798,3 @@ In quote.
In list.
.SH AUTHORS
John MacFarlane; Anonymous.

View file

@ -715,7 +715,6 @@ note] Here is an inline note.[^3]
This paragraph should not be part of the note, as it is not
indented.
[^1]:
Here is the footnote. It can go anywhere after the footnote
reference. It need not be placed at the end of the document.
@ -741,5 +740,3 @@ indented.
[^5]:
In list.

View file

@ -660,4 +660,3 @@ If you want, you can indent every line, but you can also be lazy and just indent
This paragraph should not be part of the note, as it is not indented.
<references />

View file

@ -415,4 +415,3 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
[ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
]
, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]

View file

@ -1452,4 +1452,3 @@ Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
</office:text>
</office:body>
</office:document-content>

View file

@ -669,7 +669,6 @@ Here is an inline note.[^3]
This paragraph should not be part of the note, as it is not
indented.
[^1]:
Here is the footnote. It can go anywhere after the footnote
reference. It need not be placed at the end of the document.
@ -694,5 +693,3 @@ indented.
[^5]:
In list.

View file

@ -888,6 +888,4 @@ indented.
.. [5]
In list.
.. |movie| image:: movie.jpg

View file

@ -450,4 +450,3 @@ links
}\sa180\par}
{\pard \ql \f0 \sa180 \li0 \fi0 This paragraph should not be part of the note, as it is not indented.\par}
}

View file

@ -1014,4 +1014,3 @@ And in list items.@footnote{In list.}
This paragraph should not be part of the note@comma{} as it is not indented.
@bye