aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/styles_xml.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-06-08 22:25:35 +0100
committerMichael Williamson <mike@zwobble.org>2014-06-08 22:25:35 +0100
commitf37fce68a77630a199737959e9d235d0a1263662 (patch)
tree3a491f30099c8a548d6437b09e04ada4f24f28b8 /mammoth/docx/styles_xml.py
parent6358a5201b97067e86cd06dff634bcefc6acb856 (diff)
Read style name for paragraphs out of source document
Diffstat (limited to 'mammoth/docx/styles_xml.py')
-rw-r--r--mammoth/docx/styles_xml.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mammoth/docx/styles_xml.py b/mammoth/docx/styles_xml.py
index c220740..ab3cc0f 100644
--- a/mammoth/docx/styles_xml.py
+++ b/mammoth/docx/styles_xml.py
@@ -23,16 +23,18 @@ def read_styles_xml_element(element):
for style_element in element.find_children("w:style"):
style = _read_style_element(style_element)
- styles[style.element_type][style.style_id] = style
+ element_type = style_element.attributes["w:type"]
+ style_set = styles.get(element_type)
+ if style_set is not None:
+ style_set[style.style_id] = style
return Styles(paragraph_styles, character_styles)
def _read_style_element(element):
- element_type = element.attributes["w:type"]
style_id = element.attributes["w:styleId"]
name = element.find_child("w:name").attributes["w:val"]
- return Style(element_type=element_type, style_id=style_id, name=name)
+ return Style(style_id=style_id, name=name)
-Style = collections.namedtuple("Style", ["element_type", "style_id", "name"])
+Style = collections.namedtuple("Style", ["style_id", "name"])