aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/docx/body_xml.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index f99a799..091caef 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -399,6 +399,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
for row in rows
)
if unexpected_non_rows:
+ remove_unmerged_table_cells(rows)
return _elements_result_with_messages(rows, [results.warning(
"unexpected non-row element in table, cell merging may be incorrect"
)])
@@ -438,6 +439,17 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
return _success(rows)
+ def remove_unmerged_table_cells(rows):
+ for row in rows:
+ for cell_index, cell in enumerate(row.children):
+ if isinstance(cell, documents.TableCellUnmerged):
+ row.children[cell_index] = documents.table_cell(
+ children=cell.children,
+ colspan=cell.colspan,
+ rowspan=cell.rowspan,
+ )
+
+
def read_child_elements(element):
return _read_xml_elements(element.children)