diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index a285b4db3f..a409329a22 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -2233,6 +2233,11 @@ public class HtmlHelper { break; case "div": // compose case "p": // compose + if (!"true".equals(element.attr("x-block")) && + !"true".equals(element.attr("x-paragraph"))) { + newline(ssb.length()); + newline(ssb.length()); + } break; case "i": case "em": @@ -2252,6 +2257,10 @@ public class HtmlHelper { int level = element.tagName().charAt(1) - '1'; setSpan(ssb, new RelativeSizeSpan(HEADING_SIZES[level]), start, ssb.length()); setSpan(ssb, new StyleSpan(Typeface.BOLD), start, ssb.length()); + if (!"true".equals(element.attr("x-block"))) { + newline(start); + newline(ssb.length()); + } break; case "hr": if (text_separators) { @@ -2416,6 +2425,25 @@ public class HtmlHelper { else Log.e("Invalid span " + start + "..." + end + " len=" + len + " type=" + span.getClass().getName()); } + + private void newline(int index) { + int count = 0; + + if (compress) { + int i = Math.min(index, ssb.length() - 1); + while (i >= 0) { + char kar = ssb.charAt(i); + if (kar == '\n') + count++; + else if (kar != ' ' && kar != '\u00A0') + break; + i--; + } + } + + if (count < 2) + ssb.insert(index, "\n"); + } }, document.body()); if (debug)