mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-08 23:57:44 +01:00
Fix MD parsing for texts missing after links and emoji in code blocks (#1330)
Closes #1161 Closes #1329 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1330 Co-authored-by: M M Arif <mmarif@swatian.com> Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent
b892c0b604
commit
afd42e4822
@ -995,11 +995,11 @@ public class IssueDetailActivity extends BaseActivity
|
|||||||
|
|
||||||
viewBinding.author.setText(issue.getIssue().getUser().getLogin());
|
viewBinding.author.setText(issue.getIssue().getUser().getLogin());
|
||||||
|
|
||||||
if (!cleanIssueDescription.equals("")) {
|
if (!cleanIssueDescription.isEmpty()) {
|
||||||
viewBinding.issueDescription.setVisibility(View.VISIBLE);
|
viewBinding.issueDescription.setVisibility(View.VISIBLE);
|
||||||
Markdown.render(
|
Markdown.render(
|
||||||
ctx,
|
ctx,
|
||||||
EmojiParser.parseToUnicode(cleanIssueDescription),
|
cleanIssueDescription,
|
||||||
viewBinding.issueDescription,
|
viewBinding.issueDescription,
|
||||||
issue.getRepository());
|
issue.getRepository());
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,7 +33,6 @@ import com.amulyakhare.textdrawable.TextDrawable;
|
|||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
import com.google.android.material.card.MaterialCardView;
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -534,7 +533,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
TextView textView = new TextView(context);
|
TextView textView = new TextView(context);
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
if (issueComment.getBody().equals("")) {
|
if (issueComment.getBody().isEmpty()) {
|
||||||
text =
|
text =
|
||||||
context.getString(
|
context.getString(
|
||||||
R.string.timelineRemovedLabel,
|
R.string.timelineRemovedLabel,
|
||||||
@ -1223,11 +1222,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
issueComment.getUser().getLogin(),
|
issueComment.getUser().getLogin(),
|
||||||
issueComment.getNewRef(),
|
issueComment.getNewRef(),
|
||||||
info);
|
info);
|
||||||
Markdown.render(
|
Markdown.render(context, text, recyclerView, issue.getRepository());
|
||||||
context,
|
|
||||||
EmojiParser.parseToUnicode(text),
|
|
||||||
recyclerView,
|
|
||||||
issue.getRepository());
|
|
||||||
timelineIcon.setImageDrawable(
|
timelineIcon.setImageDrawable(
|
||||||
ContextCompat.getDrawable(context, R.drawable.ic_branch));
|
ContextCompat.getDrawable(context, R.drawable.ic_branch));
|
||||||
} else if (issueComment.getType().equalsIgnoreCase("comment_ref")
|
} else if (issueComment.getType().equalsIgnoreCase("comment_ref")
|
||||||
@ -1241,11 +1236,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
issueComment.getUser().getLogin(),
|
issueComment.getUser().getLogin(),
|
||||||
issueComment.getRefIssue().getNumber(),
|
issueComment.getRefIssue().getNumber(),
|
||||||
info);
|
info);
|
||||||
Markdown.render(
|
Markdown.render(context, text, recyclerView, issue.getRepository());
|
||||||
context,
|
|
||||||
EmojiParser.parseToUnicode(text),
|
|
||||||
recyclerView,
|
|
||||||
issue.getRepository());
|
|
||||||
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||||
String text =
|
String text =
|
||||||
context.getString(
|
context.getString(
|
||||||
@ -1253,11 +1244,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
issueComment.getUser().getLogin(),
|
issueComment.getUser().getLogin(),
|
||||||
issueComment.getRefIssue().getNumber(),
|
issueComment.getRefIssue().getNumber(),
|
||||||
info);
|
info);
|
||||||
Markdown.render(
|
Markdown.render(context, text, recyclerView, issue.getRepository());
|
||||||
context,
|
|
||||||
EmojiParser.parseToUnicode(text),
|
|
||||||
recyclerView,
|
|
||||||
issue.getRepository());
|
|
||||||
}
|
}
|
||||||
timelineIcon.setImageDrawable(
|
timelineIcon.setImageDrawable(
|
||||||
ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
|
ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
|
||||||
@ -1295,11 +1282,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(avatar);
|
.into(avatar);
|
||||||
|
|
||||||
Markdown.render(
|
Markdown.render(context, issueComment.getBody(), comment, issue.getRepository());
|
||||||
context,
|
|
||||||
EmojiParser.parseToUnicode(issueComment.getBody()),
|
|
||||||
comment,
|
|
||||||
issue.getRepository());
|
|
||||||
|
|
||||||
information.setText(info);
|
information.setText(info);
|
||||||
|
|
||||||
@ -1348,7 +1331,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
assert attachment != null;
|
assert attachment != null;
|
||||||
|
|
||||||
if (attachment.size() > 0) {
|
if (!attachment.isEmpty()) {
|
||||||
|
|
||||||
attachmentFrame.setVisibility(View.VISIBLE);
|
attachmentFrame.setVisibility(View.VISIBLE);
|
||||||
LinearLayout.LayoutParams paramsAttachment =
|
LinearLayout.LayoutParams paramsAttachment =
|
||||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.helpers;
|
|||||||
|
|
||||||
import static org.mian.gitnex.helpers.AppUtil.isNightModeThemeDynamic;
|
import static org.mian.gitnex.helpers.AppUtil.isNightModeThemeDynamic;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -301,11 +302,6 @@ public class Markdown {
|
|||||||
|
|
||||||
slot.release(this);
|
slot.release(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expire() {
|
|
||||||
|
|
||||||
slot.expire(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RecyclerViewRenderer implements Runnable, Poolable {
|
private static class RecyclerViewRenderer implements Runnable, Poolable {
|
||||||
@ -567,6 +563,7 @@ public class Markdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
@ -592,8 +589,8 @@ public class Markdown {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canScrollVertically() {
|
public boolean canScrollVertically() {
|
||||||
|
|
||||||
return false; // disable RecyclerView scrolling, handeled by
|
return false; // disable RecyclerView scrolling, handled by
|
||||||
// seperate ScrollViews
|
// separate ScrollViews
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
localReference.setAdapter(localAdapter);
|
localReference.setAdapter(localAdapter);
|
||||||
@ -617,11 +614,6 @@ public class Markdown {
|
|||||||
slot.release(this);
|
slot.release(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expire() {
|
|
||||||
|
|
||||||
slot.expire(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class IssueInlineProcessor extends InlineProcessor {
|
private static class IssueInlineProcessor extends InlineProcessor {
|
||||||
|
|
||||||
private static final Pattern RE = Pattern.compile("(?<!\\w)#\\d+");
|
private static final Pattern RE = Pattern.compile("(?<!\\w)#\\d+");
|
||||||
@ -696,7 +688,7 @@ public class Markdown {
|
|||||||
instanceUrl =
|
instanceUrl =
|
||||||
instanceUrl
|
instanceUrl
|
||||||
.substring(0, instanceUrl.lastIndexOf("api/v1/"))
|
.substring(0, instanceUrl.lastIndexOf("api/v1/"))
|
||||||
.replaceAll("\\.", "\\.");
|
.replaceAll("\\.", ".");
|
||||||
this.instanceUrl = instanceUrl;
|
this.instanceUrl = instanceUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +753,7 @@ public class Markdown {
|
|||||||
shortSha = shortSha.substring(0, 10);
|
shortSha = shortSha.substring(0, 10);
|
||||||
}
|
}
|
||||||
String text;
|
String text;
|
||||||
if (matcherCommit.group(1).equals(repository.getFullName())) {
|
if (Objects.equals(matcherCommit.group(1), repository.getFullName())) {
|
||||||
text = shortSha;
|
text = shortSha;
|
||||||
} else {
|
} else {
|
||||||
text = matcherCommit.group(1) + "/" + shortSha;
|
text = matcherCommit.group(1) + "/" + shortSha;
|
||||||
@ -772,6 +764,12 @@ public class Markdown {
|
|||||||
lastNode = insertNode(linkNode, lastNode);
|
lastNode = insertNode(linkNode, lastNode);
|
||||||
|
|
||||||
i = matcherCommit.start();
|
i = matcherCommit.start();
|
||||||
|
if (commitStart > matcherCommit.end()) {
|
||||||
|
lastNode =
|
||||||
|
insertNode(
|
||||||
|
new Text(literal.substring(matcherCommit.end())),
|
||||||
|
lastNode);
|
||||||
|
}
|
||||||
} else if (issueStart < literal.length()) {
|
} else if (issueStart < literal.length()) {
|
||||||
// next one is an issue/comment
|
// next one is an issue/comment
|
||||||
if (matcherIssue.start() > i) {
|
if (matcherIssue.start() > i) {
|
||||||
@ -782,7 +780,7 @@ public class Markdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
if (matcherIssue.group(1).equals(repository.getFullName())) {
|
if (Objects.equals(matcherIssue.group(1), repository.getFullName())) {
|
||||||
text = "#" + matcherIssue.group(2);
|
text = "#" + matcherIssue.group(2);
|
||||||
} else {
|
} else {
|
||||||
text = matcherIssue.group(1) + "#" + matcherIssue.group(2);
|
text = matcherIssue.group(1) + "#" + matcherIssue.group(2);
|
||||||
@ -806,6 +804,9 @@ public class Markdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = matcherIssue.end();
|
i = matcherIssue.end();
|
||||||
|
if (literal.length() > i) {
|
||||||
|
lastNode = insertNode(new Text(literal.substring(i)), lastNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset every time to make it usable in a "pure" state
|
// reset every time to make it usable in a "pure" state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user