chiark / gitweb /
doxygen: properly handle inline elements at start of inserted paragraphs.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 13 Dec 2017 20:52:44 +0000 (21:52 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 13 Dec 2017 20:57:13 +0000 (21:57 +0100)
Okay, this should be the last broken thing.

doxygen/dox2html5.py
doxygen/test/contents_blocks/index.html
doxygen/test/contents_blocks/input.dox
doxygen/test/contents_code/index.html
doxygen/test/contents_code/input.dox
doxygen/test/contents_math/index.html
doxygen/test/contents_math/input.dox

index 088053cae11c27c6351481a70c4995b7096c1234..c8ab08c82578621b5360256f4ab4625b2313bd59 100755 (executable)
@@ -287,6 +287,19 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                     out.parsed += '</p>'
                 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 += '<p>'
+                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
index f7df930680bea654f6981b042b484d3ae417da44..5befc7626282f566e8e571cce0c0688a9ec8847e 100644 (file)
@@ -37,7 +37,7 @@
         <h1>
           My Project
         </h1>
-<p>First paragraph containing some content.</p><aside class="m-note m-warning"><h4>Attention</h4><p>An attention section.</p></aside><aside class="m-note m-default"><h4>See also</h4><p>Other section.</p></aside><p>Paragraph following the sections.</p><aside class="m-note m-info"><h4>Note</h4><p>A note.</p></aside><aside class="m-note m-danger"><h4><a href="bug.html#_bug000001" class="m-dox">Bug</a></h4><p>This is a bug.</p></aside><aside class="m-note m-dim"><h4><a href="todo.html#_todo000001" class="m-dox">Todo</a></h4><p>Or a TODO.</p></aside><aside class="m-note m-danger"><h4><a href="deprecated.html#_deprecated000001" class="m-dox">Deprecated</a></h4><p>Which is deprecated.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000001" class="m-dox">Old stuff</a></h4><p>This is old.</p></aside><blockquote><p>A blockquote</p></blockquote><p>Text right after that blockquote should be a new paragraph.</p><ul><li>A simple</li><li>List<ol><li>With one line</li><li>for each</li></ol></li><li>item, so paragraphs are removed</li></ul><ul><li>A simple</li><li>List<ol><li>With the sublist delimited</li><li>by blank lines</li></ol></li><li>should behave the same as above</li></ul><ul><li><p>A new list</p><p>of multiple</p><p>paragraphs.</p></li><li><p>Another item</p><ul><li><p>A sub list</p><p>Another paragraph</p></li></ul></li></ul><p>A paragraph after that list.</p><table class="m-table"><thead><tr><th>Table header</th><th>Another</th><th>Third</th></tr></thead><tbody><tr><td>Cell</td><td>Another cell</td><td>3rd</td></tr><tr><td>Next row</td><td></td><td>This</td></tr><tr><td>is a table</td><td><em>really</em></td><td>yes.</td></tr></tbody></table><aside class="m-note m-warning"><h4>Attention</h4><p>Attention, first paragraph.</p><p>Attention, second paragraph.</p><p>Attention, third paragraph.</p></aside><aside class="m-note m-info"><h4>Note</h4><p>A note, not merged with the above.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000002" class="m-dox">Old stuff</a></h4><p>This is not merged.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000003" class="m-dox">Old stuff</a></h4><p>With this. Only on the listing page.</p></aside>
+<p>First paragraph containing some content.</p><aside class="m-note m-warning"><h4>Attention</h4><p>An attention section.</p></aside><aside class="m-note m-default"><h4>See also</h4><p>Other section.</p></aside><p>Paragraph following the sections.</p><aside class="m-note m-info"><h4>Note</h4><p>A note.</p></aside><aside class="m-note m-danger"><h4><a href="bug.html#_bug000001" class="m-dox">Bug</a></h4><p>This is a bug.</p></aside><aside class="m-note m-dim"><h4><a href="todo.html#_todo000001" class="m-dox">Todo</a></h4><p>Or a TODO.</p></aside><aside class="m-note m-danger"><h4><a href="deprecated.html#_deprecated000001" class="m-dox">Deprecated</a></h4><p>Which is deprecated.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000001" class="m-dox">Old stuff</a></h4><p>This is old.</p></aside><blockquote><p>A blockquote</p></blockquote><p>Text right after that blockquote should be a new paragraph.</p><ul><li>A simple</li><li>List<ol><li>With one line</li><li>for each</li></ol></li><li>item, so paragraphs are removed</li></ul><ul><li>A simple</li><li>List<ol><li>With the sublist delimited</li><li>by blank lines</li></ol></li><li>should behave the same as above</li></ul><ul><li><p>A new list</p><p>of multiple</p><p>paragraphs.</p></li><li><p>Another item</p><ul><li><p>A sub list</p><p>Another paragraph</p></li></ul></li></ul><p>A paragraph after that list.</p><table class="m-table"><thead><tr><th>Table header</th><th>Another</th><th>Third</th></tr></thead><tbody><tr><td>Cell</td><td>Another cell</td><td>3rd</td></tr><tr><td>Next row</td><td></td><td>This</td></tr><tr><td>is a table</td><td><em>really</em></td><td>yes.</td></tr></tbody></table><aside class="m-note m-warning"><h4>Attention</h4><p>Attention, first paragraph.</p><p>Attention, second paragraph.</p><p>Attention, third paragraph.</p></aside><aside class="m-note m-info"><h4>Note</h4><p>A note, not merged with the above.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000002" class="m-dox">Old stuff</a></h4><p>This is not merged.</p></aside><aside class="m-note m-default"><h4><a href="old.html#_old000003" class="m-dox">Old stuff</a></h4><p>With this. Only on the listing page.</p></aside><aside class="m-note m-danger"><h4>Warning</h4><p>Non-text item after a note/whatever should be part of a paragraph:</p></aside><p><em>This is</em> inside a paragraph.</p>
       </div>
     </div>
   </div>
index ba1a7cc0d9a8ac1d877a38b3f73e9f0e8d1485b7..47046f5f2dca573a82d7094232e602d6940bdf14 100644 (file)
@@ -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
index 148c5a335cefdb52226032ad82c796513e26fa51..08919eb9c69609ce27c2509675e2bb0fd6856069 100644 (file)
@@ -42,7 +42,7 @@
     <span class="c1">// a block</span>
         <span class="c1">// that is indented</span>
     <span class="c1">// but has a lot of trailing whitespace which should be removed</span>
-<span class="p">}</span></pre><aside class="m-note m-info"><h4>Note</h4><p>Code block after a note doesn&#x27;t start a new paragraph in the XML but should be treated as a block:</p></aside><pre class="m-code"><span class="c1">// this is a new block</span></pre><aside class="m-note m-dim"><h4><a href="todo.html#_todo000001" class="m-dox">Todo</a></h4><p>However, code block after an xrefitem is delimited properly by Doxygen:</p></aside><pre class="m-code"><span class="c1">// code?</span></pre><blockquote><p>And code block after a blockquote as well:</p></blockquote><pre class="m-code"><span class="c1">// another block</span></pre><aside class="m-note m-warning"><h4>Attention</h4><p>Inline code after a note should not be treated as block, though:</p></aside><p>The <code class="m-code"><span class="k">constexpr</span></code> functions are pure.</p><p>Code block inside a list (has to be done using HTML):</p><ul><li><p>A paragraph.</p><pre class="m-code"><span class="cp">#include</span> <span class="cpf">&lt;os&gt;</span><span class="cp"></span></pre></li><li><p>Another paragraph.</p><p>Yet another</p></li><li>A single paragraph, rendered without the wrapping tag</li></ul><aside class="m-note m-info"><h4>Note</h4><p>Code block inside a note:</p><pre class="m-code"><span class="c1">// code block</span></pre><p>Another paragraph of that note.</p></aside>
+<span class="p">}</span></pre><aside class="m-note m-info"><h4>Note</h4><p>Code block after a note doesn&#x27;t start a new paragraph in the XML but should be treated as a block:</p></aside><pre class="m-code"><span class="c1">// this is a new block</span></pre><aside class="m-note m-dim"><h4><a href="todo.html#_todo000001" class="m-dox">Todo</a></h4><p>However, code block after an xrefitem is delimited properly by Doxygen:</p></aside><pre class="m-code"><span class="c1">// code?</span></pre><blockquote><p>And code block after a blockquote as well:</p></blockquote><pre class="m-code"><span class="c1">// another block</span></pre><aside class="m-note m-warning"><h4>Attention</h4><p>Inline code after a note should not be treated as block, though:</p></aside><p>The <code class="m-code"><span class="k">constexpr</span></code> functions are pure.</p><aside class="m-note m-danger"><h4>Warning</h4><p>Inline code right after a block should be part of a paragraph:</p></aside><p> <code class="m-code"><span class="kr">inline</span></code> variables are a thing?</p><p>Code block inside a list (has to be done using HTML):</p><ul><li><p>A paragraph.</p><pre class="m-code"><span class="cp">#include</span> <span class="cpf">&lt;os&gt;</span><span class="cp"></span></pre></li><li><p>Another paragraph.</p><p>Yet another</p></li><li>A single paragraph, rendered without the wrapping tag</li></ul><aside class="m-note m-info"><h4>Note</h4><p>Code block inside a note:</p><pre class="m-code"><span class="c1">// code block</span></pre><p>Another paragraph of that note.</p></aside>
       </div>
     </div>
   </div>
index 25588804c1634376e8ac625180aa70a5e600251b..c3805fa5898e90bcfcabc39529c96df9b123c525 100644 (file)
@@ -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):
 
 <ul>
index db6f42a181972419ea9e4c85ce67370ec2b45456..ba00157c0fd3bf9b41ea4f25dd81fd106d551652 100644 (file)
@@ -89,7 +89,43 @@ $ \hat q $
 <use x='0.858581' xlink:href='#eq2-g1-94' y='0'/>
 <use x='0' xlink:href='#eq2-g0-113' y='0'/>
 </g>
-</svg> is how quaternion is denoted.</p>
+</svg> is how quaternion is denoted.</p><div class="m-math"><svg height='13.7321pt' version='1.1' viewBox='164.011 -10.9857 60.0231 10.9857' width='75.0289pt'>
+<title>LaTeX Math</title>
+<desc>
+\[ a^2 + b^2 = c^2 \]
+</desc>
+<defs>
+<path d='M3.59851 -1.42267C3.53873 -1.21943 3.53873 -1.19552 3.37136 -0.968369C3.10834 -0.633624 2.58232 -0.119552 2.02042 -0.119552C1.53026 -0.119552 1.25529 -0.561893 1.25529 -1.26725C1.25529 -1.92478 1.6259 -3.26376 1.85305 -3.76588C2.25953 -4.60274 2.82142 -5.03313 3.28767 -5.03313C4.07671 -5.03313 4.23213 -4.0528 4.23213 -3.95716C4.23213 -3.94521 4.19626 -3.78979 4.18431 -3.76588L3.59851 -1.42267ZM4.36364 -4.48319C4.23213 -4.79402 3.90934 -5.27223 3.28767 -5.27223C1.93674 -5.27223 0.478207 -3.52677 0.478207 -1.75741C0.478207 -0.573848 1.17161 0.119552 1.98456 0.119552C2.64209 0.119552 3.20399 -0.394521 3.53873 -0.789041C3.65828 -0.0836862 4.22017 0.119552 4.57883 0.119552S5.22441 -0.0956413 5.4396 -0.526027C5.63088 -0.932503 5.79826 -1.66177 5.79826 -1.70959C5.79826 -1.76936 5.75044 -1.81719 5.6787 -1.81719C5.57111 -1.81719 5.55915 -1.75741 5.51133 -1.57808C5.332 -0.872727 5.10486 -0.119552 4.61469 -0.119552C4.268 -0.119552 4.24408 -0.430386 4.24408 -0.669489C4.24408 -0.944458 4.27995 -1.07597 4.38755 -1.54222C4.47123 -1.8411 4.53101 -2.10411 4.62665 -2.45081C5.06899 -4.24408 5.17659 -4.67447 5.17659 -4.7462C5.17659 -4.91357 5.04508 -5.04508 4.86575 -5.04508C4.48319 -5.04508 4.38755 -4.62665 4.36364 -4.48319Z' id='eq3-g0-97'/>
+<path d='M2.76164 -7.99801C2.7736 -8.04583 2.79751 -8.11756 2.79751 -8.17733C2.79751 -8.29689 2.67796 -8.29689 2.65405 -8.29689C2.64209 -8.29689 2.21171 -8.26102 1.99651 -8.23711C1.79328 -8.22516 1.61395 -8.20125 1.39875 -8.18929C1.11183 -8.16538 1.02814 -8.15342 1.02814 -7.93823C1.02814 -7.81868 1.1477 -7.81868 1.26725 -7.81868C1.87696 -7.81868 1.87696 -7.71108 1.87696 -7.59153C1.87696 -7.50785 1.78132 -7.16115 1.7335 -6.94595L1.44658 -5.79826C1.32702 -5.32005 0.645579 -2.60623 0.597758 -2.39103C0.537983 -2.09215 0.537983 -1.88892 0.537983 -1.7335C0.537983 -0.514072 1.21943 0.119552 1.99651 0.119552C3.38331 0.119552 4.81793 -1.66177 4.81793 -3.39527C4.81793 -4.49514 4.19626 -5.27223 3.29963 -5.27223C2.67796 -5.27223 2.11606 -4.75816 1.88892 -4.51905L2.76164 -7.99801ZM2.00847 -0.119552C1.6259 -0.119552 1.20747 -0.406476 1.20747 -1.33898C1.20747 -1.7335 1.24334 -1.96065 1.45853 -2.79751C1.4944 -2.95293 1.68568 -3.71806 1.7335 -3.87347C1.75741 -3.96912 2.46276 -5.03313 3.27572 -5.03313C3.80174 -5.03313 4.04085 -4.5071 4.04085 -3.88543C4.04085 -3.31158 3.7061 -1.96065 3.40722 -1.33898C3.10834 -0.6934 2.55841 -0.119552 2.00847 -0.119552Z' id='eq3-g0-98'/>
+<path d='M4.67447 -4.49514C4.44732 -4.49514 4.33973 -4.49514 4.17235 -4.35168C4.10062 -4.29191 3.96912 -4.11258 3.96912 -3.9213C3.96912 -3.68219 4.14844 -3.53873 4.37559 -3.53873C4.66252 -3.53873 4.98531 -3.77783 4.98531 -4.25604C4.98531 -4.82989 4.43537 -5.27223 3.61046 -5.27223C2.04433 -5.27223 0.478207 -3.56264 0.478207 -1.86501C0.478207 -0.824907 1.12379 0.119552 2.34321 0.119552C3.96912 0.119552 4.99726 -1.1477 4.99726 -1.30311C4.99726 -1.37484 4.92553 -1.43462 4.87771 -1.43462C4.84184 -1.43462 4.82989 -1.42267 4.72229 -1.31507C3.95716 -0.298879 2.82142 -0.119552 2.36712 -0.119552C1.54222 -0.119552 1.2792 -0.836862 1.2792 -1.43462C1.2792 -1.85305 1.48244 -3.0127 1.91283 -3.82565C2.22366 -4.38755 2.86924 -5.03313 3.62242 -5.03313C3.77783 -5.03313 4.43537 -5.00922 4.67447 -4.49514Z' id='eq3-g0-99'/>
+<path d='M4.77011 -2.76164H8.06974C8.23711 -2.76164 8.4523 -2.76164 8.4523 -2.97684C8.4523 -3.20399 8.24907 -3.20399 8.06974 -3.20399H4.77011V-6.50361C4.77011 -6.67098 4.77011 -6.88618 4.55492 -6.88618C4.32777 -6.88618 4.32777 -6.68294 4.32777 -6.50361V-3.20399H1.02814C0.860772 -3.20399 0.645579 -3.20399 0.645579 -2.98879C0.645579 -2.76164 0.848817 -2.76164 1.02814 -2.76164H4.32777V0.537983C4.32777 0.705355 4.32777 0.920548 4.54296 0.920548C4.77011 0.920548 4.77011 0.71731 4.77011 0.537983V-2.76164Z' id='eq3-g2-43'/>
+<path d='M8.06974 -3.87347C8.23711 -3.87347 8.4523 -3.87347 8.4523 -4.08867C8.4523 -4.31582 8.24907 -4.31582 8.06974 -4.31582H1.02814C0.860772 -4.31582 0.645579 -4.31582 0.645579 -4.10062C0.645579 -3.87347 0.848817 -3.87347 1.02814 -3.87347H8.06974ZM8.06974 -1.64981C8.23711 -1.64981 8.4523 -1.64981 8.4523 -1.86501C8.4523 -2.09215 8.24907 -2.09215 8.06974 -2.09215H1.02814C0.860772 -2.09215 0.645579 -2.09215 0.645579 -1.87696C0.645579 -1.64981 0.848817 -1.64981 1.02814 -1.64981H8.06974Z' id='eq3-g2-61'/>
+<path d='M2.24757 -1.6259C2.37509 -1.74545 2.70984 -2.00847 2.83736 -2.12005C3.33151 -2.57435 3.80174 -3.0127 3.80174 -3.73798C3.80174 -4.68643 3.00473 -5.30012 2.00847 -5.30012C1.05205 -5.30012 0.422416 -4.57484 0.422416 -3.8655C0.422416 -3.47497 0.73325 -3.41918 0.844832 -3.41918C1.0122 -3.41918 1.25928 -3.53873 1.25928 -3.84159C1.25928 -4.25604 0.860772 -4.25604 0.765131 -4.25604C0.996264 -4.83786 1.53026 -5.03711 1.9208 -5.03711C2.66202 -5.03711 3.04458 -4.40747 3.04458 -3.73798C3.04458 -2.90909 2.46276 -2.30336 1.52229 -1.33898L0.518057 -0.302864C0.422416 -0.215193 0.422416 -0.199253 0.422416 0H3.57061L3.80174 -1.42665H3.55467C3.53076 -1.26725 3.467 -0.868742 3.37136 -0.71731C3.32354 -0.653549 2.71781 -0.653549 2.59029 -0.653549H1.17161L2.24757 -1.6259Z' id='eq3-g1-50'/>
+</defs>
+<g id='eq3-page1'>
+<use x='164.011' xlink:href='#eq3-g0-97' y='-0.913201'/>
+<use x='170.156' xlink:href='#eq3-g1-50' y='-5.84939'/>
+<use x='177.545' xlink:href='#eq3-g2-43' y='-0.913201'/>
+<use x='189.306' xlink:href='#eq3-g0-98' y='-0.913201'/>
+<use x='194.283' xlink:href='#eq3-g1-50' y='-5.84939'/>
+<use x='202.336' xlink:href='#eq3-g2-61' y='-0.913201'/>
+<use x='214.762' xlink:href='#eq3-g0-99' y='-0.913201'/>
+<use x='219.8' xlink:href='#eq3-g1-50' y='-5.84939'/>
+</g>
+</svg></div><p><svg class="m-math" style="vertical-align: -0.0pt;" height='11.8434pt' version='1.1' viewBox='0 -9.47474 9.27217 9.47474' width='11.5902pt'>
+<title>LaTeX Math</title>
+<desc>
+$ c^2 $
+</desc>
+<defs>
+<path d='M4.67447 -4.49514C4.44732 -4.49514 4.33973 -4.49514 4.17235 -4.35168C4.10062 -4.29191 3.96912 -4.11258 3.96912 -3.9213C3.96912 -3.68219 4.14844 -3.53873 4.37559 -3.53873C4.66252 -3.53873 4.98531 -3.77783 4.98531 -4.25604C4.98531 -4.82989 4.43537 -5.27223 3.61046 -5.27223C2.04433 -5.27223 0.478207 -3.56264 0.478207 -1.86501C0.478207 -0.824907 1.12379 0.119552 2.34321 0.119552C3.96912 0.119552 4.99726 -1.1477 4.99726 -1.30311C4.99726 -1.37484 4.92553 -1.43462 4.87771 -1.43462C4.84184 -1.43462 4.82989 -1.42267 4.72229 -1.31507C3.95716 -0.298879 2.82142 -0.119552 2.36712 -0.119552C1.54222 -0.119552 1.2792 -0.836862 1.2792 -1.43462C1.2792 -1.85305 1.48244 -3.0127 1.91283 -3.82565C2.22366 -4.38755 2.86924 -5.03313 3.62242 -5.03313C3.77783 -5.03313 4.43537 -5.00922 4.67447 -4.49514Z' id='eq4-g0-99'/>
+<path d='M2.24757 -1.6259C2.37509 -1.74545 2.70984 -2.00847 2.83736 -2.12005C3.33151 -2.57435 3.80174 -3.0127 3.80174 -3.73798C3.80174 -4.68643 3.00473 -5.30012 2.00847 -5.30012C1.05205 -5.30012 0.422416 -4.57484 0.422416 -3.8655C0.422416 -3.47497 0.73325 -3.41918 0.844832 -3.41918C1.0122 -3.41918 1.25928 -3.53873 1.25928 -3.84159C1.25928 -4.25604 0.860772 -4.25604 0.765131 -4.25604C0.996264 -4.83786 1.53026 -5.03711 1.9208 -5.03711C2.66202 -5.03711 3.04458 -4.40747 3.04458 -3.73798C3.04458 -2.90909 2.46276 -2.30336 1.52229 -1.33898L0.518057 -0.302864C0.422416 -0.215193 0.422416 -0.199253 0.422416 0H3.57061L3.80174 -1.42665H3.55467C3.53076 -1.26725 3.467 -0.868742 3.37136 -0.71731C3.32354 -0.653549 2.71781 -0.653549 2.59029 -0.653549H1.17161L2.24757 -1.6259Z' id='eq4-g1-50'/>
+</defs>
+<g id='eq4-page1'>
+<use x='0' xlink:href='#eq4-g0-99' y='0'/>
+<use x='5.03799' xlink:href='#eq4-g1-50' y='-4.33844'/>
+</g>
+</svg> should be part of a new paragraph, not stuck out of it.</p>
       </div>
     </div>
   </div>
index 8f72d8625621ca94786f951c873963ccce2e44b9..4eb2b0a1a60d8b31542a93f5da0d980c578ab4d5 100644 (file)
@@ -8,4 +8,10 @@ Here's a block formula:
 
 And @f$ \hat q @f$ is how quaternion is denoted.
 
+@f[
+    a^2 + b^2 = c^2
+@f]
+
+@f$ c^2 @f$ should be part of a new paragraph, not stuck out of it.
+
 */