Preserve plain text spaces

pull/162/head
M66B 5 years ago
parent d03969d23f
commit d11684c5aa

@ -145,9 +145,14 @@ public class HtmlHelper {
}
// Pre formatted text
for (Element code : document.select("pre")) {
code.html(code.html().replaceAll("\\r?\\n", "<br>"));
code.tagName("div");
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]))
lines[i] = lines[i].replace(" ", "&nbsp;");
}
pre.html(TextUtils.join("<br>", lines));
pre.tagName("div");
}
// Code

@ -862,11 +862,8 @@ public class MessageHelper {
// Prevent Jsoup throwing an exception
result = result.replace("\0", "");
if (part.isMimeType("text/plain")) {
result = TextUtils.htmlEncode(result);
result = result.replaceAll("\\r?\\n", "<br>");
result = "<span>" + result + "</span>";
}
if (part.isMimeType("text/plain"))
result = "<pre>" + TextUtils.htmlEncode(result) + "</pre>";
return result;
}

Loading…
Cancel
Save