miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
841 stars 119 forks source link

Make tables GFM-compliant - support less than 3 dashes in delimiters #131

Closed not-my-profile closed 11 months ago

not-my-profile commented 2 years ago

As per the specification for GitHub flavored Markdown (GFM) the following markdown

| foo |
|-|
| bar|

should be rendered as a table:

foo
bar

However mistletoe does not do so since it expects at least three dashes:

https://github.com/miyuchina/mistletoe/blob/8447a42ffa9b83cd55b05b206e36113592723248/mistletoe/block_token.py#L643

It would probably be a good idea to ensure that mistletoe passes all 8 test cases defined in the GFM table specification.

pbodnar commented 2 years ago

@not-my-profile, thanks for your report. This seems to make sense.

I have quickly checked and historically GFM required 3 dashes (or "hyphens") in delimiters as well, but this has changed when #/github/markup/issues/371 was implemented (it is unclear when exactly that happened). And for example kramdown is also happy with just 1 dash.

So I guess we can do this. The minimum of 3 dashes is checked in several places in the code and we should also double-check that something else won't get broken.