diff options
| -rw-r--r-- | NEWS | 2 | ||||
| -rw-r--r-- | mammoth/documents.py | 3 | ||||
| -rw-r--r-- | tests/conversion_tests.py | 19 |
3 files changed, 24 insertions, 0 deletions
@@ -2,6 +2,8 @@ * Ignore style definitions using a style ID that has already been used. +* Fix conversion of unmerged table cells. + # 1.10.0 * Add "Heading" and "Body" styles, as found in documents created by Apple Pages, diff --git a/mammoth/documents.py b/mammoth/documents.py index e874775..18cc7b3 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -92,6 +92,9 @@ class TableCellUnmerged: rowspan = cobble.field() vmerge = cobble.field() + def _accept1(self, visitor, arg0): + return visitor.visit_table_cell(self, arg0) + def copy(self, **kwargs): return cobble.copy(self, **kwargs) diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index f11a69f..fd32658 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -386,6 +386,25 @@ def test_docx_table_is_converted_to_table_in_html(): assert_equal(expected_html, result.value) +def test_unmerged_table_cell_is_treated_as_table_cell(): + table = documents.table([ + documents.table_row([ + documents.table_cell_unmerged( + [_paragraph_with_text("Cell")], + colspan=1, + rowspan=1, + vmerge=False, + ), + ]), + ]) + result = convert_document_element_to_html(table) + expected_html = ( + "<table>" + + "<tr><td><p>Cell</p></td></tr>" + + "</table>") + assert_equal(expected_html, result.value) + + def test_table_style_mappings_can_be_used_to_map_tables(): table = documents.table([], style_name="Normal Table") result = convert_document_element_to_html( |
