aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx
diff options
context:
space:
mode:
Diffstat (limited to 'mammoth/docx')
-rw-r--r--mammoth/docx/body_xml.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 92ac085..2e16c26 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -71,9 +71,6 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
def text(element):
return _success(documents.Text(_inner_text(element)))
-
- def element_or_value(element):
- return element and element.attributes.get("w:val") != "false"
def run(element):
properties = element.find_child_or_null("w:rPr")
@@ -81,10 +78,10 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
.find_child_or_null("w:vertAlign") \
.attributes.get("w:val")
- is_bold = element_or_value(properties.find_child("w:b"))
- is_italic = element_or_value(properties.find_child("w:i"))
- is_underline = element_or_value(properties.find_child("w:u"))
- is_strikethrough = element_or_value(properties.find_child("w:strike"))
+ is_bold = read_boolean_element(properties.find_child("w:b"))
+ is_italic = read_boolean_element(properties.find_child("w:i"))
+ is_underline = read_boolean_element(properties.find_child("w:u"))
+ is_strikethrough = read_boolean_element(properties.find_child("w:strike"))
return _ReadResult.map_results(
_read_run_style(properties),
@@ -100,6 +97,9 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
vertical_alignment=vertical_alignment,
))
+ def read_boolean_element(element):
+ return element and element.attributes.get("w:val") != "false"
+
def paragraph(element):
properties = element.find_child_or_null("w:pPr")