fix(sanitize): prevent double user-content- prefix on footnote ids#563
Open
helloyou2012 wants to merge 1 commit into
Open
fix(sanitize): prevent double user-content- prefix on footnote ids#563helloyou2012 wants to merge 1 commit into
user-content- prefix on footnote ids#563helloyou2012 wants to merge 1 commit into
Conversation
helloyou2012
force-pushed
the
main
branch
2 times, most recently
from
July 22, 2026 02:47
800daf0 to
734b81e
Compare
user-content- prefix on footnote idsuser-content- prefix on footnote ids
Footnote and heading ids were rendered with a doubled prefix (e.g. `user-content-user-content-fn-1`) because both `remark-rehype` and `rehype-sanitize` default their `clobberPrefix` to `user-content-`, so the prefix was applied twice in the pipeline. remark-rehype emits footnote backref hrefs (`href="#fn-1"`) coordinated with its own `clobberPrefix`, so disabling the prefix upstream would desync hrefs from their targets and break footnote navigation. Disable `clobberPrefix` on rehype-sanitize instead, letting remark-rehype own the single, consistent prefixing of both hrefs and ids. - index.tsx: set `clobberPrefix: ""` on `defaultSanitizeSchema` - __tests__/footnotes.test.tsx: add regression test asserting footnote ids are prefixed exactly once - __tests__/allowed-tags.test.tsx: update assertions — user-provided ids on custom tags are no longer clobbered by sanitize
Author
|
Hi @haydenbleasel ! This PR fixes an issue where footnote links can't be navigated to. Problem: Footnote definition elements have their id prefixed with user-content- twice Root cause: Both remark-rehype and rehype-sanitize default their clobberPrefix to user-content-, and the two stages Fix: Disable clobberPrefix on rehype-sanitize so remark-rehype remains the single source of prefixing, keeping ids and Would appreciate a review — thanks! |
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.
Footnote and heading ids were rendered with a doubled prefix (e.g.
user-content-user-content-fn-1) because bothremark-rehypeandrehype-sanitizedefault theirclobberPrefixtouser-content-, sothe prefix was applied twice in the pipeline.
remark-rehype emits footnote backref hrefs (
href="#fn-1") coordinated with its ownclobberPrefix, so disabling the prefix upstream would desync hrefs from their targets and break footnote navigation. DisableclobberPrefixon rehype-sanitize instead, letting remark-rehype own the single, consistent prefixing of both hrefs and ids.clobberPrefix: ""ondefaultSanitizeSchemaids are prefixed exactly once
ids on custom tags are no longer clobbered by sanitize
Description
Type of Change
Related Issues
Fixes #
Closes #
Related to #
Changes Made
Testing
Test Coverage
Screenshots/Demos
Checklist
pnpm changeset)Changeset
Additional Notes