From c7059a164d5732d318488a2c59e4435f34649bdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Dec 2017 21:52:44 +0100 Subject: [PATCH] doxygen: properly handle inline elements at start of inserted paragraphs. Okay, this should be the last broken thing. --- doxygen/dox2html5.py | 13 +++++++++ doxygen/test/contents_blocks/index.html | 2 +- doxygen/test/contents_blocks/input.dox | 4 +++ doxygen/test/contents_code/index.html | 2 +- doxygen/test/contents_code/input.dox | 4 +++ doxygen/test/contents_math/index.html | 38 ++++++++++++++++++++++++- doxygen/test/contents_math/input.dox | 6 ++++ 7 files changed, 66 insertions(+), 3 deletions(-) diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 088053ca..c8ab08c8 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -287,6 +287,19 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. out.parsed += '

' out.write_paragraph_close_tag = False + # There might be *inline* elements that need to start a *new* + # paragraph, on the other hand. OF COURSE DOXYGEN DOESN'T DO THAT + # EITHER. There's a similar block of code that handles case with + # non-empty i.tail() at the end of the loop iteration. + if not out.write_paragraph_close_tag and (i.tag in ['linebreak', 'anchor', 'computeroutput', 'emphasis', 'bold', 'ref', 'ulink'] or (i.tag == 'formula' and not formula_block) or (i.tag == 'programlisting' and not code_block)): + # Assume sanity -- we are *either* closing a paragraph because + # a new block element appeared after inline stuff *or* opening + # a paragraph because there's inline text after a block + # element and that is mutually exclusive. + assert not end_previous_paragraph + out.parsed += '

' + out.write_paragraph_close_tag = True + # Block elements if i.tag in ['sect1', 'sect2', 'sect3']: assert element.tag != 'para' # should be top-level block element diff --git a/doxygen/test/contents_blocks/index.html b/doxygen/test/contents_blocks/index.html index f7df9306..5befc762 100644 --- a/doxygen/test/contents_blocks/index.html +++ b/doxygen/test/contents_blocks/index.html @@ -37,7 +37,7 @@

My Project

-

First paragraph containing some content.

Paragraph following the sections.

A blockquote

Text right after that blockquote should be a new paragraph.

A paragraph after that list.

Table headerAnotherThird
CellAnother cell3rd
Next rowThis
is a tablereallyyes.
+

First paragraph containing some content.

Paragraph following the sections.

A blockquote

Text right after that blockquote should be a new paragraph.

A paragraph after that list.

Table headerAnotherThird
CellAnother cell3rd
Next rowThis
is a tablereallyyes.

This is inside a paragraph.

diff --git a/doxygen/test/contents_blocks/input.dox b/doxygen/test/contents_blocks/input.dox index ba1a7cc0..47046f5f 100644 --- a/doxygen/test/contents_blocks/input.dox +++ b/doxygen/test/contents_blocks/input.dox @@ -72,6 +72,10 @@ is a table | *really* | yes. @xrefitem old "Old stuff" "Just old" With this. Only on the listing page. +@warning Non-text item after a note/whatever should be part of a paragraph: + +_This is_ inside a paragraph. + */ /** @page other Other page diff --git a/doxygen/test/contents_code/index.html b/doxygen/test/contents_code/index.html index 148c5a33..08919eb9 100644 --- a/doxygen/test/contents_code/index.html +++ b/doxygen/test/contents_code/index.html @@ -42,7 +42,7 @@ // a block // that is indented // but has a lot of trailing whitespace which should be removed -}
// this is a new block
// code?

And code block after a blockquote as well:

// another block

The constexpr functions are pure.

Code block inside a list (has to be done using HTML):

+}
// this is a new block
// code?

And code block after a blockquote as well:

// another block

The constexpr functions are pure.

inline variables are a thing?

Code block inside a list (has to be done using HTML):

diff --git a/doxygen/test/contents_code/input.dox b/doxygen/test/contents_code/input.dox index 25588804..c3805fa5 100644 --- a/doxygen/test/contents_code/input.dox +++ b/doxygen/test/contents_code/input.dox @@ -44,6 +44,10 @@ spaces. But not when it is in (@code{.cpp} std::exit(2); @endcode) parentheses. The @code{.cpp} constexpr @endcode functions are pure. +@warning Inline code right after a block should be part of a paragraph: + +@code{.cpp} inline @endcode variables are a thing? + Code block inside a list (has to be done using HTML):