Skip to content

🔗 Copy links to highlighted PDF passages - #206

Open
JFWooten4 wants to merge 1 commit into
mainfrom
text-fragment-highlight-links-20261019
Open

JFWooten4 wants to merge 1 commit into
mainfrom
text-fragment-highlight-links-20261019

Conversation

@JFWooten4

Copy link
Copy Markdown
Member

Summary

Add More PDF tools → Copy link to highlighted text. Selecting PDF text and activating this command copies a shareable link to the original PDF using Chromium's supported #page=N:~:text=... text-fragment syntax.

  • Normalize selected PDF text, percent-encode the directive (including grammar-significant hyphens), and abbreviate very long selections at a word boundary.
  • Use the original PDF URL, not the extension URL, preserving its query parameters and including the physical PDF page as a navigation hint.
  • Recognize text-fragment links when a URL is opened in PDF-magic, search the PDF's extractable text, navigate to the preferred page and scroll to the matching passage with the existing search highlighter.
  • Keep the existing Copy page link, ordinary text copying and automatic copying preference (PR #201) independent.

Limitations: This requires extractable PDF text (or an enhanced/OCR version with the same text available at the linked source). Local file:// links are only usable where the path exists. Duplicate text elsewhere may resolve ambiguously in native viewers; the included PDF page hint improves placement. Browser cross-compatibility beyond Chromium is not guaranteed.

Verification

  • Verified the commit's tree differs from main, that all six intended paths match their proposed blobs, and that the branch is one commit ahead and zero behind.
  • Added tests/text-fragment-link.test.mjs and registered it in npm test for URL generation, parsing, normalization, percent encoding, input rejection and local file paths.
  • Not run locally: Node tests, extension build, and interactive Chrome/Brave smoke testing; the GitHub connector cannot execute the repository in this environment. CI/browser checks remain necessary.

Manual test

  1. Highlight a phrase inside a text-backed PDF. Open More PDF tools → Copy link to highlighted text and paste the result.
  2. Open the copied URL in native Chromium PDF viewing and with PDF-magic enabled; check that it navigates to and highlights the selected passage.
  3. Repeat with punctuation, wrapped lines, a query-string PDF URL, and a non-first-page selection.
  4. Confirm that clicking the command without a valid PDF selection reports the missing selection and does not overwrite the clipboard.

Generate standard PDF text-fragment links from highlighted text and resolve them in the PDF-magic viewer, with focused regression coverage.

Co-authored-by: Codex Web <noreply@openai.com>
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