chiark / gitweb /
documentation/doxygen: don't add a space between <p> and <code>.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 10 Jan 2022 19:48:28 +0000 (20:48 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 10 Jan 2022 20:04:13 +0000 (21:04 +0100)
Seems obvious in retrospect, but for some reason I never realized.

documentation/doxygen.py
documentation/test_doxygen/contents_code/index.html

index e4d9c931446186213822ae27ebbab81bee3200e4..f2b74dc7c41327ded814d73632719f3ef8f61f1b 100755 (executable)
@@ -1159,9 +1159,14 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
 
             # Doxygen doesn't add a space before <programlisting> if it's
             # inline, add it manually in case there should be a space before
-            # it. However, it does add a space after it always.
+            # it. However, it does add a space after it always so we don't need
+            # to.
+            #
+            # There doesn't need to be a space if it's a start of a tag, if
+            # there's already one, if there's an opening brace before or if
+            # <para> patching started a new paragraph right before.
             if not code_block:
-                if out.parsed and not out.parsed[-1].isspace() and not out.parsed[-1] in '([{':
+                if out.parsed and not out.parsed[-1].isspace() and not out.parsed[-1] in '([{' and not out.parsed.endswith('<p>'):
                     out.parsed += ' '
 
             # Hammer unhighlighted code out of the block
index 7dd02828b13078d20594cd7ec6520dad2f7c7aab..9c072f6e9753c380cee2897dad77294d8a93f60c 100644 (file)
@@ -26,7 +26,7 @@
 <span class="c1">// Spanning multiple lines.</span></pre><p><code class="m-code"><span class="n">Inline</span><span class="o">=</span><span class="n">code</span><span class="p">;</span></code> at the start of a line. Then a code that is inside of <code class="m-code"><span class="nb">true</span> <span class="o">||</span> <span class="nb">false</span></code> a text, should be delimited by spaces. But not when it is in (<code class="m-code"><span class="n">std</span><span class="o">::</span><span class="n">exit</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span></code>) parentheses.</p><pre class="m-code">    <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-doc">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>
+<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-doc">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>