Improved plain text format

pull/167/head
M66B 5 years ago
parent 7f2e2256e5
commit 876c9f9c7d

@ -624,7 +624,6 @@ public class HtmlHelper {
private int qlevel = 0;
private int tlevel = 0;
private int plevel = 0;
private boolean nl = true;
public void head(Node node, int depth) {
if (node instanceof TextNode)
@ -653,13 +652,15 @@ public class HtmlHelper {
public void tail(Node node, int depth) {
String name = node.nodeName();
if ("a".equals(name))
append("[" + node.attr("href") + "] ");
append("[" + node.attr("href") + "]");
else if ("img".equals(name))
append("[" + node.attr("src") + "] ");
append("[" + node.attr("src") + "]");
else if ("th".equals(name) || "td".equals(name)) {
Node next = node.nextSibling();
if (next == null || !("th".equals(next.nodeName()) || "td".equals(next.nodeName())))
newline();
else
append(" ");
} else if ("blockquote".equals(name))
qlevel--;
else if ("pre".equals(name))
@ -674,12 +675,7 @@ public class HtmlHelper {
newline();
tlevel = qlevel;
}
if (!nl &&
(text != null && !text.startsWith(" ")) &&
(sb.length() > 0 && sb.charAt(sb.length() - 1) != ' '))
sb.append(" ");
sb.append(text);
nl = false;
}
private void newline() {
@ -688,7 +684,6 @@ public class HtmlHelper {
sb.append('>');
if (qlevel > 0)
sb.append(' ');
nl = true;
}
}, JsoupEx.parse(html));

Loading…
Cancel
Save