Repository navigation
write_html: make href="#" a link to the top of the document - #2189
Merged
andersonhc merged 7 commits intoNov 14, 2026
Merged
Conversation
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
andersonhc
requested changes
Nov 13, 2026
andersonhc
left a comment
Collaborator
There was a problem hiding this comment.
I found one edge case: with a portrait first page and a landscape second page, href="#" lands partway down page 1. add_link(page=1) uses the current page’s height to calculate the destination.
Could we use the first page’s height here and add a regression test with different page orientations?
# Conflicts: # CHANGELOG.md
add_link() measures the destination from the top of the current page, so from a landscape page the link landed partway down a portrait first page.
Author
|
Thanks, fixed. |
andersonhc
approved these changes
Nov 14, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
<a href="#">, as in the "Back to top" links of many web pages, makesoutput()fail afterwrite_html():An empty fragment is not a missing target: the HTML spec defines it as the top of the document, and browsers go there. Running
write_html()over about 400 real HTML pages, 4 failed this way.write_html()now makeshref="#"an internal link to the top of the first page, withadd_link(page=1), as it already does for a page number. A link to a fragment that noidor<a name>defines, such as#nowhere, still raises as before (#2048).test_html_link_to_the_top_of_the_documentputs the link on the second page and checks that it goes to the top of the first; it fails without the change. Changelog entry under 2.9.1 / Fixed.