mirror of https://github.com/M66B/FairEmail.git
Visible block content
This commit is contained in:
parent
acb89f8611
commit
e12d175f11
|
@ -748,9 +748,7 @@ public class HtmlHelper {
|
||||||
// Remove trailing br from div
|
// Remove trailing br from div
|
||||||
for (Element div : document.select("div")) {
|
for (Element div : document.select("div")) {
|
||||||
boolean inline = Boolean.parseBoolean(div.attr("x-inline"));
|
boolean inline = Boolean.parseBoolean(div.attr("x-inline"));
|
||||||
if (!inline &&
|
if (!inline && hasVisibleContent(div, true)) {
|
||||||
div.children().select("div").size() == 0 &&
|
|
||||||
hasVisibleContent(div)) {
|
|
||||||
Element last = div.lastElementSibling();
|
Element last = div.lastElementSibling();
|
||||||
if (last != null && "br".equals(last.tagName()))
|
if (last != null && "br".equals(last.tagName()))
|
||||||
last.remove();
|
last.remove();
|
||||||
|
@ -842,7 +840,7 @@ public class HtmlHelper {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
|
||||||
for (Element col : document.select("th,td")) {
|
for (Element col : document.select("th,td")) {
|
||||||
// separate columns
|
// separate columns
|
||||||
if (hasVisibleContent(col))
|
if (hasVisibleContent(col, false))
|
||||||
if (col.nextElementSibling() != null)
|
if (col.nextElementSibling() != null)
|
||||||
col.append(" ");
|
col.append(" ");
|
||||||
|
|
||||||
|
@ -854,7 +852,7 @@ public class HtmlHelper {
|
||||||
|
|
||||||
for (Element row : document.select("tr")) {
|
for (Element row : document.select("tr")) {
|
||||||
row.tagName("span");
|
row.tagName("span");
|
||||||
if (hasVisibleContent(row)) {
|
if (hasVisibleContent(row, true)) {
|
||||||
Element next = row.nextElementSibling();
|
Element next = row.nextElementSibling();
|
||||||
if (next != null && "tr".equals(next.tagName()))
|
if (next != null && "tr".equals(next.tagName()))
|
||||||
if (text_separators && view)
|
if (text_separators && view)
|
||||||
|
@ -1018,9 +1016,7 @@ public class HtmlHelper {
|
||||||
// Selective new lines
|
// Selective new lines
|
||||||
for (Element div : document.select("div")) {
|
for (Element div : document.select("div")) {
|
||||||
boolean inline = Boolean.parseBoolean(div.attr("x-inline"));
|
boolean inline = Boolean.parseBoolean(div.attr("x-inline"));
|
||||||
if (!inline &&
|
if (!inline && hasVisibleContent(div, true))
|
||||||
div.children().select("div").size() == 0 &&
|
|
||||||
hasVisibleContent(div))
|
|
||||||
div.attr("x-line-after", "true");
|
div.attr("x-line-after", "true");
|
||||||
div.tagName("span");
|
div.tagName("span");
|
||||||
}
|
}
|
||||||
|
@ -1373,7 +1369,7 @@ public class HtmlHelper {
|
||||||
return (color & 0xFFFFFF);
|
return (color & 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasVisibleContent(Element root) {
|
private static boolean hasVisibleContent(Element root, boolean block) {
|
||||||
for (Node node : root.childNodes())
|
for (Node node : root.childNodes())
|
||||||
if (node instanceof TextNode) {
|
if (node instanceof TextNode) {
|
||||||
String text = ((TextNode) node).getWholeText();
|
String text = ((TextNode) node).getWholeText();
|
||||||
|
@ -1386,6 +1382,8 @@ public class HtmlHelper {
|
||||||
Element element = (Element) node;
|
Element element = (Element) node;
|
||||||
if (element.hasText())
|
if (element.hasText())
|
||||||
return true;
|
return true;
|
||||||
|
if (block && "true".equals(element.attr("x-block")))
|
||||||
|
return false;
|
||||||
if (element.selectFirst("img[src~=.+]") != null)
|
if (element.selectFirst("img[src~=.+]") != null)
|
||||||
return true;
|
return true;
|
||||||
for (Element a : element.select("a[href~=.+]"))
|
for (Element a : element.select("a[href~=.+]"))
|
||||||
|
|
Loading…
Reference in New Issue