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