Skip to content

Fix markdown table parser consuming lines without pipes as table rows - #1626

Merged
st0012 merged 3 commits into
masterfrom
fix-markdown-table-row-without-pipe
Feb 27, 2026
Merged

Fix markdown table parser consuming lines without pipes as table rows#1626
st0012 merged 3 commits into
masterfrom
fix-markdown-table-row-without-pipe

Conversation

@st0012

@st0012 st0012 commented Feb 26, 2026

Copy link
Copy Markdown
Member

The TableRow rule in the PEG grammar allowed rows with zero pipe characters (TableItem2*). This caused lines like <br> immediately following a table to be parsed as single-cell table rows, producing spurious <td><br></td> in the rendered HTML.

Change TableItem2* to TableItem2+ so that rows not starting with | must contain at least one | to be recognized as table rows.

The TableRow rule in the PEG grammar allowed rows with zero pipe
characters (TableItem2*). This caused lines like `<br>` immediately
following a table to be parsed as single-cell table rows, producing
spurious `<td><br></td>` in the rendered HTML.

Change TableItem2* to TableItem2+ so that rows not starting with `|`
must contain at least one `|` to be recognized as table rows.
@st0012 st0012 added the bug label Feb 26, 2026
@matzbot

matzbot commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

🚀 Preview deployment available at: https://3f1c100f.rdoc-6cd.pages.dev (commit: a757b75)

@st0012
st0012 marked this pull request as ready for review February 26, 2026 11:35

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Comment thread lib/rdoc/markdown.kpeg Outdated
Change TableAlign2* to TableAlign2+ in the TableLine rule for
consistency with the TableRow fix. A separator line without any
pipe character would conflict with horizontal rule parsing anyway.
Verify that a separator line with no pipe character does not form
a valid table, matching the TableLine rule change.
@st0012
st0012 merged commit c59a7a8 into master Feb 27, 2026
74 checks passed
@st0012
st0012 deleted the fix-markdown-table-row-without-pipe branch February 27, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants