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

Issue 331 links for pdf with section url rewrites #404

Conversation

sluicing
Copy link
Contributor

@sluicing sluicing commented Jan 6, 2024

This change updates the uni.pl file to include working in-pdf links for most items.

It works by rewriting anchor tags to other files to be anchor tags to a section in the current file, so a link like this from layout.md:

See also the [libcurl examples](../libcurl/examples.md) section of this book.

becomes

See also the [libcurl examples](#libcurl__examples__md) section of this book.

in the combined uni.md

It also adds explicit section IDs referencing to '#' headings, so a heading like:

## Reply or new mail

becomes

## Reply or new mail {#project__etiquette__md-_-_-reply-or-new-mail}

KNOWN ISSUES:

The perl itself could be cleaned up a bit, but I've decided to err on the side of submitting this and doing some clean up later. If there are specific things that are too messy / to inconsistent with the rest of the code here, let me know and I'll clean them up before submitting

The links within the prose sections can be hard to notice when you're reading the doc. You can add color to the link with pandoc options, like -V colorlinks=true -V linkcolor=blue -V urlcolor=red -V toccolor=gray, but I didn't include that in this PR

There are a couple of things in the combined PDF that don't quite work right yet :

  • a couple of the section headings have [] chars in them and aren't handled well by the regexes. As one example, the index links for "--trace" include a broken link to the section starting "<command [option"

  • a couple of the section headings have anchor tags IN THE HEADING, which is handled by generates some weirdness in the Table of Contents, the "How to read this book" section has a contents entry labeled "1. The cURL Project", for that entry the "1" links to page 3, but the "The cURL Project" links to page 5, because the original section header that went into the table of contents linked to page 5.

  • the section link to '#https' within http.md doesn't work, the script doesn't add section IDs to the unordered list items

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

when I run make pdf with this patch applied it says:

[WARNING] Duplicate identifier 'bookindex__md-_-_-sect' at uni.md line 17347 column 1
broken link: http__md-_-_-https

cmdline/configfile.md Outdated Show resolved Hide resolved
@sluicing
Copy link
Contributor Author

sluicing commented Jan 7, 2024

when I run make pdf with this patch applied it says:

[WARNING] Duplicate identifier 'bookindex__md-_-_-sect' at uni.md line 17347 column 1
broken link: http__md-_-_-https

The file 'http.md' in the root directory has a link to #https; I think that might be a bad link? There isn't a matching #https heading in that file. Maybe it should be a link to http/https.md?

bagder added a commit that referenced this pull request Jan 8, 2024
@bagder
Copy link
Member

bagder commented Jan 8, 2024

The file 'http.md' in the root directory has a link to #https

Fixed now!

@bagder
Copy link
Member

bagder commented Jan 8, 2024

"This branch has conflicts that must be resolved"

Can you please fix the conflicts and force-push? You should probably not push bookindex.md as part of the PR as it changes a little too often for it to be comfortable.

@bagder
Copy link
Member

bagder commented Jan 8, 2024

. You can add color to the link with pandoc options, like -V colorlinks=true -V linkcolor=blue -V urlcolor=red -V toccolor=gray, but I didn't include that in this PR

Do they then also end up shown like that in PDF and ePUB? The PDF at least I think could really benefit of showing links (better). If so, we could do that in a separate PR.

@sluicing
Copy link
Contributor Author

sluicing commented Jan 8, 2024

Can you please fix the conflicts and force-push?

Done. Also, I updated urlify.pl to handle sections headers that were just "." and "/", introduced by recent upstream changes.

The updated PDF looks ok at a quick glance.

You should probably not push bookindex.md as part of the PR as it changes a little too often for it to be comfortable.

good point.

@bagder
Copy link
Member

bagder commented Jan 8, 2024

It still says:

This branch cannot be rebased due to conflicts

You need to rebase and force-push to get rid of that, not just merge master into this branch.

@sluicing sluicing force-pushed the sluicing-issue-331-links-for-pdf-with-section-url-rewrites branch from dbd129b to 0d69b40 Compare January 8, 2024 17:58
@sluicing
Copy link
Contributor Author

sluicing commented Jan 8, 2024

You need to rebase and force-push to get rid of that, not just merge master into this branch.

Sorry about that; tried to finish this in a hurry and completely forgot about the rebase/force-push piece.

@bagder bagder closed this in d370520 Jan 9, 2024
@bagder
Copy link
Member

bagder commented Jan 9, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants