From 82bc0fe4769483196ce8cc8147fab16b38c52e8f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 11 Sep 2025 15:21:40 +0100 Subject: Handle numbering levels defined without an index --- mammoth/docx/body_xml.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mammoth/docx/body_xml.py') diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index d3dd267..e2a490a 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -288,6 +288,12 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f if level is not None: return level + # Some malformed documents define numbering levels without an index, and + # reference the numbering using a w:numPr element without a w:ilvl child. + # To handle such cases, we assume a level of 0 as a fallback. + if num_id is not None: + return numbering.find_level(num_id, "0") + return None def _read_paragraph_indent(element): -- cgit v1.2.3