|
|
|
@ -159,23 +159,36 @@ public class HtmlHelper {
|
|
|
|
|
|
|
|
|
|
// Pre formatted text
|
|
|
|
|
for (Element pre : document.select("pre")) {
|
|
|
|
|
String[] lines = pre.html().split("\\r?\\n");
|
|
|
|
|
for (int i = 0; i < lines.length; i++) {
|
|
|
|
|
if (!"-- ".equals(lines[i])) {
|
|
|
|
|
Element div = document.createElement("div");
|
|
|
|
|
|
|
|
|
|
for (TextNode tnode : pre.textNodes()) {
|
|
|
|
|
String[] lines = tnode.getWholeText().split("\\r?\\n");
|
|
|
|
|
for (String line : lines) {
|
|
|
|
|
line = Html.escapeHtml(line);
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
int len = lines[i].length();
|
|
|
|
|
for (int j = 0; j < len; j++) {
|
|
|
|
|
char kar = lines[i].charAt(j);
|
|
|
|
|
if (kar == ' ' && j + 1 < len && lines[i].charAt(j + 1) == ' ')
|
|
|
|
|
sb.append(" ");
|
|
|
|
|
else
|
|
|
|
|
sb.append(kar);
|
|
|
|
|
if ("-- ".equals(line))
|
|
|
|
|
sb.append(line);
|
|
|
|
|
else {
|
|
|
|
|
int len = line.length();
|
|
|
|
|
for (int j = 0; j < len; j++) {
|
|
|
|
|
char kar = line.charAt(j);
|
|
|
|
|
if (kar == ' ' && j + 1 < len && line.charAt(j + 1) == ' ')
|
|
|
|
|
sb.append(" ");
|
|
|
|
|
else
|
|
|
|
|
sb.append(kar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lines[i] = sb.toString();
|
|
|
|
|
|
|
|
|
|
Element span = document.createElement("span");
|
|
|
|
|
span.html(sb.toString());
|
|
|
|
|
div.appendChild(span);
|
|
|
|
|
div.appendElement("br");
|
|
|
|
|
Log.i("span html=" + span.html());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pre.html(TextUtils.join("<br>", lines));
|
|
|
|
|
pre.tagName("div");
|
|
|
|
|
|
|
|
|
|
pre.replaceWith(div);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code
|
|
|
|
|