diff options
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | mammoth/docx/body_xml.py | 2 | ||||
| -rw-r--r-- | tests/docx/body_xml_tests.py | 4 |
3 files changed, 7 insertions, 3 deletions
@@ -1,3 +1,7 @@ +# 1.4.19 + +* Ignore w:u elements when w:val is missing. + # 1.4.18 * Emit warning instead of throwing exception when image file cannot be found for diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index 8d727a5..c11e9e5 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -127,7 +127,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return element and element.attributes.get("w:val") not in ["false", "0"] def read_underline_element(element): - return element and element.attributes.get("w:val") not in ["false", "0", "none"] + return element and element.attributes.get("w:val") not in [None, "false", "0", "none"] def paragraph(element): properties = element.find_child_or_null("w:pPr") diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py index e0328fb..d7f5509 100644 --- a/tests/docx/body_xml_tests.py +++ b/tests/docx/body_xml_tests.py @@ -275,9 +275,9 @@ class RunTests(object): assert_equal(False, run.is_underline) @istest - def run_is_underlined_if_underline_element_is_present_without_val_attribute(self): + def run_is_not_underlined_if_underline_element_is_present_without_val_attribute(self): run = self._read_run_with_properties([xml_element("w:u")]) - assert_equal(True, run.is_underline) + assert_equal(False, run.is_underline) @istest def run_is_not_underlined_if_underline_element_is_present_and_val_is_false(self): |
