A fast, helpful, and open-source document parser
tables: split PDFium merged runs on real word geometry
Logan Markewich08225ac48671
diff --git a/TABLE_TEDS_PROGRESS.md b/TABLE_TEDS_PROGRESS.mdindex 0e44f96..291f1f2 100644--- a/TABLE_TEDS_PROGRESS.md+++ b/TABLE_TEDS_PROGRESS.md@@ -5,18 +5,22 @@ Goal: close the table-fidelity (TEDS) gap against **pdf-inspector** (firecrawl)## Standing-| metric | baseline (2.10.1) | round 1 (`093ddba`) | round 2 | Δ total | pdf-inspector |-|---|---|---|---|---|---|-| **overall** | 0.8732 | 0.8757 | **0.8783** | +0.0051 | 0.8753 |-| TEDS | 0.6929 | 0.7128 | **0.7441** | **+0.0511** | 0.8141 |-| MHS | 0.8114 | 0.8175 | **0.8179** | +0.0064 | 0.7879 |-| NID | 0.9127 | 0.9129 | **0.9136** | +0.0009 | 0.9147 |--We lead on overall + MHS, trail on TEDS by **0.070** (was 0.101) and NID by 0.001.+| metric | baseline (2.10.1) | round 1 (`093ddba`) | round 2 (`520413d`) | round 3 | Δ total | pdf-inspector |+|---|---|---|---|---|---|---|+| **overall** | 0.8732 | 0.8757 | 0.8783 | **0.8786** | +0.0054 | 0.8753 |+| TEDS | 0.6929 | 0.7128 | 0.7441 | **0.7471** | **+0.0542** | 0.8141 |+| MHS | 0.8114 | 0.8175 | 0.8179 | **0.8179** | +0.0065 | 0.7879 |+| NID | 0.9127 | 0.9129 | 0.9136 | **0.9136** | +0.0009 | 0.9147 |++ParseBench table composite (the mandatory cross-check): 0.4034 → **0.4063** in+round 3, so this round is positive on *both* benchmarks.++We lead on overall + MHS, trail on TEDS by **0.067** (was 0.101) and NID by 0.001.**TEDS is scored on only 42 of the 200 docs**, so one doc = 0.024 of the mean.-Round 1 shipped as `093ddba`; round 2 adds ~190 lines, all still in-`crates/liteparse/src/markdown_layout/tables.rs`. 298 lib tests pass.+Round 1 shipped as `093ddba`, round 2 as `520413d`; round 3 is ~120 lines in+`crates/liteparse/src/markdown_layout/tables.rs` plus one line in `parser.rs`.+303 lib tests pass.## What shipped@@ -70,6 +74,36 @@ Round 1 shipped as `093ddba`; round 2 adds ~190 lines, all still inline" if the first column is a *label* column; plenty of tables just have asparse one.+## What shipped — round 3 (word-geometry column splitting)++5. **Split PDFium's merged multi-cell runs on real word geometry**+ (+0.0030 odl TEDS, +0.0029 ParseBench table, +0.0009 NID; docs 189 and 190+ up, **nothing down on either benchmark**).++ This is the root of the "track chicken-and-egg" recorded as the table+ quality ceiling: the detector needs column tracks to split a merged run, but+ the merged runs are exactly where the track evidence lives. Word boxes break+ the cycle — the gutter is visible in the geometry *before* any table+ hypothesis exists. Measured on doc 190's header: in-cell word gaps 1.76pt,+ column gutters 7.7–12.2pt.++ - `split_span_at_gutters(span)` splits one run at its internal gutters;+ `line_pieces(line)` is the tabular view of a row. A run is now what PDFium+ emitted; a *piece* is what the page calls a cell.+ - Wired into all three places that previously reasoned over raw spans:+ `infer_tracks_from_raw_items` (a single merged run now witnesses its own+ columns), `is_strong_row`, and `cells_from_raw_items_with_tracks`.+ - `parser.rs` forces `emit_word_boxes` on for markdown output. Cost measured+ at ~3% user CPU over 40 docs.++ **The threshold must be relative, never absolute.** The same 4pt gap is a+ gutter in 6pt type and an ordinary space in 12pt type — this is the same+ trap recorded in the missing-spaces work. Instead, sort the run's own gaps+ and look for a bimodal jump: real gutters run 3.4–4.4× the in-cell gap,+ while fully-justified prose (the one reliable counterfeit) tops out ~1.3×.+ Requires ≥3 words, since two words give one gap with nothing to compare it+ to. Unit tests cover both the firing case and the justified-prose case.+## Cross-benchmark check is mandatory for table work**opendataloader-bench alone is not enough.** Round 2 looked perfect on it — four@@ -109,10 +143,23 @@ that report in place**, so copy it aside before running a variant.tuned bench config and prints the delta vs `prediction/liteparse` (the frozen 2.10.1baseline). Verified byte-identical to the recorded baseline on all 200 docs.Takes ~1–2 min. **Always A/B; per-doc deltas matter more than the mean.**+- **Geometry dumps** (`crates/liteparse/examples/`, run with+ `cargo run -q --release -p liteparse --example <name> -- <pdf>`):+ `dump_rects_raw` prints every graphic primitive plus each text item with its+ word boxes and inter-word gaps — this is what made the gutter signal visible;+ `dump_chars_raw <pdf> <page> <ymin> <ymax>` drops to per-character boxes.+ `dump_table_rects` gives the h/v stroke counts per page, which is how you tell+ a booktabs table (`h_strokes=6 v_strokes=0`) from a fully ruled one.+ Beware: vector-drawn math glyphs show up as ~170 tiny `stroked_rects` and can+ produce a phantom table rect (doc 165).- **Debug envs**: `LITEPARSE_DEBUG_TABLE=1 LITEPARSE_DEBUG_RULED=1` on a single`lit parse ... --format markdown --image-mode off --no-ocr --no-links -q`.These print every gate rejection with its numbers. **Use these first** — twice Iinferred a mechanism from the emitted markdown and was wrong.+ `LITEPARSE_DEBUG_GUTTER=1` prints every in-run column split with its ratio.+- **Never rebuild the binary while a bench run is in flight** — both harnesses+ shell out to `target/release/lit`, so a mid-run `cargo build` silently mixes+ two variants into one score.- **pdf-inspector repro**: `git clone --depth 1 https://github.com/firecrawl/pdf-inspector`,`cargo build --release --bin pdf2md` (~28s), run `pdf2md <pdf> --raw`. Its outputs andscores are already committed at `opendataloader-bench/prediction/pdf-inspector/`.@@ -152,12 +199,32 @@ So the dominant problem is **misfiling**, not dropping, text.Related: `TABLE_MAX_EMPTY_CELL_FRACTION` cannot be relaxed (see below), so this needsa different route — likely the tagged struct tree (item 5).-5. **Tagged `/Table` structure tree — unused by us entirely.** pdf-inspector's *highest- priority* detector (`detect_struct.rs`): walks StructTreeRoot for `/Table` `/TR`- `/TD`, links cells to text via **MCID**, gates on coverage (0.3 internal, 0.5 of band- items). We already parse `struct_nodes` (`extract.rs:134`, exposed on `ParsedPage`)- but consume it *only* for heading levels (`classify.rs:622`). The plumbing exists;- the detector does not. Biggest structural bet available.+5. ~~**Tagged `/Table` structure tree**~~ — **DEAD. Do not build this.** Measured+ before writing any code: **0 of the 200 opendataloader-bench PDFs carry a+ structure tree at all**, and 0 of the first 120 ParseBench docs do either.+ A tagged-`/Table` detector would be pure dead code against every benchmark we+ optimize. The extractor is fine — verified against a LibreOffice-exported+ tagged PDF, which returns the full `Document > Table > TR > TH/TD` tree — the+ corpora are simply untagged. pdf-inspector's lead comes from somewhere else.+ Probe: `lit parse <pdf> --format json --extract-structure-tree` and count+ nodes under `pages[].structure_tree.roots`. Still worth having for *real+ user* documents someday, but it can never show up in these numbers.++6. **Sub-word tracks are still on the table.** Round 3 uses word boxes only to+ split runs into pieces. `split_text_at_x_anchors` still locates a split by+ *linear interpolation over character index*, which is why doc 83 emits+ `10 .1%`. Feeding real word x's into that function is the obvious next step.++7. **Doc 190's last row (`Merge v4 | SLERP`, −0.126).** The header row is fixed;+ the final body row still falls out because its second cell (`SLERP`, x=182.9)+ sits 14pt off the track inferred from the rows above (`Average`, x=168) —+ past the 6pt `TABLE_TRACK_TOLERANCE_PT`. Needs track *ranges* rather than+ points; touch with care, that tolerance gates several paths.++8. **Docs 81/83/84 (same source family, −0.64 summed).** One grid component+ spans two stacked tables, so each is evaluated with the other's rows empty+ and both die on `empty-frac 0.60`. See the trim experiment in negative+ results for what does *not* work.## Negative results — do not retry blind@@ -175,6 +242,22 @@ So the dominant problem is **misfiling**, not dropping, text.- **Restricting the 2-row relaxation to table-free gaps, with no content gate**:doc 147 still −0.822, 14 docs lose NID (−0.0030). The gap restriction addresses thewrong mechanism. Justified prose is the counterfeit, and it lives *in* the gaps.+- **Trimming fully-empty edge rows off a ruled grid** (aimed at docs 81/83/84,+ where one component covers two stacked tables so each sees the other's rows as+ empty). Tried four increasingly-gated variants; all net-negative or a wash:+ | variant | odl TEDS vs round 3 |+ |---|---|+ | trim unconditionally | −0.0122 (docs 130, 127, 81 fall from ~1.0 to ~0.75) |+ | trim only if the untrimmed grid fails the density gate | identical — the pre-check is not predictive, `flatten_header_band` / `merge_stacked_header` rescue those grids *later* |+ | retry trimmed only after the untrimmed build returns `None` | identical again |+ | + strict density on the retained block, + require ≥3 trimmed rows and ≥4 kept | −0.0006 (83 +0.084, 84 +0.066, 81 −0.119, 82 −0.055) |++ The mechanism the gating missed: the trimmed run doesn't fill a hole, it+ **outranks a better table another detector already produced**. Docs 81/127+ regress because the ruled run wins with one column too many+ (`Number | of clauses` split across two columns) over a correct borderless+ table. Fixing this class needs either detector-priority plumbing or splitting+ the *component* — not a post-hoc row trim. Reverted; not in the shipped diff.- **A second full-width-spanner guard in `flatten_header_band`** (reject the flattenwhen a produced header cell exceeds 100 chars, aimed at doc 200): **exactly zerodelta** — this is the second guard to die here. The `[ruled] colspan header flatten`diff --git a/crates/liteparse/src/markdown_layout/flags.rs b/crates/liteparse/src/markdown_layout/flags.rsindex 3fdab7e..9ca25c5 100644--- a/crates/liteparse/src/markdown_layout/flags.rs+++ b/crates/liteparse/src/markdown_layout/flags.rs@@ -18,3 +18,4 @@ env_set_flag!(DEBUG_MD, "LITEPARSE_DEBUG_MD");env_set_flag!(DEBUG_TABLE, "LITEPARSE_DEBUG_TABLE");env_set_flag!(DEBUG_RULED, "LITEPARSE_DEBUG_RULED");env_set_flag!(DEBUG_CROSS_REGION, "LITEPARSE_DEBUG_CROSS_REGION");+env_set_flag!(DEBUG_GUTTER, "LITEPARSE_DEBUG_GUTTER");diff --git a/crates/liteparse/src/markdown_layout/tables.rs b/crates/liteparse/src/markdown_layout/tables.rsindex 4b783f4..81b1ff5 100644--- a/crates/liteparse/src/markdown_layout/tables.rs+++ b/crates/liteparse/src/markdown_layout/tables.rs@@ -46,6 +46,165 @@ const TABLE_ROW_GAP_MULTIPLIER: f32 = 2.5;/// (rejecting irregular spacing that's more likely prose or a footer block).const TABLE_ROW_SPACING_MAX_CV: f32 = 0.5;+/// Minimum ratio between the smallest "wide" inter-word gap and the largest+/// ordinary one for a span's internal gaps to read as bimodal — i.e. for the+/// wide ones to be column gutters rather than stretched justification spaces.+///+/// Measured separation is large: real gutters run 3.4–4.4× the in-cell word+/// gap (7.29 vs 2.13 on a booktabs worksheet header, 7.73 vs 1.76 on a+/// two-column-label results table), while fully-justified prose — the one+/// thing that reliably counterfeits column structure — tops out around 1.3×.+const SPAN_GUTTER_MIN_RATIO: f32 = 2.5;++/// Absolute floor (points) on a gap treated as an in-span column gutter, so+/// tightly-kerned small text can't manufacture columns out of a 1pt jitter.+const SPAN_GUTTER_MIN_PT: f32 = 3.0;++/// One horizontal piece of a PDFium text run: the run split at its internal+/// column gutters. Most runs yield a single piece.+#[derive(Debug, Clone)]+pub(super) struct SpanPiece<'a> {+ pub(super) x: f32,+ pub(super) end_x: f32,+ pub(super) text: String,+ /// The run this piece came from — for bold/font lookups.+ pub(super) span: &'a TextItem,+}++/// Split one PDFium run into column pieces at its internal gutters.+///+/// PDFium routinely emits a whole table row — several cells — as a single run,+/// which is the root of the track chicken-and-egg: the detector needs tracks to+/// split runs, but the runs are where the track evidence lives. Word boxes+/// break the cycle, because the gutter is plainly visible in the geometry+/// before any table hypothesis exists.+///+/// Detection is *relative to the run itself*, never a constant threshold: sort+/// the inter-word gaps, find the largest ratio jump, and accept the split only+/// when that jump clears [`SPAN_GUTTER_MIN_RATIO`]. A fixed gap threshold+/// cannot work here — the same 4pt gap is a gutter in 6pt type and an ordinary+/// space in 12pt type.+///+/// Returns a single piece covering the whole run when it has no word boxes,+/// fewer than three words, or no bimodal gap.+pub(super) fn split_span_at_gutters(span: &TextItem) -> Vec<SpanPiece<'_>> {+ let whole = || {+ vec![SpanPiece {+ x: span.x,+ end_x: span.x + span.width.max(0.0),+ text: collapse_whitespace(span.text.trim()),+ span,+ }]+ };+ // Only words that lie within this run's own x-extent count: projection can+ // append a merged neighbour's word boxes onto a run without re-slicing the+ // text, so `words` is a superset in that case.+ let x1 = span.x + span.width.max(0.0);+ let words: Vec<&crate::types::WordBox> = span+ .words+ .iter()+ .filter(|w| !w.text.trim().is_empty() && w.x >= span.x - 1.0 && w.x <= x1 + 1.0)+ .collect();+ // Two words give exactly one gap, which is trivially "the largest" — no+ // ratio to test against, so there is no evidence of bimodality.+ if words.len() < 3 {+ return whole();+ }+ // The word list must actually reconstruct the run's text, or the split+ // points would not correspond to the text we are about to slice.+ let rebuilt = collapse_whitespace(+ &words+ .iter()+ .map(|w| w.text.trim())+ .collect::<Vec<_>>()+ .join(" "),+ );+ if rebuilt != collapse_whitespace(span.text.trim()) {+ return whole();+ }++ let gaps: Vec<f32> = words+ .windows(2)+ .map(|w| w[1].x - (w[0].x + w[0].width.max(0.0)))+ .collect();+ let mut sorted = gaps.clone();+ sorted.sort_by(f32::total_cmp);+ // Largest ratio jump between adjacent sorted gaps: the boundary between+ // "ordinary space" and "gutter", if there is one.+ let mut cut = None;+ let mut best_ratio = SPAN_GUTTER_MIN_RATIO;+ for i in 0..sorted.len() - 1 {+ let (lo, hi) = (sorted[i], sorted[i + 1]);+ if hi < SPAN_GUTTER_MIN_PT {+ continue;+ }+ let ratio = hi / lo.max(0.1);+ if ratio >= best_ratio {+ best_ratio = ratio;+ cut = Some(hi);+ }+ }+ let Some(threshold) = cut else {+ return whole();+ };++ let mut pieces: Vec<SpanPiece<'_>> = Vec::new();+ let mut current: Vec<&crate::types::WordBox> = vec![words[0]];+ for (i, gap) in gaps.iter().enumerate() {+ if *gap >= threshold {+ pieces.push(piece_from_words(¤t, span));+ current.clear();+ }+ current.push(words[i + 1]);+ }+ pieces.push(piece_from_words(¤t, span));+ pieces.retain(|p| !p.text.is_empty());+ if pieces.len() < 2 {+ return whole();+ }+ if *super::flags::DEBUG_GUTTER {+ eprintln!(+ "[gutter] thr={:.2} ratio={:.2} {:?}",+ threshold,+ best_ratio,+ pieces.iter().map(|p| p.text.as_str()).collect::<Vec<_>>()+ );+ }+ pieces+}++fn piece_from_words<'a>(words: &[&crate::types::WordBox], span: &'a TextItem) -> SpanPiece<'a> {+ let x = words.first().map_or(span.x, |w| w.x);+ let end_x = words+ .last()+ .map_or(span.x + span.width.max(0.0), |w| w.x + w.width.max(0.0));+ SpanPiece {+ x,+ end_x,+ text: collapse_whitespace(+ &words+ .iter()+ .map(|w| w.text.trim())+ .collect::<Vec<_>>()+ .join(" "),+ ),+ span,+ }+}++/// All column pieces on a line, left to right. This is the tabular view of a+/// row: what PDFium calls a run is not what the page calls a cell.+pub(super) fn line_pieces(line: &ProjectedLine) -> Vec<SpanPiece<'_>> {+ let mut pieces: Vec<SpanPiece<'_>> = line+ .spans+ .iter()+ .filter(|s| !s.text.trim().is_empty())+ .flat_map(split_span_at_gutters)+ .collect();+ pieces.sort_by(|a, b| a.x.total_cmp(&b.x));+ pieces+}+/// One cell within a tabular row: contributing spans aggregated to text and/// its leftmost x position, used to align cells across rows into column/// "tracks".@@ -344,12 +503,9 @@ const TABLE_TRACK_INFERENCE_MAX_ROWS: usize = 12;fn infer_tracks_from_raw_items(lines: &[ProjectedLine], start_idx: usize) -> Vec<f32> {let mut xs: Vec<f32> = Vec::new();let push_row_xs = |xs: &mut Vec<f32>, line: &ProjectedLine| {- let row_xs: Vec<f32> = line- .spans- .iter()- .filter(|s| !s.text.trim().is_empty())- .map(|s| s.x)- .collect();+ // Piece x's, not span x's: a row PDFium emitted as one merged run+ // still witnesses its columns through its internal gutters.+ let row_xs: Vec<f32> = line_pieces(line).iter().map(|p| p.x).collect();// Skip 0- or 1-item rows — they don't carry column info and can// introduce noise from single-cell prose lines.if row_xs.len() >= 2 {@@ -419,17 +575,12 @@ fn cells_from_raw_items_with_tracks(line: &ProjectedLine,tracks: &[f32],) -> Option<Vec<TableCell>> {- let mut spans: Vec<&TextItem> = line- .spans- .iter()- .filter(|s| !s.text.trim().is_empty())- .collect();- spans.sort_by(|a, b| a.x.total_cmp(&b.x));- // Require ≥ 2 PDFium spans on the row. A 1-span row spanning multiple- // tracks is almost always prose (wrapped paragraph whose x-range+ let spans = line_pieces(line);+ // Require ≥ 2 column pieces on the row. A single-piece row spanning+ // multiple tracks is almost always prose (wrapped paragraph whose x-range// happens to overlap the track region); shredding it at whitespace// anchors corrupts the body text. Real merged-numeric table rows still- // have a label span and a values span (≥ 2).+ // have a label piece and a values piece (≥ 2).if spans.len() < 2 {return None;}@@ -455,7 +606,7 @@ fn cells_from_raw_items_with_tracks(};for span in &spans {let x0 = span.x;- let x1 = span.x + span.width.max(0.0);+ let x1 = span.end_x;let covered: Vec<usize> = tracks.iter().enumerate()@@ -480,13 +631,18 @@ fn cells_from_raw_items_with_tracks(let idx = covered[0];push_text(&mut cells[idx].text, &span.text);cells[idx].end_x = cells[idx].end_x.max(x1);- if is_bold_item(span) {+ if is_bold_item(span.span) {cells[idx].bold = true;}}_ => {- let pieces = split_span_at_anchors(span, &covered, tracks)?;- let bold = is_bold_item(span);+ let pieces = split_text_at_x_anchors(+ &span.text,+ span.x,+ span.end_x - span.x,+ &covered[1..].iter().map(|&i| tracks[i]).collect::<Vec<_>>(),+ )?;+ let bold = is_bold_item(span.span);for (idx, piece) in covered.iter().zip(pieces.iter()) {if piece.is_empty() {return None;@@ -768,17 +924,13 @@ fn try_detect_table_inferred(// and the table would fall to the header-seeded path that drops a column.let tol = TABLE_TRACK_TOLERANCE_PT;let is_strong_row = |line: &ProjectedLine| -> bool {- let spans: Vec<&TextItem> = line- .spans- .iter()- .filter(|s| !s.text.trim().is_empty())- .collect();+ let spans = line_pieces(line);if spans.len() < tracks.len() {return false;}spans.iter().all(|s| {let x0 = s.x;- let x1 = s.x + s.width.max(0.0);+ let x1 = s.end_x;tracks.iter().filter(|&&t| t >= x0 - tol && t <= x1 + tol)@@ -4063,6 +4215,86 @@ mod tests {use super::super::test_helpers::{line, line_with_spans, rect_borders, stroke};use super::*;+ /// One PDFium run whose words sit at the given (x, width) positions.+ fn run_with_words(words: &[(&str, f32, f32)]) -> TextItem {+ let x = words[0].1;+ let last = words[words.len() - 1];+ TextItem {+ text: words+ .iter()+ .map(|(t, _, _)| *t)+ .collect::<Vec<_>>()+ .join(" "),+ x,+ width: last.1 + last.2 - x,+ height: 10.0,+ font_size: Some(10.0),+ words: words+ .iter()+ .map(|(t, wx, ww)| crate::types::WordBox {+ text: (*t).into(),+ x: *wx,+ y: 0.0,+ width: *ww,+ height: 10.0,+ })+ .collect(),+ ..Default::default()+ }+ }++ fn piece_texts(span: &TextItem) -> Vec<String> {+ split_span_at_gutters(span)+ .into_iter()+ .map(|p| p.text)+ .collect()+ }++ #[test]+ fn merged_run_splits_at_its_column_gutters() {+ // doc 190's header: PDFium emits eight cells as one run. In-cell word+ // gaps are 1.76pt; the gutters are 7.7–12.2pt.+ let span = run_with_words(&[+ ("Merge", 172.5, 18.3),+ ("Method", 192.5, 21.9),+ ("H6", 226.6, 8.6),+ ("(Avg.)", 237.0, 18.1),+ ("ARC", 263.5, 14.5),+ ]);+ assert_eq!(piece_texts(&span), ["Merge Method", "H6 (Avg.)", "ARC"]);+ }++ #[test]+ fn justified_prose_does_not_split() {+ // Justification stretches spaces to 3.4pt against a 2.73pt norm — a+ // 1.25× jump, far under the bimodality bar. This is the counterfeit the+ // ratio test exists to reject.+ let span = run_with_words(&[+ ("may", 306.1, 19.0),+ ("not", 327.8, 14.1),+ ("be", 344.6, 10.4),+ ("as", 357.8, 9.2),+ ("crucial.", 369.7, 32.7),+ ("Thus,", 405.8, 24.8),+ ("we", 433.3, 12.8),+ ]);+ assert_eq!(piece_texts(&span).len(), 1);+ }++ #[test]+ fn run_without_word_boxes_stays_whole() {+ let mut span = run_with_words(&[("A", 0.0, 5.0), ("B", 20.0, 5.0), ("C", 26.0, 5.0)]);+ span.words.clear();+ assert_eq!(piece_texts(&span), ["A B C"]);+ }++ #[test]+ fn two_word_run_has_no_bimodality_to_measure() {+ // One gap is trivially the largest; there is nothing to compare it to.+ let span = run_with_words(&[("Added", 60.3, 24.1), ("Relative", 118.0, 31.1)]);+ assert_eq!(piece_texts(&span), ["Added Relative"]);+ }+fn rows(v: &[&[&str]]) -> Vec<Vec<String>> {v.iter().map(|r| r.iter().map(|s| s.to_string()).collect())@@ -4072,7 +4304,10 @@ mod tests {#[test]fn wrapped_cell_lines_fold_into_their_row() {let mut r = rows(&[- &["Knowledge", "● To understand the meaning of reducing and recycling"],+ &[+ "Knowledge",+ "● To understand the meaning of reducing and recycling",+ ],&["", "and how they connect ● To be familiar with the 7 Rs"],&["Skills", "● To implement waste management into daily"],&["", "life ● To promote reducing before recycling"],@@ -4091,7 +4326,11 @@ mod tests {// Regression: doc 45/47. A `Total` line legitimately has an empty label// column; folding it into the last data row destroys both rows.let mut r = rows(&[- &["7", "Traditional and Modern Mental Health Organization", "15"],+ &[+ "7",+ "Traditional and Modern Mental Health Organization",+ "15",+ ],&["", "Total", "27,926"],]);merge_continuation_rows(&mut r);diff --git a/crates/liteparse/src/parser.rs b/crates/liteparse/src/parser.rsindex 486f418..6376d3b 100644--- a/crates/liteparse/src/parser.rs+++ b/crates/liteparse/src/parser.rs@@ -483,7 +483,11 @@ impl LiteParse {extract::ExtractionOutputOptions {extract_content_bounds: self.config.extract_content_bounds,extract_images: self.config.effective_extract_images(),- emit_word_boxes: self.config.emit_word_boxes,+ // The markdown table detector splits PDFium's merged+ // multi-cell runs on real word geometry, so it needs word+ // boxes even when the caller didn't ask for them.+ emit_word_boxes: self.config.emit_word_boxes+ || self.config.output_format == crate::config::OutputFormat::Markdown,extract_text_metadata: self.config.extract_text_metadata,extract_vector_graphics: self.config.extract_vector_graphics,extract_annotations: self.config.extract_annotations,