From 08ab6e99a1c6e0d6e49273694887282c8a635a19 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 8 Jul 2019 20:14:33 +0200 Subject: [PATCH] Prevent too many line breaks --- .../java/eu/faircode/email/HtmlHelper.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 319afc60ba..09921742a5 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -185,17 +185,6 @@ public class HtmlHelper { document.select("ul").tagName("div"); // Tables - for (Element div : document.select("div")) { - Element parent = div.parent(); - while (parent != null) { - if ("td".equals(parent.tagName())) { - div.tagName("span"); // Prevent white space - break; - } - parent = parent.parent(); - } - } - for (Element col : document.select("th,td")) { // separate columns by a space if (col.nextElementSibling() == null) { @@ -309,6 +298,13 @@ public class HtmlHelper { if (e.isBlock() && !e.hasText() && e.select("img").size() == 0) e.remove(); + // Prevent too many line breaks + for (Element div : document.select("div")) { + div.tagName("span"); + if (div.parent() != null) + div.after(document.createElement("br")); + } + Element body = document.body(); return (body == null ? "" : body.html()); }