This commit is contained in:
M66B
2020-08-12 10:29:59 +02:00
parent 4727598373
commit 5156aeba85
5 changed files with 2 additions and 95 deletions

View File

@@ -1688,72 +1688,6 @@ public class HtmlHelper {
return ssb.toString();
}
static void convertLists(Document document) {
if (BuildConfig.DEBUG)
return;
for (Element span : document.select("span")) {
// Skip signature and referenced message
boolean body = true;
Element parent = span.parent();
while (parent != null) {
if ("div".equals(parent.tagName()) &&
!TextUtils.isEmpty(parent.attr("fairemail"))) {
body = false;
break;
}
parent = parent.parent();
}
if (!body)
continue;
Element list = null;
for (int i = 0; i < span.childNodeSize(); i++) {
boolean item = false;
Node node = span.childNode(i);
if (node instanceof TextNode) {
String text = ((TextNode) node).text().trim();
Node next = node.nextSibling();
if ((/*text.startsWith("* ") ||*/ text.startsWith("- ")) &&
(next == null || "br".equals(next.nodeName()))) {
item = true;
String type = (text.startsWith("* ") ? "ul" : "ol");
Element li = document.createElement("li");
li.text(text.substring(2));
if (list == null || !list.tagName().equals(type)) {
Node before = node.previousSibling();
if (before != null && "br".equals(before.nodeName())) {
before.remove();
i--;
}
list = document.createElement(type);
list.appendChild(li);
node.replaceWith(list);
} else {
list.appendChild(li);
node.remove();
i--;
}
if (next != null)
next.remove();
}
} else {
if (list != null && "br".equals(node.nodeName())) {
node.remove();
i--;
}
}
if (!item)
list = null;
}
}
}
static Spanned highlightHeaders(Context context, String headers) {
int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
SpannableStringBuilder ssb = new SpannableStringBuilder(headers);