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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class IndentedCodeBlockNodeRenderer implements NodeRenderer {
@Override
public Set<Class<? extends Node>> getNodeTypes() {
// Return the node types we want to use this renderer for.
return Collections.<Class<? extends Node>>singleton(IndentedCodeBlock.class);
return Set.of(IndentedCodeBlock.class);
}

@Override
Expand Down Expand Up @@ -274,7 +274,7 @@ Then, configure the extension on the builders:
```java
import org.commonmark.ext.gfm.tables.TablesExtension;

List<Extension> extensions = Arrays.asList(TablesExtension.create());
List<Extension> extensions = List.of(TablesExtension.create());
Parser parser = Parser.builder()
.extensions(extensions)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
import org.commonmark.testutil.RenderingTestCase;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class AutolinkTest extends RenderingTestCase {

private static final Set<Extension> EXTENSIONS = Collections.singleton(AutolinkExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(AutolinkExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).build();

Expand Down Expand Up @@ -73,43 +71,43 @@ public void sourceSpans() {

Paragraph paragraph = (Paragraph) document.getFirstChild();
Text abc = (Text) paragraph.getFirstChild();
assertEquals(Arrays.asList(SourceSpan.of(0, 0, 3)),
assertEquals(List.of(SourceSpan.of(0, 0, 3)),
abc.getSourceSpans());

assertTrue(abc.getNext() instanceof SoftLineBreak);

Link one = (Link) abc.getNext().getNext();
assertEquals("http://example.com/one", one.getDestination());
assertEquals(Arrays.asList(SourceSpan.of(1, 0, 22)),
assertEquals(List.of(SourceSpan.of(1, 0, 22)),
one.getSourceSpans());

assertTrue(one.getNext() instanceof SoftLineBreak);

Text def = (Text) one.getNext().getNext();
assertEquals("def ", def.getLiteral());
assertEquals(Arrays.asList(SourceSpan.of(2, 0, 4)),
assertEquals(List.of(SourceSpan.of(2, 0, 4)),
def.getSourceSpans());

Link two = (Link) def.getNext();
assertEquals("http://example.com/two", two.getDestination());
assertEquals(Arrays.asList(SourceSpan.of(2, 4, 22)),
assertEquals(List.of(SourceSpan.of(2, 4, 22)),
two.getSourceSpans());

assertTrue(two.getNext() instanceof SoftLineBreak);

Text ghi = (Text) two.getNext().getNext();
assertEquals("ghi ", ghi.getLiteral());
assertEquals(Arrays.asList(SourceSpan.of(3, 0, 4)),
assertEquals(List.of(SourceSpan.of(3, 0, 4)),
ghi.getSourceSpans());

Link three = (Link) ghi.getNext();
assertEquals("http://example.com/three", three.getDestination());
assertEquals(Arrays.asList(SourceSpan.of(3, 4, 24)),
assertEquals(List.of(SourceSpan.of(3, 4, 24)),
three.getSourceSpans());

Text jkl = (Text) three.getNext();
assertEquals(" jkl", jkl.getLiteral());
assertEquals(Arrays.asList(SourceSpan.of(3, 28, 4)),
assertEquals(List.of(SourceSpan.of(3, 28, 4)),
jkl.getSourceSpans());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.commonmark.renderer.text.TextContentNodeRendererFactory;
import org.commonmark.renderer.text.TextContentRenderer;

import java.util.Collections;
import java.util.Set;

/**
Expand Down Expand Up @@ -106,7 +105,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {

@Override
public Set<Character> getSpecialCharacters() {
return Collections.singleton('~');
return Set.of('~');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.commonmark.ext.gfm.strikethrough.internal;

import org.commonmark.renderer.html.HtmlWriter;
import org.commonmark.renderer.html.HtmlNodeRendererContext;
import org.commonmark.node.Node;
import org.commonmark.renderer.html.HtmlNodeRendererContext;
import org.commonmark.renderer.html.HtmlWriter;

import java.util.Collections;
import java.util.Map;

public class StrikethroughHtmlNodeRenderer extends StrikethroughNodeRenderer {
Expand All @@ -19,7 +18,7 @@ public StrikethroughHtmlNodeRenderer(HtmlNodeRendererContext context) {

@Override
public void render(Node node) {
Map<String, String> attributes = context.extendAttributes(node, "del", Collections.<String, String>emptyMap());
Map<String, String> attributes = context.extendAttributes(node, "del", Map.of());
html.tag("del", attributes);
renderChildren(node);
html.tag("/del");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import org.commonmark.node.Node;
import org.commonmark.renderer.NodeRenderer;

import java.util.Collections;
import java.util.Set;

abstract class StrikethroughNodeRenderer implements NodeRenderer {

@Override
public Set<Class<? extends Node>> getNodeTypes() {
return Collections.<Class<? extends Node>>singleton(Strikethrough.class);
return Set.of(Strikethrough.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import org.commonmark.renderer.markdown.MarkdownRenderer;
import org.junit.Test;

import java.util.Collections;
import java.util.Set;

import static org.junit.Assert.assertEquals;

public class StrikethroughMarkdownRendererTest {

private static final Set<Extension> EXTENSIONS = Collections.singleton(StrikethroughExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(StrikethroughExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final MarkdownRenderer RENDERER = MarkdownRenderer.builder().extensions(EXTENSIONS).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Collections;
import java.util.List;
import java.util.Set;

@RunWith(Parameterized.class)
public class StrikethroughSpecTest extends RenderingTestCase {

private static final Set<Extension> EXTENSIONS = Collections.singleton(StrikethroughExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(StrikethroughExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
import org.commonmark.testutil.RenderingTestCase;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

import static java.util.Collections.singleton;
import static org.junit.Assert.assertEquals;

public class StrikethroughTest extends RenderingTestCase {

private static final Set<Extension> EXTENSIONS = singleton(StrikethroughExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(StrikethroughExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final HtmlRenderer HTML_RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).build();
private static final TextContentRenderer CONTENT_RENDERER = TextContentRenderer.builder()
Expand Down Expand Up @@ -98,7 +97,7 @@ public void textContentRenderer() {
@Test
public void requireTwoTildesOption() {
Parser parser = Parser.builder()
.extensions(singleton(StrikethroughExtension.builder()
.extensions(Set.of(StrikethroughExtension.builder()
.requireTwoTildes(true)
.build()))
.customDelimiterProcessor(new SubscriptDelimiterProcessor())
Expand All @@ -118,7 +117,7 @@ public void sourceSpans() {
Node document = parser.parse("hey ~~there~~\n");
Paragraph block = (Paragraph) document.getFirstChild();
Node strikethrough = block.getLastChild();
assertEquals(Arrays.asList(SourceSpan.of(0, 4, 9)),
assertEquals(List.of(SourceSpan.of(0, 4, 9)),
strikethrough.getSourceSpans());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.commonmark.renderer.text.TextContentNodeRendererFactory;
import org.commonmark.renderer.text.TextContentRenderer;

import java.util.Collections;
import java.util.Set;

/**
Expand Down Expand Up @@ -78,7 +77,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {

@Override
public Set<Character> getSpecialCharacters() {
return Collections.singleton('|');
return Set.of('|');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.commonmark.renderer.html.HtmlNodeRendererContext;
import org.commonmark.renderer.html.HtmlWriter;

import java.util.Collections;
import java.util.Map;

public class TableHtmlNodeRenderer extends TableNodeRenderer {
Expand Down Expand Up @@ -60,14 +59,14 @@ protected void renderCell(TableCell tableCell) {
}

private Map<String, String> getAttributes(Node node, String tagName) {
return context.extendAttributes(node, tagName, Collections.<String, String>emptyMap());
return context.extendAttributes(node, tagName, Map.of());
}

private Map<String, String> getCellAttributes(TableCell tableCell, String tagName) {
if (tableCell.getAlignment() != null) {
return context.extendAttributes(tableCell, tagName, Collections.singletonMap("align", getAlignValue(tableCell.getAlignment())));
return context.extendAttributes(tableCell, tagName, Map.of("align", getAlignValue(tableCell.getAlignment())));
} else {
return context.extendAttributes(tableCell, tagName, Collections.<String, String>emptyMap());
return context.extendAttributes(tableCell, tagName, Map.of());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package org.commonmark.ext.gfm.tables.internal;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.commonmark.ext.gfm.tables.TableBlock;
import org.commonmark.ext.gfm.tables.TableBody;
import org.commonmark.ext.gfm.tables.TableCell;
import org.commonmark.ext.gfm.tables.TableHead;
import org.commonmark.ext.gfm.tables.TableRow;
import org.commonmark.ext.gfm.tables.*;
import org.commonmark.node.Node;
import org.commonmark.renderer.NodeRenderer;

import java.util.Set;

abstract class TableNodeRenderer implements NodeRenderer {

@Override
public Set<Class<? extends Node>> getNodeTypes() {
return new HashSet<>(Arrays.asList(
return Set.of(
TableBlock.class,
TableHead.class,
TableBody.class,
TableRow.class,
TableCell.class
));
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import org.commonmark.renderer.markdown.MarkdownRenderer;
import org.junit.Test;

import java.util.Collections;
import java.util.Set;

import static org.junit.Assert.assertEquals;

public class TableMarkdownRendererTest {

private static final Set<Extension> EXTENSIONS = Collections.singleton(TablesExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(TablesExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final MarkdownRenderer RENDERER = MarkdownRenderer.builder().extensions(EXTENSIONS).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

@RunWith(Parameterized.class)
public class TablesSpecTest extends RenderingTestCase {

private static final Set<Extension> EXTENSIONS = Collections.singleton(TablesExtension.create());
private static final Set<Extension> EXTENSIONS = Set.of(TablesExtension.create());
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
private static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).build();

Expand Down
Loading