UNPKG

markdown-it-multimd-table-ext

Version:

Multimarkdown table syntax plugin for markdown-it markdown parser

628 lines (581 loc) 7.59 kB
--- desc: Optional features undefined in standard --- multiline: a backslash at end to join cell contents with the following line AGAINST requirement 3 Backslashes put behind trailing spaces . A | B ----------|------- text: | 1 \ - over | 2 \ - several | \ - lines | . <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td> <p>text:</p> <ul> <li>over</li> <li>several</li> <li>lines</li> </ul> </td> <td> <p>1 2</p> </td> </tr> </tbody> </table> . Backslashes put behind trailing pipes . A | B | ----------|-------| text: | 1 |\ - over | 2 |\ - several | |\ - lines | | . <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td> <p>text:</p> <ul> <li>over</li> <li>several</li> <li>lines</li> </ul> </td> <td> <p>1 2</p> </td> </tr> </tbody> </table> . [Issue #22](github.com/RedBug312/markdown-it-multimd-table/issues/22) Paragraphs inside multi-line rows . | A | B | | --- | --- | | 1 | 2 | \ | | 3 | \ | | | \ | | 4 | . <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td> <p>1</p> </td> <td> <p>2 3</p> <p>4</p> </td> </tr> </tbody> </table> . (corner case; ensure not to crash the whole parser) Backslashes put at end of thead/tbody . A | B |\ ----------|-------| text: | 1 |\ - over | 2 |\ - several | |\ - lines | |\ . <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td>text:</td> <td>1</td> </tr> <tr> <td>- over</td> <td>2</td> </tr> <tr> <td>- several</td> <td></td> </tr> <tr> <td>- lines</td> <td></td> </tr> </tbody> </table> . Colspan in multi-line rows . A | B | C | D | E -------|-------|---------|------|------ large || another |||\ single || single |||\ row || row ||| . <table> <thead> <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> </tr> </thead> <tbody> <tr> <td colspan="2"> <p>large single row</p> </td> <td colspan="3"> <p>another single row</p> </td> </tr> </tbody> </table> . [Issue #19](github.com/RedBug312/markdown-it-multimd-table/issues/19) Nested lists in multi-line rows . A | B | ----------|-------| text: | 1 |\ - over | 2 |\ - several | |\ - lines | | . <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td> <p>text:</p> <ul> <li>over</li> <li>several <ul> <li>lines</li> </ul> </li> </ul> </td> <td> <p>1 2</p> </td> </tr> </tbody> </table> . [Issue #19](github.com/RedBug312/markdown-it-multimd-table/issues/19) Fenced code blocks in multi-line rows . code | describe | -----------------------|-----------| ```python | |\ for i in range(5): | Print a |\ print('*' * 5) | square. |\ ``` | | for i in range(5): | Print a |\ print('*' * i) | triangle. | . <table> <thead> <tr> <th>code</th> <th>describe</th> </tr> </thead> <tbody> <tr> <td> <pre><code class="language-python">for i in range(5): print('*' * 5) </code></pre> </td> <td> <p>Print a square.</p> </td> </tr> <tr> <td> <pre><code>for i in range(5): print('*' * i) </code></pre> </td> <td> <p>Print a triangle.</p> </td> </tr> </tbody> </table> . [Issue #35](https://github.com/RedBug312/markdown-it-multimd-table/issues/35) First column left empty and not nested yet . x | y ---------|--------- test1 | test2 \ | test3 . <table> <thead> <tr> <th>x</th> <th>y</th> </tr> </thead> <tbody> <tr> <td> <p>test1</p> </td> <td> <p>test2 test3</p> </td> </tr> </tbody> </table> . NOTE: the empty line seems needed, or the table is viewed as paragraph continuation. See https://spec.commonmark.org/0.29/#example-227. First column left empty and nested under list item . - list-item x | y ---------|--------- test1 | test2 \ | test3 . <ul> <li> <p>list-item</p> <table> <thead> <tr> <th>x</th> <th>y</th> </tr> </thead> <tbody> <tr> <td> <p>test1</p> </td> <td> <p>test2 test3</p> </td> </tr> </tbody> </table> </li> </ul> . rowspan: '^^' in a cell indicates it should be merged with the cell above UNDEFINED feature Rowspan and colspan in one table cell . | A ||| |------|------|------| | B | C | D | | ^^ | E | F | | G || H | | ^^ || I | | ^^ || J | . <table> <thead> <tr> <th colspan="3">A</th> </tr> </thead> <tbody> <tr> <td rowspan="2">B</td> <td>C</td> <td>D</td> </tr> <tr> <td>E</td> <td>F</td> </tr> <tr> <td colspan="2" rowspan="3">G</td> <td>H</td> </tr> <tr> <td>I</td> </tr> <tr> <td>J</td> </tr> </tbody> </table> . [Issue #39](github.com/redbug312/markdown-it-multimd-table/issues/39) Rowspan and colspan in one table cell base case . | | | | |----|----|----| | A | B || | C | ^^ || . <table> <thead> <tr> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>A</td> <td colspan="2" rowspan="2">B</td> </tr> <tr> <td>C</td> </tr> </tbody> </table> . Rowspan at first line . | ^^ | A | B | |------|------|------| | ^^ | C | D | | ^^ | E | F | . <table> <thead> <tr> <th>^^</th> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td rowspan="2">^^</td> <td>C</td> <td>D</td> </tr> <tr> <td>E</td> <td>F</td> </tr> </tbody> </table> . Rowspan in multi-line rows . | A ||| |------|------|------| | B | C | D \ | B | C | D | | ^^ | E | F \ | | E | F | . <table> <thead> <tr> <th colspan="3">A</th> </tr> </thead> <tbody> <tr> <td rowspan="2"> <p>B B</p> </td> <td> <p>C C</p> </td> <td> <p>D D</p> </td> </tr> <tr> <td> <p>E E</p> </td> <td> <p>F F</p> </td> </tr> </tbody> </table> . Escape character works on rowspan signs . PREP | TIME ----------|------- at | 7:00 \^^ | . <table> <thead> <tr> <th>PREP</th> <th>TIME</th> </tr> </thead> <tbody> <tr> <td>at</td> <td>7:00</td> </tr> <tr> <td>^^</td> </tr> </tbody> </table> . headerless: table header can be eliminated AGAINST requirement 2 [Issue #21](github.com/RedBug312/markdown-it-multimd-table/issues/21) Simplest table without header . |----------|-----| |Headerless|table| . <table> <tbody> <tr> <td>Headerless</td> <td>table</td> </tr> </tbody> </table> . (corner case; table must have 2 more lines) Table with separator only failed . |---|---|---| . <p>|---|---|---|</p> . (corner case; ensure not to crash the whole parser) Table with separator and empty data row . |---|---|---| | . <p>|---|---|---| |</p> . multibody: enable multiple table body by default AGAINST note 9 if disabled [Issue #34](https://github.com/RedBug312/markdown-it-multimd-table/issues/34) Multibody table but disabled the feature . | --- | --- | | 1 | 2 | | 3 | 4 | A paragraph contains pipes (|). | --- | --- | | 5 | 6 | | 7 | 8 | . <table> <tbody> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </tbody> </table> <p>A paragraph contains pipes (|).</p> <table> <tbody> <tr> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> </tr> </tbody> </table> . autolabel: create table caption id even if not labeled AGAINST note 7 if disabled [Issue #50](https://github.com/redbug312/markdown-it-multimd-table/issues/50) Table not labeled with autolabel disabled . | --- | --- | | 1 | 2 | | 3 | 4 | [nolabel] . <table> <caption style="caption-side: bottom">nolabel</caption> <tbody> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </tbody> </table> .