From d12d00f3ed36f0ffe8f8920cf028fb977a18ce24 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 13 Jun 2024 12:55:42 +0100 Subject: Handle highlight value of none --- lib/docx/body-reader.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 78c732e..28bd2ef 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -95,7 +95,7 @@ function BodyReader(options) { isStrikethrough: readBooleanElement(element.first("w:strike")), isAllCaps: readBooleanElement(element.first("w:caps")), isSmallCaps: readBooleanElement(element.first("w:smallCaps")), - highlight: element.firstOrEmpty("w:highlight").attributes["w:val"] + highlight: readHighlightValue(element.firstOrEmpty("w:highlight").attributes["w:val"]) }; }); } @@ -118,6 +118,14 @@ function BodyReader(options) { } } + function readHighlightValue(value) { + if (!value || value === "none") { + return null; + } else { + return value; + } + } + function readParagraphStyle(element) { return readStyle(element, "w:pStyle", "Paragraph", styles.findParagraphStyleById); } -- cgit v1.2.3