Skip to content

Commit 9c7a140

Browse files
committed
feat: support HTML table tags in doc comments
Previously, an HTML table in a doc comment triggered: warning: HTML <table> tag not followed by pure text and then a fatal error: the existing HTML start-tag handler could only gather pure text between a tag and its matching end tag. The doc-comment extractor now recognizes `<table>`/`<tr>`/`<th>`/`<td>` and populates the existing `TableBlock`/`TableRow`/`TableCell` metadata. The HTML and Adoc generators each gain a doc/block/table partial. The Adoc output uses the `[%header]` table attribute when the first row is a header; the HTML output emits plain `<table>`/`<tr>`/`<th>`/`<td>`. The XML generator already serialized the metadata generically. Not (yet?) supported: - HTML attributes on `<table>`/`<tr>`/`<th>`/`<td>` (`align`, `colspan`, `rowspan`, `class`, `style`, ...). Column alignment is therefore never populated (`TableBlock::Alignments` is always empty) and cells cannot span rows or columns. - `<caption>`, `<col>`, and `<colgroup>`. - Block-level content inside cells (paragraphs, lists, code blocks). Cells currently hold only inline content. Closes issue #1146.
1 parent a3366b0 commit 9c7a140

28 files changed

Lines changed: 2474 additions & 1 deletion

mrdocs.rnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ grammar
726726
element table-row
727727
{
728728
element is-header { Bool }?,
729-
element cells { TableCell }*
729+
TableCell*
730730
}
731731

732732
TableBlock =
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{#if items.[0].is_header}}[%header]
2+
{{/if}}|===
3+
{{#each items}}{{#each cells}}| {{> doc/inline-container }} {{/each}}
4+
{{/each}}|===
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<table>
2+
{{#each items}}<tr>
3+
{{#each cells}}{{#if ../is_header}}<th>{{> doc/inline-container }}</th>{{else}}<td>{{> doc/inline-container }}</td>{{/if}}
4+
{{/each}}</tr>
5+
{{/each}}</table>

0 commit comments

Comments
 (0)