aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/body_xml.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-06-13 12:58:12 +0100
committerMichael Williamson <mike@zwobble.org>2024-06-13 12:58:12 +0100
commit9892cf6c3fc0e3ef2a4095a742c8e8fb73113fb4 (patch)
tree262c1a5b9357fe2ad9ae1aad9646c162c67df220 /mammoth/docx/body_xml.py
parentb874c8214b9734cc8cca5ef21176ff7cc16fcee3 (diff)
Handle highlight value of none
Diffstat (limited to 'mammoth/docx/body_xml.py')
-rw-r--r--mammoth/docx/body_xml.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 83cbd90..e1e70a5 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -102,7 +102,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
is_strikethrough = read_boolean_element(properties.find_child("w:strike"))
is_all_caps = read_boolean_element(properties.find_child("w:caps"))
is_small_caps = read_boolean_element(properties.find_child("w:smallCaps"))
- highlight = properties.find_child_or_null("w:highlight").attributes.get("w:val")
+ highlight = read_highlight_value(properties.find_child_or_null("w:highlight").attributes.get("w:val"))
def add_complex_field_hyperlink(children):
hyperlink_kwargs = current_hyperlink_kwargs()
@@ -139,6 +139,12 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
def read_underline_element(element):
return element and element.attributes.get("w:val") not in [None, "false", "0", "none"]
+ def read_highlight_value(value):
+ if not value or value == "none":
+ return None
+ else:
+ return value
+
def paragraph(element):
properties = element.find_child_or_null("w:pPr")