aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mammoth/conversion.py5
-rw-r--r--tests/conversion_tests.py10
2 files changed, 14 insertions, 1 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index cbe207a..eb09ded 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -166,7 +166,10 @@ class _DocumentConverter(documents.element_visitor(args=1)):
def visit_table(self, table, context):
- body_index = find_index(lambda child: not child.is_header, table.children)
+ body_index = find_index(
+ lambda child: not isinstance(child, documents.TableRow) or not child.is_header,
+ table.children,
+ )
if body_index is None:
body_index = len(table.children)
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
index 3fd9e34..9b81bf1 100644
--- a/tests/conversion_tests.py
+++ b/tests/conversion_tests.py
@@ -346,6 +346,16 @@ def tbody_is_omitted_if_all_rows_are_headers():
@istest
+def unexpected_table_children_do_not_cause_error():
+ table = documents.table([
+ documents.tab(),
+ ])
+ result = convert_document_element_to_html(table)
+ expected_html = "<table>\t</table>"
+ assert_equal(expected_html, result.value)
+
+
+@istest
def empty_cells_are_preserved_in_table():
table = documents.table([
documents.table_row([