mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-19 13:48:58 +00:00
Suppress extra p new line when margin/padding is zero
This commit is contained in:
parent
5bb5e9802d
commit
2d951d3b7a
1 changed files with 14 additions and 7 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue