Skip to content

A line break inside an HTML table cell keeps the words on either side apart - #1281

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:fix/html-table-cell-keeps-line-breaks
Oct 16, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:fix/html-table-cell-keeps-line-breaks

Conversation

@Maya-Kid

Copy link
Copy Markdown
Contributor

table::grid() reads HTML table cells with dom_query's text(), which joins text nodes end to end, so words split by a <br>, <p>, <div> or <li> run together unless the source has whitespace between them.

Problem

On dev 15fd7d5, utopia_ingest::parse("page.html", …) reads

<table><tr><th>Well</th><th>Depth<br>(m)</th><th>Readings</th></tr>
<tr><td><p>North</p><p>Field</p></td><td>1200</td><td>10<br>20</td></tr></table>

as

| Well | Depth(m) | Readings |
| --- | --- | --- |
| NorthField | 1200 | 1020 |

Two readings become one number, the failure #813 fixed in Word cells and #1042 in slide table cells. Every HTML path lifts its tables through grid(): .html files, whether uploaded, synced or fetched by a URL source (Readability's article or the raw page), feed entries and their linked articles, and MinerU table bodies.

Change

  • grid() reads a cell with formatted_text(), which breaks lines at <br>, <hr>, <li> and block elements but joins inline ones (<b>9</b>50 stays 950); clean folds the breaks into single spaces.

Verification

  • table::tests::a_line_break_inside_a_cell_keeps_the_words_on_either_side_apart covers <br> in a header and a value, <p>, <div>, <li> and inline <b>. Without the fix it fails, printing Depth(m), NorthField, 1020, SouthRidge and 79.
  • By hand (each path ends in grid()): the table above as a short page, inside a long article Readability keeps, and through fragment_to_markdown reads 1020 on dev and 10 20 here.
  • Linux x86_64 container, Rust 1.98.1, PostgreSQL 16 + pgvector 0.8.6, Poppler, DB required, at 4ef3d08: fmt and clippy clean; cargo test --locked --workspace 1,564 passed, 0 failed, 6 ignored.

Limits

  • Breaks drawn only by CSS (a display:block <span>) or by tags outside dom_query's list (<center>, <dt>/<dd>) still join.
  • A <br> inside a Chinese label now leaves a space (归属于母公司 所有者的净利润), as Word and slide cells already do.
  • Documents already ingested keep the joined text until reprocessed.

… apart

Signed-off-by: dada-yan <BinjunYann@gmail.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you. Reading cells with formatted_text() is the right one-line fix: it splits at <br> and block elements and still joins inline ones, so 10<br>20 stops reading as 1020 while <b>9</b>50 stays 950. That matches what #813 and #1042 did for Word and slide cells. Merging.

@WaylandYang
WaylandYang merged commit bda0bc4 into deeplethe:dev Oct 16, 2026
6 checks passed
@Maya-Kid
Maya-Kid deleted the fix/html-table-cell-keeps-line-breaks branch October 16, 2026 23:29
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.

2 participants