Improved table formatting

This commit is contained in:
M66B 2019-03-10 11:14:39 +00:00
parent 5260f1a971
commit d5f8bebeeb
1 changed files with 12 additions and 1 deletions

View File

@ -36,6 +36,7 @@ import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.safety.Whitelist;
import org.jsoup.select.Elements;
import org.jsoup.select.NodeTraversor;
import org.jsoup.select.NodeVisitor;
@ -72,11 +73,21 @@ public class HtmlHelper {
.addProtocols("img", "src", "data")));
for (Element td : document.select("th,td")) {
Elements br = td.select("br");
br.after(" ");
br.remove();
Elements div = td.select("div");
div.tagName("span");
Element next = td.nextElementSibling();
if (next != null && ("th".equals(next.tagName()) || "td".equals(next.tagName())))
td.append("<span> </span>");
td.append("&nbsp;");
else
td.append("<br>");
if ("th".equals(td.tagName()))
td.html("<strong>" + td.html() + "<strong>");
}
for (Element ol : document.select("ol,ul"))