mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Improve link side effect with Markdown
This commit is contained in:
parent
c9a86aae01
commit
5a804fd892
2 changed files with 9 additions and 2 deletions
|
@ -40,10 +40,12 @@ public class MarkdownConverter {
|
|||
|
||||
public int regexPosition(List<MarkdownItem> markdownItems) {
|
||||
int position = 0;
|
||||
int loopedPosition = 0;
|
||||
for (MarkdownItem markdownItem : markdownItems) {
|
||||
if (markdownItem.code.equals(code) && position <= this.position) {
|
||||
if (markdownItem.code.equals(code) && loopedPosition <= this.position) {
|
||||
position++;
|
||||
}
|
||||
loopedPosition++;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
|
|
@ -191,8 +191,13 @@ public class SpannableHelper {
|
|||
final Spanned markdown = markwon.toMarkdown(initialContent.toString());
|
||||
content = new SpannableStringBuilder(markdown);
|
||||
position = 0;
|
||||
|
||||
for (MarkdownConverter.MarkdownItem markdownItem : markdownConverter.markdownItems) {
|
||||
Pattern p = Pattern.compile("(" + Pattern.quote(markdownItem.code) + ")", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
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);
|
||||
Matcher m = p.matcher(content);
|
||||
int fetchPosition = 1;
|
||||
while (m.find()) {
|
||||
|
|
Loading…
Reference in a new issue