fix(pptx): preserve merged table cell spans

GP
3d ago
+40-3

Summary

partition_pptx() rendered every PowerPoint table grid position as its own HTML cell. python-pptx still returns positions covered by a merge (is_spanned) with empty text, and the HTML was built with htmlify_matrix_of_cell_texts(), which cannot record a span. metadata.text_as_html therefore dropped the merge and inserted blank cells.

A 3x3 table built with python-pptx, merging cell(0, 0) across cell(0, 1) ("horizontal") and cell(1, 0) down through cell(2, 0) ("vertical"), partitions on main (293d235c) as:

<table><tr><td>horizontal</td><td/><td>right</td></tr><tr><td>vertical</td><td>middle</td><td>r1</td></tr><tr><td/><td>bottom</td><td>r2</td></tr></table>

Covered cells are now omitted, and each merge origin is emitted with its span_width and span_height through the spanned-cell helper DOCX partitioning already uses:

<table><tr><td colspan="2">horizontal</td><td>right</td></tr><tr><td rowspan="2">vertical</td><td>middle</td><td>r1</td></tr><tr><td>bottom</td><td>r2</td></tr></table>

element.text stays horizontal right vertical middle r1 bottom r2. Unmerged tables, including fake-power-point-table.pptx, keep the same HTML.

Validation

pytest -q test_unstructured/partition/test_pptx.py
ruff check .
ruff format --check .

119 passed. Ruff check and format are clean on the changed files and the rest of the tree.

Checklist

  • The PR title is a user-facing release-note entry with a conventional commit prefix.
  • Apply a category label (enhancement, bug, or an appropriate existing label), or ask a maintainer to apply it.
    • A fork can't set labels; this is a bug.
  • For breaking changes, use ! in the title and explain impact and migration above.
    • Merged PPTX tables gain colspan/rowspan in text_as_html. Plain text and unmerged tables stay the same.