aboutsummaryrefslogtreecommitdiffstats
path: root/tests/autolink.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/autolink.rs')
-rw-r--r--tests/autolink.rs88
1 files changed, 44 insertions, 44 deletions
diff --git a/tests/autolink.rs b/tests/autolink.rs
index d2b0956..1b20e08 100644
--- a/tests/autolink.rs
+++ b/tests/autolink.rs
@@ -1,7 +1,7 @@
-extern crate micromark;
-use micromark::{
+extern crate markdown;
+use markdown::{
mdast::{Link, Node, Paragraph, Root, Text},
- micromark, micromark_to_mdast, micromark_with_options,
+ to_html, to_html_with_options, to_mdast,
unist::Position,
CompileOptions, Constructs, Options, ParseOptions,
};
@@ -19,241 +19,241 @@ fn autolink() -> Result<(), String> {
};
assert_eq!(
- micromark("<http://foo.bar.baz>"),
+ to_html("<http://foo.bar.baz>"),
"<p><a href=\"http://foo.bar.baz\">http://foo.bar.baz</a></p>",
"should support protocol autolinks (1)"
);
assert_eq!(
- micromark("<http://foo.bar.baz/test?q=hello&id=22&boolean>"),
+ to_html("<http://foo.bar.baz/test?q=hello&id=22&boolean>"),
"<p><a href=\"http://foo.bar.baz/test?q=hello&amp;id=22&amp;boolean\">http://foo.bar.baz/test?q=hello&amp;id=22&amp;boolean</a></p>",
"should support protocol autolinks (2)"
);
assert_eq!(
- micromark("<irc://foo.bar:2233/baz>"),
+ to_html("<irc://foo.bar:2233/baz>"),
"<p><a href=\"irc://foo.bar:2233/baz\">irc://foo.bar:2233/baz</a></p>",
"should support protocol autolinks w/ non-HTTP schemes"
);
assert_eq!(
- micromark("<MAILTO:FOO@BAR.BAZ>"),
+ to_html("<MAILTO:FOO@BAR.BAZ>"),
"<p><a href=\"MAILTO:FOO@BAR.BAZ\">MAILTO:FOO@BAR.BAZ</a></p>",
"should support protocol autolinks in uppercase"
);
assert_eq!(
- micromark("<a+b+c:d>"),
+ to_html("<a+b+c:d>"),
"<p><a href=\"\">a+b+c:d</a></p>",
"should support protocol autolinks w/ incorrect URIs (1, default)"
);
assert_eq!(
- micromark_with_options("<a+b+c:d>", &danger)?,
+ to_html_with_options("<a+b+c:d>", &danger)?,
"<p><a href=\"a+b+c:d\">a+b+c:d</a></p>",
"should support protocol autolinks w/ incorrect URIs (1, danger)"
);
assert_eq!(
- micromark("<made-up-scheme://foo,bar>"),
+ to_html("<made-up-scheme://foo,bar>"),
"<p><a href=\"\">made-up-scheme://foo,bar</a></p>",
"should support protocol autolinks w/ incorrect URIs (2, default)"
);
assert_eq!(
- micromark_with_options("<made-up-scheme://foo,bar>", &danger)?,
+ to_html_with_options("<made-up-scheme://foo,bar>", &danger)?,
"<p><a href=\"made-up-scheme://foo,bar\">made-up-scheme://foo,bar</a></p>",
"should support protocol autolinks w/ incorrect URIs (2, danger)"
);
assert_eq!(
- micromark("<http://../>"),
+ to_html("<http://../>"),
"<p><a href=\"http://../\">http://../</a></p>",
"should support protocol autolinks w/ incorrect URIs (3)"
);
assert_eq!(
- micromark_with_options("<localhost:5001/foo>", &danger)?,
+ to_html_with_options("<localhost:5001/foo>", &danger)?,
"<p><a href=\"localhost:5001/foo\">localhost:5001/foo</a></p>",
"should support protocol autolinks w/ incorrect URIs (4)"
);
assert_eq!(
- micromark("<http://foo.bar/baz bim>"),
+ to_html("<http://foo.bar/baz bim>"),
"<p>&lt;http://foo.bar/baz bim&gt;</p>",
"should not support protocol autolinks w/ spaces"
);
assert_eq!(
- micromark("<http://example.com/\\[\\>"),
+ to_html("<http://example.com/\\[\\>"),
"<p><a href=\"http://example.com/%5C%5B%5C\">http://example.com/\\[\\</a></p>",
"should not support character escapes in protocol autolinks"
);
assert_eq!(
- micromark("<foo@bar.example.com>"),
+ to_html("<foo@bar.example.com>"),
"<p><a href=\"mailto:foo@bar.example.com\">foo@bar.example.com</a></p>",
"should support email autolinks (1)"
);
assert_eq!(
- micromark("<foo+special@Bar.baz-bar0.com>"),
+ to_html("<foo+special@Bar.baz-bar0.com>"),
"<p><a href=\"mailto:foo+special@Bar.baz-bar0.com\">foo+special@Bar.baz-bar0.com</a></p>",
"should support email autolinks (2)"
);
assert_eq!(
- micromark("<a@b.c>"),
+ to_html("<a@b.c>"),
"<p><a href=\"mailto:a@b.c\">a@b.c</a></p>",
"should support email autolinks (3)"
);
assert_eq!(
- micromark("<foo\\+@bar.example.com>"),
+ to_html("<foo\\+@bar.example.com>"),
"<p>&lt;foo+@bar.example.com&gt;</p>",
"should not support character escapes in email autolinks"
);
assert_eq!(
- micromark("<>"),
+ to_html("<>"),
"<p>&lt;&gt;</p>",
"should not support empty autolinks"
);
assert_eq!(
- micromark("< http://foo.bar >"),
+ to_html("< http://foo.bar >"),
"<p>&lt; http://foo.bar &gt;</p>",
"should not support autolinks w/ space"
);
assert_eq!(
- micromark("<m:abc>"),
+ to_html("<m:abc>"),
"<p>&lt;m:abc&gt;</p>",
"should not support autolinks w/ a single character for a scheme"
);
assert_eq!(
- micromark("<foo.bar.baz>"),
+ to_html("<foo.bar.baz>"),
"<p>&lt;foo.bar.baz&gt;</p>",
"should not support autolinks w/o a colon or at sign"
);
assert_eq!(
- micromark("http://example.com"),
+ to_html("http://example.com"),
"<p>http://example.com</p>",
"should not support protocol autolinks w/o angle brackets"
);
assert_eq!(
- micromark("foo@bar.example.com"),
+ to_html("foo@bar.example.com"),
"<p>foo@bar.example.com</p>",
"should not support email autolinks w/o angle brackets"
);
// Extra:
assert_eq!(
- micromark("<*@example.com>"),
+ to_html("<*@example.com>"),
"<p><a href=\"mailto:*@example.com\">*@example.com</a></p>",
"should support autolinks w/ atext (1)"
);
assert_eq!(
- micromark("<a*@example.com>"),
+ to_html("<a*@example.com>"),
"<p><a href=\"mailto:a*@example.com\">a*@example.com</a></p>",
"should support autolinks w/ atext (2)"
);
assert_eq!(
- micromark("<aa*@example.com>"),
+ to_html("<aa*@example.com>"),
"<p><a href=\"mailto:aa*@example.com\">aa*@example.com</a></p>",
"should support autolinks w/ atext (3)"
);
assert_eq!(
- micromark("<aaa©@example.com>"),
+ to_html("<aaa©@example.com>"),
"<p>&lt;aaa©@example.com&gt;</p>",
"should support non-atext in email autolinks local part (1)"
);
assert_eq!(
- micromark("<a*a©@example.com>"),
+ to_html("<a*a©@example.com>"),
"<p>&lt;a*a©@example.com&gt;</p>",
"should support non-atext in email autolinks local part (2)"
);
assert_eq!(
- micromark("<asd@.example.com>"),
+ to_html("<asd@.example.com>"),
"<p>&lt;asd@.example.com&gt;</p>",
"should not support a dot after an at sign in email autolinks"
);
assert_eq!(
- micromark("<asd@e..xample.com>"),
+ to_html("<asd@e..xample.com>"),
"<p>&lt;asd@e..xample.com&gt;</p>",
"should not support a dot after another dot in email autolinks"
);
assert_eq!(
- micromark(
+ to_html(
"<asd@012345678901234567890123456789012345678901234567890123456789012>"),
"<p><a href=\"mailto:asd@012345678901234567890123456789012345678901234567890123456789012\">asd@012345678901234567890123456789012345678901234567890123456789012</a></p>",
"should support 63 character in email autolinks domains"
);
assert_eq!(
- micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123>"),
+ to_html("<asd@0123456789012345678901234567890123456789012345678901234567890123>"),
"<p>&lt;asd@0123456789012345678901234567890123456789012345678901234567890123&gt;</p>",
"should not support 64 character in email autolinks domains"
);
assert_eq!(
- micromark(
+ to_html(
"<asd@012345678901234567890123456789012345678901234567890123456789012.a>"),
"<p><a href=\"mailto:asd@012345678901234567890123456789012345678901234567890123456789012.a\">asd@012345678901234567890123456789012345678901234567890123456789012.a</a></p>",
"should support a TLD after a 63 character domain in email autolinks"
);
assert_eq!(
- micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123.a>"),
+ to_html("<asd@0123456789012345678901234567890123456789012345678901234567890123.a>"),
"<p>&lt;asd@0123456789012345678901234567890123456789012345678901234567890123.a&gt;</p>",
"should not support a TLD after a 64 character domain in email autolinks"
);
assert_eq!(
- micromark(
+ to_html(
"<asd@a.012345678901234567890123456789012345678901234567890123456789012>"),
"<p><a href=\"mailto:asd@a.012345678901234567890123456789012345678901234567890123456789012\">asd@a.012345678901234567890123456789012345678901234567890123456789012</a></p>",
"should support a 63 character TLD in email autolinks"
);
assert_eq!(
- micromark("<asd@a.0123456789012345678901234567890123456789012345678901234567890123>"),
+ to_html("<asd@a.0123456789012345678901234567890123456789012345678901234567890123>"),
"<p>&lt;asd@a.0123456789012345678901234567890123456789012345678901234567890123&gt;</p>",
"should not support a 64 character TLD in email autolinks"
);
assert_eq!(
- micromark("<asd@-example.com>"),
+ to_html("<asd@-example.com>"),
"<p>&lt;asd@-example.com&gt;</p>",
"should not support a dash after `@` in email autolinks"
);
assert_eq!(
- micromark("<asd@e-xample.com>"),
+ to_html("<asd@e-xample.com>"),
"<p><a href=\"mailto:asd@e-xample.com\">asd@e-xample.com</a></p>",
"should support a dash after other domain characters in email autolinks"
);
assert_eq!(
- micromark("<asd@e--xample.com>"),
+ to_html("<asd@e--xample.com>"),
"<p><a href=\"mailto:asd@e--xample.com\">asd@e--xample.com</a></p>",
"should support a dash after another dash in email autolinks"
);
assert_eq!(
- micromark("<asd@example-.com>"),
+ to_html("<asd@example-.com>"),
"<p>&lt;asd@example-.com&gt;</p>",
"should not support a dash before a dot in email autolinks"
);
assert_eq!(
- micromark_with_options(
+ to_html_with_options(
"<a@b.co>",
&Options {
parse: ParseOptions {
@@ -271,7 +271,7 @@ fn autolink() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast(
+ to_mdast(
"a <https://alpha.com> b <bravo@charlie.com> c.",
&ParseOptions::default()
)?,