Skip to content

Fix jagged GFM table round-trip by not padding short rows - #10

Open
BetterAndBetterII wants to merge 1 commit into
syntax-tree:mainfrom
BetterAndBetterII:fix/gfm-table-roundtrip-cell-counts
Open

BetterAndBetterII wants to merge 1 commit into
syntax-tree:mainfrom
BetterAndBetterII:fix/gfm-table-roundtrip-cell-counts

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, or if asked for, I added adequate tests
  • If applicable, or if asked for, I added documentation
  • If applicable, or if asked for, I updated package.json for relevant changes (versions, scripts, etc)

Description of changes

Parsing a GFM table with short body rows, then stringifying and re-parsing, padded those rows to the header width. markdown-table always emits a rectangle, so a later parse saw extra empty cells and the AST drifted.

After markdown-table runs, drop the padded cells so stringify keeps each row’s real cell count. Header and delimiter rows stay at header width. Tests cover the issue fixtures (a|| / || / ||||||) plus a jagged aligned table and escaped pipes in cells.

Fixes #8.

markdown-table always emits a rectangle. After stringify+parse, short
body rows gained empty cells. Strip padded cells so AST widths survive.
@github-actions github-actions Bot added the 👋 phase/new Post is being triaged automatically label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

Hi! It seems you removed the template which we require. Here are our templates (pick the one you want to use and click *raw* to see its source):

I won’t send you any further notifications about this, but I’ll keep on updating this comment, and hide it when done!

Thanks,
— bb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👋 phase/new Post is being triaged automatically

Development

Successfully merging this pull request may close these issues.

Parsing a GFM table with rows of unequal cell counts, then stringifying and re-parsing, changes the tableRow cell counts to match the header width.

1 participant