Wrap images in paragraphs, cleanup

pull/147/head
M66B 6 years ago
parent 6c5dd6fb1e
commit e9f1d31c34

@ -55,10 +55,6 @@ public class HtmlHelper {
private static final List<String> heads = Arrays.asList("p", "h1", "h2", "h3", "h4", "h5", "tr"); private static final List<String> heads = Arrays.asList("p", "h1", "h2", "h3", "h4", "h5", "tr");
private static final List<String> tails = Arrays.asList("br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5"); private static final List<String> tails = Arrays.asList("br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5");
static String getBody(String html) {
return Jsoup.parse(html).body().html();
}
static String sanitize(String html, boolean quotes) { static String sanitize(String html, boolean quotes) {
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist Document document = Jsoup.parse(Jsoup.clean(html, Whitelist
.relaxed() .relaxed()
@ -86,6 +82,12 @@ public class HtmlHelper {
} }
} }
for (Element img : document.select("img")) {
Element p = document.createElement("p");
img.replaceWith(p);
p.appendChild(img);
}
if (!quotes) if (!quotes)
for (Element quote : document.select("blockquote")) for (Element quote : document.select("blockquote"))
quote.text("&#8230;"); quote.text("&#8230;");

Loading…
Cancel
Save