diff --git a/src/main/java/org/zwobble/mammoth/internal/docx/StatefulBodyXmlReader.java b/src/main/java/org/zwobble/mammoth/internal/docx/StatefulBodyXmlReader.java index 6fc0c67..246f69e 100644 --- a/src/main/java/org/zwobble/mammoth/internal/docx/StatefulBodyXmlReader.java +++ b/src/main/java/org/zwobble/mammoth/internal/docx/StatefulBodyXmlReader.java @@ -203,7 +203,8 @@ private Optional currentHyperlinkComplexField() { } private Optional readHighlight(XmlElementLike properties) { - return readVal(properties, "w:highlight"); + return readVal(properties, "w:highlight") + .filter(value -> !value.isEmpty() && !value.equals("none")); } private boolean isBold(XmlElementLike properties) { diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java index a5cb989..3cfb161 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -879,6 +879,17 @@ public void runHasHighlightReadFromProperties() { assertThat(result, hasProperty("highlight", equalTo(Optional.of("yellow")))); } + @Test + public void whenHighlightIsNoneThenRunhasNoHighlight() { + XmlElement element = runXmlWithProperties( + element("w:highlight", map("w:val", "none")) + ); + + DocumentElement result = readSuccess(bodyReader(), element); + + assertThat(result, hasProperty("highlight", equalTo(Optional.empty()))); + } + @Test public void canReadTabElement() { XmlElement element = element("w:tab");