I have modified my implementation to what I consider to be the correct behaviour:
Given this input:
| `Column1 |` | Column2 |
| ----------- | ------- |
| 0 | 1 |
the output is:
[meh@meh-host cmark]$ ./build/src/cmark example.md -e piped-tables -t xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
<paragraph>
<text>| </text>
<code>Column1 |</code>
<text> | Column2 |</text>
<softbreak />
<text>| ----------- | ------- |</text>
<softbreak />
<text>| 0 | 1 |</text>
</paragraph>
</document>
[meh@meh-host cmark]$
Given this input:
| `Column1 \|` | Column2 |
| ------------ | ------- |
| 0 | 1 |
The output is:
[meh@meh-host cmark]$ ./build/src/cmark example.md -e piped-tables -t xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
<table>
<table_header>
<table_cell>
<text> </text>
<code>Column1 |</code>
</table_cell>
<table_cell>
<text> Column2</text>
</table_cell>
</table_header>
<table_row>
<table_cell>
<text> 0</text>
</table_cell>
<table_cell>
<text> 1</text>
</table_cell>
</table_row>
</table>
</document>
[meh@meh-host cmark]$
Given this input:
| `Column1 |` Column2 |
| -------- | -------- |
| 0 `|` 1 |
Output is:
[meh@meh-host cmark]$ ./build/src/cmark example.md -e piped-tables -t xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
<table>
<table_header>
<table_cell>
<text> </text>
<text>`</text>
<text>Column1</text>
</table_cell>
<table_cell>
<text>`</text>
<text> Column2</text>
</table_cell>
</table_header>
<table_row>
<table_cell>
<text> 0 </text>
<text>`</text>
</table_cell>
<table_cell>
<text>`</text>
<text> 1</text>
</table_cell>
</table_row>
</table>
</document>
[meh@meh-host cmark]$
Finally, if one wishes to have this last sample not render as a table, it is enough to escape any of the pipes outside of a code block:
| `Column1 |` Column2 \|
| -------- | -------- |
| 0 `|` 1 |
Output is:
[meh@meh-host cmark]$ ./build/src/cmark example.md -e piped-tables -t xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
<paragraph>
<text>| </text>
<code>Column1 |</code>
<text> Column2 </text>
<text>|</text>
<softbreak />
<text>| -------- | -------- |</text>
<softbreak />
<text>| 0 </text>
<code>|</code>
<text> 1 |</text>
</paragraph>
</document>
[meh@meh-host cmark]$
I’m happy with this behaviour, seems to solve the issues that were raised here as far as I can tell?