Skip to content

fix(header): keep a first row whose labels wrap onto a second line - #226

Open
mangeshraut712 wants to merge 2 commits into
firecrawl:mainfrom
mangeshraut712:fix/anydoc-223-multiline-header
Open

mangeshraut712 wants to merge 2 commits into
firecrawl:mainfrom
mangeshraut712:fix/anydoc-223-multiline-header

Conversation

@mangeshraut712

@mangeshraut712 mangeshraut712 commented Nov 11, 2026 •

Copy link
Copy Markdown

Summary

resolve_header_rows returned 0 as soon as a first-row label contained a line break, so a Word table whose label wraps onto a second line (a second paragraph or a Shift+Enter break) got an empty header row, with the real labels pushed into the body.

The rule is now:

  • A wrapped label is still treated as data if any of its lines is a number, date or boolean (name | 12<br>13 stays in the body).
  • Otherwise it is accepted, but it abstains from the type vote. The row is promoted only on the votes of its single-line labels.
  • The row-shape fallback (text over text, no type signal) still requires every label to be single-line.

That keeps the false positive mentioned in the issue in the body: Alice | N/A<br>(not measured) over a numeric column has no single-line label voting for it, so nothing changes there.

Fixes #223.

Verification

  • New unit test multiline_label_abstains_and_defers_to_single_line_votes covers the issue table, the Alice | N/A<br>(not measured) row, a wrapped numeric cell and an all-text table with a wrapped label.
  • DOCX files built with python-docx 1.2.0, run through cargo run --example convert:
    • Issue repro with a second paragraph and with an inline break: both now give | Date | Start<br>End | Room | as the header. On main both give an empty header row.
    • The single-line version is unchanged.
    • The Alice table renders the same as on main (empty header, Alice row in the body).
  • cargo test --lib: 287 passed. cargo test --tests: header_collision, robustness and snapshot suites pass, with no snapshot changes.
  • cargo fmt --all -- --check and cargo clippy --all-targets clean.

Summary by cubic

Fixes header row detection for Word tables whose first-row labels wrap onto a second line (second paragraph or Shift+Enter break), so the table keeps a real header instead of an empty one with labels pushed into the body.

  • A wrapped label is treated as data only if any of its lines is a number, date, or boolean; otherwise it stays in the header.
  • Wrapped labels abstain from the type vote, so the row is promoted by its single-line labels alone.
  • The text-over-text fallback still requires all labels to be single-line, keeping rows like Alice | N/A<br>(not measured) over numeric data in the body.

Fixes #223.

Written for commit 3a88c2c. Summary will update on new commits.

View guided diff

A first-row label holding a line break (a second paragraph or a
Shift+Enter break in a Word cell) made resolve_header_rows treat the
row as data, so the table got an empty header row above it.

A wrapped label is now accepted unless one of its lines is a number,
date or boolean. It casts no vote of its own, so the row is promoted
only on the votes of its single-line labels, and the row-shape fallback
still requires single-line labels. This keeps rows such as
'Alice | N/A<br>(not measured)' over a numeric column in the body.

Fixes firecrawl#223

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Re-trigger cubic

… label

'col\n2' was rejected early because its second line is a number, so it
never reached the row-shape fallback it was meant to cover.
@mangeshraut712

Copy link
Copy Markdown
Author

Small test follow-up in the latest commit: the all-text case used col\n2, which is rejected early because 2 is a number, so it never reached the single-line check in the row-shape fallback. It now uses col\ntwo. cargo test --lib: 287 passed, fmt clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docx: a line break in a column label stops header detection

1 participant