fix(markdoc): resolve custom attributes on built-in table tag#15457
Merged
matthewp merged 2 commits intowithastro:mainfrom Feb 14, 2026
Merged
fix(markdoc): resolve custom attributes on built-in table tag#15457matthewp merged 2 commits intowithastro:mainfrom
matthewp merged 2 commits intowithastro:mainfrom
Conversation
…ed names
In Markdoc, `table` exists as both a tag (`{% table %}`) and a node
(the inner table structure). When users configure custom attributes on
`nodes.table` or `tags.table`, the AST propagates those attributes to
both the tag and node, but validation only checks the schema for each
type independently. This caused "Invalid attribute" errors when
attributes were declared on only one side.
Add `syncTagNodeAttributes()` to automatically merge attribute
declarations between tags and nodes that share the same name after
config setup, so users can define attributes on either side.
Fixes withastro#14220
🦋 Changeset detectedLatest commit: cdc4074 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
matthewp
reviewed
Feb 10, 2026
| */ | ||
| function syncTagNodeAttributes(config: MergedConfig): void { | ||
| // Use `as any` for built-in schema access since Markdoc's types don't have string index signatures | ||
| const builtinTags: Record<string, any> = Markdoc.tags; |
Contributor
There was a problem hiding this comment.
Can you just omit the type here since it will be the type of the value you're assigning
matthewp
reviewed
Feb 10, 2026
| function syncTagNodeAttributes(config: MergedConfig): void { | ||
| // Use `as any` for built-in schema access since Markdoc's types don't have string index signatures | ||
| const builtinTags: Record<string, any> = Markdoc.tags; | ||
| const builtinNodes: Record<string, any> = Markdoc.nodes; |
Contributor
Author
|
re the type annotations on builtinTags/builtinNodes: tried removing them but it causes TS7053 errors. |
matthewp
approved these changes
Feb 14, 2026
Merged
FredKSchott
pushed a commit
that referenced
this pull request
Feb 15, 2026
* fix(markdoc): sync custom attributes between tags and nodes with shared names
In Markdoc, `table` exists as both a tag (`{% table %}`) and a node
(the inner table structure). When users configure custom attributes on
`nodes.table` or `tags.table`, the AST propagates those attributes to
both the tag and node, but validation only checks the schema for each
type independently. This caused "Invalid attribute" errors when
attributes were declared on only one side.
Add `syncTagNodeAttributes()` to automatically merge attribute
declarations between tags and nodes that share the same name after
config setup, so users can define attributes on either side.
Fixes #14220
* chore: clarify why explicit types are needed on builtinTags/builtinNodes
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.
Changes
syncTagNodeAttributes()topackages/integrations/markdoc/src/runtime.tsthat runs after config setuptableexists as both a tag ({% table %}) and a node (the inner table structure). Attributes on the tag propagate to the child node in the AST, so both schemas must declare the same attributes forMarkdoc.validate()to passnodes.tableortags.table, this function syncs the attribute declarations to the counterpart, preventing "Invalid attribute" validation errorsMarkdoc.tagsandMarkdoc.nodes(currently onlytable)Testing
test/render-table-attrs.test.jswith build + dev tests using a fixture that configuresnodes.tablewith a custombackgroundattributeDocs
Fixes #14220