Repository navigation
🐞 Reconstruct PDF reading order and safely reorder text objects - #5
Merged
Merged
Conversation
Replay only the selected reading-order changes on the separately squashed paragraph-rebuilding parent; preserve the tested reading-order and text-object safeguards. Co-authored-by: Codex Web <noreply@openai.com>
JFWooten4
force-pushed
the
sugar-belle-reading-order-20261014
branch
from
October 15, 2026 22:29
1d3ee35 to
ac23193
Compare
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.
Summary
Reconstruct PDF reading order from the printed page layout during
--retag, rather than reusing the order of text objects in the content stream. The reported example is Nine to Noon, PDF page 6: attribution → paperback ISBN → hardback ISBN → disclaimer. Its current stream puts the disclaimer before the ISBN lines, causing discontinuous selection/copying in macOS Preview.q … Qtext drawing scopes, retaining their local clipping/transforms and refusing movement across Form/image or graphics-state barriers. Re-extract text positions after any safe movement so tag offsets do not become stale.--retaghandling of optional-content scopes, existing metadata and bookmarks, and decorative Forms.Tests and evidence
tests/test_reading_order.py: page-6 footer ordering, mixed-font runs, two-column contents with spanning headings, paragraph/gutter separation, safe scoped reordering, Form barriers, and idempotent reconstruction.tests/test_reading_order_pdf.py, an optional full-book regression that uses the source PDF whenPDF_MAGIC_BOOKis set and checks repeated retagging, unchanged raster output, links, bookmarks, metadata, printed wording, andqpdf --check.Validation still required before merge: run the full PDF integration tests on the actual book, run
qpdf --check, and manually drag-select/copy the footer in macOS Preview across all four lines. The current environment lacks the nativepikepdf/qpdftest pipeline and macOS Preview. Improved/ActualTextor text extraction alone is not evidence that native Preview highlighting or copy/paste works.Dependency
This is a stacked PR targeting
bella-brella, which introduces--retag. Merge the lower PR first, then retarget this one tomainbefore merging. No original book has been replaced or committed.#4