Skip to content

Commit 0c87234

Browse files
committed
Fix conversion of unmerged table cells
1 parent 70e02c7 commit 0c87234

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Ignore style definitions using a style ID that has already been used.
44

5+
* Fix conversion of unmerged table cells.
6+
57
# 1.10.0
68

79
* Add "Heading" and "Body" styles, as found in documents created by Apple Pages,

mammoth/documents.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class TableCellUnmerged:
9292
rowspan = cobble.field()
9393
vmerge = cobble.field()
9494

95+
def _accept1(self, visitor, arg0):
96+
return visitor.visit_table_cell(self, arg0)
97+
9598
def copy(self, **kwargs):
9699
return cobble.copy(self, **kwargs)
97100

tests/conversion_tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,25 @@ def test_docx_table_is_converted_to_table_in_html():
386386
assert_equal(expected_html, result.value)
387387

388388

389+
def test_unmerged_table_cell_is_treated_as_table_cell():
390+
table = documents.table([
391+
documents.table_row([
392+
documents.table_cell_unmerged(
393+
[_paragraph_with_text("Cell")],
394+
colspan=1,
395+
rowspan=1,
396+
vmerge=False,
397+
),
398+
]),
399+
])
400+
result = convert_document_element_to_html(table)
401+
expected_html = (
402+
"<table>" +
403+
"<tr><td><p>Cell</p></td></tr>" +
404+
"</table>")
405+
assert_equal(expected_html, result.value)
406+
407+
389408
def test_table_style_mappings_can_be_used_to_map_tables():
390409
table = documents.table([], style_name="Normal Table")
391410
result = convert_document_element_to_html(

0 commit comments

Comments
 (0)