Repository navigation
Add validation for invalid Markdoc table syntax - #603
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds stricter validation for Markdoc’s advanced (list-based) table syntax so invalid non-row content inside {% table %} is surfaced via Markdoc.validate(), preventing silently broken HTML tables.
Changes:
- Add
table-syntaxvalidation errors when non-row nodes appear at the table body row level (including within conditional wrappers). - Refactor table transform helpers (
isConditionalTag,isComment) and introduce a sharedunexpectedContentError. - Add Jest unit tests plus marktest fixtures covering valid/invalid conditional usage in tables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/transforms/table.ts |
Implements validation during the advanced table transform and emits table-syntax errors for unexpected row-level content. |
src/transforms/table.test.ts |
Adds unit tests for validation behavior across valid/invalid table/conditional/comment scenarios. |
spec/marktest/tests.yaml |
Adds marktest coverage for conditional-in-cell rendering and invalid body content errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
yue-stripe
marked this pull request as draft
March 9, 2026 22:39
…e conditional, update location tagging
yue-stripe
marked this pull request as ready for review
March 9, 2026 23:07
maxblank-stripe
approved these changes
Mar 9, 2026
yue-stripe
added a commit
that referenced
this pull request
Mar 10, 2026
To cut a new release for #603
yue-stripe
added a commit
that referenced
this pull request
Mar 10, 2026
To cut a new release for #603
2 tasks done
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.
Summary
Markdoc supports a list-based syntax to define tables. Currently, the advanced table transform accepts invalid syntax where a non-list node is provided in place of a
tr. If the node is not wrapped in a conditional row, it gets skipped, while if the node is in a conditional it gets rendered as a sibling element to thetr's.Sandbox to demonstrate
The correct syntax would be to either make the item into a conditional row, or indent it to make it a conditional paragraph within the cell (cells 1 & 2 in the sandbox)
Motivation
tbodyortheadcan only containtrelements, so the invalid syntax can produce silently broken HTML tables. This PR adds validation to prevent that. Now,Markdoc.validate()will surface invalid table syntax errors.Tests