Skip to content

Fix Markdoc custom transform dropped for tag/node names with dashes#17191

Open
eldardada wants to merge 1 commit into
withastro:mainfrom
eldardada:fix/markdoc-dashed-node-names
Open

Fix Markdoc custom transform dropped for tag/node names with dashes#17191
eldardada wants to merge 1 commit into
withastro:mainfrom
eldardada:fix/markdoc-dashed-node-names

Conversation

@eldardada

@eldardada eldardada commented Jun 24, 2026

Copy link
Copy Markdown

Changes

Custom Markdoc transform functions were being dropped for tags and nodes whose names need bracket access, like side-note.

Here is why. When you set a custom render component, resolveComponentImports removes the transform unless that transform "respects" render (issue #9708, added in #15335). It worked that out by string-matching the transform's source for config.tags?.<key>?.render or config.nodes?.<key>?.render, which only covers dot notation.

A key like side-note can't be read with dot notation at all (config.tags?.side-note?.render parses as a subtraction), so those transforms have to use bracket notation: config.tags?.['side-note']?.render. The old check never matched that, so the transform was always treated as not respecting render and deleted, which broke the tag.

The detection now handles bracket notation alongside dot notation, plus optional chaining and whitespace. Includes a changeset (@astrojs/markdoc patch).

Fixes #17118.

Testing

Added packages/integrations/markdoc/test/resolve-component-imports.test.ts, a unit test over the exported resolveComponentImports:

  • a render-respecting transform on a dashed tag (side-note, via bracket access) is kept;
  • a transform that does not respect render is still removed so render wins.

I checked it both ways: the first case fails on main (transform deleted) and passes with this change. The full package suite is green too. pnpm --filter @astrojs/markdoc test runs 50 tests, including the existing render-with-transform test for #9708. tsc -b, biome check, prettier --check, and eslint are all clean on the changed files.

Docs

No docs changes. This restores the documented behavior (a custom render together with a custom transform) for tag and node names that contain dashes, and there is no public API change.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 391e07a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@astrojs/markdoc Patch
@performance/mdoc Patch
@test/content-intellisense Patch
@test/core-image-deletion Patch
@test/markdoc-content-collections Patch
@test/content-layer-markdoc Patch
@test/headings-custom Patch
@test/headings Patch
@test/image-assets-custom Patch
@test/image-assets Patch
@test/markdoc-propagated-assets Patch
@test/markdoc-render-with-space Patch
@test/markdoc-render-html Patch
@test/markdoc-render-null Patch
@test/markdoc-render-partials Patch
@test/markdoc-render-simple Patch
@test/markdoc-render-table-attrs Patch
@test/markdoc-render-typographer Patch
@test/markdoc-render-with-components Patch
@test/markdoc-render-with-config Patch
@test/markdoc-render-with-extends-components Patch
@test/markdoc-render-with-indented-components Patch
@test/markdoc-render-with-transform Patch
@test/markdoc-variables Patch

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

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Jun 24, 2026
@eldardada eldardada force-pushed the fix/markdoc-dashed-node-names branch 2 times, most recently from 850d54f to 5270964 Compare June 24, 2026 20:56
@eldardada eldardada force-pushed the fix/markdoc-dashed-node-names branch from 5270964 to 391e07a Compare June 24, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6.x] Markdoc v1.x doesn't support dashes in node names, breaks with unconventional formatting

1 participant