fix(table): reject a non-delimiter second row instead of eating it#467
Open
chuenchen309 wants to merge 1 commit into
Open
fix(table): reject a non-delimiter second row instead of eating it#467chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
`_process_thead` only checked that the alignment row had the same cell count as the header; any cell that was not a dash rule fell through to `aligns.append(None)` (a valid no-align column). A second line that is ordinary pipe-separated text (no `---` delimiter) was therefore accepted as the delimiter row, turning non-table text into a table and silently dropping that line from the output. Require every alignment cell to be a dash rule (optionally colon-flanked) or empty; otherwise it is not a delimiter row and the block is not a table. Empty cells stay allowed so existing tables like `- |` keep working. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #467 +/- ##
=======================================
Coverage 91.32% 91.33%
=======================================
Files 34 34
Lines 3515 3518 +3
Branches 697 698 +1
=======================================
+ Hits 3210 3213 +3
Misses 184 184
Partials 121 121
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The bug
Three lines of ordinary pipe-separated text get turned into a table, and the middle line silently disappears:
Today this renders as a
<table>whose header isName | Age, whose body isJane | 25, and whereJohn | 30is gone — it was consumed as the "delimiter" row.Cause
_process_theadchecks that the alignment row has the same cell count as the header, but it never checks that the cells are actually delimiters. A cell that isn't a dash rule falls through toaligns.append(None):Noneis the legitimate value for a no-align---column, so a row likeJohn | 30is accepted as a valid no-align delimiter, and the block becomes a table with that line eaten.Fix
Require each alignment cell to be a dash rule (optionally colon-flanked) or empty. Anything else means the second line isn't a delimiter row, so it isn't a table:
Empty cells stay allowed, so existing tables such as
(the
Misc Tablefixture, where the delimiter cell is empty) keep working. This matches the delimiter-cell set from the php-markdown / GFM spec that the plugin follows.Verification
tests/fixtures/table.txtexamples (a non-delimiter second row now stays a paragraph). They fail onmainand pass with this change, across both the plain andspeedupvariants.1141 passed. No existing table fixture changed — every valid table (alignment, empty delimiter cells, escaped pipes,nptable, mismatch handling) renders as before.ruff checkclean.Disclosure: this PR was authored by an AI coding agent (Claude Code) running on this account: the AI found the bug, ran the repro, wrote the tests, and wrote this description. The human account holder reviews every change and is accountable for it. The verification above is real and re-runnable from the diff. If this isn't the kind of contribution you want, say so and I'll close it.