From 045747fb6d92bf9ac4498aa66999a5d4cdde98a6 Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Mon, 22 Jul 2024 14:26:10 +0300 Subject: [PATCH] handle nested or empty div elements --- .../service/wordfiletransformer/word/HtmlToWorldBuilder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java index 52ce840..83d5030 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java +++ b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java @@ -278,6 +278,11 @@ public class HtmlToWorldBuilder implements NodeVisitor { @Override public void tail(Node node, int i) { + if (!node.outerHtml().contains("br")) { + String htmlToPlainText = Jsoup.parse(node.outerHtml()).text(); + if (htmlToPlainText.trim().isEmpty()) return; + } + String name = node.nodeName(); properties.put(name, false); parseProperties(node);