markup icon indicating copy to clipboard operation
markup copied to clipboard

Table with backticked vertical bar `|` as element doesn't render

Open nschloe opened this issue 2 years ago • 2 comments

This table renders just fine:

| `a` |
|:---:|
a

When replacing a by |, it fails to render as a table:

| `|` |
|:---:|

| | | |:---:|

The parser should be able to ignore the backticked vertical bar.

nschloe avatar Oct 19 '23 17:10 nschloe

I don't think this is a bug. pulldown-cmark and commonmark-hs-extensions both do the same thing, because this result falls out of CommonMark's rule that block-level parsing (like tables) has higher priority than inline-level parsing.

This requires a bit of a design crutch to avoid making the result you want inexpressible: backslash escaped pipes in table cells are handled in a separate pass from inline parsing, and will not render the backslash when inline code is used (even though inline code normally passes through backslashes as-is). For example, this table renders as shown:

| `\|` |
|:----:|
|

This is the same reason why, even though inline code is allowed to have line breaks, an asterisk will interrupt it and start a list.

`5
/ 3`

`5
* 3`

5 / 3

`5

  • 3`

notriddle avatar Oct 19 '23 18:10 notriddle