Block quote white space improvement

This commit is contained in:
M66B 2019-09-24 17:18:33 +02:00
parent 9f0656d2c3
commit f8fcb9c08b
1 changed files with 16 additions and 5 deletions

View File

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