Repository navigation
Conversation
With remark-mdx, the node filters saw an inline HTML element only as mdxJsxTextElement, so disallowedNodes: ['a'] dropped Markdown links but kept <a href> anchors. customMdxDeserialize now removes an element whose deserialize rule key is listed in disallowedNodes before the rule runs. allowedNodes keeps its behavior: mdxJsxTextElement admits inline HTML and MDX elements and mdxJsxFlowElement admits block ones.
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 5ee4bd4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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.
🧭 Task plan: docs/plans/5140-mdx-element-node-filters.md
Closes #5140
Why
With
remark-mdx,deserializeMdcheckedallowedNodesanddisallowedNodesagainst an inline HTML element's mdast type,mdxJsxTextElement, never against the node its rule produces.disallowedNodes: ['a']dropped Markdown links but kept<a href>anchors, and since #5139 those anchors keep their URL.Scope
customMdxDeserialize(packages/markdown/src/lib/deserializer/utils/customMdxDeserialize.ts) resolves the element's rule key once: the plugin key the tag resolves to, or the tag name when no plugin owns it. When a rule exists anddisallowedNodeslists that key, it returns nothing before the rule runs.aremoves<a href>,underlineremoves<u>,brremoves<br>.allowedNodesandallowNodekeep their behavior. TheallowedNodesanddisallowedNodesJSDoc inMarkdownPlugin.tsand the Markdown docs page describe both.deserializer/deserializeMd.spec.tsand a patch changeset.Tradeoffs
disallowedNodesonly. Checking allowlists by key would drop<br>and<span>text from allowlists that admitmdxJsxTextElement, since keys likebrandspanhave no plugin to list.Blast Radius
The change affects only
deserializeMdcalls that useremark-mdxand a non-emptydisallowedNodes. Markdown nested in**,*and~~still skips the node filters, as onmain; #5142 tracks that gap.Verification
removes inline html elements whose deserialize rule key is disallowedfails without the new check and passes with it.keeps inline html under an allowlist that admits mdxJsxTextElementpins the allowlist behavior.pnpm --filter @platejs/markdown test: 274 pass.pnpm check: exit 0 (Biome, 54 typecheck tasks, 3,569 fast tests plus the slow suites).