Notebook markdown renderer emits duplicate heading ids
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Bug description
The notebook markdown renderer's heading id generation (`extensions/markdown-language-features/notebook/index.ts`, `addNamedHeaderRendering`) deduplicates slugs with a counter, but never registers the generated `-N` suffixed id it emits. Only the base slug is recorded.
For headings `Foo`, `Foo-1`, `Foo`:
- expected (github-slugger semantics): `foo`, `foo-1`, `foo-2`
- observed: `foo`, `foo-1`, `foo-1` because the third heading builds its deduped id from the base slug counter and emits `foo-1` again without noticing that id was already handed out earlier.
Duplicate DOM ids mean anchor links from github.com do not scroll to the right heading inside the notebook webview.
### Steps to reproduce
1. Render notebook markdown containing headings `Foo`, `Foo-1`, `Foo`.
2. Inspect the rendered header ids: the second and third both get `foo-1`.
### Expected behavior
Every emitted id, including generated `-N` suffixes, is registered so later duplicates advance until a free id, matching github-slugger output (`foo-2` for the third heading).
### Version tested
Commit `38ec3d57f91b` on `main`; reproduced by running the renderer module through the real markdown-it pipeline and inspecting produced ids. A fix is ready.
Contributor guide
Assessment
This issue has not been assessed yet.