Custom render: fixed extra spacing

This commit is contained in:
M66B 2020-04-25 10:44:16 +02:00
parent 02332b93b7
commit 7f6b935aea
1 changed files with 11 additions and 11 deletions

View File

@ -1829,9 +1829,11 @@ public class HtmlHelper {
continue;
// Remove whitespace before/after newlines
text = text.replaceAll("\\s+\\r?\\n\\s+", " ");
text = text.replaceAll("\\s*\\r?\\n\\s*", " ");
if (i == 0 || (block.get(i - 1).text().endsWith(" ")))
if (i == 0 ||
block.get(i - 1).text().equals("") ||
block.get(i - 1).text().endsWith(" "))
while (text.startsWith(" "))
text = text.substring(1);
@ -1839,16 +1841,14 @@ public class HtmlHelper {
while (text.endsWith(" "))
text = text.substring(0, text.length() - 1);
if (debug) {
if (i == 0)
tnode.text("<" + text);
else if (i == block.size() - 1)
tnode.text(text + ">");
else
tnode.text(text);
tnode.text(text);
}
} else
tnode.text(text);
if (debug) {
if (block.size() > 0) {
block.get(0).text("<" + block.get(0));
block.get(block.size() - 1).text(block.get(block.size() - 1) + ">");
}
}
}
}, document.body());