From d5f8bebeeb73ea0a3e2ef359c5e9987d120ac066 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 10 Mar 2019 11:14:39 +0000 Subject: [PATCH] Improved table formatting --- app/src/main/java/eu/faircode/email/HtmlHelper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1921025438..15ae90cecc 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -36,6 +36,7 @@ import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; import org.jsoup.nodes.TextNode; import org.jsoup.safety.Whitelist; +import org.jsoup.select.Elements; import org.jsoup.select.NodeTraversor; import org.jsoup.select.NodeVisitor; @@ -72,11 +73,21 @@ public class HtmlHelper { .addProtocols("img", "src", "data"))); for (Element td : document.select("th,td")) { + Elements br = td.select("br"); + br.after(" "); + br.remove(); + + Elements div = td.select("div"); + div.tagName("span"); + Element next = td.nextElementSibling(); if (next != null && ("th".equals(next.tagName()) || "td".equals(next.tagName()))) - td.append(" "); + td.append(" "); else td.append("
"); + + if ("th".equals(td.tagName())) + td.html("" + td.html() + ""); } for (Element ol : document.select("ol,ul"))