chiark / gitweb /
doxygen: support <pre> tags.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 10:55:09 +0000 (11:55 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 12:49:08 +0000 (13:49 +0100)
I can't comprehend why there is a separate <verbatim> and
<preformatted> tag.

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

index fee4c88b03f16c1966be6f04e2205fd21f781e03..07e4b62bea0fe3ff0aece2ce9de0ff93c94e5253 100755 (executable)
@@ -214,7 +214,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
         # - <heading>
         # - <blockquote>
         # - <simplesect> (if not describing return type) and <xrefsect>
-        # - <verbatim>
+        # - <verbatim>, <preformatted> (those are the same thing!)
         # - <variablelist>, <itemizedlist>, <orderedlist>
         # - <image>, <table>
         # - <mcss:div>
@@ -238,7 +238,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
             end_previous_paragraph = False
 
             # Straightforward elements
-            if i.tag in ['heading', 'blockquote', 'xrefsect', 'variablelist', 'verbatim', 'itemizedlist', 'orderedlist', 'image', 'table', '{http://mcss.mosra.cz/doxygen/}div']:
+            if i.tag in ['heading', 'blockquote', 'xrefsect', 'variablelist', 'verbatim', 'preformatted', 'itemizedlist', 'orderedlist', 'image', 'table', '{http://mcss.mosra.cz/doxygen/}div']:
                 end_previous_paragraph = True
 
             # <simplesect> describing return type is cut out of text flow, so
@@ -566,10 +566,10 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
 
             out.parsed += '</dl>'
 
-        elif i.tag == 'verbatim':
+        elif i.tag in ['verbatim', 'preformatted']:
             assert element.tag == 'para' # is inside a paragraph :/
             has_block_elements = True
-            out.parsed += '<pre class="m-code">{}</pre>'.format(html.escape(i.text))
+            out.parsed += '<pre>{}</pre>'.format(html.escape(i.text))
 
         elif i.tag == 'image':
             assert element.tag == 'para' # is inside a paragraph :/
index 6341068b2b427212c8c667625429711b18409413..8c1b50828ccf064813f14e827bc0bd721bb0a02c 100644 (file)
         <h1>
           My Project
         </h1>
-<section id="section"><h2><a href="#section">Page section</a></h2><blockquote><p>A blockquote.</p></blockquote><pre class="m-code">Preformatted text.
-</pre><p>Paragraph<br />with<br />explicit<br />line<br />breaks.</p><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>
+<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>
       </div>
     </div>
   </div>
index 33fc329ed5f8b2541ea7503d7fba71345c3aa087..c35d0ff3f99172f7c51122fc425dc28c4526d9d7 100644 (file)
@@ -8,6 +8,10 @@
 
 Paragraph \n with \n explicit \n line \n breaks.
 
+<pre>Differently
+  preformatted
+text.</pre>
+
 @subsection subsection Page subsection
 
 -   Unordered