Fix quoted text

This commit is contained in:
Thomas 2022-11-06 11:27:12 +01:00
parent 0dead60a4c
commit 51e031f065
2 changed files with 3 additions and 5 deletions

View File

@ -330,7 +330,7 @@ public class Helper {
public static final Pattern wikipediaPattern = Pattern.compile("([\\w_-]+)\\.wikipedia.org/(((?!([\"'<])).)*)");
public static final Pattern codePattern = Pattern.compile("code=([\\w-]+)");
public static final Pattern nitterIDPattern = Pattern.compile("/status/(\\d+)");
public static final Pattern emailPattern = Pattern.compile("(\\s+[\\w_.-]+@[a-zA-Z0-9][a-zA-Z0-9.-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+)");
public static final Pattern urlPattern = Pattern.compile(
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",

View File

@ -38,7 +38,6 @@ import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.text.style.QuoteSpan;
import android.text.style.URLSpan;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
@ -92,8 +91,7 @@ public class SpannableHelper {
if (text == null) {
return null;
}
text = text.replaceAll("((<\\s?p\\s?>|<\\s?br\\s?/?>)&gt;(.*))<\\s?br\\s?/?>", "$2<blockquote>$3</blockquote><br>");
text = text.replaceAll("((<\\s?br\\s?/?>)&gt;(.*))<\\s?/p\\s?/?>", "$2<blockquote>$3</blockquote></p>");
text = text.replaceAll("((<\\s?p\\s?>|<\\s?br\\s?\\/?>)&gt;(((?!([<])).)*))", "$2<blockquote>$3</blockquote>");
Pattern imgPattern = Pattern.compile("<img [^>]*src=\"([^\"]+)\"[^>]*>");
Matcher matcherImg = imgPattern.matcher(text);
HashMap<String, String> imagesToReplace = new LinkedHashMap<>();
@ -672,7 +670,7 @@ public class SpannableHelper {
private static void emails(Context context, Spannable content) {
// --- For all patterns defined in Helper class ---
Pattern pattern = Patterns.EMAIL_ADDRESS;
Pattern pattern = Helper.emailPattern;
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {