From cee62eea4e52484a473128f342e2a497e32261b7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 11 Sep 2025 15:07:41 +0100 Subject: Handle numbering levels defined without an index --- lib/docx/body-reader.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/docx/body-reader.js') diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 5cdb4ef..826424b 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -670,6 +670,13 @@ function readNumberingProperties(styleId, element, numbering) { } } + // 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 (numId !== undefined) { + return numbering.findLevel(numId, "0"); + } + return null; } -- cgit v1.2.3