From fa80313f6b473173c886c1e5709011f7b1593b12 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Thu, 9 May 2013 21:25:25 +0900 Subject: [PATCH] Should preserve spaces at first of line. --- src/com/fsck/k9/helper/HtmlConverter.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/helper/HtmlConverter.java b/src/com/fsck/k9/helper/HtmlConverter.java index 42382d206..c39337672 100644 --- a/src/com/fsck/k9/helper/HtmlConverter.java +++ b/src/com/fsck/k9/helper/HtmlConverter.java @@ -212,6 +212,7 @@ public class HtmlConverter { StringReader reader = new StringReader(text); StringBuilder buff = new StringBuilder(text.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH); 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 quotesThisLine = 0; // How deep we should be quoting for this line. try { @@ -224,14 +225,18 @@ public class HtmlConverter { buff.append(HTML_NEWLINE); isStartOfLine = true; quotesThisLine = 0; + spaces = 0; break; case '&': + spaces = 0; buff.append("&"); break; case '<': + spaces = 0; buff.append("<"); break; case '>': + spaces = 0; if (isStartOfLine) { quotesThisLine++; } else { @@ -243,13 +248,18 @@ public class HtmlConverter { } break; case '\r': + spaces = 0; break; case ' ': 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. - break; + spaces++; } + else { + buff.append((char)c); + } + break; default: if (isStartOfLine) { // Not a quote character and not a space. Content is starting now. @@ -265,6 +275,10 @@ public class HtmlConverter { } } quoteDepth = quotesThisLine; + + while (spaces-- > 0) { + buff.append(' '); + } } buff.append((char)c); }//switch