Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed https://markdown-it.github.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

472 lines
5.7 KiB

Simple:
.
| Heading 1 | Heading 2
| --------- | ---------
| Cell 1 | Cell 2
| Cell 3 | Cell 4
.
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
.
Column alignment:
.
| Header 1 | Header 2 | Header 3 | Header 4 |
| :------: | -------: | :------- | -------- |
| Cell 1 | Cell 2 | Cell 3 | Cell 4 |
| Cell 5 | Cell 6 | Cell 7 | Cell 8 |
.
<table>
<thead>
<tr>
<th style="text-align:center">Header 1</th>
<th style="text-align:right">Header 2</th>
<th style="text-align:left">Header 3</th>
<th>Header 4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">Cell 1</td>
<td style="text-align:right">Cell 2</td>
<td style="text-align:left">Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
<td style="text-align:center">Cell 5</td>
<td style="text-align:right">Cell 6</td>
<td style="text-align:left">Cell 7</td>
<td>Cell 8</td>
</tr>
</tbody>
</table>
.
Nested emphases:
.
Header 1|Header 2|Header 3|Header 4
:-------|:------:|-------:|--------
Cell 1 |Cell 2 |Cell 3 |Cell 4
*Cell 5*|Cell 6 |Cell 7 |Cell 8
.
<table>
<thead>
<tr>
<th style="text-align:left">Header 1</th>
<th style="text-align:center">Header 2</th>
<th style="text-align:right">Header 3</th>
<th>Header 4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Cell 1</td>
<td style="text-align:center">Cell 2</td>
<td style="text-align:right">Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
<td style="text-align:left"><em>Cell 5</em></td>
<td style="text-align:center">Cell 6</td>
<td style="text-align:right">Cell 7</td>
<td>Cell 8</td>
</tr>
</tbody>
</table>
.
Nested tables inside blockquotes:
.
> foo|foo
> ---|---
> bar|bar
baz|baz
.
<blockquote>
<table>
<thead>
<tr>
<th>foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>bar</td>
</tr>
</tbody>
</table>
</blockquote>
<p>baz|baz</p>
.
Minimal one-column:
.
| foo
|----
| test2
.
<table>
<thead>
<tr>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>test2</td>
</tr>
</tbody>
</table>
.
This is parsed as one big table:
.
- foo|foo
---|---
bar|bar
.
<table>
<thead>
<tr>
<th>- foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>bar</td>
</tr>
</tbody>
</table>
.
Second line should not contain symbols except "-", ":", "|" and " ":
.
foo|foo
---|---s
bar|bar
.
<p>foo|foo
—|---s
bar|bar</p>
.
Second line should contain "|" symbol:
.
foo|foo
---:---
bar|bar
.
<p>foo|foo
—:---
bar|bar</p>
.
Second line should not have empty columns in the middle:
.
foo|foo
---||---
bar|bar
.
<p>foo|foo
—||—
bar|bar</p>
.
Wrong alignment symbol position:
.
foo|foo
---|-::-
bar|bar
.
<p>foo|foo
—|-::-
bar|bar</p>
.
Title line should contain "|" symbol:
.
foo
---|---
bar|bar
.
<p>foo
—|---
bar|bar</p>
.
Should terminate paragraph:
.
paragraph
foo|foo
---|---
bar|bar
.
<p>paragraph</p>
<table>
<thead>
<tr>
<th>foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>bar</td>
</tr>
</tbody>
</table>
.
Should be terminated via row without "|" symbol:
.
foo|foo
---|---
paragraph
.
<table>
<thead>
<tr>
<th>foo</th>
<th>foo</th>
</tr>
</thead>
<tbody></tbody>
</table>
<p>paragraph</p>
.
Delimiter escaping:
.
| Heading 1 \\\\| Heading 2
| --------- | ---------
| Cell\|1\|| Cell\|2
\| Cell\\\|3 \\| Cell\|4
.
<table>
<thead>
<tr>
<th>Heading 1 \\</th>
<th>Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell|1|</td>
<td>Cell|2</td>
</tr>
<tr>
<td>| Cell\|3 \</td>
<td>Cell|4</td>
</tr>
</tbody>
</table>
.
Pipes inside backticks don't split cells:
.
| Heading 1 | Heading 2
| --------- | ---------
| Cell 1 | Cell 2
| `Cell|3` | Cell 4
.
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td><code>Cell|3</code></td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
.
Unclosed backticks don't count
.
| Heading 1 | Heading 2
| --------- | ---------
| Cell 1 | Cell 2
| `Cell 3| Cell 4
.
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>`Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
.
Another complicated backticks case
.
| Heading 1 | Heading 2
| --------- | ---------
| Cell 1 | Cell 2
| \\\`|\\\`
.
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>\`</td>
<td>\`</td>
</tr>
</tbody>
</table>
.
Should be parsed before code blocks:
.
foo | bar
----- | -----
aaa | bbb
.
<table>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>aaa</td>
<td>bbb</td>
</tr>
</tbody>
</table>
.
An amount of rows might be different across the table (issue #171):
.
| 1 | 2 |
| :-----: | :-----: | :-----: |
| 3 | 4 | 5 | 6 |
.
<table>
<thead>
<tr>
<th style="text-align:center">1</th>
<th style="text-align:center">2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">3</td>
<td style="text-align:center">4</td>
</tr>
</tbody>
</table>
.
An amount of rows might be different across the table #2:
.
| 1 | 2 | 3 | 4 |
| :-----: | :-----: | :-----: | :-----: |
| 5 | 6 |
.
<table>
<thead>
<tr>
<th style="text-align:center">1</th>
<th style="text-align:center">2</th>
<th style="text-align:center">3</th>
<th style="text-align:center">4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">5</td>
<td style="text-align:center">6</td>
<td style="text-align:center"></td>
<td style="text-align:center"></td>
</tr>
</tbody>
</table>
.
Allow one-column tables (issue #171):
.
| foo |
:-----:
| bar |
.
<table>
<thead>
<tr>
<th style="text-align:center">foo</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">bar</td>
</tr>
</tbody>
</table>
.