Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

third occurence of heading with the same title cannot be referenced, [myst.xref_missing] #878

Open
ClementPinard opened this issue Feb 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ClementPinard
Copy link

ClementPinard commented Feb 26, 2024

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

sphinx : 6.2.1
docutils 0.19

What operating system are you using?

Ubuntu 22.04

Describe the Bug

In the docs (especially here https://myst-parser.readthedocs.io/en/latest/syntax/cross-referencing.html#implicit-targets) it says that the slugs for headings matches the github slugger.
As such, when headings have the same name, the second occurence gets a suffix of -1, and the third should get -2 and so on.

It looks like this works for myst parser but only for two headings. As soon as there are 3 headings with the same name (can happen with subsections that follow a pattern between sections), any cross ref fails

Capture d’écran du 2024-02-26 23-40-38

See how I get the warning 'myst' reference target not found: 'heading-2' [myst.xref_missing] even though the slug does exist in the html.

Expected Behavior

[Link to the heading 3](#heading-2) should link to the third occurence of the heading titled "heading" and not issue a warning

To Reproduce

This bug is very to reproduce since it happens on the live preview
https://myst-parser.readthedocs.io/en/latest/live-preview.html#

# Heading

Hallo world!

[Link to the heading](#heading)

[Link to the heading 2](#heading-1)

[Link to the heading 3](#heading-2)

# Heading

The second heading

# Heading

the third heading

I kept the default configuration, i.e.

myst_enable_extensions:
- colon_fence
- deflist
- dollarmath
myst_heading_anchors: 2
myst_highlight_code_blocks: true
@ClementPinard ClementPinard added the bug Something isn't working label Feb 26, 2024
Copy link

welcome bot commented Feb 26, 2024

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant