Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
distribution: 'zulu'

- name: Android Lint checks
run: cd commonmark-android-test && ./gradlew :app:lint
run: cd commonmark-android-test && ./gradlew :app:lint && ./gradlew :app:animalsnifferDebug
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extensible library with the following features:

The library is supported on Java 11 and later. It works on Android too,
but that is on a best-effort basis, please report problems. For Android the
minimum API level is 19, see the
minimum API level is 24, see the
[commonmark-android-test](commonmark-android-test)
directory.

Expand Down
4 changes: 2 additions & 2 deletions commonmark-android-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Current `minSdk` is 19

Requirements:

* Java 11 or above
* Android SDK 30
* Java 17 or above (supported by the Gradle wrapper version)
* Android SDK Platform 30 and SDK Build Tools 36.0.0

Configuration
-----
Expand Down
9 changes: 8 additions & 1 deletion commonmark-android-test/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Check Java API usage
plugins {
id 'ru.vyarus.animalsniffer' version '2.0.1'
}

apply plugin: 'com.android.application'

android {
Expand All @@ -6,7 +11,7 @@ android {

defaultConfig {
applicationId "org.commonmark.android.test"
minSdk 19
minSdk 24
targetSdk 30
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -49,4 +54,6 @@ android {

dependencies {
implementation('org.nibor.autolink:autolink:0.11.0')

signature 'net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature'
}
2 changes: 1 addition & 1 deletion commonmark-android-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:9.4.1'
}
}

Expand Down
Binary file modified commonmark-android-test/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 9 additions & 10 deletions commonmark-android-test/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 54 additions & 34 deletions commonmark-android-test/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.commonmark.ext.autolink;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
import org.commonmark.Extension;
Expand Down Expand Up @@ -57,7 +58,12 @@ public Builder linkTypes(AutolinkType... linkTypes) {
throw new NullPointerException("linkTypes must not be null");
}

return this.linkTypes(Set.of(linkTypes));
if (linkTypes.length == 0) {
throw new IllegalArgumentException("linkTypes must not be empty");
}

this.linkTypes = EnumSet.copyOf(Arrays.asList(linkTypes));
return this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.commonmark.ext.footnotes;

import java.util.Collections;
import java.util.Set;
import org.commonmark.Extension;
import org.commonmark.ext.footnotes.internal.*;
Expand Down Expand Up @@ -83,7 +84,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {

@Override
public Set<Character> getSpecialCharacters() {
return Set.of();
return Collections.emptySet();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.commonmark.ext.footnotes.internal;

import java.util.Collections;
import java.util.List;
import org.commonmark.ext.footnotes.FootnoteDefinition;
import org.commonmark.node.Block;
Expand Down Expand Up @@ -54,7 +55,7 @@ public BlockContinue tryContinue(ParserState parserState) {
public List<DefinitionMap<?>> getDefinitions() {
var map = new DefinitionMap<>(FootnoteDefinition.class);
map.putIfAbsent(block.getLabel(), block);
return List.of(map);
return Collections.singletonList(map);
}

public static class Factory implements BlockParserFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public FootnoteHtmlNodeRenderer(HtmlNodeRendererContext context) {

@Override
public Set<Class<? extends Node>> getNodeTypes() {
return Set.of(FootnoteReference.class, InlineFootnote.class, FootnoteDefinition.class);
return Collections.unmodifiableSet(
new HashSet<>(
Arrays.asList(
FootnoteReference.class,
InlineFootnote.class,
FootnoteDefinition.class)));
}

@Override
Expand Down Expand Up @@ -203,7 +208,10 @@ private ReferenceInfo registerReference(Node node, String label) {
}

private void renderReference(Node node, ReferenceInfo referenceInfo) {
html.tag("sup", context.extendAttributes(node, "sup", Map.of("class", "footnote-ref")));
html.tag(
"sup",
context.extendAttributes(
node, "sup", Collections.singletonMap("class", "footnote-ref")));

var href = "#" + referenceInfo.definitionId;
var attrs = new LinkedHashMap<String, String>();
Expand Down Expand Up @@ -231,7 +239,7 @@ private void renderDefinition(Node def, ReferencedDefinition referencedDefinitio
// Because we're manually rendering the <p> for the last paragraph, do the same
// for all other paragraphs for consistency (Paragraph rendering might be
// overwritten by a custom renderer).
html.tag("p", context.extendAttributes(node, "p", Map.of()));
html.tag("p", context.extendAttributes(node, "p", Collections.emptyMap()));
renderChildren(node);
html.tag("/p");
html.line();
Expand All @@ -241,14 +249,14 @@ private void renderDefinition(Node def, ReferencedDefinition referencedDefinitio
node = node.getNext();
}

html.tag("p", context.extendAttributes(lastParagraph, "p", Map.of()));
html.tag("p", context.extendAttributes(lastParagraph, "p", Collections.emptyMap()));
renderChildren(lastParagraph);
html.raw(" ");
renderBackrefs(def, referencedDefinition);
html.tag("/p");
html.line();
} else if (def instanceof InlineFootnote) {
html.tag("p", context.extendAttributes(def, "p", Map.of()));
html.tag("p", context.extendAttributes(def, "p", Collections.emptyMap()));
renderChildren(def);
html.raw(" ");
renderBackrefs(def, referencedDefinition);
Expand Down Expand Up @@ -283,7 +291,8 @@ private void renderBackrefs(Node def, ReferencedDefinition referencedDefinition)
if (refNumber > 1) {
html.tag(
"sup",
context.extendAttributes(def, "sup", Map.of("class", "footnote-ref")));
context.extendAttributes(
def, "sup", Collections.singletonMap("class", "footnote-ref")));
html.raw(String.valueOf(refNumber));
html.tag("/sup");
}
Expand Down
Loading
Loading