-
Notifications
You must be signed in to change notification settings - Fork 197
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
👌 IMPROVE: Allow for heading anchor links in docutils #678
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if
#target
is also defined as a section label as well? E.g. if there's content like:And does the behavior change at all if instead the reference was
[](myfile.md#target)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, to note, this behaviour is intended to change with jupyter-book/myst-enhancement-proposals#10 (to search for more things), but currently:
For both
#target
andmyfile.md#target
the ONLY targets that are searched for are myst-anchor slugs, e.g. in your example#target
will NOT be found, and#some-section
would be found ONLY ifmyst_heading_anchors=1
(or greater) is set.Here is where these slugs are computed and stored (when a heading is encountered):
MyST-Parser/myst_parser/mdit_to_docutils/base.py
Lines 756 to 758 in 919209b
Then, for references of the form
#target
, these can be "immediately" resolved, at the end of the document parse:MyST-Parser/myst_parser/mdit_to_docutils/base.py
Lines 238 to 242 in 919209b
For references of the form
myfile.md#target
, we need to wait until all documents have been parsed, and so these are resolved in a post-transform:MyST-Parser/myst_parser/sphinx_ext/myst_refs.py
Lines 90 to 92 in 919209b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok - I thought this was implementing that part of the MEP, but if this is just a step forward in anticipation of the MEP, I think we should just merge it as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeh, no because obviously that could start breaking peoples projects, so that needs to be done with great care 😅 (and ideally provide them a way to migrate)
With jupyter-book/myst-enhancement-proposals#10, we would like
#target
to search through essentially all targets on that page (and possibly all pages); headings, figures, tables, equations, ...inv:key:domain:type#name
links)In #613 I have kind of achieved this, but it does involve some "patching" of sphinx's code, for example they do some weird stuff with creating latex labels, which I guess does introduce a bit more potential maintenance burden.