Block quote white space improvement

pull/162/head
M66B 5 years ago
parent 9f0656d2c3
commit f8fcb9c08b

@ -907,34 +907,45 @@ public class MessageHelper {
int level = 0; int level = 0;
String[] lines = result.split("\\r?\\n"); String[] lines = result.split("\\r?\\n");
for (String line : lines) { for (String line : lines) {
// Opening quotes
int tlevel = 0; int tlevel = 0;
while (line.trim().startsWith(">")) { while (line.startsWith(">")) {
tlevel++; tlevel++;
if (tlevel > level) if (tlevel > level)
sb.append("<blockquote>"); sb.append("<blockquote>");
while (line.startsWith(" "))
line = line.substring(1); // >
if (line.startsWith(" "))
line = line.substring(1); line = line.substring(1);
line = line.substring(1);
} }
// Closing quotes
for (int i = 0; i < level - tlevel; i++) for (int i = 0; i < level - tlevel; i++)
sb.append("</blockquote>"); sb.append("</blockquote>");
level = tlevel; level = tlevel;
// Show as-is
line = Html.escapeHtml(line); line = Html.escapeHtml(line);
// Non breaking spaces
boolean start = true;
int len = line.length(); int len = line.length();
for (int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
char kar = line.charAt(j); char kar = line.charAt(j);
if (kar == ' ' && if (kar == ' ' &&
j + 1 < len && line.charAt(j + 1) == ' ') (start || j + 1 < len && line.charAt(j + 1) == ' '))
sb.append("&nbsp;"); sb.append("&nbsp;");
else else {
start = false;
sb.append(kar); sb.append(kar);
}
} }
sb.append("<br>"); sb.append("<br>");
} }
// Closing quotes
for (int i = 0; i < level; i++) for (int i = 0; i < level; i++)
sb.append("</blockquote>"); sb.append("</blockquote>");

Loading…
Cancel
Save