Whitespace simplification

pull/178/head
M66B 5 years ago
parent dc4eea12cf
commit da852076ce

@ -1827,8 +1827,6 @@ public class HtmlHelper {
for (int i = 0; i < block.size(); ) { for (int i = 0; i < block.size(); ) {
tnode = block.get(i); tnode = block.get(i);
text = tnode.getWholeText(); text = tnode.getWholeText();
if (text.contains("7,80"))
Log.i("Here");
if ("-- ".equals(text)) { if ("-- ".equals(text)) {
i++; i++;
@ -1848,6 +1846,14 @@ public class HtmlHelper {
text = text.substring(index); text = text.substring(index);
} }
// Remove multiple trailing whitespace
index = text.length() - 1;
while (isWhiteSpace(text, index) &&
(i == block.size() - 1 || index == 0 || isWhiteSpace(text, index - 1)))
index--;
text = text.substring(0, index + 1);
tnode.text(text); tnode.text(text);
if (TextUtils.isEmpty(text)) if (TextUtils.isEmpty(text))
@ -1856,27 +1862,14 @@ public class HtmlHelper {
i++; i++;
} }
// Remove trailing whitespace // Remove last trailing whitespace
int i = block.size(); if (block.size() > 0) {
while (i > 0) { tnode = block.get(block.size() - 1);
tnode = block.get(i - 1);
text = tnode.getWholeText(); text = tnode.getWholeText();
index = text.length() - 1; if (endsWithWhitespace(text)) {
if (isWhiteSpace(text, index)) { text = text.substring(0, text.length() - 1);
index--;
while (isWhiteSpace(text, index))
index--;
text = text.substring(0, index + 1);
tnode.text(text); tnode.text(text);
}
if (TextUtils.isEmpty(text))
i--;
else
break;
} else
break;
} }
if (debug) { if (debug) {

Loading…
Cancel
Save