From 19a8412b0fdd6955b28042c470022cfbb8ff55e0 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 20 Mar 2024 19:12:21 +0000 Subject: Prefer numbering properties to numbering from paragraph style --- mammoth/docx/body_xml.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mammoth') diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index f880c72..005ad3d 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -236,17 +236,17 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return results.warning("{0} style with ID {1} was referenced but not defined in the document".format(style_type, style_id)) def _read_numbering_properties(paragraph_style_id, element): + num_id = element.find_child_or_null("w:numId").attributes.get("w:val") + level_index = element.find_child_or_null("w:ilvl").attributes.get("w:val") + if num_id is not None and level_index is not None: + return numbering.find_level(num_id, level_index) + if paragraph_style_id is not None: level = numbering.find_level_by_paragraph_style_id(paragraph_style_id) if level is not None: return level - num_id = element.find_child_or_null("w:numId").attributes.get("w:val") - level_index = element.find_child_or_null("w:ilvl").attributes.get("w:val") - if num_id is None or level_index is None: - return None - else: - return numbering.find_level(num_id, level_index) + return None def _read_paragraph_indent(element): attributes = element.attributes -- cgit v1.2.3