mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Fixed spacing plain text
This commit is contained in:
parent
151101ebc0
commit
86964b942d
1 changed files with 17 additions and 4 deletions
|
@ -691,13 +691,14 @@ public class HtmlHelper {
|
|||
private int qlevel = 0;
|
||||
private int tlevel = 0;
|
||||
private int plevel = 0;
|
||||
private int lindex = 0;
|
||||
|
||||
public void head(Node node, int depth) {
|
||||
if (node instanceof TextNode)
|
||||
if (plevel > 0) {
|
||||
String[] lines = ((TextNode) node).getWholeText().split("\\r?\\n");
|
||||
for (String line : lines) {
|
||||
append(line);
|
||||
append(line, true);
|
||||
newline();
|
||||
}
|
||||
} else
|
||||
|
@ -738,19 +739,31 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
private void append(String text) {
|
||||
append(text, false);
|
||||
}
|
||||
|
||||
private void append(String text, boolean raw) {
|
||||
if (tlevel != qlevel) {
|
||||
newline();
|
||||
tlevel = qlevel;
|
||||
}
|
||||
|
||||
if (!raw && !"-- ".equals(text)) {
|
||||
text = text.trim();
|
||||
if (lindex > 0)
|
||||
text = " " + text;
|
||||
}
|
||||
|
||||
sb.append(text);
|
||||
lindex += text.length();
|
||||
}
|
||||
|
||||
private void newline() {
|
||||
lindex = 0;
|
||||
sb.append("\n");
|
||||
|
||||
for (int i = 0; i < qlevel; i++)
|
||||
sb.append('>');
|
||||
if (qlevel > 0)
|
||||
sb.append(' ');
|
||||
sb.append("> ");
|
||||
}
|
||||
}, JsoupEx.parse(html));
|
||||
|
||||
|
|
Loading…
Reference in a new issue