Skip to content

Reject GFM tables where the delimiter row has more cells than the header - #479

Open
simpleqt wants to merge 1 commit into
commonmark:mainfrom
simpleqt:fix/gfm-table-delimiter-more-cells
Open

simpleqt wants to merge 1 commit into
commonmark:mainfrom
simpleqt:fix/gfm-table-delimiter-more-cells

Conversation

@simpleqt

Copy link
Copy Markdown
Contributor

Reject GFM tables where the delimiter row has more cells than the header

TableBlockParser accepted a table when the delimiter row had at least as many cells as the header row. The GFM spec requires the counts to match ("The header row must match the delimiter row in the number of cells. If not, a table will not be recognized"), and cmark-gfm enforces strict equality. For example, this was parsed as a table and now stays a paragraph:

Abc|Def
---|-|-
1|2

The existing test only covered the delimiter row having fewer cells; this adds the missing more-cells direction (separatorMustNotHaveMorePartsThanHead). All 78 tables-module tests and the 2302 core-module tests pass.

TableBlockParser accepted a table when the delimiter row had at least as
many cells as the header row. The GFM spec requires the counts to match:
"The header row must match the delimiter row in the number of cells. If
not, a table will not be recognized", and cmark-gfm enforces strict
equality (header_row->n_columns != delimiter_row->n_columns rejects the
table). For example, the following was parsed as a table and now stays a
paragraph:

Abc|Def
---|-|-
1|2

Signed-off-by: simpleqt <2015900818@qq.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 09:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

2 participants