mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-07 09:33:39 +02:00
Suppress extra p new line when margin/padding is zero
This commit is contained in:
@@ -659,10 +659,16 @@ public class HtmlHelper {
|
||||
else if (key.endsWith("bottom"))
|
||||
p[0] = null;
|
||||
|
||||
if (p[0] != null && p[0] > 0.5)
|
||||
element.attr("x-line-before", "true");
|
||||
if (p[2] != null && p[2] > 0.5)
|
||||
element.attr("x-line-after", "true");
|
||||
if (p[0] != null)
|
||||
if (p[0] == 0)
|
||||
element.attr("x-line-before", "false");
|
||||
else if (p[0] > 0.5)
|
||||
element.attr("x-line-before", "true");
|
||||
if (p[2] != null)
|
||||
if (p[2] == 0)
|
||||
element.attr("x-line-after", "false");
|
||||
else if (p[2] > 0.5)
|
||||
element.attr("x-line-after", "true");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -704,7 +710,8 @@ public class HtmlHelper {
|
||||
|
||||
// Paragraphs
|
||||
for (Element p : document.select("p")) {
|
||||
p.appendElement("br");
|
||||
if (!"false".equals(p.attr("x-line-after")))
|
||||
p.appendElement("br");
|
||||
p.tagName("div");
|
||||
}
|
||||
|
||||
@@ -958,13 +965,13 @@ public class HtmlHelper {
|
||||
div.tagName("span");
|
||||
|
||||
for (Element e : document.select("*[x-line-before],*[x-line-after]")) {
|
||||
if (!TextUtils.isEmpty(e.attr("x-line-before"))) {
|
||||
if ("true".equals(e.attr("x-line-before"))) {
|
||||
Element prev = e.previousElementSibling();
|
||||
if (prev == null || !"br".equals(prev.tagName()))
|
||||
e.prependElement("br");
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(e.attr("x-line-after"))) {
|
||||
if ("true".equals(e.attr("x-line-after"))) {
|
||||
Element next = e.nextElementSibling();
|
||||
if (next == null || !"br".equals(next.tagName()))
|
||||
e.appendElement("br");
|
||||
|
||||
Reference in New Issue
Block a user