Added hiding/showing blockquotes

This commit is contained in:
M66B
2018-12-21 15:19:07 +01:00
parent a60b1b642d
commit a74c1e835b
6 changed files with 89 additions and 33 deletions

View File

@@ -55,7 +55,7 @@ public class HtmlHelper {
return Jsoup.parse(html).body().html();
}
static String sanitize(String html) {
static String sanitize(String html, boolean quotes) {
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist
.relaxed()
.addProtocols("img", "src", "cid")
@@ -82,6 +82,10 @@ public class HtmlHelper {
}
}
if (!quotes)
for (Element quote : document.select("blockquote"))
quote.text("…");
NodeTraversor.traverse(new NodeVisitor() {
@Override
public void head(Node node, int depth) {
@@ -242,6 +246,6 @@ public class HtmlHelper {
return String.format("<p>%s %s:</p>\n<blockquote>%s</blockquote>",
Html.escapeHtml(new Date(message.received).toString()),
Html.escapeHtml(MessageHelper.getFormattedAddresses(message.from, true)),
sanitize ? sanitize(html) : getBody(html));
sanitize ? sanitize(html, true) : getBody(html));
}
}