Skip to content

🐞 Match hyphenated PDF text across printed line breaks - #229

Merged
lindsey-pony[bot] merged 2 commits into
mainfrom
g4-roseluck-hyphenated-search
Nov 18, 2026
Merged

lindsey-pony[bot] merged 2 commits into
mainfrom
g4-roseluck-hyphenated-search

Conversation

@JFWooten4

Copy link
Copy Markdown
Member

Problem

PDF search misses words hyphenated at the end of a printed line. In the GovInfo 2025 edition of 17 CFR 248.30, page 2 shows both a complete account and ac- followed by count on the next line. Searching for account should find and highlight both.

Changes

  • Treat a hyphen at the end of a PDF.js text item marked hasEOL as a discretionary line break when the following item begins with a letter.
  • Preserve the original text-item offsets and include the printed hyphen when highlighting a match that spans the line break. No PDF bytes, rendered text, selection, or clipboard contents are changed.
  • Keep explicitly hyphenated queries (risk-based), literal in-line hyphens, and wrapped URL punctuation searchable without removing their hyphens.
  • Add five regression cases for the photographed ac- / count split, literal hyphens, unrelated fragments, URL hyphens, and soft hyphens.

Verification

  • Ran six focused local Node checks on the matching implementation: all passed.
  • Verified the pushed branch differs from main only in src/viewer/search/search-matches.js and tests/search-matches.test.mjs; it is two commits ahead and zero behind.
  • Full repository CI and a browser smoke test remain to be run.

Browser check

  1. Open the reference PDF, page 2 in PDF-magic.
  2. Search for account; verify the intact occurrence and the ac- / count occurrence are both counted and highlighted.
  3. Search for recommend to check another line-wrapped word, and search a real hyphenated word to check that literal punctuation remains supported.

Related work

  • PR #206 established the search-backed PDF text-fragment highlighting workflow.
  • PR #225 addressed PDF viewer search/indexing memory retention; this change keeps the source-offset model and does not add a separate document-wide text cache.

Write PR descriptions automatically.

JFWooten4 and others added 2 commits November 18, 2026 12:48
Make PDF searches match words split by printed end-of-line hyphens while retaining
literal hyphen and URL searches, source-aligned highlighting, and copy behavior.

Co-authored-by: ChatGPT 6 <noreply@openai.com>
Cover end-of-line hyphenation, original source spans, preserved literal hyphens,
URL punctuation, unrelated lines, and discretionary soft hyphens.

Co-authored-by: ChatGPT 6 <noreply@openai.com>
@lindsey-pony
lindsey-pony Bot merged commit ed47f90 into main Nov 18, 2026
14 checks passed
@lindsey-pony
lindsey-pony Bot deleted the g4-roseluck-hyphenated-search branch November 18, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant