From: Vladimír Vondruš Date: Mon, 29 Jan 2018 20:39:55 +0000 (+0100) Subject: doxygen: don't die on empty elements. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=316d7b0c6e171461ef5a8a5b3be51fc8978e561c;p=blog.git doxygen: don't die on empty elements. Include the block ones in the output, remove the inline ones. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 9c72cc5b..8f08e571 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -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 += '
{}
'.format(html.escape(i.text)) + out.parsed += '
{}
'.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 += ''.format(extract_id(i)) elif i.tag == 'computeroutput': - out.parsed += '{}'.format(parse_inline_desc(state, i).strip()) + content = parse_inline_desc(state, i).strip() + if content: out.parsed += '{}'.format(content) elif i.tag == 'emphasis': - out.parsed += '{}'.format( + content = parse_inline_desc(state, i).strip() + if content: out.parsed += '{}'.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 += '{}'.format( + content = parse_inline_desc(state, i).strip() + if content: out.parsed += '{}'.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) diff --git a/doxygen/test/contents_typography/index.html b/doxygen/test/contents_typography/index.html index 8c1b5082..d9d28eb3 100644 --- a/doxygen/test/contents_typography/index.html +++ b/doxygen/test/contents_typography/index.html @@ -25,7 +25,7 @@

Page section

A blockquote.

Preformatted text.
 

Paragraph
with
explicit
line
breaks.

Differently
   preformatted
-text.

Page subsection

  • Unordered
  • list
  • of
    • nested
    • items
  • and back

Sub-sub section

  1. Ordered
  2. list
  3. of
    1. nested
    2. items
  4. and back

This is a typewriter text, emphasis and bold. Emphasis with typewriter and bold nested. http://google.com and URL. En-dash – and em-dash —. Reference to a Page subsection. Named reference with special characters in title: » Warnings «. Reference with escaped characters in title: <anchor>.

+text.

Page subsection

  • Unordered
  • list
  • of
    • nested
    • items
  • and back

Sub-sub section

  1. Ordered
  2. list
  3. of
    1. nested
    2. items
  4. and back

This is a typewriter text, emphasis and bold. Emphasis with typewriter and bold nested. http://google.com and URL. En-dash – and em-dash —. Reference to a Page subsection. Named reference with special characters in title: » Warnings «. Reference with escaped characters in title: <anchor>.

Empty elements:

diff --git a/doxygen/test/contents_typography/input.dox b/doxygen/test/contents_typography/input.dox index c35d0ff3..0d437a89 100644 --- a/doxygen/test/contents_typography/input.dox +++ b/doxygen/test/contents_typography/input.dox @@ -39,6 +39,8 @@ and [URL](http://google.com). En-dash -- and em-dash ---. Reference to a @ref warnings "» Warnings «". Reference with escaped characters in title: @ref an-anchor "". +Empty elements:

+
 */
 
 /** @page warnings Content that produces warnings