Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not treat zero-cell rows as valid #812

Merged

Conversation

notriddle
Copy link
Collaborator

@notriddle notriddle commented Jan 19, 2024

Table rows must have at least one cell. A single pipe, on its own, doesn't count.

The behavior on babelmark is pretty diverse, but this behavior is chosen to align with GFM.

✓ means it treats the zero cell lines with only a pipe as not being valid rows, but otherwise parses as a table.

x means it treats the zero cell lines with only a pipe as a valid row.

? means it does something else.

Implementation -> first second third
pulldown-cmark (after this PR)
github/cmark-gfm
pycmarkgfm
pandoc gfm1
parsedown x x
php-markdown-extra x x
markdown-it x x 2
DFM x x x
league/commonmark GFM x x x
s9e/TextFormatter x x x
MD4C x x x
cebe x x x
pandoc x x x
multimarkdown ?3 ?3 ?3
markdig ?3 ?3 ?3
maruku ?4 ?4 ?4

Link to Babelmark 3 test

| Table | Header |
|-------|--------|
| Table | Body   |
|
| Not   | Enough |


| Table | Header |
|-------|--------|
| Table | Body   |
|→
| Not   | Enough |
.
<table><thead><tr><th>Table</th><th>Header</th></thead><tbody>
<tr><td>Table</td><td>Body</td></tr>
</tbody></table>
<p>|
| Not   | Enough |</p>
<table><thead><tr><th>Table</th><th>Header</th></thead><tbody>
<tr><td>Table</td><td>Body</td></tr>
</tbody></table>
<p>|→
| Not   | Enough |</p>
| Table | Header |
|-------|--------|
|
.
<table><thead><tr><th>Table</th><th>Header</th></thead><tbody>
</tbody></table>
<p>|</p>
|
|-------|--------|
| Table | Body   |
.
<p>|
|-------|--------|
| Table | Body   |</p>

Footnotes

  1. Not on babelmark 3. I ran it on https://pandoc.org/try/?params=%7B%22text%22%3A%22%7C+Table+%7C+Header+%7C%5Cn%7C-------%7C--------%7C%5Cn%7C+Table+%7C+Body+++%7C%5Cn%7C%5Cn%7C+Not+++%7C+Enough+%7C%5Cn%5Cn%7C+Table+%7C+Header+%7C%5Cn%7C-------%7C--------%7C%5Cn%7C%5Cn%5Cn%7C%5Cn%7C-------%7C--------%7C%5Cn%7C+Table+%7C+Body+++%7C%5Cn%22%2C%22to%22%3A%22html5%22%2C%22from%22%3A%22gfm%22%2C%22standalone%22%3Afalse%2C%22embed-resources%22%3Afalse%2C%22table-of-contents%22%3Afalse%2C%22number-sections%22%3Afalse%2C%22citeproc%22%3Afalse%2C%22html-math-method%22%3A%22plain%22%2C%22wrap%22%3A%22auto%22%2C%22highlight-style%22%3Anull%2C%22files%22%3A%7B%7D%2C%22template%22%3Anull%7D

  2. Markdown-it changed some time between the version on their playground
    https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%7C%20Table%20%7C%20Header%20%7C%5Cn%7C-------%7C--------%7C%5Cn%7C%20Table%20%7C%20Body%20%20%20%7C%5Cn%7C%5Cn%7C%20Not%20%20%20%7C%20Enough%20%7C%5Cn%5Cn%7C%20Table%20%7C%20Header%20%7C%5Cn%7C-------%7C--------%7C%5Cn%7C%5Cn%5Cn%7C%5Cn%7C-------%7C--------%7C%5Cn%7C%20Table%20%7C%20Body%20%20%20%7C%5Cn%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D and the version Babelmark 3 uses.

  3. Multimarkdown and Markdig don't recognize these at tables at all,
    even though I know they support pipe tables. 2 3 4 5 6

  4. Maruku swallows much of the text entirely in these test cases. 2 3

This brings pulldown-cmark into alignment with GFM.
@Martin1887
Copy link
Collaborator

A pity not being aligned with Pandoc, but GFM is the reference here. Thanks!

@Martin1887 Martin1887 merged commit 89a3343 into pulldown-cmark:master Jan 20, 2024
1 check passed
@notriddle notriddle deleted the notriddle/rej-zero-cell-row branch January 20, 2024 14:48
notriddle pushed a commit to notriddle/pulldown-cmark that referenced this pull request Jan 20, 2024
…ro-cell-row

Do not treat zero-cell rows as valid
notriddle pushed a commit to notriddle/pulldown-cmark that referenced this pull request Jan 20, 2024
…ro-cell-row

Do not treat zero-cell rows as valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants