-
fix: first table chunk preserve col/row span (#4343)
发布于
2026-04-24 17:22:26 +00:00 Summary
When a
Tableelement was split into multipleTableChunks, the
first chunk lostcolspan/rowspanon its header
cells while continuation chunks kept them — producing inconsistent
merged-cell structure across a single split table.Root cause:
HtmlTable.from_html_textcallse.attrib.clear()on every
descendant during compactification, intending to drop
cosmetic attributes (border,class,style, …). That also wiped
colspan/rowspan. Continuation chunks escaped the bug
because their repeated headers come fromsource_row_htmlscaptured
before the strip; the first chunk's rows flow through
the compactified tree directly.Fix
Preserve
colspanandrowspanthrough theattrib.clear()step in
unstructured/common/html_table.py. They're structural,
not cosmetic, and the rest of the chunking pipeline then carries them
through unchanged.Tests
test_html_table.py::but_it_preserves_colspan_and_rowspan_as_structural_cell_attributes
— unit guarantee that
compactification keeps the two span attributes and still strips
class/style/id/data-*.test_base.py::and_it_preserves_colspan_and_rowspan_in_the_first_chunk_header_rows
— end-to-end regression: the first
TableChunkof a split table keepscolspan/rowspanon header cells,
matching continuation chunks.Both tests fail on
mainand pass with this change.
Note
Low Risk
Low risk, localized change to table HTML normalization that only
preserves two structural attributes; main impact is on downstream
TableChunkHTML fidelity for merged headers.Overview
Fixes a regression whereHtmlTable.from_html_text()compactification
stripped structuralcolspan/rowspan, causing the first chunk of a
split table to lose merged-header layout while continuation chunks
retained it.Updates the attribute-stripping step to preserve
colspanand
rowspan, adds unit + end-to-end chunking regression tests to assert
consistent header spans across chunks, and bumps the release to
0.22.23with a changelog entry.Reviewed by Cursor Bugbot for commit
5463e776ce02a269db84713431280375cc092cc8. Bugbot is set up for automated
code reviews on this repo. Configure
here.下载附件