chiark / gitweb /
doxygen: parsing <linebreak> tags.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 6 Dec 2017 23:24:39 +0000 (00:24 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 7 Dec 2017 01:23:50 +0000 (02:23 +0100)
doxygen/dox2html5.py
doxygen/test/contents_typography/index.html
doxygen/test/contents_typography/input.dox

index 0271dfc4a80450ba16642b5892c479775aca2f8e..cd3eca76fe46d721768cb9201d7ecfee598c185a 100755 (executable)
@@ -410,6 +410,10 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
             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>:
@@ -616,9 +620,15 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
             # 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>.
index eef3e86ae32566bcfd5504001cbd9b396960021f..2b8417a68f1f70fbb85fa1a232e59093710ad249 100644 (file)
@@ -38,7 +38,7 @@
           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 &ndash; and em-dash &mdash;. 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 &ndash; and em-dash &mdash;. Reference to a <a href="index.html#subsection" class="m-dox">Page subsection</a>.</p></section></section></section>
       </div>
     </div>
   </div>
index 411b8d32c3a13cd913b1444593f721e2f1f0fb1b..90b59ffea201380c7c609f02f3a555791b877843 100644 (file)
@@ -6,6 +6,8 @@
 
     Preformatted text.
 
+Paragraph \n with \n explicit \n line \n breaks.
+
 @subsection subsection Page subsection
 
 -   Unordered