Prevent too many line breaks

This commit is contained in:
M66B 2019-07-08 20:14:33 +02:00
parent 619a6685ea
commit 08ab6e99a1
1 changed files with 7 additions and 11 deletions

View File

@ -185,17 +185,6 @@ public class HtmlHelper {
document.select("ul").tagName("div"); document.select("ul").tagName("div");
// Tables // 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")) { for (Element col : document.select("th,td")) {
// separate columns by a space // separate columns by a space
if (col.nextElementSibling() == null) { if (col.nextElementSibling() == null) {
@ -309,6 +298,13 @@ public class HtmlHelper {
if (e.isBlock() && !e.hasText() && e.select("img").size() == 0) if (e.isBlock() && !e.hasText() && e.select("img").size() == 0)
e.remove(); 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(); Element body = document.body();
return (body == null ? "" : body.html()); return (body == null ? "" : body.html());
} }