mirror of
https://codeberg.org/tom79/Fedilab
synced 2025-01-07 08:19:23 +01:00
Fix tags issue with RTL and bookmark
This commit is contained in:
parent
ac24e25da0
commit
9b91ebf317
@ -113,6 +113,22 @@ public class SpannableHelper {
|
|||||||
return convert(context, text, status, account, announcement, viewWeakReference, callback, true);
|
return convert(context, text, status, account, announcement, viewWeakReference, callback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isRTL(String s) {
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
byte d = Character.getDirectionality(s.charAt(i));
|
||||||
|
if (d == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
|
||||||
|
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC ||
|
||||||
|
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING ||
|
||||||
|
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static Spannable convert(Context context, String text,
|
public static Spannable convert(Context context, String text,
|
||||||
Status status, Account account, Announcement announcement,
|
Status status, Account account, Announcement announcement,
|
||||||
WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml) {
|
WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml) {
|
||||||
@ -196,8 +212,12 @@ public class SpannableHelper {
|
|||||||
|
|
||||||
String sb = Pattern.compile("\\A[A-Za-z0-9_]").matcher(markdownItem.code).find() ? "\\b" : "";
|
String sb = Pattern.compile("\\A[A-Za-z0-9_]").matcher(markdownItem.code).find() ? "\\b" : "";
|
||||||
String eb = Pattern.compile("[A-Za-z0-9_]\\z").matcher(markdownItem.code).find() ? "\\b" : "\\B";
|
String eb = Pattern.compile("[A-Za-z0-9_]\\z").matcher(markdownItem.code).find() ? "\\b" : "\\B";
|
||||||
|
Pattern p;
|
||||||
Pattern p = Pattern.compile(sb + "(" + Pattern.quote(markdownItem.code) + ")" + eb, Pattern.CASE_INSENSITIVE);
|
if (!isRTL(initialContent.toString())) {
|
||||||
|
p = Pattern.compile(sb + "(" + Pattern.quote(markdownItem.code) + ")" + eb, Pattern.UNICODE_CASE);
|
||||||
|
} else {
|
||||||
|
p = Pattern.compile(eb + "(" + Pattern.quote(markdownItem.code) + ")" + sb, Pattern.UNICODE_CASE);
|
||||||
|
}
|
||||||
Matcher m = p.matcher(content);
|
Matcher m = p.matcher(content);
|
||||||
int fetchPosition = 1;
|
int fetchPosition = 1;
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user