-
Notifications
You must be signed in to change notification settings - Fork 479
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
attempt to fix broken PDF links #1909
Conversation
Thank you for the PR! I'm planning a backport release with some TeX fixes, and this fits in there perfectly.
So I do think we need to consistently use the
It's a design decision that predates me, but yes, I'm quite confident it's there to make sure we don't accidentally break the TeX by due to some weird characters. The docstrings
I presume it was there to be consistent with the original Markdown writer. But I agree that it doesn't serve any purpose in the PDF.
I am fine with the macro as well, but I wonder if we could use |
Also, while we're doing this, could you factor out the |
As I said, my understanding is limited. But are two identical anchor ids allowed? How can you distinguish between the various targets if you refer to an id that occurs more than once?
For anchors there is already Lines 130 to 137 in 6c92d59
# a second argument that would be the empty string for LaTeX. (Or one keeps it as it is invisible the user anyway.)
|
You mean in at-ref links? You can't, and if you try, it leads to an error. If that is necessary, the users can use the at-id feature to give a heading a unique label. However, this is not a problem as most anchors do not explicitly get referred to. But we still want to generate the anchors (e.g. in HTML) so that users could copy-paste the URLs.
Yep, that's fair. Let's stick to the macro.
Yeah, but LaTeXWriter does additional processing that is specific to it, so I think there should be a function in |
OK, I think that now the treatment of Let me know what you think. If you think it's ready for merging, then I can first make a rebase to get a single clean commit. |
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.
This is excellent! I like the splitting of the logic into these separate functions.
Could you also add a note into CHANGELOG.md
?
cc25856
to
f62a004
Compare
Co-authored-by: Morten Piibeleht <[email protected]>
f08c83e
to
e5dd30b
Compare
I've updated the changelog and rebased the branch. (It took me a few attempts to figure out how links work in the changelog file.) Should be ready now for merging. |
Thanks @matthias314! |
(cherry picked from commit f72552a)
This is supposed to address several issues regarding the PDF version of the Julia documentation, namely JuliaLang/julia#38054 and probably also the second comment in JuliaLang/julia#43652. This PR certainly needs improvements, but hopefully it gets the ball rolling. I find it annoying that the Julia documentation has so many broken links, and with this PR they all seem to disappear.
As far as I can tell, the main problem is that the field
anchor.nth
is used when creating a hypertarget inDocumenter.jl/src/Writers/LaTeXWriter.jl
Lines 275 to 279 in 6c92d59
anchor.nth == 1
or in general. In the case of the Julia documentation, the value seems to be always1
, so I have omitted this field completely. I have noticed that inHTMLWriter.jl
the caseanchor.nth == 1
receives special treatment.A secondary problem is that the hypertarget is inserted before the text it refers to. Many targets are chapter or section headings, so there is a good chance that there will be a page break between the target and the text. On the other hand, if the target is moved behind the text, then the text is not visible when users follow the link. I've addressed this by using the LaTeX macro
\label
to create the target. Such labels then need to be referenced by\hyperref
instead of\hyperlink
. Since I don't know how to tell from within Julia which kind of target a link refers to, I have added a macro\hyperlinkref
todocumenter.sty
which inserts either\hyperref
or\hyperlink
, depending on whether a corresponding label exists or not.Other changes: In
Documenter.jl/src/Writers/LaTeXWriter.jl
Lines 290 to 294 in 6c92d59
For the Julia documentation, the methods
latex(io::IO, index::Documents.IndexNode, page, doc)
andlatex(io::IO, contents::Documents.ContentsNode, page, doc)
are apparently never called, so changes in this code haven't been tested. In the latter function I have kept theanchor.nth
when generating the link id, and I've moved the assignmentid =
to where it belongs.I've also noticed that you use hashes of the anchor ids to get the target labels. Would it be a problem to simply use the ids themselves? For example. can they contain any characters that cause problems?