Append newline to the LineBreak of various writers

This change improves output formatting of content with a large amount of force line breaks, such as line-blocks. The following writers are affected:

* Dokuwiki
* HTML
* EPUB (via HTML)
* LaTeX
* MediaWiki
* OpenDocument
* Texinfo

This commit resolves #1924
This commit is contained in:
Tim Lin 2015-02-04 22:42:22 -08:00
parent fb7a03dcda
commit 0c18f3a854
13 changed files with 21 additions and 13 deletions

View file

@ -459,7 +459,7 @@ inlineToDokuWiki _ (RawInline f str)
| f == Format "html" = return $ "<html>" ++ str ++ "</html>"
| otherwise = return ""
inlineToDokuWiki _ (LineBreak) = return "\\\\ "
inlineToDokuWiki _ (LineBreak) = return "\\\\\n"
inlineToDokuWiki _ Space = return " "

View file

@ -656,7 +656,8 @@ inlineToHtml opts inline =
case inline of
(Str str) -> return $ strToHtml str
(Space) -> return $ strToHtml " "
(LineBreak) -> return $ if writerHtml5 opts then H5.br else H.br
(LineBreak) -> return $ (if writerHtml5 opts then H5.br else H.br)
<> strToHtml "\n"
(Span (id',classes,kvs) ils)
-> inlineListToHtml opts ils >>=
return . addAttrs opts attr' . H.span

View file

@ -802,7 +802,7 @@ inlineToLaTeX (RawInline f str)
| f == Format "latex" || f == Format "tex"
= return $ text str
| otherwise = return empty
inlineToLaTeX (LineBreak) = return "\\\\"
inlineToLaTeX (LineBreak) = return $ "\\\\" <> cr
inlineToLaTeX Space = return space
inlineToLaTeX (Link txt ('#':ident, _)) = do
contents <- inlineListToLaTeX txt

View file

@ -375,7 +375,7 @@ inlineToMediaWiki (RawInline f str)
| f == Format "html" = return str
| otherwise = return ""
inlineToMediaWiki (LineBreak) = return "<br />"
inlineToMediaWiki (LineBreak) = return "<br />\n"
inlineToMediaWiki Space = return " "

View file

@ -370,7 +370,7 @@ inlineToOpenDocument :: WriterOptions -> Inline -> State WriterState Doc
inlineToOpenDocument o ils
| Space <- ils = inTextStyle space
| Span _ xs <- ils = inlinesToOpenDocument o xs
| LineBreak <- ils = return $ selfClosingTag "text:line-break" []
| LineBreak <- ils = return $ selfClosingTag "text:line-break" [] <> cr
| Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s
| Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l
| Strong l <- ils = withTextStyle Bold $ inlinesToOpenDocument o l

View file

@ -421,7 +421,7 @@ inlineToTexinfo (RawInline f str)
return $ text "@tex" $$ text str $$ text "@end tex"
| f == "texinfo" = return $ text str
| otherwise = return empty
inlineToTexinfo (LineBreak) = return $ text "@*"
inlineToTexinfo (LineBreak) = return $ text "@*" <> cr
inlineToTexinfo Space = return $ char ' '
inlineToTexinfo (Link txt (src@('#':_), _)) = do

View file

@ -6,7 +6,8 @@ Some people use single underlines for //emphasis//.
Above the line is <sup>superscript</sup> and below the line is <sub>subscript</sub>.
A line\\ break.
A line\\
break.
hello %%//%% world %%**%% from %%__%% me

View file

@ -36,7 +36,8 @@ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Beca
Heres one with a bullet. * criminey.
There should be a hard line break\\ here.
There should be a hard line break\\
here.
----

View file

@ -35,7 +35,8 @@
<p>Heres a regular paragraph.</p>
<p>In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.</p>
<p>Heres one with a bullet. * criminey.</p>
<p>There should be a hard line break<br />here.</p>
<p>There should be a hard line break<br />
here.</p>
<hr />
<h1 id="block-quotes">Block Quotes</h1>
<p>E-mail style:</p>

View file

@ -109,7 +109,8 @@ item.
Here's one with a bullet. * criminey.
There should be a hard line break\\here.
There should be a hard line break\\
here.
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}

View file

@ -36,7 +36,8 @@ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Beca
Heres one with a bullet. * criminey.
There should be a hard line break<br />here.
There should be a hard line break<br />
here.
-----

View file

@ -896,7 +896,8 @@ of a paragraph looked like a list item.</text:p>
<text:p text:style-name="Text_20_body">Heres one with a bullet. *
criminey.</text:p>
<text:p text:style-name="Text_20_body">There should be a hard line
break<text:line-break />here.</text:p>
break<text:line-break />
here.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Block
Quotes</text:h>

View file

@ -129,7 +129,8 @@ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Beca
Here's one with a bullet. * criminey.
There should be a hard line break@*here.
There should be a hard line break@*
here.
@iftex
@bigskip@hrule@bigskip