1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Fix to preserve spaces

This commit is contained in:
Koji Arai 2013-05-09 23:08:11 +09:00
parent 3c83f7354e
commit 6c4461cd13

View File

@ -218,6 +218,22 @@ public class HtmlConverter {
try { try {
int c; int c;
while ((c = reader.read()) != -1) { while ((c = reader.read()) != -1) {
switch (c) {
case '\n':
case '&':
case '<':
case '\r':
if (isStartOfLine) {
while (spaces-- > 0) {
buff.append(' ');
}
}
else {
spaces = 0;
}
break;
}
switch (c) { switch (c) {
case '\n': case '\n':
// pine treats <br> as two newlines, but <br/> as one newline. Use <br/> so our messages aren't // pine treats <br> as two newlines, but <br/> as one newline. Use <br/> so our messages aren't
@ -225,14 +241,11 @@ public class HtmlConverter {
buff.append(HTML_NEWLINE); buff.append(HTML_NEWLINE);
isStartOfLine = true; isStartOfLine = true;
quotesThisLine = 0; quotesThisLine = 0;
spaces = 0;
break; break;
case '&': case '&':
spaces = 0;
buff.append("&amp;"); buff.append("&amp;");
break; break;
case '<': case '<':
spaces = 0;
buff.append("&lt;"); buff.append("&lt;");
break; break;
case '>': case '>':
@ -248,12 +261,9 @@ public class HtmlConverter {
} }
break; break;
case '\r': case '\r':
spaces = 0;
break; break;
case ' ': case ' ':
if (isStartOfLine) { if (isStartOfLine) {
// If we're still in the start of the line and we have spaces, don't output them, since they
// may be collapsed by our div-converting magic.
spaces++; spaces++;
} }
else { else {