executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
742 stars 196 forks source link

Cannot link to RST sections since 0.17.0 #872

Open JulianGro opened 7 months ago

JulianGro commented 7 months ago

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

Sphinx 6.2.1

What operating system are you using?

Linux

Describe the Bug

On myst-parser versions before 0.17.0, you can link to RST sections via something like:

[Load and Run a Script](get-started-with-scripting.html#load-and-run-a-script)

This was broken in 0.17.0 https://github.com/executablebooks/MyST-Parser/issues/519#issuecomment-1044450711 As far as I can tell, there is still no way to link to RST sections again. It looks like the following should work:

[Load and Run a Script](get-started-with-scripting.rst#load-and-run-a-script)

But that throws a warning and breaks the link:

WARNING: local id not found in doc 'script/get-started-with-scripting': 'load-and-run-a-script' [myst.xref_missing]

Expected Behavior

[Load and Run a Script](get-started-with-scripting.rst#load-and-run-a-script)

should just link to the "load-and-run-a-script" section.

To Reproduce

Here are two example files that should reproduce the issue in a minimal project: RST_MD_example.zip

welcome[bot] commented 7 months ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

sumezulike commented 6 months ago

Can you provide a full minimal example? Your example includes a lot of unnecessary stuff and link generation works for me when I remove the references to non-existing files.

JulianGro commented 6 months ago

It indeed seems like the following syntax works now:

+ [Load and Run a Script](get-started-with-scripting.rst#load-and-run-a-script)

However, it does still throw a warning:

myst-test/source/write-scripts.md:3: WARNING: local id not found in doc 'get-started-with-scripting': 'load-and-run-a-script' [myst.xref_missing]

Here is a full minimal example: myst-test.zip write-scripts.md tries to link to a section in the RST, which throws a warning. The README has instruction on how to build the documentation.

Not sure if I saw the warning and assumed that it wouldn't work, if a theme we use breaks it, or if it was broken in the past while still throwing the same warning.

sumezulike commented 6 months ago

I could verify that (seemingly?) unnecessary warnings are being printed, I'll try to write a fix for that. The links all seem to work, though.