From ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 10:40:01 +0200 Subject: Rename crate to `markdown` --- tests/link_resource.rs | 156 ++++++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 78 deletions(-) (limited to 'tests/link_resource.rs') diff --git a/tests/link_resource.rs b/tests/link_resource.rs index 4554d86..5f9cddc 100644 --- a/tests/link_resource.rs +++ b/tests/link_resource.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, Options, ParseOptions, }; @@ -19,455 +19,455 @@ fn link_resource() -> Result<(), String> { }; assert_eq!( - micromark("[link](/uri \"title\")"), + to_html("[link](/uri \"title\")"), "

link

", "should support links" ); assert_eq!( - micromark("[link](/uri)"), + to_html("[link](/uri)"), "

link

", "should support links w/o title" ); assert_eq!( - micromark("[link]()"), + to_html("[link]()"), "

link

", "should support links w/o destination" ); assert_eq!( - micromark("[link](<>)"), + to_html("[link](<>)"), "

link

", "should support links w/ empty enclosed destination" ); assert_eq!( - micromark("[link](/my uri)"), + to_html("[link](/my uri)"), "

[link](/my uri)

", "should not support links w/ spaces in destination" ); assert_eq!( - micromark("[link]()"), + to_html("[link]()"), "

link

", "should support links w/ spaces in enclosed destination" ); assert_eq!( - micromark("[link](foo\nbar)"), + to_html("[link](foo\nbar)"), "

[link](foo\nbar)

", "should not support links w/ line endings in destination" ); assert_eq!( - micromark_with_options("[link]()", &danger)?, + to_html_with_options("[link]()", &danger)?, "

[link]()

", "should not support links w/ line endings in enclosed destination" ); assert_eq!( - micromark("[a]()"), + to_html("[a]()"), "

a

", "should support links w/ closing parens in destination" ); assert_eq!( - micromark("[link]()"), + to_html("[link]()"), "

[link](<foo>)

", "should not support links w/ enclosed destinations w/o end" ); assert_eq!( - micromark_with_options("[a](\n[a](c)", &danger)?, + to_html_with_options("[a](\n[a](c)", &danger)?, "

[a](<b)c\n[a](<b)c>\n[a](c)

", "should not support links w/ unmatched enclosed destinations" ); assert_eq!( - micromark("[link](\\(foo\\))"), + to_html("[link](\\(foo\\))"), "

link

", "should support links w/ destinations w/ escaped parens" ); assert_eq!( - micromark("[link](foo(and(bar)))"), + to_html("[link](foo(and(bar)))"), "

link

", "should support links w/ destinations w/ balanced parens" ); assert_eq!( - micromark("[link](foo\\(and\\(bar\\))"), + to_html("[link](foo\\(and\\(bar\\))"), "

link

", "should support links w/ destinations w/ escaped parens" ); assert_eq!( - micromark("[link]()"), + to_html("[link]()"), "

link

", "should support links w/ enclosed destinations w/ parens" ); assert_eq!( - micromark_with_options("[link](foo\\)\\:)", &danger)?, + to_html_with_options("[link](foo\\)\\:)", &danger)?, "

link

", "should support links w/ escapes in destinations" ); assert_eq!( - micromark("[link](#fragment)"), + to_html("[link](#fragment)"), "

link

", "should support links w/ destinations to fragments" ); assert_eq!( - micromark("[link](http://example.com#fragment)"), + to_html("[link](http://example.com#fragment)"), "

link

", "should support links w/ destinations to URLs w/ fragments" ); assert_eq!( - micromark("[link](http://example.com?foo=3#frag)"), + to_html("[link](http://example.com?foo=3#frag)"), "

link

", "should support links w/ destinations to URLs w/ search and fragments" ); assert_eq!( - micromark("[link](foo\\bar)"), + to_html("[link](foo\\bar)"), "

link

", "should not support non-punctuation character escapes in links" ); assert_eq!( - micromark("[link](foo%20bä)"), + to_html("[link](foo%20bä)"), "

link

", "should support character references in links" ); assert_eq!( - micromark("[link](\"title\")"), + to_html("[link](\"title\")"), "

link

", "should not support links w/ only a title" ); assert_eq!( - micromark("[link](/url \"title\")"), + to_html("[link](/url \"title\")"), "

link

", "should support titles w/ double quotes" ); assert_eq!( - micromark("[link](/url 'title')"), + to_html("[link](/url 'title')"), "

link

", "should support titles w/ single quotes" ); assert_eq!( - micromark("[link](/url (title))"), + to_html("[link](/url (title))"), "

link

", "should support titles w/ parens" ); assert_eq!( - micromark("[link](/url \"title \\\""\")"), + to_html("[link](/url \"title \\\""\")"), "

link

", "should support character references and escapes in titles" ); assert_eq!( - micromark("[link](/url \"title\")"), + to_html("[link](/url \"title\")"), "

link

", "should not support unicode whitespace between destination and title" ); assert_eq!( - micromark("[link](/url \"title \"and\" title\")"), + to_html("[link](/url \"title \"and\" title\")"), "

[link](/url "title "and" title")

", "should not support nested balanced quotes in title" ); assert_eq!( - micromark("[link](/url 'title \"and\" title')"), + to_html("[link](/url 'title \"and\" title')"), "

link

", "should support the other quotes in titles" ); assert_eq!( - micromark("[link]( /uri\n \"title\" )"), + to_html("[link]( /uri\n \"title\" )"), "

link

", "should support whitespace around destination and title (1)" ); assert_eq!( - micromark("[link](\t\n/uri \"title\")"), + to_html("[link](\t\n/uri \"title\")"), "

link

", "should support whitespace around destination and title (2)" ); assert_eq!( - micromark("[link](/uri \"title\"\t\n)"), + to_html("[link](/uri \"title\"\t\n)"), "

link

", "should support whitespace around destination and title (3)" ); assert_eq!( - micromark("[link] (/uri)"), + to_html("[link] (/uri)"), "

[link] (/uri)

", "should not support whitespace between label and resource" ); assert_eq!( - micromark("[link [foo [bar]]](/uri)"), + to_html("[link [foo [bar]]](/uri)"), "

link [foo [bar]]

", "should support balanced brackets" ); assert_eq!( - micromark("[link] bar](/uri)"), + to_html("[link] bar](/uri)"), "

[link] bar](/uri)

", "should not support unbalanced brackets (1)" ); assert_eq!( - micromark("[link [bar](/uri)"), + to_html("[link [bar](/uri)"), "

[link bar

", "should not support unbalanced brackets (2)" ); assert_eq!( - micromark("[link \\[bar](/uri)"), + to_html("[link \\[bar](/uri)"), "

link [bar

", "should support characer escapes" ); assert_eq!( - micromark("[link *foo **bar** `#`*](/uri)"), + to_html("[link *foo **bar** `#`*](/uri)"), "

link foo bar #

", "should support content" ); assert_eq!( - micromark("[![moon](moon.jpg)](/uri)"), + to_html("[![moon](moon.jpg)](/uri)"), "

\"moon\"

", "should support an image as content" ); assert_eq!( - micromark("[foo [bar](/uri)](/uri)"), + to_html("[foo [bar](/uri)](/uri)"), "

[foo bar](/uri)

", "should not support links in links (1)" ); assert_eq!( - micromark("[foo *[bar [baz](/uri)](/uri)*](/uri)"), + to_html("[foo *[bar [baz](/uri)](/uri)*](/uri)"), "

[foo [bar baz](/uri)](/uri)

", "should not support links in links (2)" ); assert_eq!( - micromark("![[[foo](uri1)](uri2)](uri3)"), + to_html("![[[foo](uri1)](uri2)](uri3)"), "

\"[foo](uri2)\"

", "should not support links in links (3)" ); assert_eq!( - micromark("*[foo*](/uri)"), + to_html("*[foo*](/uri)"), "

*foo*

", "should prefer links over emphasis (1)" ); assert_eq!( - micromark("[foo *bar](baz*)"), + to_html("[foo *bar](baz*)"), "

foo *bar

", "should prefer links over emphasis (2)" ); assert_eq!( - micromark_with_options("[foo ", &danger)?, + to_html_with_options("[foo ", &danger)?, "

[foo

", "should prefer HTML over links" ); assert_eq!( - micromark("[foo`](/uri)`"), + to_html("[foo`](/uri)`"), "

[foo](/uri)

", "should prefer code over links" ); assert_eq!( - micromark("[foo"), + to_html("[foo"), "

[foohttp://example.com/?search=](uri)

", "should prefer autolinks over links" ); assert_eq!( - micromark("[foo"), + to_html("[foo"), "

[foohttp://example.com/?search=](uri)

", "should prefer autolinks over links" ); // Extra assert_eq!( - micromark("[]()"), + to_html("[]()"), "

", "should support an empty link" ); // See: assert_eq!( - micromark("[](<> \"\")"), + to_html("[](<> \"\")"), "

", "should ignore an empty title" ); assert_eq!( - micromark_with_options("[a](\"c\")", &danger)?, + to_html_with_options("[a](\"c\")", &danger)?, "

[a]("c")

", "should require whitespace between enclosed destination and title" ); assert_eq!( - micromark("[](<"), + to_html("[](<"), "

[](<

", "should not support an unclosed enclosed destination" ); assert_eq!( - micromark("[]("), + to_html("[]("), "

[](

", "should not support an unclosed destination" ); assert_eq!( - micromark("[](\\<)"), + to_html("[](\\<)"), "

", "should support unenclosed link destination starting w/ escapes" ); assert_eq!( - micromark("[](<\\<>)"), + to_html("[](<\\<>)"), "

", "should support enclosed link destination starting w/ escapes" ); assert_eq!( - micromark("[](\\"), + to_html("[](\\"), "

[](\\

", "should not support unenclosed link destination starting w/ an incorrect escape" ); assert_eq!( - micromark("[](<\\"), + to_html("[](<\\"), "

[](<\\

", "should not support enclosed link destination starting w/ an incorrect escape" ); assert_eq!( - micromark("[](a \""), + to_html("[](a \""), "

[](a "

", "should not support an eof in a link title (1)" ); assert_eq!( - micromark("[](a '"), + to_html("[](a '"), "

[](a '

", "should not support an eof in a link title (2)" ); assert_eq!( - micromark("[](a ("), + to_html("[](a ("), "

[](a (

", "should not support an eof in a link title (3)" ); assert_eq!( - micromark("[](a \"\\"), + to_html("[](a \"\\"), "

[](a "\\

", "should not support an eof in a link title escape (1)" ); assert_eq!( - micromark("[](a '\\"), + to_html("[](a '\\"), "

[](a '\\

", "should not support an eof in a link title escape (2)" ); assert_eq!( - micromark("[](a (\\"), + to_html("[](a (\\"), "

[](a (\\

", "should not support an eof in a link title escape (3)" ); assert_eq!( - micromark("[](a \"\\\"\")"), + to_html("[](a \"\\\"\")"), "

", "should support a character escape to start a link title (1)" ); assert_eq!( - micromark("[](a '\\'')"), + to_html("[](a '\\'')"), "

", "should support a character escape to start a link title (2)" ); assert_eq!( - micromark("[](a (\\)))"), + to_html("[](a (\\)))"), "

", "should support a character escape to start a link title (3)" ); assert_eq!( - micromark("[&©&](example.com/&©& \"&©&\")"), + to_html("[&©&](example.com/&©& \"&©&\")"), "

&©&

", "should support character references in links" ); assert_eq!( - micromark("[a](1())"), + to_html("[a](1())"), "

a

", "should support 1 set of parens" ); assert_eq!( - micromark("[a](1(2()))"), + to_html("[a](1(2()))"), "

a

", "should support 2 sets of parens" ); assert_eq!( - micromark( + to_html( "[a](1(2(3(4(5(6(7(8(9(10(11(12(13(14(15(16(17(18(19(20(21(22(23(24(25(26(27(28(29(30(31(32()))))))))))))))))))))))))))))))))"), "

a

", "should support 32 sets of parens" ); assert_eq!( - micromark( + to_html( "[a](1(2(3(4(5(6(7(8(9(10(11(12(13(14(15(16(17(18(19(20(21(22(23(24(25(26(27(28(29(30(31(32(33())))))))))))))))))))))))))))))))))"), "

[a](1(2(3(4(5(6(7(8(9(10(11(12(13(14(15(16(17(18(19(20(21(22(23(24(25(26(27(28(29(30(31(32(33())))))))))))))))))))))))))))))))))

", "should not support 33 or more sets of parens" ); assert_eq!( - micromark("[a](b \"\n c\")"), + to_html("[a](b \"\n c\")"), "

a

", "should support an eol at the start of a title" ); assert_eq!( - micromark("[a](b( \"c\")"), + to_html("[a](b( \"c\")"), "

[a](b( "c")

", "should not support whitespace when unbalanced in a raw destination" ); assert_eq!( - micromark("[a](\0)"), + to_html("[a](\0)"), "

a

", "should support a single NUL character as a link resource" ); assert_eq!( - micromark_to_mdast( + to_mdast( "a [alpha]() b [bravo](charlie 'delta') c.", &ParseOptions::default() )?, -- cgit