From 67e389ff9bafd086fd0ce39f74527aabab4a9d10 Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 09:30:54 +0800 Subject: [PATCH 1/8] update flexmark from 0.42.14 to 0.64.8 --- app/build.gradle | 3 +- .../markdown/MarkdownTextConverter.java | 23 +++++----- .../ext/katex/FlexmarkKatexExtension.java | 43 ++++++++++--------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7ac929e0ec..3a26e06c5f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ if (enable_plugin_kotlin) { rootProject.ext.version_minSdk = 18 // https://github.com/vsch/flexmark-java/releases -ext.version_library_flexmark = "0.42.14" +ext.version_library_flexmark = "0.64.8" android { buildToolsVersion rootProject.ext.version_buildTools @@ -136,7 +136,6 @@ dependencies { } - // UI libs implementation 'com.pixplicity.generate:library:1.1.8' implementation 'com.github.AppIntro:AppIntro:6.2.0' diff --git a/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java b/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java index d93047b13a..2c34a7c82b 100644 --- a/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java +++ b/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java @@ -22,6 +22,7 @@ import com.vladsch.flexmark.ext.ins.InsExtension; import com.vladsch.flexmark.ext.jekyll.front.matter.JekyllFrontMatterExtension; import com.vladsch.flexmark.ext.jekyll.tag.JekyllTagExtension; +import com.vladsch.flexmark.ext.superscript.SuperscriptExtension; import com.vladsch.flexmark.ext.tables.TablesExtension; import com.vladsch.flexmark.ext.toc.SimTocExtension; import com.vladsch.flexmark.ext.toc.TocExtension; @@ -36,18 +37,20 @@ import com.vladsch.flexmark.html.renderer.AttributablePart; import com.vladsch.flexmark.html.renderer.LinkResolverContext; import com.vladsch.flexmark.parser.Parser; -import com.vladsch.flexmark.superscript.SuperscriptExtension; import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; -import com.vladsch.flexmark.util.builder.Extension; -import com.vladsch.flexmark.util.html.Attributes; -import com.vladsch.flexmark.util.options.MutableDataHolder; -import com.vladsch.flexmark.util.options.MutableDataSet; +import com.vladsch.flexmark.util.data.MutableDataHolder; +import com.vladsch.flexmark.util.data.MutableDataSet; +import com.vladsch.flexmark.util.html.MutableAttributes; +import com.vladsch.flexmark.util.misc.Extension; import net.gsantner.markor.R; import net.gsantner.markor.format.TextConverterBase; import net.gsantner.opoc.util.GsContextUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -317,7 +320,7 @@ public String convertMarkup(String markup, Context context, boolean lightMode, b //////////// // Markup parsing - afterwards = HTML Document document = flexmarkParser.parse(markup); - converted = fmaText + flexmarkRenderer.withOptions(options).render(document); + converted = fmaText + flexmarkRenderer.builder(options).build().render(document); // After render changes: Fixes for Footnotes (converter creates footnote +
+ ref#(click) --> remove line break) if (converted.contains("footnote-")) { @@ -455,7 +458,7 @@ private String replaceTokens(final String markup, final Map private static class LineNumberIdProvider implements AttributeProvider { @Override - public void setAttributes(Node node, AttributablePart part, Attributes attributes) { + public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { final Document document = node.getDocument(); final int lineNumber = document.getLineNumber(node.getStartOffset()); attributes.addValue("line", "" + lineNumber); @@ -465,12 +468,12 @@ public void setAttributes(Node node, AttributablePart part, Attributes attribute private static class LineNumberIdProviderFactory implements AttributeProviderFactory { @Override - public Set> getAfterDependents() { + public @Nullable Set> getAfterDependents() { return null; } @Override - public Set> getBeforeDependents() { + public @Nullable Set> getBeforeDependents() { return null; } @@ -480,7 +483,7 @@ public boolean affectsGlobalScope() { } @Override - public AttributeProvider create(LinkResolverContext context) { + public @NotNull AttributeProvider apply(@NotNull LinkResolverContext context) { return new LineNumberIdProvider(); } } diff --git a/app/thirdparty/java/other/com/vladsch/flexmark/ext/katex/FlexmarkKatexExtension.java b/app/thirdparty/java/other/com/vladsch/flexmark/ext/katex/FlexmarkKatexExtension.java index 9fbf5be84d..6865e9e679 100644 --- a/app/thirdparty/java/other/com/vladsch/flexmark/ext/katex/FlexmarkKatexExtension.java +++ b/app/thirdparty/java/other/com/vladsch/flexmark/ext/katex/FlexmarkKatexExtension.java @@ -31,9 +31,7 @@ package other.com.vladsch.flexmark.ext.katex; -import com.vladsch.flexmark.ast.DelimitedNode; import com.vladsch.flexmark.ast.util.ReferenceRepository; -import com.vladsch.flexmark.html.CustomNodeRenderer; import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.NodeRenderer; @@ -43,18 +41,23 @@ import com.vladsch.flexmark.parser.InlineParser; import com.vladsch.flexmark.parser.InlineParserExtension; import com.vladsch.flexmark.parser.InlineParserExtensionFactory; +import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.parser.Parser; +import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.VisitHandler; import com.vladsch.flexmark.util.ast.Visitor; -import com.vladsch.flexmark.util.builder.Extension; +import com.vladsch.flexmark.util.data.DataHolder; +import com.vladsch.flexmark.util.data.DataKey; +import com.vladsch.flexmark.util.data.MutableDataHolder; +import com.vladsch.flexmark.util.data.MutableDataSetter; import com.vladsch.flexmark.util.html.Attribute; -import com.vladsch.flexmark.util.options.DataHolder; -import com.vladsch.flexmark.util.options.DataKey; -import com.vladsch.flexmark.util.options.MutableDataHolder; -import com.vladsch.flexmark.util.options.MutableDataSetter; +import com.vladsch.flexmark.util.misc.Extension; import com.vladsch.flexmark.util.sequence.BasedSequence; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; @@ -260,7 +263,7 @@ public static class KatexDisplayMathParser implements InlineParserExtension { private final KatexOptions options; Pattern MATH_PATTERN = Pattern.compile("\\$\\$((?:.|\n)+?)\\$\\$"); - public KatexDisplayMathParser(final InlineParser inlineParser) { + public KatexDisplayMathParser(final LightInlineParser inlineParser) { options = new KatexOptions(inlineParser.getDocument()); } @@ -273,7 +276,7 @@ public void finalizeBlock(final InlineParser inlineParser) { } @Override - public boolean parse(final InlineParser inlineParser) { + public boolean parse(@NotNull LightInlineParser inlineParser) { if (inlineParser.peek(1) == '$') { BasedSequence input = inlineParser.getInput(); Matcher matcher = inlineParser.matcher(MATH_PATTERN); @@ -292,7 +295,7 @@ public boolean parse(final InlineParser inlineParser) { public static class Factory implements InlineParserExtensionFactory { @Override - public Set> getAfterDependents() { + public @Nullable Set> getAfterDependents() { return null; } @@ -302,12 +305,12 @@ public CharSequence getCharacters() { } @Override - public Set> getBeforeDependents() { + public @Nullable Set> getBeforeDependents() { return null; } @Override - public InlineParserExtension create(final InlineParser inlineParser) { + public @NotNull InlineParserExtension apply(@NotNull LightInlineParser inlineParser) { return new KatexDisplayMathParser(inlineParser); } @@ -322,7 +325,7 @@ public static class KatexInlineMathParser implements InlineParserExtension { private final KatexOptions options; Pattern MATH_PATTERN = Pattern.compile("(?> getAfterDependents() { + public @Nullable Set> getAfterDependents() { return null; } @@ -364,12 +367,12 @@ public CharSequence getCharacters() { } @Override - public Set> getBeforeDependents() { + public @Nullable Set> getBeforeDependents() { return null; } @Override - public InlineParserExtension create(final InlineParser inlineParser) { + public @NotNull InlineParserExtension apply(@NotNull LightInlineParser inlineParser) { return new KatexInlineMathParser(inlineParser); } @@ -395,13 +398,13 @@ public KatexNodeRenderer(DataHolder options) { public Set> getNodeRenderingHandlers() { Set> set = new HashSet>(); // @formatter:off - set.add(new NodeRenderingHandler(KatexInlineMath.class, new CustomNodeRenderer() { + set.add(new NodeRenderingHandler(KatexInlineMath.class, new NodeRenderingHandler.CustomNodeRenderer() { @Override public void render(KatexInlineMath node, NodeRendererContext context, HtmlWriter html) { KatexNodeRenderer.this.render(node, context, html); } })); - set.add(new NodeRenderingHandler(KatexDisplayMath.class, new CustomNodeRenderer() { + set.add(new NodeRenderingHandler(KatexDisplayMath.class, new NodeRenderingHandler.CustomNodeRenderer() { @Override public void render(KatexDisplayMath node, NodeRendererContext context, HtmlWriter html) { KatexNodeRenderer.this.render(node, context, html); @@ -425,7 +428,7 @@ private void render(final KatexDisplayMath node, final NodeRendererContext conte public static class Factory implements NodeRendererFactory { @Override - public NodeRenderer create(final DataHolder options) { + public @NotNull NodeRenderer apply(@NotNull DataHolder options) { return new KatexNodeRenderer(options); } } From 2034ec2ff902fce0ea54d070cbaedfbcee4ed8c9 Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 09:43:47 +0800 Subject: [PATCH 2/8] fix deprecated warnings in build.gradle(app) --- app/build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3a26e06c5f..514f9064ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,6 @@ rootProject.ext.version_minSdk = 18 ext.version_library_flexmark = "0.64.8" android { - buildToolsVersion rootProject.ext.version_buildTools - compileSdkVersion rootProject.ext.version_compileSdk defaultConfig { resValue "string", "manifest_package_id", "net.gsantner.markor" @@ -31,6 +29,7 @@ android { multiDexEnabled true minSdkVersion rootProject.ext.version_minSdk targetSdkVersion rootProject.ext.version_compileSdk + compileSdk rootProject.ext.version_compileSdk buildConfigField "boolean", "IS_TEST_BUILD", "false" buildConfigField "boolean", "IS_GPLAY_BUILD", "false" buildConfigField "String[]", "DETECTED_ANDROID_LOCALES", "${findUsedAndroidLocales()}" @@ -40,7 +39,7 @@ android { setProperty("archivesBaseName", applicationId + "-v" + versionCode + "-" + versionName) } - flavorDimensions "default" + flavorDimensions = ["default"] productFlavors { flavorAtest { applicationId "net.gsantner.markor_test" From 3e0173785a09f376ed600b01639588032edf3d19 Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 09:44:36 +0800 Subject: [PATCH 3/8] update recyclerview from 1.2.1 to 1.3.2 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 514f9064ec..5264c9c639 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -100,7 +100,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.preference:preference:1.2.0' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.browser:browser:1.4.0' From 73ba7a3bd0ede290f0a1abb42df8d61a4760cd2c Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 09:55:45 +0800 Subject: [PATCH 4/8] update commons-io from 2.7 to 2.13.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 5264c9c639..5ebb7cb10d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -144,7 +144,7 @@ dependencies { // Tool libraries //noinspection AnnotationProcessorOnCompilePath - implementation 'commons-io:commons-io:2.7' + implementation 'commons-io:commons-io:2.13.0' if (enable_plugin_kotlin) { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${version_plugin_kotlin}" } From d272dbc9766a2ff0a7a111c9f6fd1288a16788ff Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 10:03:54 +0800 Subject: [PATCH 5/8] update browser from 1.4.0 to 1.8.0 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5ebb7cb10d..4eb7bcdcc9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,7 +13,7 @@ if (enable_plugin_kotlin) { apply plugin: 'kotlin-kapt' } -rootProject.ext.version_minSdk = 18 +rootProject.ext.version_minSdk = 19 // https://github.com/vsch/flexmark-java/releases ext.version_library_flexmark = "0.64.8" @@ -103,7 +103,7 @@ dependencies { implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.preference:preference:1.2.0' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' - implementation 'androidx.browser:browser:1.4.0' + implementation 'androidx.browser:browser:1.8.0' // Markdown convertor (Flexmark) implementation "com.vladsch.flexmark:flexmark:${version_library_flexmark}" From 22ab527a728567af9f834fbc2ec239aac917feab Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 10:12:04 +0800 Subject: [PATCH 6/8] update preference from 1.2.0 to 1.2.1 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 4eb7bcdcc9..8d02870809 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -101,7 +101,7 @@ dependencies { implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' - implementation 'androidx.preference:preference:1.2.0' + implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.browser:browser:1.8.0' From 268b2a40c16b3ec55a4b4dcdf3289ef6c875a8b0 Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 10:27:34 +0800 Subject: [PATCH 7/8] update material from 1.6.1 to 1.12.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 8d02870809..f703c96a79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,7 +98,7 @@ dependencies { // Android standard libs implementation "androidx.multidex:multidex:2.0.1" implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'com.google.android.material:material:1.6.1' + implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.preference:preference-ktx:1.2.1' From dc0c00ca21422258c2b14a6e5d6352452c55ea71 Mon Sep 17 00:00:00 2001 From: Li Guanglin Date: Sun, 4 Aug 2024 10:32:05 +0800 Subject: [PATCH 8/8] update appcompat from 1.4.2 to 1.7.0 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f703c96a79..87c1152ec6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,7 +13,7 @@ if (enable_plugin_kotlin) { apply plugin: 'kotlin-kapt' } -rootProject.ext.version_minSdk = 19 +rootProject.ext.version_minSdk = 21 // https://github.com/vsch/flexmark-java/releases ext.version_library_flexmark = "0.64.8" @@ -97,7 +97,7 @@ dependencies { // Android standard libs implementation "androidx.multidex:multidex:2.0.1" - implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.3.2'