mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Paste plain text without quoting
This commit is contained in:
parent
7c00859a58
commit
0ba3e9e9df
2 changed files with 23 additions and 17 deletions
|
@ -77,7 +77,7 @@ public class EditTextCompose extends FixedEditText {
|
|||
CharSequence text = item.getText();
|
||||
if (text == null)
|
||||
return false;
|
||||
html = "<div>" + HtmlHelper.formatPre(text.toString()) + "</div>";
|
||||
html = "<div>" + HtmlHelper.formatPre(text.toString(), false) + "</div>";
|
||||
}
|
||||
|
||||
Document document = HtmlHelper.sanitizeCompose(context, html, false);
|
||||
|
|
|
@ -1293,31 +1293,37 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
static String formatPre(String text) {
|
||||
return formatPre(text, true);
|
||||
}
|
||||
|
||||
static String formatPre(String text, boolean quote) {
|
||||
int level = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[] lines = text.split("\\r?\\n");
|
||||
for (String line : lines) {
|
||||
// Opening quotes
|
||||
// https://tools.ietf.org/html/rfc3676#section-4.5
|
||||
int tlevel = 0;
|
||||
while (line.startsWith(">")) {
|
||||
tlevel++;
|
||||
if (tlevel > level)
|
||||
sb.append("<blockquote>");
|
||||
if (quote) {
|
||||
int tlevel = 0;
|
||||
while (line.startsWith(">")) {
|
||||
tlevel++;
|
||||
if (tlevel > level)
|
||||
sb.append("<blockquote>");
|
||||
|
||||
line = line.substring(1); // >
|
||||
line = line.substring(1); // >
|
||||
|
||||
if (line.startsWith(" >"))
|
||||
line = line.substring(1);
|
||||
if (line.startsWith(" >"))
|
||||
line = line.substring(1);
|
||||
}
|
||||
if (tlevel > 0)
|
||||
if (line.length() > 0 && line.charAt(0) == ' ')
|
||||
line = line.substring(1);
|
||||
|
||||
// Closing quotes
|
||||
for (int i = 0; i < level - tlevel; i++)
|
||||
sb.append("</blockquote>");
|
||||
level = tlevel;
|
||||
}
|
||||
if (tlevel > 0)
|
||||
if (line.length() > 0 && line.charAt(0) == ' ')
|
||||
line = line.substring(1);
|
||||
|
||||
// Closing quotes
|
||||
for (int i = 0; i < level - tlevel; i++)
|
||||
sb.append("</blockquote>");
|
||||
level = tlevel;
|
||||
|
||||
// Tabs characters
|
||||
StringBuilder l = new StringBuilder();
|
||||
|
|
Loading…
Reference in a new issue