aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/body_xml.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-09-11 15:21:40 +0100
committerMichael Williamson <mike@zwobble.org>2025-09-11 15:21:40 +0100
commit82bc0fe4769483196ce8cc8147fab16b38c52e8f (patch)
treee53ef888e6d880ce76a3843a479231ba36de550e /mammoth/docx/body_xml.py
parent8216e5ae1770955ad2400cee764c7f8ec56483bf (diff)
Handle numbering levels defined without an index
Diffstat (limited to 'mammoth/docx/body_xml.py')
-rw-r--r--mammoth/docx/body_xml.py6
1 files changed, 6 insertions, 0 deletions
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):