Skip to content
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

Make print page (print.html) links link to anchors on the print page #1738

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HollowMan6
Copy link

Resolves #1736

Let all the anchors id on the print page to have a path id prefix to
help locate.

e.g. bar/foo.md#abc -> #bar-foo-abc

Also append a dummy div to the start of the original page to make sure
that original page links without an anchor can also be located.

Signed-off-by: Hollow Man [email protected]

@HollowMan6 HollowMan6 marked this pull request as draft February 2, 2022 13:53
@HollowMan6 HollowMan6 marked this pull request as ready for review February 2, 2022 16:06
@HollowMan6
Copy link
Author

Tested on the following Rust Bookshelf books with the js code here checking broken links also unavailable anchors on print.html.

With this PR now all the links on the print page are self-contained, no broken links found except for those who are broken originally, or has self-made JavaScript that needs adaptation (ferris.js in Rust Programming Language).

Title Source Original Book Online Version
Cargo Book Source HTML
Edition Guide Source HTML
Embedded Rust Book Source HTML
Mdbook User Guide Source HTML
Rust Reference Source HTML
Rust By Example Source HTML
Rust Programming Language Source HTML
Rustc Book Source HTML
Rustdoc Book Source HTML
Rustonomicon Source HTML

Please review, Will appreciate if this PR can be merged.

cc: @ehuss

@dyaso
Copy link

dyaso commented Jul 15, 2022

This was very helpful for me, it would be nice if this could be merged so i didn't have to build HollowMan6's fork myself in order to generate PDFs whose internal links work

@ehuss ehuss added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Oct 13, 2022
@HollowMan6
Copy link
Author

Hi @ehuss , I've noticed that you added the S-waiting-on-author label to this PR recently, but I can't see any code change requests and even reviews for this PR. Am I missing something and what should I response/clarify?

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a partial review, there are some other things that I'd like to follow up on.

src/utils/mod.rs Outdated Show resolved Hide resolved
src/utils/mod.rs Outdated Show resolved Hide resolved
src/renderer/html_handlebars/hbs_renderer.rs Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Oct 17, 2022

but I can't see any code change requests and even reviews for this PR. Am I missing something and what should I response/clarify?

I'm so sorry. I had a partial review that I wrote a long time ago, but never finished and didn't click the submit button. But GitHub displays the review on the conversation page as-if it was submitted (with a little icon that I overlooked), so I thought I had submitted it.

@HollowMan6
Copy link
Author

This is just a partial review, there are some other things that I'd like to follow up on.

Done! Thanks for reviewing. Would love to see it get merged in the near future.

@tetsushiawano
Copy link

i'm using hallowman fork to create pdf files now. waiting for this branch to move to master.

@HollowMan6
Copy link
Author

Hi, @ehuss! It took me some time to resolve the conflicts this time, so I hope this can get merged soon, any plans for continue reviewing?

@Dylan-DPC
Copy link
Member

Thanks. We will review it when we get the time so don't worry :)

@HollowMan6
Copy link
Author

HollowMan6 commented Feb 8, 2024

I checked the broken links again with the methods described at: #1738 (comment) and fixed the following issues:

Now no other broken links are found with the current version.

@idoleat
Copy link

idoleat commented Nov 12, 2024

Should we change the label to S-waiting-on-review ?

@Dylan-DPC Dylan-DPC added S-waiting-on-review Status: waiting on a review and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Nov 20, 2024
Let all the anchors id on the print page to have a path id prefix to
help locate.

e.g. bar/foo.md#abc -> #bar-foo-abc

Also append a dummy div to the start of the original page to make sure
that original page links without an anchor can also be located.

Fix to remove all the `./` in the normalized path id so that for
"./foo/bar.html#abc" we still get "#foo-bar-abc"

Add support for redirect link anchors in print page so that anchors can
also be redirected, also handle URL redirect links on print page

Handle all the elements id to add a path prefix, also make path id to
all be the lower case

Fix for print page footnote links by adding the path id prefix

Signed-off-by: Hollow Man <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert all the links in the generated print.html for linking inside the book into URL fragment form
8 participants