Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docling/backend/html_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,7 @@ def parse_table_data(
row_span -= 1
while (
col_idx < num_cols
and row_idx + start_row_span < num_rows
and grid[row_idx + start_row_span][col_idx] is not None
):
col_idx += 1
Expand Down
18 changes: 18 additions & 0 deletions tests/test_backend_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ def test_heading_levels():
assert found_lvl_1 and found_lvl_2


def test_table_header_rowspan_without_body_does_not_crash():
# A table whose only row is a `th` with rowspan (no body rows to span into)
# used to raise IndexError: get_html_table_row_col counts no rows for an
# all-header-rowspan row, so the grid was empty and the cell-placement read
# went out of bounds. It should not crash and should keep the cell.
Comment on lines +172 to +175

@ceberam ceberam Jul 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would remove these inline comments. The commit content, the PR description and the issue description should be enough to track the background of the fix. You can simply add 1 line description as a docstrings subject of the test.

src = b"<table><tr><th rowspan='2'>h</th></tr></table>"
in_doc = InputDocument(
path_or_stream=BytesIO(src),
format=InputFormat.HTML,
backend=HTMLDocumentBackend,
filename="t.html",
)
doc = HTMLDocumentBackend(in_doc=in_doc, path_or_stream=BytesIO(src)).convert()

assert len(doc.tables) == 1
assert [cell.text for cell in doc.tables[0].data.table_cells] == ["h"]


def test_ordered_lists():
test_set: list[tuple[bytes, str]] = []

Expand Down
Loading