fix: keep side-by-side ruled tables separate - #392
Conversation
|
Thanks for merging #394. Its This PR also includes the mirrored case: side-by-side ruled grids that share row coordinates. That case still appears possible because I can rebase this PR onto the latest |
|
If there is an actual doc this occurs on, happy to make it work |
Follow-up comment for PR #392Thanks for asking for an actual document. I ran a local reproduction using a neutral Word document converted to PDF. The document contains only generic release-channel and support-window examples; it has no customer data, credentials, internal project names, or business-specific content. The PDF contains two independent ruled tables placed side by side. Their horizontal rules use the same y coordinates, with a clear horizontal gutter between the tables. Compared with the 2.10.1 base commit:
This confirms that The same end-to-end document also exposed a separate downstream issue: the text projection stage still groups text from the two columns into the same projected line. The ruled-table candidates are then rejected for text overhang, and fallback detection produces one merged table. This is a separate line-grouping / table-consumption issue rather than a failure of the geometry-component split itself. I opened a separate follow-up issue for that downstream behavior: #414. I suggest keeping this PR narrowly scoped to separated ruled grid components. I can rebase this PR onto the current I have not uploaded the PDF or added it as a repository fixture yet. I can provide the self-authored, generic fixture if you would like to inspect it. |
|
Update: the synthetic reproduction PDF is now available here: It is a self-authored Word-to-PDF document containing two independent side-by-side ruled tables with shared row coordinates. PR #392 separates their geometry components; the remaining downstream projected-line issue and its tested fix are documented in #414. |
514a2ef to
9d740a4
Compare
|
Rebased onto the latest |
|
This PR doesn't fix the file attached in the Issue comment |
|
Thanks for calling this out — you were correct that the previous PR head did I reproduced the public CLI failure again at the exact previous head
The PR now includes the second-stage fix at lit parse /input.pdf --no-ocr --format markdown --output /results/output.md --quietthe output now has two independent headings and two independent 3-column I also tested an adjacent smaller shape rather than assuming it was covered. Would you be willing to re-review the updated PR against the published PDF? |
Summary
This PR now fixes the published side-by-side ruled-table reproduction through
the public Markdown output path:
table rectangle;
top-to-bottom order across bands;
Fixes #414.
Root cause
The visible failure had two stages:
After the geometry component was fixed, a downstream stage was still wrong:
The earlier version of this PR fixed only the first stage, which is why it did
not fix the document linked in the issue comment.
Fix
The two commits keep the responsibilities explicit:
9d740a4changes horizontal segment clustering so collinear segments mergeonly when their x ranges overlap or nearly touch. The row-gap / stacked-grid
behavior from feat: improve table extraction quality #394 remains unchanged.
26b79a6passes detected ruled-table rectangles into projected-lineconstruction. Same-y items owned by different table rectangles cannot
become one projected line, and table-owned lines are ordered by independent
table bands before table consumption.
Nearby labels are associated only when at least half of the label width belongs
to exactly one table rectangle and the vertical gap is small. A page-spanning
heading that overlaps multiple tables remains unowned. The patch does not
globally change y tolerance, table-confidence thresholds, or fallback logic.
Public reproduction document
e9b56e7a3f1d990d9e1f1b63b46e5d89b8ce1afaa85c9e17a09d83d1f5563b8dThis is a self-authored, synthetic one-page Word-to-PDF document containing no
customer, personal, credential, internal-project, or business-specific data.
The same command was used for all three versions:
Before / after
main@2fd644a9d740a426b79a6Current output:
Regression coverage
The public Markdown seam tests cover:
Two focused ordering tests also cover:
band.
Validation
cargo fmt --all -- --checkcargo clippy -p liteparse --all-targets: passed with existing repository warningswas the existing LibreOffice-dependent
.doclifetime test becauseLibreOffice is not installed in that container
two-table output above
Follow-up boundary
A smaller adjacent PDF with two same-y headings above two 3-row x 2-column
tables exposes a separate Markdown heading-continuation heuristic after the
tables are already correctly separated. It is documented with its own public
fixture and negative-test requirements in #418. This PR does not claim to fix
that distinct heading-classification case.