-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from commonmark/spec-0.31
Update spec to 0.31.2
- Loading branch information
Showing
10 changed files
with
202 additions
and
167 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
commonmark-integration-test/src/test/java/org/commonmark/integration/Extensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.commonmark.integration; | ||
|
||
import org.commonmark.Extension; | ||
import org.commonmark.ext.autolink.AutolinkExtension; | ||
import org.commonmark.ext.front.matter.YamlFrontMatterExtension; | ||
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension; | ||
import org.commonmark.ext.gfm.tables.TablesExtension; | ||
import org.commonmark.ext.image.attributes.ImageAttributesExtension; | ||
import org.commonmark.ext.ins.InsExtension; | ||
import org.commonmark.ext.task.list.items.TaskListItemsExtension; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Extensions { | ||
|
||
static final List<Extension> ALL_EXTENSIONS = Arrays.asList( | ||
AutolinkExtension.create(), | ||
ImageAttributesExtension.create(), | ||
InsExtension.create(), | ||
StrikethroughExtension.create(), | ||
TablesExtension.create(), | ||
TaskListItemsExtension.create(), | ||
YamlFrontMatterExtension.create()); | ||
} |
37 changes: 37 additions & 0 deletions
37
...-integration-test/src/test/java/org/commonmark/integration/ExtensionsIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.commonmark.integration; | ||
|
||
import org.commonmark.parser.Parser; | ||
import org.commonmark.renderer.html.HtmlRenderer; | ||
import org.commonmark.testutil.RenderingTestCase; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests to ensure all extensions work well together. | ||
*/ | ||
public class ExtensionsIntegrationTest extends RenderingTestCase { | ||
|
||
protected static final Parser PARSER = Parser.builder() | ||
.extensions(Extensions.ALL_EXTENSIONS) | ||
.build(); | ||
protected static final HtmlRenderer RENDERER = HtmlRenderer.builder() | ||
.extensions(Extensions.ALL_EXTENSIONS) | ||
.percentEncodeUrls(true) | ||
.build(); | ||
|
||
@Test | ||
public void testImageAttributes() { | ||
assertRendering("![text](/url.png){height=5 width=6}", "<p><img src=\"/url.png\" alt=\"text\" height=\"5\" width=\"6\" /></p>\n"); | ||
} | ||
|
||
@Test | ||
public void testTaskListItems() { | ||
assertRendering("- [ ] task to do\n- [x] task done\n", | ||
"<ul>\n<li><input type=\"checkbox\" disabled=\"\"> task to do</li>\n" + | ||
"<li><input type=\"checkbox\" disabled=\"\" checked=\"\"> task done</li>\n</ul>\n"); | ||
|
||
} | ||
|
||
protected String render(String source) { | ||
return RENDERER.render(PARSER.parse(source)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
package org.commonmark.integration; | ||
|
||
import org.commonmark.Extension; | ||
import org.commonmark.ext.autolink.AutolinkExtension; | ||
import org.commonmark.ext.image.attributes.ImageAttributesExtension; | ||
import org.commonmark.ext.ins.InsExtension; | ||
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension; | ||
import org.commonmark.ext.gfm.tables.TablesExtension; | ||
import org.commonmark.ext.front.matter.YamlFrontMatterExtension; | ||
import org.commonmark.ext.task.list.items.TaskListItemsExtension; | ||
import org.commonmark.renderer.html.HtmlRenderer; | ||
import org.commonmark.parser.Parser; | ||
import org.commonmark.testutil.example.Example; | ||
import org.commonmark.testutil.SpecTestCase; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.*; | ||
|
@@ -24,17 +15,9 @@ | |
*/ | ||
public class SpecIntegrationTest extends SpecTestCase { | ||
|
||
protected static final List<Extension> EXTENSIONS = Arrays.asList( | ||
AutolinkExtension.create(), | ||
ImageAttributesExtension.create(), | ||
InsExtension.create(), | ||
StrikethroughExtension.create(), | ||
TablesExtension.create(), | ||
TaskListItemsExtension.create(), | ||
YamlFrontMatterExtension.create()); | ||
protected static final Parser PARSER = Parser.builder().extensions(EXTENSIONS).build(); | ||
protected static final Parser PARSER = Parser.builder().extensions(Extensions.ALL_EXTENSIONS).build(); | ||
// The spec says URL-escaping is optional, but the examples assume that it's enabled. | ||
protected static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(EXTENSIONS).percentEncodeUrls(true).build(); | ||
protected static final HtmlRenderer RENDERER = HtmlRenderer.builder().extensions(Extensions.ALL_EXTENSIONS).percentEncodeUrls(true).build(); | ||
protected static final Map<String, String> OVERRIDDEN_EXAMPLES = getOverriddenExamples(); | ||
|
||
public SpecIntegrationTest(Example example) { | ||
|
@@ -59,7 +42,7 @@ private static Map<String, String> getOverriddenExamples() { | |
Map<String, String> m = new HashMap<>(); | ||
|
||
// Not a spec autolink because of space, but the resulting text contains a valid URL | ||
m.put("<http://foo.bar/baz bim>\n", "<p><<a href=\"http://foo.bar/baz\">http://foo.bar/baz</a> bim></p>\n"); | ||
m.put("<https://foo.bar/baz bim>\n", "<p><<a href=\"https://foo.bar/baz\">https://foo.bar/baz</a> bim></p>\n"); | ||
|
||
// Not a spec autolink, but the resulting text contains a valid email | ||
m.put("<foo\\[email protected]>\n", "<p><<a href=\"mailto:[email protected]\">[email protected]</a>></p>\n"); | ||
|
@@ -68,10 +51,10 @@ private static Map<String, String> getOverriddenExamples() { | |
m.put("<heck://bing.bong>\n", "<p><<a href=\"heck://bing.bong%3E\">heck://bing.bong></a></p>\n"); | ||
|
||
// Not a spec autolink because of spaces, but autolink extension doesn't limit schemes | ||
m.put("< http://foo.bar >\n", "<p>< <a href=\"http://foo.bar\">http://foo.bar</a> ></p>\n"); | ||
m.put("< https://foo.bar >\n", "<p>< <a href=\"https://foo.bar\">https://foo.bar</a> ></p>\n"); | ||
|
||
// Plain autolink | ||
m.put("http://example.com\n", "<p><a href=\"http://example.com\">http://example.com</a></p>\n"); | ||
m.put("https://example.com\n", "<p><a href=\"https://example.com\">https://example.com</a></p>\n"); | ||
|
||
// Plain autolink | ||
m.put("[email protected]\n", "<p><a href=\"mailto:[email protected]\">[email protected]</a></p>\n"); | ||
|
@@ -80,13 +63,6 @@ private static Map<String, String> getOverriddenExamples() { | |
m.put("---\nFoo\n---\nBar\n---\nBaz\n", "<h2>Bar</h2>\n<p>Baz</p>\n"); | ||
m.put("---\n---\n", ""); | ||
|
||
// Image attributes | ||
m.put("![text](/url.png){height=5 width=6}", "<img src=\"/url.png\" alt=\"text\" height=\"5\" width=\"6\" />"); | ||
|
||
// Task list items | ||
m.put("- [ ] task to do\n- [x] task done\n", "<ul>\n<li><input type=\"checkbox\" disabled=\"\"> task to do</li>\n" + | ||
"<li><input type=\"checkbox\" disabled=\"\" checked=\"\"> task done</li>\n</ul>\n"); | ||
|
||
return m; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.