aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/ProcessRedditSuperscript.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SuperscriptInlineProcessor.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java5
15 files changed, 196 insertions, 7 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 10429eeb..9026ab5c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -153,6 +153,7 @@ dependencies {
implementation "io.noties.markwon:linkify:$markwonVersion"
implementation "io.noties.markwon:recycler-table:$markwonVersion"
implementation "io.noties.markwon:simple-ext:$markwonVersion"
+ implementation "io.noties.markwon:html:$markwonVersion"
implementation "io.noties.markwon:inline-parser:$markwonVersion"
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
implementation 'me.saket:better-link-movement-method:2.2.0'
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index db2353dc..2ffa10e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -50,6 +50,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -68,7 +70,9 @@ import ml.docilealligator.infinityforreddit.comment.SendComment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@@ -163,7 +167,12 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
Markwon markwon = Markwon.builder(this)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
@@ -206,7 +215,12 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
Markwon postBodyMarkwon = Markwon.builder(this)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
}))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index 7a54b5d1..92bd1ec8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -47,6 +47,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -59,7 +61,9 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
public class FullMarkdownActivity extends BaseActivity {
@@ -134,8 +138,14 @@ public class FullMarkdownActivity extends BaseActivity {
Markwon markwon = Markwon.builder(this)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -151,7 +161,7 @@ public class FullMarkdownActivity extends BaseActivity {
}
return super.processMarkdown(markdownStringBuilder.toString());
}
-
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index d5c8cb61..644ac4b5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -51,6 +51,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -65,7 +67,9 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -159,8 +163,14 @@ public class WikiActivity extends BaseActivity {
markwon = Markwon.builder(this)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -176,7 +186,7 @@ public class WikiActivity extends BaseActivity {
}
return super.processMarkdown(markdownStringBuilder.toString());
}
-
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index cc0e640d..1a3fb7ac 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -42,6 +42,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -61,7 +63,9 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@@ -119,8 +123,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mMarkwon = Markwon.builder(mActivity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -136,7 +146,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
return super.processMarkdown(markdownStringBuilder.toString());
}
-
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index a06b476d..8a6cb8b9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -47,6 +47,11 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlEmptyTagReplacement;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.ImageHandler;
+import io.noties.markwon.html.tag.LinkHandler;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -69,7 +74,9 @@ import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@@ -163,8 +170,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mCommentMarkwon = Markwon.builder(mActivity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -180,7 +193,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
return super.processMarkdown(markdownStringBuilder.toString());
}
-
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
index 4c0ae441..5b6aae99 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
@@ -34,6 +34,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -46,6 +48,8 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.message.FetchMessage;
import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.message.ReadMessage;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import retrofit2.Retrofit;
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
@@ -102,8 +106,14 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
mMarkwon = Markwon.builder(mContext)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -119,6 +129,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
return super.processMarkdown(markdownStringBuilder.toString());
}
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index ccb19b26..8663da52 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -73,6 +73,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -110,7 +112,9 @@ import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -229,8 +233,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mPostDetailMarkwon = Markwon.builder(mActivity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
+ /*
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
@@ -246,7 +256,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
return super.processMarkdown(markdownStringBuilder.toString());
}
-
+ */
@Override
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
index e4ca0dd0..99adc221 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
@@ -27,6 +27,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -37,7 +39,9 @@ import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivi
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.message.Message;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -69,7 +73,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
index 6cf4ee07..4eb9d5d8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
@@ -22,6 +22,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -32,6 +34,8 @@ import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private Markwon markwon;
@@ -43,7 +47,12 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
markwon = Markwon.builder(activity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
index d8cf1fe9..4264f36a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
@@ -6,6 +6,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
+import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -72,7 +73,8 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
}
if (markdownText != null) {
- markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
+ //markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
+ markdownText = markdownText.replaceAll("&gt;", ">");
copyMarkdownTextView.setOnClickListener(view -> {
showCopyDialog(markdownText);
dismiss();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
index f02db229..416b3046 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -34,6 +34,8 @@ import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
@@ -55,6 +57,8 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
+import ml.docilealligator.infinityforreddit.utils.ProcessRedditSuperscript;
+import ml.docilealligator.infinityforreddit.utils.SuperscriptInlineProcessor;
import retrofit2.Retrofit;
public class SidebarFragment extends Fragment {
@@ -107,7 +111,12 @@ public class SidebarFragment extends Fragment {
Markwon markwon = Markwon.builder(activity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
}))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
+ .usePlugin(new ProcessRedditSuperscript())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/ProcessRedditSuperscript.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/ProcessRedditSuperscript.java
new file mode 100644
index 00000000..0dc539d7
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/ProcessRedditSuperscript.java
@@ -0,0 +1,46 @@
+package ml.docilealligator.infinityforreddit.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import io.noties.markwon.AbstractMarkwonPlugin;
+
+public class ProcessRedditSuperscript extends AbstractMarkwonPlugin {
+ private static final Pattern re = Pattern.compile("(?:\\^\\((.+?)\\))|(?:\\^(\\S+))");
+
+ @Override
+ public String processMarkdown(String markdown) {
+ StringBuilder builder = new StringBuilder();
+ Matcher matcher = re.matcher(markdown);
+ int start = 0;
+
+ while (matcher.find()) {
+ try {
+ String match;
+ if ((match = matcher.group(1)) != null || (match = matcher.group(2)) != null) {
+ builder.append(markdown.substring(start, matcher.start()))
+ .append("<sup>")
+ .append(match)
+ .append("</sup>");
+ start = matcher.end();
+ } else {
+ throw new NullPointerException();
+ }
+ } catch(NullPointerException e) {
+ e.printStackTrace();
+ } finally {
+ continue;
+ }
+ }
+
+ if (start < markdown.length()) {
+ builder.append(markdown.substring(start));
+ }
+
+ if(builder.length() > 0) {
+ return builder.toString(); }
+ else {
+ return markdown;
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SuperscriptInlineProcessor.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SuperscriptInlineProcessor.java
new file mode 100644
index 00000000..136a69d4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SuperscriptInlineProcessor.java
@@ -0,0 +1,32 @@
+package ml.docilealligator.infinityforreddit.utils;
+
+import androidx.annotation.Nullable;
+
+import org.commonmark.node.HtmlInline;
+import org.commonmark.node.Node;
+
+import java.util.regex.Pattern;
+
+import io.noties.markwon.inlineparser.InlineProcessor;
+
+public class SuperscriptInlineProcessor extends InlineProcessor {
+ private static final Pattern HTML_TAG = Pattern.compile("</?sup>", Pattern.CASE_INSENSITIVE);
+
+ @Override
+ public char specialCharacter() {
+ return '<';
+ }
+
+ @Nullable
+ @Override
+ protected Node parse() {
+ String m = match(HTML_TAG);
+ if (m != null) {
+ HtmlInline node = new HtmlInline();
+ node.setLiteral(m);
+ return node;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
index ad2b7405..16aeb642 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -65,6 +65,8 @@ public class Utils {
.replaceAll("((?<=[\\s])|^)/[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com$0)")
.replaceAll("((?<=[\\s])|^)[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com/$0)")
.replaceAll("\\^{2,}", "^")
+ .replaceAll("(</?sup)>", "$1&gt;")
+ .replaceAll(">!", "&gt;!")
.replaceAll("(^|^ *|\\n *)#(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)##(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)###(?!($|\\s|#))", "$0 ")
@@ -72,7 +74,8 @@ public class Utils {
.replaceAll("(^|^ *|\\n *)#####(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)######(?!($|\\s|#))", "$0 "));
- return fixSuperScript(regexed);
+ //return fixSuperScript(regexed);
+ return regexed.toString();
}
private static String fixSuperScript(StringBuilder regexed) {