fix(pdf): keep positioned math out of tables - #87
Merged
Merged
Conversation
Stacked fractions and superscripts in the text layer were detected as borderless tables, and equation numbers became headings. fixes #77
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
mdgate-demo | d468c44 | Aug 27 2026, 04:57 AM |
toScript now normalizes Unicode superscript digits before applying the vertical-offset script map. The math-layout heuristic no longer treats ± or typographic minus as operators, so compact numeric grids stay tables.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Minus-only equations become tables
- The eqNums path now still treats − and ± as operators, so numbered minus-only formulas are rejected as tables while signed numeric grids stay tables.
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 91d20f3. Configure here.
Numbered display equations whose only operator is − or ± still match the eqNums path. Signed numeric tables stay tables.
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.



Confirmed #77: glyph runs that
pdftotext -layoutalready has were turned into ragged GFM tables, and equation numbers / math lead-ins were promoted to headings. Formulas that are images or paths (empty inpdftotext) stay out of scope.Changes
∂/∑, equation numbers)hᵖ⁺¹,H⁺) without treating the next paragraph as subscriptsd/dtand∂L/∂qstacks intod/dtstyle fractionsChecked against the issue examples: Lagrange / Richardson formulas stay as text,
(3.18)is not a heading,or inverselyis not a heading, and real tables (year headers, P-value grids) still convert.fixes #77
Note
Medium Risk
Heuristic changes affect table detection and heading/script merging across all PDFs; misclassification could hide real tables or alter typography, though tests target the reported regressions.
Overview
Improves PDF→markdown for scientific text so aligned math glyphs stay as prose instead of GFM tables, and display lines are less often turned into headings.
Text merging: Adds
mergeStackedMathin the finish pipeline (after script merge) to join vertically stacked pairs liked/dtintod/dt. Superscript/subscript attachment now covers letters and operators (hᵖ⁺¹,H₂), with tighter font-size and vertical-offset rules so baseline hyphens and unrelated lines are not scripted.Table detection: Borderless table acceptance rejects grids that
looksLikeMathLayout(equation numbers, math operators/glyphs, short operator-heavy cells) while still allowing compact numeric tables with±/−.Headings: Skips isolated-line and header promotion for equation numbers, math-heavy lines, lowercase lead-ins, colon endings, and similar false positives.
Adds
math.test.ts, table/math regression tests, and a small snapshot tweak for endnote superscript attachment.Reviewed by Cursor Bugbot for commit d468c44. Bugbot is set up for automated code reviews on this repo. Configure here.