Skip to content

Implicit header slugs are used (e.g. in sidebar) instead of explicit ones #1073

@flying-sheep

Description

@flying-sheep

What version of myst-parser are you using?

4.0.1

What version dependencies are you using?

sphinx 8.2.3
docutils 0.21.2

What operating system are you using?

Linux

Describe the Bug

Even when setting myst_heading_anchors = 0, the headings get auto-generated (=unstable) HTML ids.

This would be OKish if those could only be figured out by inspecting the HTML, but they seem to be used as the primary ID in the HTML (e.g. in sphinx-book-theme’s sidebar).

Expected Behavior

When an explicit header target is set using the (foo)= syntax, that one should be the canonical one used by the sidebar and in objects.inv (I think the latter is probably already the case)

When implementing this, you should document if the first or the last explicit target is treated as the canonical one.

To Reproduce

(foo)=
# Bar

the above should render to <h1 id="foo">Bar</h1> and nothing should have the ID “bar”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions