mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-15 22:15:15 -05:00
Should preserve spaces at first of line.
This commit is contained in:
parent
ae681cb7fe
commit
fa80313f6b
@ -212,6 +212,7 @@ public class HtmlConverter {
|
|||||||
StringReader reader = new StringReader(text);
|
StringReader reader = new StringReader(text);
|
||||||
StringBuilder buff = new StringBuilder(text.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH);
|
StringBuilder buff = new StringBuilder(text.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH);
|
||||||
boolean isStartOfLine = false; // Are we currently at the start of a line?
|
boolean isStartOfLine = false; // Are we currently at the start of a line?
|
||||||
|
int spaces = 0;
|
||||||
int quoteDepth = 0; // Number of DIVs deep we are.
|
int quoteDepth = 0; // Number of DIVs deep we are.
|
||||||
int quotesThisLine = 0; // How deep we should be quoting for this line.
|
int quotesThisLine = 0; // How deep we should be quoting for this line.
|
||||||
try {
|
try {
|
||||||
@ -224,14 +225,18 @@ 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("&");
|
buff.append("&");
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
|
spaces = 0;
|
||||||
buff.append("<");
|
buff.append("<");
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
|
spaces = 0;
|
||||||
if (isStartOfLine) {
|
if (isStartOfLine) {
|
||||||
quotesThisLine++;
|
quotesThisLine++;
|
||||||
} else {
|
} else {
|
||||||
@ -243,13 +248,18 @@ 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
|
// 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.
|
// may be collapsed by our div-converting magic.
|
||||||
break;
|
spaces++;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
buff.append((char)c);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (isStartOfLine) {
|
if (isStartOfLine) {
|
||||||
// Not a quote character and not a space. Content is starting now.
|
// Not a quote character and not a space. Content is starting now.
|
||||||
@ -265,6 +275,10 @@ public class HtmlConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
quoteDepth = quotesThisLine;
|
quoteDepth = quotesThisLine;
|
||||||
|
|
||||||
|
while (spaces-- > 0) {
|
||||||
|
buff.append(' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buff.append((char)c);
|
buff.append((char)c);
|
||||||
}//switch
|
}//switch
|
||||||
|
Loading…
Reference in New Issue
Block a user