mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix tags issue with RTL and bookmark
This commit is contained in:
parent
ac24e25da0
commit
9b91ebf317
1 changed files with 22 additions and 2 deletions
|
@ -113,6 +113,22 @@ public class SpannableHelper {
|
|||
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,
|
||||
Status status, Account account, Announcement announcement,
|
||||
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 eb = Pattern.compile("[A-Za-z0-9_]\\z").matcher(markdownItem.code).find() ? "\\b" : "\\B";
|
||||
|
||||
Pattern p = Pattern.compile(sb + "(" + Pattern.quote(markdownItem.code) + ")" + eb, Pattern.CASE_INSENSITIVE);
|
||||
Pattern p;
|
||||
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);
|
||||
int fetchPosition = 1;
|
||||
while (m.find()) {
|
||||
|
|
Loading…
Reference in a new issue