use super::*; #[test] fn autolink_www() { html_opts!( [extension.autolink], "www.autolink.com\n", "

www.autolink.com

\n", ); } #[test] fn autolink_email() { html_opts!( [extension.autolink], "john@smith.com\n", "

john@smith.com

\n", ); } #[test] fn autolink_scheme() { html_opts!( [extension.autolink], concat!("https://google.com/search\n", "rdar://localhost.com/blah"), concat!( "

https://google.com/search\n", "rdar://localhost.com/blah

\n" ), ); } #[test] fn autolink_scheme_multiline() { html_opts!( [extension.autolink], "https://google.com/search\nhttps://www.google.com/maps", "

https://google.com/search\nhttps://www.google.com/maps

\n", ); } #[test] fn autolink_no_link_bad() { html_opts!( [extension.autolink], concat!("@a.b.c@. x\n", "\n", "n@. x\n"), concat!("

@a.b.c@. x

\n", "

n@. x

\n"), ); } #[test] fn autolink_parentheses_balanced() { let examples = [ [ "http://www.pokemon.com/Pikachu_(Electric)", "

http://www.pokemon.com/Pikachu_(Electric)

\n", ], [ "http://www.pokemon.com/Pikachu_((Electric)", "

http://www.pokemon.com/Pikachu_((Electric)

\n", ], [ "http://www.pokemon.com/Pikachu_(Electric))", "

http://www.pokemon.com/Pikachu_(Electric))

\n", ], [ "http://www.pokemon.com/Pikachu_((Electric))", "

http://www.pokemon.com/Pikachu_((Electric))

\n", ], ]; for example in examples { html_opts!([extension.autolink], example[0], example[1]); } for example in examples { html_opts!( [extension.autolink, parse.relaxed_autolinks], example[0], example[1] ); } } #[test] fn autolink_brackets_unbalanced() { html_opts!( [extension.autolink], "http://example.com/[abc]]...\n", "

http://example.com/[abc]]...

\n", ); } #[test] fn autolink_ignore_links_in_brackets() { let examples = [ ["[https://foo.com]", "

[https://foo.com]

\n"], ["[[https://foo.com]]", "

[[https://foo.com]]

\n"], [ "[[Foo|https://foo.com]]", "

[[Foo|https://foo.com]]

\n", ], [ "[]", "

[https://foo.com]

\n", ], ]; for example in examples { html_opts!([extension.autolink], example[0], example[1], no_roundtrip); } } #[test] fn autolink_relaxed_links_in_brackets() { let examples = [ [ "[https://foo.com]", "

[https://foo.com]

\n", ], [ "[[https://foo.com]]", "

[[https://foo.com]]

\n", ], [ "[[Foo|https://foo.com]]", "

[[Foo|https://foo.com]]

\n", ], [ "[]", "

[https://foo.com]

\n", ], [ "[http://foo.com/](url)", "

http://foo.com/

\n", ], ["[http://foo.com/](url", "

[http://foo.com/](url

\n"], [ "[www.foo.com/](url)", "

www.foo.com/

\n", ], [ "{https://foo.com}", "

{https://foo.com}

\n", ], [ "[this http://and.com that](url)", "

this http://and.com that

\n", ], [ "[this that](url)", "

this http://and.com that

\n", ], [ "{this http://and.com that}(url)", "

{this http://and.com that}(url)

\n", ], [ "[http://foo.com](url)\n[http://bar.com]\n\n[http://bar.com]: http://bar.com/extra", "

http://foo.com\nhttp://bar.com

\n", ], ]; for example in examples { html_opts!( [extension.autolink, parse.relaxed_autolinks], example[0], example[1] ); } } #[test] fn autolink_relaxed_links_brackets_balanced() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "http://example.com/[abc]]...\n", "

http://example.com/[abc]]...

\n", ); } #[test] fn autolink_relaxed_links_curly_braces_balanced() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "http://example.com/{abc}}...\n", "

http://example.com/{abc}}...

\n", ); } #[test] fn autolink_relaxed_links_curly_parentheses_balanced() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "http://example.com/(abc))...\n", "

http://example.com/(abc))...

\n", ); } #[test] fn autolink_relaxed_links_schemes() { let examples = [ [ "https://foo.com", "

https://foo.com

\n", ], [ "smb:///Volumes/shared/foo.pdf", "

smb:///Volumes/shared/foo.pdf

\n", ], [ "irc://irc.freenode.net/git", "

irc://irc.freenode.net/git

\n", ], [ "rdar://localhost.com/blah", "

rdar://localhost.com/blah

\n", ], ]; for example in examples { html_opts!( [extension.autolink, parse.relaxed_autolinks], example[0], example[1] ); } } #[test] fn sourcepos_correctly_restores_context() { assert_ast_match!( [], "ab _cde_ f@g.ee h*ijklm* n", (document (1:1-1:26) [ (paragraph (1:1-1:26) [ (text (1:1-1:3) "ab ") (emph (1:4-1:8) [ (text (1:5-1:7) "cde") ]) (text (1:9-1:17) " f@g.ee h") (emph (1:18-1:24) [ (text (1:19-1:23) "ijklm") ]) (text (1:25-1:26) " n") ]) ]) ); assert_ast_match!( [extension.autolink], "ab _cde_ f@g.ee h*ijklm* n", (document (1:1-1:26) [ (paragraph (1:1-1:26) [ (text (1:1-1:3) "ab ") (emph (1:4-1:8) [ (text (1:5-1:7) "cde") ]) (text (1:9-1:9) " ") (link (1:10-1:15) "mailto:f@g.ee" [ (text (1:10-1:15) "f@g.ee") ]) (text (1:16-1:17) " h") (emph (1:18-1:24) [ (text (1:19-1:23) "ijklm") ]) (text (1:25-1:26) " n") ]) ]) ); } #[test] fn autolink_cmark_edge_382() { html_opts!( [extension.autolink], "See <<<http://example.com/>>>", "

See <<<http://example.com/>>>

\n", ); } #[test] fn autolink_cmark_edge_388() { html_opts!( [extension.autolink], "http://example.com/src/_mocks_/vscode.js", "

http://example.com/src/_mocks_/vscode.js

\n", ); } #[test] fn autolink_cmark_edge_423() { html_opts!( [extension.autolink, extension.strikethrough], concat!( "Here's an autolink: ", "https://www.unicode.org/review/pri453/feedback.html#:~:text=Fri%20Jun%2024%2009:56:01%20CDT%202022", " and another one ", "https://www.unicode.org/review/pri453/feedback.html#:~:text=Fri%20Jun%2024%2009:56:01%20CDT%202022", ".", ), concat!( "

Here's an autolink: ", r#""#, "https://www.unicode.org/review/pri453/feedback.html#:~:text=Fri%20Jun%2024%2009:56:01%20CDT%202022", " and another one ", r#""#, "https://www.unicode.org/review/pri453/feedback.html#:~:text=Fri%20Jun%2024%2009:56:01%20CDT%202022", ".

\n", ), ); } #[test] fn autolink_cmark_edge_58() { html_opts!( [extension.autolink, extension.superscript], "https://www.wolframalpha.com/input/?i=x^2+(y-(x^2)^(1/3))^2=1", concat!( "

", r#""#, "https://www.wolframalpha.com/input/?i=x^2+(y-(x^2)^(1/3))^2=1", "

\n", ), ); } #[test] fn autolink_failing_spec_image() { html_opts!( [extension.autolink], "![http://inline.com/image](http://inline.com/image)", "

\"http://inline.com/image\"

\n", ); } #[test] fn autolink_failing_spec_underscores() { html_opts!( [extension.autolink], "Underscores not allowed in host name www.xxx.yyy._zzz", "

Underscores not allowed in host name www.xxx.yyy._zzz

\n", ); } #[test] fn autolink_fuzz_leading_colon() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "://-", "

://-

\n", no_roundtrip, ); } #[test] fn autolink_fuzz_we() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "we://w", "

we://w

\n", no_roundtrip, ); } #[test] fn autolink_sourcepos() { assert_ast_match!( [extension.autolink], "a www.makea.fish x\n" "\n" "b https://www.com y\n" "\n" "c foo@www.com z\n" , (document (1:1-5:17) [ (paragraph (1:1-1:20) [ (text (1:1-1:3) "a ") (link (1:4-1:17) "http://www.makea.fish" [ (text (1:4-1:17) "www.makea.fish") ]) (text (1:18-1:20) " x") ]) (paragraph (3:1-3:21) [ (text (3:1-3:3) "b ") (link (3:4-3:18) "https://www.com" [ (text (3:4-3:18) "https://www.com") ]) (text (3:19-3:21) " y") ]) (paragraph (5:1-5:17) [ (text (5:1-5:3) "c ") (link (5:4-5:14) "mailto:foo@www.com" [ (text (5:4-5:14) "foo@www.com") ]) (text (5:15-5:17) " z") ]) ]) ); } #[test] fn autolink_consecutive_email() { assert_ast_match!( [extension.autolink], "scyther@pokemon.com/beedrill@pokemon.com", (document (1:1-1:40) [ (paragraph (1:1-1:40) [ (link (1:1-1:19) "mailto:scyther@pokemon.com" [ (text (1:1-1:19) "scyther@pokemon.com") ]) (text (1:20-1:20) "/") (link (1:21-1:40) "mailto:beedrill@pokemon.com" [ (text (1:21-1:40) "beedrill@pokemon.com") ]) ]) ]) ); } #[test] fn autolink_consecutive_email_smart() { assert_ast_match!( [extension.autolink, parse.smart], "scyther@pokemon.com--beedrill@pokemon.com", (document (1:1-1:41) [ (paragraph (1:1-1:41) [ (link (1:1-1:19) "mailto:scyther@pokemon.com" [ (text (1:1-1:19) "scyther@pokemon.com") ]) (text (1:20-1:21) "–") // en-dash (link (1:22-1:41) "mailto:beedrill@pokemon.com" [ (text (1:22-1:41) "beedrill@pokemon.com") ]) ]) ]) ); } #[test] fn autolink_not_generated_inside_links() { html_opts!( [extension.autolink], "[Contact user@example.com for help](http://support.example.com)", "

Contact user@example.com for help

\n", ); html_opts!( [extension.autolink], "[Visit https://www.example.com](http://example.com)", "

Visit https://www.example.com

\n", ); html_opts!( [extension.autolink], "[Check out www.example.com](http://example.com)", "

Check out www.example.com

\n", ); } #[test] fn autolink_not_generated_inside_images() { // Test that emails inside image alt text don't become autolinks html_opts!( [extension.autolink], "![Contact user@example.com](image.png)", "

\"Contact

\n", ); html_opts!( [extension.autolink], "![Visit https://www.example.com](image.png)", "

\"Visit

\n", ); html_opts!( [extension.autolink], "![Check www.example.com](image.png)", "

\"Check

\n", ); } #[test] fn autolink_not_generated_inside_wikilinks() { html_opts!( [extension.autolink, extension.wikilinks_title_after_pipe], "[[http://example.com|Contact user@example.com]]", "

Contact user@example.com

\n", ); html_opts!( [extension.autolink, extension.wikilinks_title_after_pipe], "[[http://example.com|Visit https://www.example.com]]", "

Visit https://www.example.com

\n", ); html_opts!( [extension.autolink, extension.wikilinks_title_before_pipe], "[[Check www.example.com|http://example.com]]", "

Check www.example.com

\n", ); } #[test] fn ipv6_host_scoped() { html_opts!( [extension.autolink, parse.relaxed_autolinks], "scoped https://[fe80::1ff:fe23:4567:890a%25eth2]", "

scoped https://[fe80::1ff:fe23:4567:890a%25eth2]

\n", ); } #[test] fn ipv6_relaxed() { html_opts!( [extension.autolink], "hi: nex://[fe80::1ff:fe23:4567:890a%25eth2]/z/x", "

hi: nex://[fe80::1ff:fe23:4567:890a%25eth2]/z/x

\n", ); html_opts!( [extension.autolink, parse.relaxed_autolinks], "hi: nex://[fe80::1ff:fe23:4567:890a%25eth2]/z/x", "

hi: nex://[fe80::1ff:fe23:4567:890a%25eth2]/z/x

\n", ); } #[test] fn autolink_bare_www() { html_opts!( [extension.autolink], "foo www. foo", "

foo www. foo

\n", ); html_opts!( [extension.autolink, parse.relaxed_autolinks], "foo www. foo", "

foo www. foo

\n", ); } #[test] fn autolink_bare_scheme() { html_opts!( [extension.autolink], "foo http:// foo", "

foo http:// foo

\n", ); html_opts!( [extension.autolink, parse.relaxed_autolinks], "foo http:// foo", "

foo http:// foo

\n", ); } #[test] fn autolink_with_unicode_isolation() { html_opts!( [extension.autolink], "https://www.example.com/", "

https://www.example.com/

\n", ); html_opts!( [extension.autolink], "\u{2068}https://www.example.com/\u{2069}", "

\u{2068}https://www.example.com/\u{2069}

\n", ); }