Fix snippet heading anchors always scrolling to first file for non-Markdown markup
What does this MR do and why?
Fixes Heading anchors in a snippet always scroll to f... (#604237) for Non-Markdown markup. Manually verified in GDK-in-a-box.
Non-Markdown markup only
Applies to Org-mode, reStructuredText, MediaWiki, etc. Markdown is out of scope. Repository file rendering is unaffected.
Approach
Prefix heading slugs with the snippet's filename so that anchors no longer collide across files:
| File (e.g.) | Before: Both scroll to first heading | After: Each scrolls to its own |
|---|---|---|
planning.org |
<h1 id="user-content-summary"><a href="#summary"> |
<h1 id="user-content-planning-summary"><a href="#planning-summary"> |
review.org |
<h1 id="user-content-summary"><a href="#summary"> ← duplicate! |
<h1 id="user-content-review-summary"><a href="#review-summary"> |
Notes
No docs updates included – this area isn't well covered by existing documentation. If there are specific docs that should be updated, please flag them.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by skkzsh