Open prescod opened 2 years 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:
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 myst_heading_anchors = 3
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 #
is present in a markdown link, and if so, then somehow:
#
linkNot sure how feasible that is though
I think there is some confusion is some of the later comments, conflating the use of .html
and .md
extensions: myst_heading_anchors
only work for .md
extensions, i.e. [text](page.md#something)
will link to a heading # something
(or # Something
, etc) on page.md
, providing at least myst_heading_anchors=1
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 .md
format:
[b](c.md)
[b](c.md#foo)
If you specifically only want markdown style links to output "external hrefs", then you can use:
myst_all_links_external = True
this will simply output every text link as e.g. text`, without any "smart" referencing
Hi there, for jupyter-book
, whatshould I input into _config.yml
to achieve this auto header generation?
Currently I put this in but it does not work:
parse:
myst_url_schemes: [mailto, http, https]
myst_heading_anchors: 3
Same for me, I cannot use markdown link with anchor to link to a generated <section id="xxx">
tag of another page.
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: 'myst' cross-reference target not found: 'anchor-below' [myst.xref_missing]
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}.
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: 'myst' cross-reference target not found: 'anchor-below' [myst.xref_missing]
warning can be handled: https://myst-parser--717.org.readthedocs.build/en/717/syntax/cross-referencing.html#handling-invalid-references
why does it create a warning even though it works?
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 suppress_warnings = ['myst.xref_missing']
to my configuration as it would hide real, actual broken cross-references.
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