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>
.


Allow tabs as a separator on 2nd line
.
|	foo	|	bar	|
|	---	|	---	|
|	baz	|	quux	|
.
<table>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>baz</td>
<td>quux</td>
</tr>
</tbody>
</table>
.


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>
.

`\` in tables should not count as escaped backtick
.
# | 1 | 2
--|--|--
x | `\` | `x`
.
<table>
<thead>
<tr>
<th>#</th>
<th>1</th>
<th>2</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
<td><code>\</code></td>
<td><code>x</code></td>
</tr>
</tbody>
</table>
.

Tables should handle escaped backticks
.
# | 1 | 2
--|--|--
x | \`\` | `x`
.
<table>
<thead>
<tr>
<th>#</th>
<th>1</th>
<th>2</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
<td>``</td>
<td><code>x</code></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>
.


Allow indented tables (issue #325):
.
  | Col1a | Col2a |
  | ----- | ----- |
  | Col1b | Col2b |
.
<table>
<thead>
<tr>
<th>Col1a</th>
<th>Col2a</th>
</tr>
</thead>
<tbody>
<tr>
<td>Col1b</td>
<td>Col2b</td>
</tr>
</tbody>
</table>
.


Tables should not be indented more than 4 spaces (1st line):
.
    | Col1a | Col2a |
  | ----- | ----- |
  | Col1b | Col2b |
.
<pre><code>| Col1a | Col2a |
</code></pre>
<p>| ----- | ----- |
| Col1b | Col2b |</p>
.


Tables should not be indented more than 4 spaces (2nd line):
.
  | Col1a | Col2a |
    | ----- | ----- |
  | Col1b | Col2b |
.
<p>| Col1a | Col2a |
| ----- | ----- |
| Col1b | Col2b |</p>
.


Tables should not be indented more than 4 spaces (3rd line):
.
  | Col1a | Col2a |
  | ----- | ----- |
    | Col1b | Col2b |
.
<table>
<thead>
<tr>
<th>Col1a</th>
<th>Col2a</th>
</tr>
</thead>
<tbody></tbody>
</table>
<pre><code>| Col1b | Col2b |
</code></pre>
.


Allow tables with empty body:
.
  | Col1a | Col2a |
  | ----- | ----- |
.
<table>
<thead>
<tr>
<th>Col1a</th>
<th>Col2a</th>
</tr>
</thead>
<tbody></tbody>
</table>
.


Align row should be at least as large as any actual rows:
.
Col1a | Col1b | Col1c
----- | -----
Col2a | Col2b | Col2c
.
<p>Col1a | Col1b | Col1c
----- | -----
Col2a | Col2b | Col2c</p>
.
