chiark / gitweb /
doxygen: don't die on empty elements.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 20:39:55 +0000 (21:39 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 22:54:01 +0000 (23:54 +0100)
Include the block ones in the output, remove the inline ones.

doxygen/dox2html5.py
doxygen/test/contents_typography/index.html
doxygen/test/contents_typography/input.dox

index 9c72cc5bd2082f2fc4bb6342e2b32e588d6a48be..8f08e571e434e7554b55eb74c638238dcb3114bc 100755 (executable)
@@ -573,7 +573,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
         elif i.tag in ['verbatim', 'preformatted']:
             assert element.tag == 'para' # is inside a paragraph :/
             has_block_elements = True
-            out.parsed += '<pre>{}</pre>'.format(html.escape(i.text))
+            out.parsed += '<pre>{}</pre>'.format(html.escape(i.text or ''))
 
         elif i.tag == 'image':
             assert element.tag == 'para' # is inside a paragraph :/
@@ -759,17 +759,20 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
             out.parsed += '<a name="{}"></a>'.format(extract_id(i))
 
         elif i.tag == 'computeroutput':
-            out.parsed += '<code>{}</code>'.format(parse_inline_desc(state, i).strip())
+            content = parse_inline_desc(state, i).strip()
+            if content: out.parsed += '<code>{}</code>'.format(content)
 
         elif i.tag == 'emphasis':
-            out.parsed += '<em{}>{}</em>'.format(
+            content = parse_inline_desc(state, i).strip()
+            if content: out.parsed += '<em{}>{}</em>'.format(
                 ' class="{}"'.format(add_inline_css_class) if add_inline_css_class else '',
-                parse_inline_desc(state, i).strip())
+                content)
 
         elif i.tag == 'bold':
-            out.parsed += '<strong{}>{}</strong>'.format(
+            content = parse_inline_desc(state, i).strip()
+            if content: out.parsed += '<strong{}>{}</strong>'.format(
                 ' class="{}"'.format(add_inline_css_class) if add_inline_css_class else '',
-                parse_inline_desc(state, i).strip())
+                content)
 
         elif i.tag == 'ref':
             out.parsed += parse_ref(state, i)
index 8c1b50828ccf064813f14e827bc0bd721bb0a02c..d9d28eb3c4bfba96ff113ab4b8aa5134c3ff13af 100644 (file)
@@ -25,7 +25,7 @@
 <section id="section"><h2><a href="#section">Page section</a></h2><blockquote><p>A blockquote.</p></blockquote><pre>Preformatted text.
 </pre><p>Paragraph<br />with<br />explicit<br />line<br />breaks.</p><pre>Differently
   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>. <em>Emphasis with <code>typewriter</code> and <strong>bold</strong> nested.</em> <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>. Named reference with special characters in title: <a href="warnings.html" class="m-dox">&raquo; Warnings &laquo;</a>. Reference with escaped characters in&nbsp;title: <a href="index.html#an-anchor" class="m-dox">&lt;anchor&gt;</a>.</p></section></section></section>
+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>. <em>Emphasis with <code>typewriter</code> and <strong>bold</strong> nested.</em> <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>. Named reference with special characters in title: <a href="warnings.html" class="m-dox">&raquo; Warnings &laquo;</a>. Reference with escaped characters in&nbsp;title: <a href="index.html#an-anchor" class="m-dox">&lt;anchor&gt;</a>.</p><p>Empty elements:</p><pre></pre></section></section></section>
       </div>
     </div>
   </div>
index c35d0ff3f99172f7c51122fc425dc28c4526d9d7..0d437a89225b389dae138b69cc4a3f40f87dd62f 100644 (file)
@@ -39,6 +39,8 @@ and [URL](http://google.com). En-dash -- and em-dash ---. Reference to a
 @ref warnings "&raquo; Warnings &laquo;". Reference with escaped characters
 in&nbsp;title: @ref an-anchor "<anchor>".
 
+Empty elements: <em></em> <tt></tt> <strong></strong> <pre></pre>
+
 */
 
 /** @page warnings Content that produces warnings