aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/body_xml.py
diff options
context:
space:
mode:
Diffstat (limited to 'mammoth/docx/body_xml.py')
-rw-r--r--mammoth/docx/body_xml.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index e499cce..d3dd267 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -399,7 +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)
+ 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"
)])
@@ -410,7 +410,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
for cell in row.children
)
if unexpected_non_cells:
- remove_unmerged_table_cells(rows)
+ rows = remove_unmerged_table_cells(rows)
return _elements_result_with_messages(rows, [results.warning(
"unexpected non-cell element in table row, cell merging may be incorrect"
)])
@@ -441,14 +441,17 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
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,
- )
+ return list(map(
+ transforms.element_of_type(
+ documents.TableCellUnmerged,
+ lambda cell: documents.table_cell(
+ children=cell.children,
+ colspan=cell.colspan,
+ rowspan=cell.rowspan,
+ ),
+ ),
+ rows,
+ ))
def read_child_elements(element):