Repository navigation
Read a typographic hyphen in a PDF link target as a plain hyphen - #293
Open
thesanogoeffect wants to merge 2 commits into
Open
thesanogoeffect wants to merge 2 commits into
thesanogoeffect wants to merge 2 commits into
Conversation
Some publishers' PDFs write a link annotation's target with the hyphen U+2010 where the address has "-". repair_links_from_targets compares a printed link with the targets after squeezing out hyphens, so the printed "https://doi.org/10.13020/1f35-rn20" matched the target "https://doi.org/10.13020/1f35%E2%80%90rn20" and took its spelling: the url table's href did not resolve, and the printed address became link_text. _target now reads U+2010 and U+2011 in a target as "-", as the character or percent-encoded, and drops a soft hyphen. The printed link is then the target itself and is left alone. A dash or minus sign is kept, since an address can mean one. The same reading applies to the targets of the annotations on a table. On the 24 BES papers of the link comparison (--fast, CPU) this changes four url rows of 10.1111/2041-210X.13821 and nothing else.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #293 +/- ##
=======================================
Coverage 91.14% 91.14%
=======================================
Files 344 344
Lines 73647 73649 +2
Branches 13667 13667
=======================================
+ Hits 67125 67129 +4
+ Misses 4041 4040 -1
+ Partials 2481 2480 -1 🚀 New features to boost your workflow:
|
…leased The automatic merge filed the note under 0.9.2, which main has already closed.
This branch has not been deployed
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.
What this fixes
Since #283 and #284 a URL's
hrefis taken from the PDF's own link annotation when one covers the printed link. Some publishers write that target with the typographic hyphen U+2010 where the address has "-". The DOI printed as10.13020/1f35-rn20then came out ashttps://doi.org/10.13020/1f35%E2%80%90rn20, which does not resolve. bibr 0.7.3 exported the plain hyphen, so this came in with the link-target work that 0.9.2 ships._target()inbibr/structure/table_links.pynow reads U+2010 and U+2011 in a link target as "-", as the character or percent-encoded, and drops a soft hyphen. A dash or a minus sign is kept, since an address can mean one.Measured
--faston the CPU over the 24 papers of the BES link comparison (metacheck #634),origin/mainagainst this branch, every export pair compared:url[11]https://doi.org/10.13020/1f35%E2%80%90rn20https://doi.org/10.13020/1f35-rn20url[15]https://doi.org/10.1111/j.2517%E2%80%906161.1977.tb01619.xhttps://doi.org/10.1111/j.2517-6161.1977.tb01619.xurl[16]https://doi.org/10.1007/s10463%E2%80%90014%E2%80%900493%E2%80%906https://doi.org/10.1007/s10463-014-0493-6url[21]https://doi.org/10.1007/978%E2%80%900%E2%80%90387%E2%80%9098135%E2%80%902https://doi.org/10.1007/978-0-387-98135-2link_textgoes from the printed address to null: the printed link now is the target, so it is no longer a repaired link. 0.7.3 exported them the same way.Not covered
LinkTargets.printed_formsstill keeps U+2010 in a target, so such a target cannot help join a link wrapped over a line break.http://www.R–project.orgin one paper) is body-text handling and is left alone.Tests
tests/test_table_links.pygains 17 cases on made-up addresses (32 pass); 471 tests pass across the 13 files that cover link targets, text links, the document layer and the url table.ruff checkandruff format --checkare clean."Dependency and source security" will fail here until #285 lands: the audit exception for PYSEC-2026-3447 on
mainexpired on 23 November.