github / cmark-gfm

GitHub's fork of cmark, a CommonMark parsing and rendering library and program in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GFM tables: escaped escapes are incorrectly treated as escapes

wooorm opened this issue · comments

commented

Take this example:

| Head          |
| ------------- |
| A | Alpha     |
| B \| Bravo    |
| C \\| Charlie |
| D \\\| Delta  |
| E \\\\| Echo  |

Yields:

Head
A
B | Bravo
C | Charlie
D \| Delta
E \| Echo

To explain, this is a table with one column (because the header row / delimiter row each have one cell).
That means that “Alpha” disappears: body rows with superfluous columns, drop those columns.
It also makes sense that “Bravo” (and “Delta) show: the pipes are escaped, so they both are part of the one cell in their row.

However, this issue is about the cases of “Charlie” (and “Echo”). They appear, but should disappear like “Alpha”. The backslashes are themselves escaped: they should not escape the pipe.

Taking a different example from markdown:

*a*

\*b*

\\*c*

a

*b*

\c

…both a and c are emphasised, the escape only “works” for b.