From 526d7789f403bc6a6b18c356bfe2f2a243ef44ba Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 11 Sep 2019 22:20:00 +0200 Subject: [PATCH] Check if div has content --- .../main/java/eu/faircode/email/HtmlHelper.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 2187f681c6..16b502ff0a 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -366,9 +366,19 @@ public class HtmlHelper { // Prevent too many line breaks for (Element div : document.select("div")) { div.tagName("span"); - if (div.childNodeSize() == 1 && div.childNode(0) instanceof TextNode) + + boolean content = false; + for (Node child : div.childNodes()) + if (child instanceof TextNode || + (child instanceof Element && "img".equals(child.nodeName()))) { + content = true; + break; + } + + if (content) { div.appendElement("br"); - div.appendElement("br"); + div.appendElement("br"); + } } Element body = document.body();