has_block_elements = True
out.parsed += '<table class="m-table{}">'.format(
' ' + add_css_class if add_css_class else '')
+ thead_written = False
inside_tbody = False
row: ET.Element
is_header = entry.attrib['thead'] == 'yes'
is_header_row = is_header_row and is_header
row_data += '<{0}>{1}</{0}>'.format('th' if is_header else 'td', parse_desc(state, entry))
+
+ # Table head is opened upon encountering first header row
+ # and closed upon encountering first body row (in case it was
+ # ever opened). Encountering header row inside body again will
+ # not do anything special.
if is_header_row:
- assert not inside_tbody # Assume there's only one header row
- out.parsed += '<thead><tr>{}</tr></thead><tbody>'.format(row_data)
- inside_tbody = True
+ if not thead_written:
+ out.parsed += '<thead>'
+ thead_written = True
else:
- out.parsed += '<tr>{}</tr>'.format(row_data)
+ if thead_written and not inside_tbody:
+ out.parsed += '</thead>'
+ if not inside_tbody:
+ out.parsed += '<tbody>'
+ inside_tbody = True
+
+ out.parsed += '<tr>{}</tr>'.format(row_data)
if inside_tbody: out.parsed += '</tbody>'
out.parsed += '</table>'
<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><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>
+<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><table class="m-table"><thead><tr><th>Table</th><th>with</th></tr><tr><th>two</th><th>row</th></tr></thead><tbody><tr><td>table</td><td>header</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>