-
Notifications
You must be signed in to change notification settings - Fork 200
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
MyST does not link to anchors within non-auto-generated markdown or HTML files #564
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
This also seems to come up for links to Markdown anchors, e.g. [some other page](page.md#something) |
Same issue here. What is happening? This is clearly documented to work. |
Note that we of course also activate |
I believe that the anchors linking only works for header anchors that are auto-generated. If you link to a header that wasn't auto-generated then MyST won't find it. At least that was the behavior that @nthiery and I ran into when we tried to reproduce this (he mentioned the same problem) Perhaps it would be possible for this functionality to check whether a
Not sure how feasible that is though |
I think there is some confusion is some of the later comments, conflating the use of For: Works: [b](c.html)
Does not work: [b](c.html#foo) linking to built html documents is not recommended, since it in essence goes against the output format agnostic nature of sphinx, e.g. it would not work if you tried to build a LaTeX PDF etc myst-parser provides a number of ways to make the links output format agnostic: https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#markdown-links-and-referencing In this case, one should ideally be linking to the actual Markdown documents, i.e. using the [b](c.md)
[b](c.md#foo) If you specifically only want markdown style links to output "external hrefs", then you can use:
this will simply output every text link as e.g. text`, without any "smart" referencing |
Hi there, for Currently I put this in but it does not work:
|
Same for me, I cannot use markdown link with anchor to link to a generated |
Also does not work to do this: This is a [reference to an anchor below](#anchor-below).
<a name="anchor-below">[1]</a> This is an anchor. But it works on GitHub (as well as other markdown renderers that support HTML). [1] This is an anchor. |
It works with https://myst-parser--717.org.readthedocs.build/en/717/syntax/cross-referencing.html#default-destination-resolution 😉 You'll get a warning, but then will still generate the link
warning can be handled: https://myst-parser--717.org.readthedocs.build/en/717/syntax/cross-referencing.html#handling-invalid-references |
With https://myst-parser--717.org.readthedocs.build/en/717/syntax/cross-referencing.html#customising-external-url-resolution, you can also specifically denote a link as "external": This is a [reference to an anchor below](#anchor-below){.external}. |
…when possible - inter-page links must only use .html extension when followed by an anchor - e.g. ../index.html#list-of-licenses - workaround for executablebooks/MyST-Parser#564, executablebooks/MyST-Parser#749
…when possible - inter-page links must only use .html extension when followed by an anchor - e.g. ../index.html#list-of-licenses - workaround for executablebooks/MyST-Parser#564, executablebooks/MyST-Parser#749
why does it create a warning even though it works? |
- fixes shaarli#1451 - tools/.gitattributes: exclude doc/conf.py and doc/requirements.txt from zip exports - tools/doc/sphinx: suppress myst.xref_missing warnings caused by executablebooks/MyST-Parser#564 - dockerfile: use makefile/sphinx instead of mkdocs to build HTML documentation - dockerfile: add bash to the docs build container (make: bash: No such file or directory) - tools/doc/readthedocs: force use of python 3.11 (readthedocs ERROR: No matching distribution found for sphinx==7.1.0) - tools/doc/readthedocs: add all required configuration variables https://docs.readthedocs.io/en/latest/config-file/v2.html#build-os - tools/doc/readthedocs: override build commands to allow the source directory to be different from the conf.py directory (https://docs.readthedocs.io/en/stable/config-file/v2.html#build-commands, readthedocs/readthedocs.org#1543) - tools/doc/readthedocs: manually set output directory (readthedocs ERROR: No _readthedocs/html folder was created during this build.) - doc: replace all references to mkdocs with sphinx
I can confirm that the warning is still there on 2.0.0, despite the link being properly generated. I don't want to add Can this be fixed so that the warning is not shown for valid cross-references? Thanks |
Describe the bug
context
When I do this:
expectation
I expected two links.
bug
But instead only one link is created.
problem
This is a problem for people who need to link to anchors inside of HTML files.
Reproduce the bug
List your environment
The text was updated successfully, but these errors were encountered: