Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flexmark from 0.42.14 to 0.64.8, minSdk to 21 #2407

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ if (enable_plugin_kotlin) {
apply plugin: 'kotlin-kapt'
}

rootProject.ext.version_minSdk = 18
rootProject.ext.version_minSdk = 21

// 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
compileSdkVersion rootProject.ext.version_compileSdk

defaultConfig {
resValue "string", "manifest_package_id", "net.gsantner.markor"
Expand All @@ -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()}"
Expand All @@ -40,7 +39,7 @@ android {
setProperty("archivesBaseName", applicationId + "-v" + versionCode + "-" + versionName)
}

flavorDimensions "default"
flavorDimensions = ["default"]
productFlavors {
flavorAtest {
applicationId "net.gsantner.markor_test"
Expand Down Expand Up @@ -98,13 +97,13 @@ 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 '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.2.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.preference:preference-ktx:1.2.1'
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}"
Expand Down Expand Up @@ -136,7 +135,6 @@ dependencies {
}



// UI libs
implementation 'com.github.Pixplicity:gene-rate:v1.1.8'
implementation 'com.github.AppIntro:AppIntro:6.2.0'
Expand All @@ -145,7 +143,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}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 + <br> + ref#(click) --> remove line break)
if (converted.contains("footnote-")) {
Expand Down Expand Up @@ -455,7 +458,7 @@ private String replaceTokens(final String markup, final Map<String, List<String>

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);
Expand All @@ -465,12 +468,12 @@ public void setAttributes(Node node, AttributablePart part, Attributes attribute
private static class LineNumberIdProviderFactory implements AttributeProviderFactory {

@Override
public Set<Class<? extends AttributeProviderFactory>> getAfterDependents() {
public @Nullable Set<Class<?>> getAfterDependents() {
return null;
}

@Override
public Set<Class<? extends AttributeProviderFactory>> getBeforeDependents() {
public @Nullable Set<Class<?>> getBeforeDependents() {
return null;
}

Expand All @@ -480,7 +483,7 @@ public boolean affectsGlobalScope() {
}

@Override
public AttributeProvider create(LinkResolverContext context) {
public @NotNull AttributeProvider apply(@NotNull LinkResolverContext context) {
return new LineNumberIdProvider();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}

Expand All @@ -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);
Expand All @@ -292,7 +295,7 @@ public boolean parse(final InlineParser inlineParser) {

public static class Factory implements InlineParserExtensionFactory {
@Override
public Set<Class<? extends InlineParserExtensionFactory>> getAfterDependents() {
public @Nullable Set<Class<?>> getAfterDependents() {
return null;
}

Expand All @@ -302,12 +305,12 @@ public CharSequence getCharacters() {
}

@Override
public Set<Class<? extends InlineParserExtensionFactory>> getBeforeDependents() {
public @Nullable Set<Class<?>> getBeforeDependents() {
return null;
}

@Override
public InlineParserExtension create(final InlineParser inlineParser) {
public @NotNull InlineParserExtension apply(@NotNull LightInlineParser inlineParser) {
return new KatexDisplayMathParser(inlineParser);
}

Expand All @@ -322,7 +325,7 @@ public static class KatexInlineMathParser implements InlineParserExtension {
private final KatexOptions options;
Pattern MATH_PATTERN = Pattern.compile("(?<!\\$)\\$((?:.|\n)+?)\\$(?!\\$)");

public KatexInlineMathParser(final InlineParser inlineParser) {
public KatexInlineMathParser(final LightInlineParser inlineParser) {
options = new KatexOptions(inlineParser.getDocument());
}

Expand All @@ -335,7 +338,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);
Expand All @@ -354,7 +357,7 @@ public boolean parse(final InlineParser inlineParser) {

public static class Factory implements InlineParserExtensionFactory {
@Override
public Set<Class<? extends InlineParserExtensionFactory>> getAfterDependents() {
public @Nullable Set<Class<?>> getAfterDependents() {
return null;
}

Expand All @@ -364,12 +367,12 @@ public CharSequence getCharacters() {
}

@Override
public Set<Class<? extends InlineParserExtensionFactory>> getBeforeDependents() {
public @Nullable Set<Class<?>> getBeforeDependents() {
return null;
}

@Override
public InlineParserExtension create(final InlineParser inlineParser) {
public @NotNull InlineParserExtension apply(@NotNull LightInlineParser inlineParser) {
return new KatexInlineMathParser(inlineParser);
}

Expand All @@ -395,13 +398,13 @@ public KatexNodeRenderer(DataHolder options) {
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
Set<NodeRenderingHandler<?>> set = new HashSet<NodeRenderingHandler<?>>();
// @formatter:off
set.add(new NodeRenderingHandler<KatexInlineMath>(KatexInlineMath.class, new CustomNodeRenderer<KatexInlineMath>() {
set.add(new NodeRenderingHandler<KatexInlineMath>(KatexInlineMath.class, new NodeRenderingHandler.CustomNodeRenderer<KatexInlineMath>() {
@Override
public void render(KatexInlineMath node, NodeRendererContext context, HtmlWriter html) {
KatexNodeRenderer.this.render(node, context, html);
}
}));
set.add(new NodeRenderingHandler<KatexDisplayMath>(KatexDisplayMath.class, new CustomNodeRenderer<KatexDisplayMath>() {
set.add(new NodeRenderingHandler<KatexDisplayMath>(KatexDisplayMath.class, new NodeRenderingHandler.CustomNodeRenderer<KatexDisplayMath>() {
@Override
public void render(KatexDisplayMath node, NodeRendererContext context, HtmlWriter html) {
KatexNodeRenderer.this.render(node, context, html);
Expand All @@ -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);
}
}
Expand Down
Loading