-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[singlehtml] toctree no filename with anchor #13717
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
Conversation
On sphinx-doc#11970, same-document links dropped the uri (filename part). On sphinx-doc#12551, fixes to do not include the filename on hyperlinks was added. So an anchor for a: * doc reference: #document-my-page * ref reference: #my-anchor. On sphinx-doc#13037, fix_refuris was removed, which would blindly rmatch #.* . However, sphinx-doc#12551 missed the toctree constructor, which was still generating: * #document-my-page#my-anchor. Modify _resolve_toctree() to do not include rel_uri if the is an anchorname.
The toctree for anchors do not contain the uri (filename) anymore.
The toctree for anchors do not contain the uri (filename) anymore.
This reverts commit c822bb7.
This reverts commit 3ae15cf.
Changed the approach to only affect singlehtml. toctree_html = context["toctree"](
collapse=False,
titles_only=False,
maxdepth=-1,
includehidden=True,
) It may be worth considering that after all, having the filename in the anchor pinging @jayaddison for insight |
@gastmaier sorry for the delay in initial review. Please could you add a CHANGES entry and a test? Hopefully one of us will have time for a detailed review in the near future. A |
My issue with my solution is that it doesn't resolve the cross-doc id collision, since id collision is resolved only per doc and not across doc. Maybe it just needs its own spin of hypertarget at the exact locations as the latex writer, but I will revisit it later. (1) These are valid HTML anchors, but but require escaping when manipulating with: #document-test\/extra\#test {color: #f00;} and javascript document.querySelector('#document-test\\/extra\\#test') |
Sorry, I was away on holiday and am catching up on notifications currently. I like the objective of this changeset and will find some time to review #13739 during the next few days. |
Purpose
Fix toctree links to page anchor in the singlehtml output.
Only matters for themes that include the right sidebar in the singlehtml page, but particularly useful for using the singlehtml to then generate a pdf (since the toctree allows fine tuning the depth of the table of contents).
On #11970, same-document links dropped the uri (filename part). On #12551, fixes to do not include the filename on hyperlinks was added. So an anchor for a:
#document-my-page
#my-anchor
.On #13037, fix_refuris was removed, which would blindly rmatch #.*
However, #12551 missed the toctree constructor, which was still generating:
#document-my-page#my-anchor
Modify _resolve_toctree() to do not include rel_uri if the is an anchorname.
Tests failing
These two tests are failing, from the immediate previous commit:
It may be necessary to make the code specific to when the builder is singlehtml.
References