Skip to content

Commit bb8c71f

Browse files
committed
Format using mvn spotless:apply
Had to reflow some multi-line comments, but other than that all good.
1 parent e1d5292 commit bb8c71f

255 files changed

Lines changed: 5401 additions & 4568 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/AutolinkExtension.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
import java.util.EnumSet;
44
import java.util.Set;
5-
65
import org.commonmark.Extension;
76
import org.commonmark.ext.autolink.internal.AutolinkPostProcessor;
87
import org.commonmark.parser.Parser;
98
import org.commonmark.renderer.html.HtmlRenderer;
109

1110
/**
1211
* Extension for automatically turning plain URLs and email addresses into links.
13-
* <p>
14-
* Create it with {@link #create()} and then configure it on the builders
15-
* ({@link org.commonmark.parser.Parser.Builder#extensions(Iterable)},
16-
* {@link HtmlRenderer.Builder#extensions(Iterable)}).
17-
* </p>
18-
* <p>
19-
* The parsed links are turned into normal {@link org.commonmark.node.Link} nodes.
20-
* </p>
12+
*
13+
* <p>Create it with {@link #create()} and then configure it on the builders ({@link
14+
* org.commonmark.parser.Parser.Builder#extensions(Iterable)}, {@link
15+
* HtmlRenderer.Builder#extensions(Iterable)}).
16+
*
17+
* <p>The parsed links are turned into normal {@link org.commonmark.node.Link} nodes.
2118
*/
2219
public class AutolinkExtension implements Parser.ParserExtension {
2320

@@ -51,8 +48,8 @@ public static class Builder {
5148
private Set<AutolinkType> linkTypes = EnumSet.allOf(AutolinkType.class);
5249

5350
/**
54-
* @param linkTypes the link types that should be converted. By default,
55-
* all {@link AutolinkType}s are converted.
51+
* @param linkTypes the link types that should be converted. By default, all {@link
52+
* AutolinkType}s are converted.
5653
* @return {@code this}
5754
*/
5855
public Builder linkTypes(AutolinkType... linkTypes) {
@@ -64,8 +61,8 @@ public Builder linkTypes(AutolinkType... linkTypes) {
6461
}
6562

6663
/**
67-
* @param linkTypes the link types that should be converted. By default,
68-
* all {@link AutolinkType}s are converted.
64+
* @param linkTypes the link types that should be converted. By default, all {@link
65+
* AutolinkType}s are converted.
6966
* @return {@code this}
7067
*/
7168
public Builder linkTypes(Set<AutolinkType> linkTypes) {
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
package org.commonmark.ext.autolink;
22

3-
/**
4-
* The types of strings that can be automatically turned into links.
5-
*/
3+
/** The types of strings that can be automatically turned into links. */
64
public enum AutolinkType {
7-
/**
8-
* URL such as {@code http://example.com}
9-
*/
5+
/** URL such as {@code http://example.com} */
106
URL,
11-
/**
12-
* Email address such as {@code foo@example.com}
13-
*/
7+
/** Email address such as {@code foo@example.com} */
148
EMAIL,
15-
/**
16-
* URL such as {@code www.example.com}
17-
*/
9+
/** URL such as {@code www.example.com} */
1810
WWW
1911
}

commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/internal/AutolinkPostProcessor.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.autolink.internal;
22

3+
import java.util.*;
34
import org.commonmark.ext.autolink.AutolinkType;
45
import org.commonmark.node.*;
56
import org.commonmark.parser.PostProcessor;
@@ -8,8 +9,6 @@
89
import org.nibor.autolink.LinkType;
910
import org.nibor.autolink.Span;
1011

11-
import java.util.*;
12-
1312
public class AutolinkPostProcessor implements PostProcessor {
1413

1514
private final LinkExtractor linkExtractor;
@@ -38,9 +37,7 @@ public AutolinkPostProcessor(Set<AutolinkType> linkTypes) {
3837
}
3938
}
4039

41-
this.linkExtractor = LinkExtractor.builder()
42-
.linkTypes(types)
43-
.build();
40+
this.linkExtractor = LinkExtractor.builder().linkTypes(types).build();
4441
}
4542

4643
@Override

commonmark-ext-autolink/src/test/java/org/commonmark/ext/autolink/AutolinkTest.java

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.commonmark.ext.autolink;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.util.List;
6+
import java.util.Set;
37
import org.commonmark.Extension;
48
import org.commonmark.node.*;
59
import org.commonmark.parser.IncludeSourceSpans;
@@ -8,64 +12,69 @@
812
import org.commonmark.testutil.RenderingTestCase;
913
import org.junit.jupiter.api.Test;
1014

11-
import java.util.List;
12-
import java.util.Set;
13-
14-
import static org.assertj.core.api.Assertions.assertThat;
15-
1615
public class AutolinkTest extends RenderingTestCase {
1716

1817
private static final Set<Extension> EXTENSIONS = Set.of(AutolinkExtension.create());
1918
private static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build();
20-
private static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).build();
21-
22-
private static final Set<Extension> NO_WWW_EXTENSIONS = Set.of(AutolinkExtension.builder()
23-
.linkTypes(AutolinkType.URL, AutolinkType.EMAIL)
24-
.build());
25-
private static final Parser NO_WWW_PARSER = Parser.builder().extensions(NO_WWW_EXTENSIONS).build();
26-
private static final HtmlRenderer NO_WWW_RENDERER = HtmlRenderer.builder().extensions(NO_WWW_EXTENSIONS).build();
19+
private static final HtmlRenderer RENDERER =
20+
HtmlRenderer.builder().extensions(EXTENSIONS).build();
21+
22+
private static final Set<Extension> NO_WWW_EXTENSIONS =
23+
Set.of(
24+
AutolinkExtension.builder()
25+
.linkTypes(AutolinkType.URL, AutolinkType.EMAIL)
26+
.build());
27+
private static final Parser NO_WWW_PARSER =
28+
Parser.builder().extensions(NO_WWW_EXTENSIONS).build();
29+
private static final HtmlRenderer NO_WWW_RENDERER =
30+
HtmlRenderer.builder().extensions(NO_WWW_EXTENSIONS).build();
2731

2832
@Test
2933
public void oneTextNode() {
30-
assertRendering("foo http://one.org/ bar http://two.org/",
34+
assertRendering(
35+
"foo http://one.org/ bar http://two.org/",
3136
"<p>foo <a href=\"http://one.org/\">http://one.org/</a> bar <a href=\"http://two.org/\">http://two.org/</a></p>\n");
3237
}
3338

3439
@Test
3540
public void textNodeAndOthers() {
36-
assertRendering("foo http://one.org/ bar `code` baz http://two.org/",
41+
assertRendering(
42+
"foo http://one.org/ bar `code` baz http://two.org/",
3743
"<p>foo <a href=\"http://one.org/\">http://one.org/</a> bar <code>code</code> baz <a href=\"http://two.org/\">http://two.org/</a></p>\n");
3844
}
3945

4046
@Test
4147
public void tricky() {
42-
assertRendering("http://example.com/one. Example 2 (see http://example.com/two). Example 3: http://example.com/foo_(bar)",
43-
"<p><a href=\"http://example.com/one\">http://example.com/one</a>. " +
44-
"Example 2 (see <a href=\"http://example.com/two\">http://example.com/two</a>). " +
45-
"Example 3: <a href=\"http://example.com/foo_(bar)\">http://example.com/foo_(bar)</a></p>\n");
48+
assertRendering(
49+
"http://example.com/one. Example 2 (see http://example.com/two). Example 3: http://example.com/foo_(bar)",
50+
"<p><a href=\"http://example.com/one\">http://example.com/one</a>. "
51+
+ "Example 2 (see <a href=\"http://example.com/two\">http://example.com/two</a>). "
52+
+ "Example 3: <a href=\"http://example.com/foo_(bar)\">http://example.com/foo_(bar)</a></p>\n");
4653
}
4754

4855
@Test
4956
public void emailUsesMailto() {
50-
assertRendering("foo@example.com",
57+
assertRendering(
58+
"foo@example.com",
5159
"<p><a href=\"mailto:foo@example.com\">foo@example.com</a></p>\n");
5260
}
5361

5462
@Test
5563
public void emailWithTldNotLinked() {
56-
assertRendering("foo@com",
57-
"<p>foo@com</p>\n");
64+
assertRendering("foo@com", "<p>foo@com</p>\n");
5865
}
5966

6067
@Test
6168
public void dontLinkTextWithinLinks() {
62-
assertRendering("<http://example.com>",
69+
assertRendering(
70+
"<http://example.com>",
6371
"<p><a href=\"http://example.com\">http://example.com</a></p>\n");
6472
}
6573

6674
@Test
6775
public void wwwLinks() {
68-
assertRendering("www.example.com",
76+
assertRendering(
77+
"www.example.com",
6978
"<p><a href=\"http://www.example.com\">www.example.com</a></p>\n");
7079
}
7180

@@ -77,14 +86,17 @@ public void noWwwLinks() {
7786

7887
@Test
7988
public void sourceSpans() {
80-
Parser parser = Parser.builder()
81-
.extensions(EXTENSIONS)
82-
.includeSourceSpans(IncludeSourceSpans.BLOCKS_AND_INLINES)
83-
.build();
84-
Node document = parser.parse("abc\n" +
85-
"http://example.com/one\n" +
86-
"def http://example.com/two\n" +
87-
"ghi http://example.com/three jkl");
89+
Parser parser =
90+
Parser.builder()
91+
.extensions(EXTENSIONS)
92+
.includeSourceSpans(IncludeSourceSpans.BLOCKS_AND_INLINES)
93+
.build();
94+
Node document =
95+
parser.parse(
96+
"abc\n"
97+
+ "http://example.com/one\n"
98+
+ "def http://example.com/two\n"
99+
+ "ghi http://example.com/three jkl");
88100

89101
Paragraph paragraph = (Paragraph) document.getFirstChild();
90102
Text abc = (Text) paragraph.getFirstChild();

commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/FootnoteDefinition.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
/**
66
* A footnote definition, e.g.:
7+
*
78
* <pre><code>
89
* [^foo]: This is the footnote text
910
* </code></pre>
10-
* The {@link #getLabel() label} is the text in brackets after {@code ^}, so {@code foo} in the example. The contents
11-
* of the footnote are child nodes of the definition, a {@link org.commonmark.node.Paragraph} in the example.
12-
* <p>
13-
* Footnote definitions are parsed even if there's no corresponding {@link FootnoteReference}.
11+
*
12+
* The {@link #getLabel() label} is the text in brackets after {@code ^}, so {@code foo} in the
13+
* example. The contents of the footnote are child nodes of the definition, a {@link
14+
* org.commonmark.node.Paragraph} in the example.
15+
*
16+
* <p>Footnote definitions are parsed even if there's no corresponding {@link FootnoteReference}.
1417
*/
1518
public class FootnoteDefinition extends CustomBlock {
1619

@@ -24,4 +27,3 @@ public String getLabel() {
2427
return label;
2528
}
2629
}
27-

commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/FootnoteReference.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
/**
66
* A footnote reference, e.g. <code>[^foo]</code> in <code>Some text with a footnote[^foo]</code>
7-
* <p>
8-
* The {@link #getLabel() label} is the text within brackets after {@code ^}, so {@code foo} in the example. It needs to
9-
* match the label of a corresponding {@link FootnoteDefinition} for the footnote to be parsed.
7+
*
8+
* <p>The {@link #getLabel() label} is the text within brackets after {@code ^}, so {@code foo} in
9+
* the example. It needs to match the label of a corresponding {@link FootnoteDefinition} for the
10+
* footnote to be parsed.
1011
*/
1112
public class FootnoteReference extends CustomNode {
1213
private String label;

commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/FootnotesExtension.java

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.footnotes;
22

3+
import java.util.Set;
34
import org.commonmark.Extension;
45
import org.commonmark.ext.footnotes.internal.*;
56
import org.commonmark.parser.Parser;
@@ -9,42 +10,45 @@
910
import org.commonmark.renderer.markdown.MarkdownNodeRendererFactory;
1011
import org.commonmark.renderer.markdown.MarkdownRenderer;
1112

12-
import java.util.Set;
13-
1413
/**
1514
* Extension for footnotes with syntax like GitHub Flavored Markdown:
15+
*
1616
* <pre><code>
1717
* Some text with a footnote[^1].
1818
*
1919
* [^1]: The text of the footnote.
2020
* </code></pre>
21+
*
2122
* The <code>[^1]</code> is a {@link FootnoteReference}, with "1" being the label.
22-
* <p>
23-
* The line with <code>[^1]: ...</code> is a {@link FootnoteDefinition}, with the contents as child nodes (can be a
24-
* paragraph like in the example, or other blocks like lists).
25-
* <p>
26-
* All the footnotes (definitions) will be rendered in a list at the end of a document, no matter where they appear in
27-
* the source. The footnotes will be numbered starting from 1, then 2, etc, depending on the order in which they appear
28-
* in the text (and not dependent on the label). The footnote reference is a link to the footnote, and from the footnote
29-
* there is a link back to the reference (or multiple).
30-
* <p>
31-
* There is also optional support for inline footnotes, use {@link #builder()} and then set {@link Builder#inlineFootnotes}.
3223
*
33-
* @see <a href="https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#footnotes">GitHub docs for footnotes</a>
24+
* <p>The line with <code>[^1]: ...</code> is a {@link FootnoteDefinition}, with the contents as
25+
* child nodes (can be a paragraph like in the example, or other blocks like lists).
26+
*
27+
* <p>All the footnotes (definitions) will be rendered in a list at the end of a document, no matter
28+
* where they appear in the source. The footnotes will be numbered starting from 1, then 2, etc,
29+
* depending on the order in which they appear in the text (and not dependent on the label). The
30+
* footnote reference is a link to the footnote, and from the footnote there is a link back to the
31+
* reference (or multiple).
32+
*
33+
* <p>There is also optional support for inline footnotes, use {@link #builder()} and then set
34+
* {@link Builder#inlineFootnotes}.
35+
*
36+
* @see <a
37+
* href="https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#footnotes">GitHub
38+
* docs for footnotes</a>
3439
*/
35-
public class FootnotesExtension implements Parser.ParserExtension,
36-
HtmlRenderer.HtmlRendererExtension,
37-
MarkdownRenderer.MarkdownRendererExtension {
40+
public class FootnotesExtension
41+
implements Parser.ParserExtension,
42+
HtmlRenderer.HtmlRendererExtension,
43+
MarkdownRenderer.MarkdownRendererExtension {
3844

3945
private final boolean inlineFootnotes;
4046

4147
private FootnotesExtension(boolean inlineFootnotes) {
4248
this.inlineFootnotes = inlineFootnotes;
4349
}
4450

45-
/**
46-
* The extension with the default configuration (no support for inline footnotes).
47-
*/
51+
/** The extension with the default configuration (no support for inline footnotes). */
4852
public static Extension create() {
4953
return builder().build();
5054
}
@@ -70,17 +74,18 @@ public void extend(HtmlRenderer.Builder rendererBuilder) {
7074

7175
@Override
7276
public void extend(MarkdownRenderer.Builder rendererBuilder) {
73-
rendererBuilder.nodeRendererFactory(new MarkdownNodeRendererFactory() {
74-
@Override
75-
public NodeRenderer create(MarkdownNodeRendererContext context) {
76-
return new FootnoteMarkdownNodeRenderer(context);
77-
}
77+
rendererBuilder.nodeRendererFactory(
78+
new MarkdownNodeRendererFactory() {
79+
@Override
80+
public NodeRenderer create(MarkdownNodeRendererContext context) {
81+
return new FootnoteMarkdownNodeRenderer(context);
82+
}
7883

79-
@Override
80-
public Set<Character> getSpecialCharacters() {
81-
return Set.of();
82-
}
83-
});
84+
@Override
85+
public Set<Character> getSpecialCharacters() {
86+
return Set.of();
87+
}
88+
});
8489
}
8590

8691
public static class Builder {
@@ -89,6 +94,7 @@ public static class Builder {
8994

9095
/**
9196
* Enable support for inline footnotes without definitions, e.g.:
97+
*
9298
* <pre>
9399
* Some text^[this is an inline footnote]
94100
* </pre>

commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/InlineFootnote.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
import org.commonmark.node.CustomNode;
44

5-
public class InlineFootnote extends CustomNode {
6-
}
5+
public class InlineFootnote extends CustomNode {}

0 commit comments

Comments
 (0)