You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only actual Markdown headings outside fenced code blocks should receive IDs.
Expected output:
Fenced code reproduction
## Reusable API
Reusable API {#reusable-api}
Actual behavior
The current implementation can also modify the heading inside the tilde fenced block:
Fenced code reproduction
## Reusable API {#reusable-api}
Reusable API {#reusable-api-1}
The code example should remain unchanged and should not affect the slug generated for the real heading.
The same issue can occur with longer backtick fences containing shorter backtick sequences.
Your environment
Operating System: Microsoft Windows 11, version 26H2, OS Build 26300.9974
Browser: Google Chrome 157.0.0.0
Node.js: v26.13.1 LTS
Package Manager: pnpm 12.21.0
In writeMarkdownHeadingId, code detection only checks if the line starts with three backticks, so tildes get skipped and shorter backticks inside longer fences exit early. Tracking the opening fence character and length across both passes fixes this without breaking existing heading IDs. I tested this locally with cases covering tildes and nested fences on fix/write-heading-ids-fenced-code if you want a PR.
Activity
TbhVishal commentedon Nov 19, 2026
In
writeMarkdownHeadingId, code detection only checks if the line starts with three backticks, so tildes get skipped and shorter backticks inside longer fences exit early. Tracking the opening fence character and length across both passes fixes this without breaking existing heading IDs. I tested this locally with cases covering tildes and nested fences onfix/write-heading-ids-fenced-codeif you want a PR.