Format with less white space

pull/162/head
M66B 6 years ago
parent 75bc04bd36
commit 63dcefd935

@ -206,12 +206,19 @@ public class HtmlHelper {
// Tables // Tables
for (Element col : document.select("th,td")) { for (Element col : document.select("th,td")) {
// separate columns by a space boolean content = false;
if (col.nextElementSibling() == null) { for (Element e : col.children())
if (col.selectFirst("div,table,p") == null) if (!e.isBlock() && hasContent(e)) {
content = true;
break;
}
// separate columns
if (content)
if (col.nextElementSibling() == null)
col.appendElement("br"); col.appendElement("br");
} else else
col.append(" "); col.appendText(" ");
if ("th".equals(col.tagName())) if ("th".equals(col.tagName()))
col.tagName("strong"); col.tagName("strong");
@ -345,10 +352,7 @@ public class HtmlHelper {
// Remove block elements displaying nothing // Remove block elements displaying nothing
for (Element e : document.select("*")) for (Element e : document.select("*"))
if (e.isBlock() && if (e.isBlock() && !hasContent(e))
!e.hasText() &&
e.select("br").size() == 0 &&
e.select("img").size() == 0)
e.remove(); e.remove();
// Prevent too many line breaks // Prevent too many line breaks
@ -362,6 +366,10 @@ public class HtmlHelper {
return (body == null ? "" : body.html()); return (body == null ? "" : body.html());
} }
private static boolean hasContent(Element element) {
return (element.hasText() || element.selectFirst("img") != null);
}
static Drawable decodeImage(final Context context, final long id, String source, boolean show, final TextView view) { static Drawable decodeImage(final Context context, final long id, String source, boolean show, final TextView view) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean compact = prefs.getBoolean("compact", false); boolean compact = prefs.getBoolean("compact", false);

Loading…
Cancel
Save