mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Prevent extra newlines
This commit is contained in:
parent
87b5ccb5b9
commit
2b34877425
1 changed files with 35 additions and 12 deletions
|
@ -844,19 +844,42 @@ public class HtmlHelper {
|
|||
for (Element col : row.children()) {
|
||||
Element next = col.nextElementSibling();
|
||||
|
||||
// Get nodes with content
|
||||
List<Node> nodes = new ArrayList<>(col.childNodes());
|
||||
while (nodes.size() > 0) {
|
||||
Node first = nodes.get(0);
|
||||
if (first instanceof TextNode && ((TextNode) first).isBlank()) {
|
||||
nodes.remove(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
Node last = nodes.get(nodes.size() - 1);
|
||||
if (last instanceof TextNode && ((TextNode) last).isBlank()) {
|
||||
nodes.remove(nodes.size() - 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Merge single images into next column
|
||||
if (col.childNodeSize() == 1 &&
|
||||
(next == null ||
|
||||
next.attr("x-align")
|
||||
.equals(col.attr("x-align")))) {
|
||||
Node lonely = col.childNode(0);
|
||||
if (lonely instanceof Element &&
|
||||
"img".equals(lonely.nodeName())) {
|
||||
lonely.remove();
|
||||
lonely.removeAttr("x-block");
|
||||
merge.add(lonely);
|
||||
if (next != null)
|
||||
continue;
|
||||
if (nodes.size() == 1) {
|
||||
Node lonely = nodes.get(0);
|
||||
|
||||
// prevent extra newlines
|
||||
lonely.removeAttr("x-paragraph");
|
||||
|
||||
if (next == null ||
|
||||
next.attr("x-align")
|
||||
.equals(col.attr("x-align"))) {
|
||||
if (lonely instanceof Element &&
|
||||
"img".equals(lonely.nodeName())) {
|
||||
lonely.remove();
|
||||
lonely.removeAttr("x-block");
|
||||
merge.add(lonely);
|
||||
if (next != null)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue