@@ -56,17 +56,19 @@ def read_styles_xml_element(element):
5656 "paragraph" : paragraph_styles ,
5757 "character" : character_styles ,
5858 "table" : table_styles ,
59+ "numbering" : numbering_styles ,
5960 }
6061
6162 for style_element in element .find_children ("w:style" ):
62- style = _read_style_element (style_element )
6363 element_type = style_element .attributes ["w:type" ]
6464 if element_type == "numbering" :
65- numbering_styles [ style . style_id ] = _read_numbering_style_element (style_element )
65+ style = _read_numbering_style_element (style_element )
6666 else :
67- style_set = styles .get (element_type )
68- if style_set is not None :
69- style_set [style .style_id ] = style
67+ style = _read_style_element (style_element )
68+
69+ style_set = styles .get (element_type )
70+ if style_set is not None :
71+ style_set [style .style_id ] = style
7072
7173 return Styles (
7274 paragraph_styles = paragraph_styles ,
@@ -80,19 +82,25 @@ def read_styles_xml_element(element):
8082
8183
8284def _read_style_element (element ):
83- style_id = element . attributes [ "w:styleId" ]
85+ style_id = _read_style_id ( element )
8486 name = element .find_child_or_null ("w:name" ).attributes .get ("w:val" )
8587 return Style (style_id = style_id , name = name )
8688
8789
88- NumberingStyle = collections .namedtuple ("NumberingStyle" , ["num_id" ])
90+ NumberingStyle = collections .namedtuple ("NumberingStyle" , ["style_id" , " num_id" ])
8991
9092
9193def _read_numbering_style_element (element ):
94+ style_id = _read_style_id (element )
95+
9296 num_id = element \
9397 .find_child_or_null ("w:pPr" ) \
9498 .find_child_or_null ("w:numPr" ) \
9599 .find_child_or_null ("w:numId" ) \
96100 .attributes .get ("w:val" )
97101
98- return NumberingStyle (num_id = num_id )
102+ return NumberingStyle (style_id = style_id , num_id = num_id )
103+
104+
105+ def _read_style_id (element ):
106+ return element .attributes ["w:styleId" ]
0 commit comments