has_block_elements = True
out.parsed += '<pre class="m-code">{}</pre>'.format(html.escape(i.text))
+ elif i.tag == 'linebreak':
+ # Strip all whitespace before the linebreak, as it is of no use
+ out.parsed = out.parsed.rstrip() + '<br/>'
+
elif i.tag == 'programlisting':
# If it seems to be a standalone code paragraph, don't wrap it in
# <p> and use <pre>:
# is done by the caller.
out.parsed += html.escape(i.tail.lstrip())
- # Otherwise strip only if requested by the called
+ # Otherwise strip if requested by the caller or if this is right after
+ # a line break
elif i.tail:
- out.parsed += html.escape(i.tail.strip() if trim else i.tail)
+ tail: str = html.escape(i.tail)
+ if trim:
+ tail = tail.strip()
+ elif out.parsed.endswith('<br/>'):
+ tail = tail.lstrip()
+ out.parsed += tail
# Brief description always needs to be single paragraph because we're
# sending it out without enclosing <p>.
My Project
</h1>
<section id="section"><h2><a href="#section">Page section</a></h2><blockquote><p>A blockquote.</p></blockquote><pre class="m-code">Preformatted text.
-</pre><section id="subsection"><h3><a href="#subsection">Page subsection</a></h3><ul><li>Unordered</li><li>list</li><li>of<ul><li>nested</li><li>items</li></ul></li><li>and back</li></ul><section id="subsubsection"><h4><a href="#subsubsection">Sub-sub section</a></h4><ol><li>Ordered</li><li>list</li><li>of<ol><li>nested</li><li>items</li></ol></li><li>and back</li></ol><p><a name="an-anchor"></a> This is a <code>typewriter text</code>, <em>emphasis</em> and <strong>bold</strong>. <a href="http://google.com">http:/<wbr/>/<wbr/>google.com</a> and <a href="http://google.com">URL</a>. En-dash – and em-dash —. Reference to a <a href="index.html#subsection" class="m-dox">Page subsection</a>.</p></section></section></section>
+</pre><p>Paragraph<br/>with<br/>explicit<br/>line<br/>breaks.</p><section id="subsection"><h3><a href="#subsection">Page subsection</a></h3><ul><li>Unordered</li><li>list</li><li>of<ul><li>nested</li><li>items</li></ul></li><li>and back</li></ul><section id="subsubsection"><h4><a href="#subsubsection">Sub-sub section</a></h4><ol><li>Ordered</li><li>list</li><li>of<ol><li>nested</li><li>items</li></ol></li><li>and back</li></ol><p><a name="an-anchor"></a> This is a <code>typewriter text</code>, <em>emphasis</em> and <strong>bold</strong>. <a href="http://google.com">http:/<wbr/>/<wbr/>google.com</a> and <a href="http://google.com">URL</a>. En-dash – and em-dash —. Reference to a <a href="index.html#subsection" class="m-dox">Page subsection</a>.</p></section></section></section>
</div>
</div>
</div>