Added table image merger

pull/187/head
M66B 4 years ago
parent 1dc1b0ae6f
commit 0303fbea87

@ -840,7 +840,27 @@ public class HtmlHelper {
for (Element row : table.children()) {
row.tagName("div");
List<Node> merge = new ArrayList<>();
for (Element col : row.children()) {
Element next = col.nextElementSibling();
if (col.childNodeSize() == 1) {
Node lonely = col.childNode(0);
if (lonely instanceof Element &&
"img".equals(lonely.nodeName())) {
lonely.remove();
lonely.removeAttr("x-block");
merge.add(lonely);
if (next != null)
continue;
}
}
if (merge.size() > 0) {
for (int m = merge.size() - 1; m >= 0; m--)
col.prependChild(merge.get(m));
merge.clear();
}
if ("th".equals(col.tagName())) {
Element strong = new Element("strong");
for (Node child : new ArrayList<>(col.childNodes())) {
@ -856,11 +876,13 @@ public class HtmlHelper {
"start".equals(align))
col.tagName("div").removeAttr("x-block");
if (col.childNodeSize() > 0 &&
col.nextElementSibling() != null)
if (next != null && col.childNodeSize() > 0)
col.appendText("\u2002"); // ensp
}
if (merge.size() != 0)
throw new AssertionError("merge");
if (text_separators && view)
row.appendElement("hr")
.attr("x-block", "true")

Loading…
Cancel
Save