github / cmark-gfm

GitHub's fork of cmark, a CommonMark parsing and rendering library and program in C
Other
893 stars 173 forks source link

GFM Tables vs List precedence #333

Open rlidwka opened 1 year ago

rlidwka commented 1 year ago

See discussion in https://github.com/laurent22/joplin/issues/7858, https://github.com/markdown-it/markdown-it/pull/767.

There is a parsing ambiguity in the following code:

a | b
- | -
1 | 2

It can be interpreted as a table or a list. As of now, github parses it as a list:

a b
1 2

But GFM spec doesn't currently mention anything about list vs table precedence. I believe it should be defined in the spec, as a few people ran into this already.

Three choices here:

  1. The snippet above is a table. In this case, test should be added to spec, and cmark-gfm should be fixed.
  2. The snippet above is a list. In this case, test should be added to spec.
  3. Or this is actual undefined behavior up to implementors, so it should be clearly written in spec as such (I personally would prefer to keep those at a minimum).