fix(pdf): keep extractable chart labels out of broken tables - #86
Merged
Merged
Conversation
Chart ticks, bar values, and legends were detected as tables, and axis gridlines were marked as underline/strike. Skip rotated items in table detection, reject chart-like grids, join rotated date labels, and ignore rules that run far past a glyph. fixes #76
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
mdgate-demo | c04205f | Aug 26 2026, 01:08 PM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Percent tables rejected as ticks
- looksLikeLabeledTicks now rejects only when a percent/numeric row appears above the category labels, so header-first percent summary tables are kept.
- ✅ Fixed: Digit headers marked as junk
- looksLikeHeaderlessJunk now keeps two-row grids whose header cells are mostly lettered tokens such as Q1 or 1st.
- ✅ Fixed: Numeric grids treated as dates
- looksLikeDateFragments now requires a slash in the grid, so short all-numeric matrices are no longer treated as date junk.
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 0e9f24b. Configure here.
Chart-junk checks were dropping ordinary summary tables, Q1-style headers, and ruled numeric matrices.
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
Confirmed #76: extractable chart text (
pdftotext -layoutalready has it) was turned into broken tables, and axis/grid lines were tagged as underline/strike. Raster-only charts remain out of scope.Changes
01/2019instead of0 1/ 201 9) and adjacent numeric TJ fragmentsReal tables (ruled grids, named columns, year headers) still convert as markdown tables. Checked against the issue examples: categories, years, dates, and scores stay as text instead of empty-cell tables.
fixes #76
Note
Medium Risk
Changes core PDF-to-markdown heuristics for tables, line joining, and underline detection; regressions could drop real tables or alter formatting on edge-case PDFs, but behavior is heavily test-backed.
Overview
Chart and axis text in PDFs was being misread as markdown tables and decorated with false underline/strike from long grid lines. This PR tightens table detection and text assembly so those layouts stay plain text while real tables still convert.
Table detection exports
isUprightfrom layout and ignores rotated glyphs when building ruled and borderless grids. Borderless acceptance adds several chart-shaped rejectors (stacked date fragments, category+year legends, scattered bar values, percent rows with category ticks, numeric scatter without real headers, and similar junk). Prose-heavy multi-column grids are filtered a bit more aggressively.Markdown extraction runs a new
mergeNumericFragmentspass after script merging so TJ-split percents and nearby numeric shards become single tokens.shouldJoinItemsuses orientation: upright runs still use horizontal gaps; rotated runs can join by proximity. Underline/strike matching skips horizontal rules that extend far beyond the text width (typical chart baselines) while keeping short rules under real words.Regression tests cover chart ticks, rotated dates, split percents, and that legitimate tables (year headers, Q columns, percent summaries, ruled matrices) are unchanged.
Reviewed by Cursor Bugbot for commit c04205f. Bugbot is set up for automated code reviews on this repo. Configure here.