From 23cce968f8890eaacfe3043b16f2441f4051585d Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 25 Aug 2023 18:26:43 +0200 Subject: [PATCH] Mardown: stop parsing tags and support strike text --- app/build.gradle | 2 ++ .../android/mastodon/helper/SpannableHelper.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9196fa6f..dd5a2fd1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -190,6 +190,8 @@ dependencies { implementation 'io.noties.markwon:core:4.6.2' implementation 'io.noties.markwon:ext-tables:4.6.2' implementation 'io.noties.markwon:syntax-highlight:4.6.2' + implementation 'io.noties.markwon:ext-strikethrough:4.6.2' + implementation 'io.noties.markwon:inline-parser:4.6.2' annotationProcessor 'io.noties:prism4j-bundler:2.0.0' //************ CAST **************/// diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java index 78ea913d..4cbfa8c8 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java @@ -90,9 +90,13 @@ import app.fedilab.android.mastodon.client.entities.app.MarkdownConverter; import app.fedilab.android.mastodon.ui.drawer.StatusAdapter; import app.fedilab.android.mastodon.viewmodel.mastodon.FiltersVM; import es.dmoral.toasty.Toasty; +import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.SoftBreakAddsNewLinePlugin; +import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.ext.tables.TablePlugin; +import io.noties.markwon.inlineparser.HtmlInlineProcessor; +import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin; import io.noties.markwon.syntax.Prism4jThemeDefault; import io.noties.markwon.syntax.SyntaxHighlightPlugin; import io.noties.prism4j.Prism4j; @@ -202,7 +206,17 @@ public class SpannableHelper { final Markwon markwon = Markwon.builder(context) .usePlugin(TablePlugin.create(context)) .usePlugin(SoftBreakAddsNewLinePlugin.create()) - .usePlugin(SyntaxHighlightPlugin.create(new Prism4j(new MySuperGrammerLocator()), Prism4jThemeDefault.create())).build(); + .usePlugin(SyntaxHighlightPlugin.create(new Prism4j(new MySuperGrammerLocator()), Prism4jThemeDefault.create())) + .usePlugin(StrikethroughPlugin.create()) + .usePlugin(MarkwonInlineParserPlugin.create()) + .usePlugin(new AbstractMarkwonPlugin() { + @Override + public void configure(@NonNull Registry registry) { + registry.require(MarkwonInlineParserPlugin.class, plugin -> plugin.factoryBuilder() + .excludeInlineProcessor(HtmlInlineProcessor.class)); + } + }) + .build(); final Spanned markdown = markwon.toMarkdown(initialContent.toString()); content = new SpannableStringBuilder(markdown);