Remove quotes

pull/215/head
M66B 1 year ago
parent 3a9b56438d
commit 77ccdd48c3

@ -425,7 +425,7 @@ public class EntityRule {
Document d = JsoupEx.parse(html);
if (skip_quotes)
d.select("blockquote").remove();
HtmlHelper.removeQuotes(d);
if (jsoup) {
String selector = value.substring(JSOUP_PREFIX.length());
if (d.select(selector).isEmpty() != not)

@ -103,9 +103,15 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
return null;
Document d = JsoupEx.parse(file);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean remove_signatures = prefs.getBoolean("remove_signatures", false);
if (remove_signatures)
HtmlHelper.removeSignatures(d);
HtmlHelper.removeQuotes(d);
d = HtmlHelper.sanitizeView(context, d, false);
HtmlHelper.removeSignatures(d);
d.select("blockquote").remove();
if (OpenAI.isAvailable(context)) {
String model = prefs.getString("openai_model", OpenAI.DEFAULT_MODEL);

@ -349,15 +349,19 @@ public class FragmentDialogTranslate extends FragmentDialogBase {
EntityMessage message = db.message().getMessage(id);
File file = EntityMessage.getFile(context, id);
String html = Helper.readText(file);
Document d = HtmlHelper.sanitizeCompose(context, html, false);
if (!file.exists())
return null;
Document d = JsoupEx.parse(file);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean remove_signatures = prefs.getBoolean("remove_signatures", false);
if (remove_signatures)
HtmlHelper.removeSignatures(d);
d.select("blockquote").remove();
HtmlHelper.removeQuotes(d);
d = HtmlHelper.sanitizeView(context, d, false);
HtmlHelper.truncate(d, HtmlHelper.MAX_TRANSLATABLE_TEXT_SIZE);

@ -2859,6 +2859,25 @@ public class HtmlHelper {
});
}
static void removeQuotes(Document d) {
// Gmail
Elements quotes = d.body().select(".gmail_quote");
if (quotes.size() > 0) {
quotes.remove();
return;
}
// Outlook: <div id="appendonsend">
quotes = d.body().select("div#appendonsend");
if (quotes.size() > 0) {
quotes.nextAll().remove();
quotes.remove();
return;
}
d.select("blockquote").remove();
}
static String truncate(String text, int at) {
if (text.length() < at)
return text;

Loading…
Cancel
Save