extern crate micromark; use micromark::micromark; #[test] fn image() { assert_eq!( micromark("[link](/uri \"title\")"), "

link

", "should support links" ); assert_eq!( micromark("![foo](/url \"title\")"), "

\"foo\"

", "should support image w/ resource" ); // To do: attention. // assert_eq!( // micromark("[foo *bar*]: train.jpg \"train & tracks\"\n\n![foo *bar*]"), // "

\"foo

", // "should support image as shortcut reference" // ); // To do: tags in images. // assert_eq!( // micromark("![foo ![bar](/url)](/url2)"), // "

\"foo

", // "should “support” images in images" // ); // To do: tags in images. // assert_eq!( // micromark("![foo [bar](/url)](/url2)"), // "

\"foo

", // "should “support” links in images" // ); // To do: tags in images. // assert_eq!( // micromark("[foo *bar*]: train.jpg \"train & tracks\"\n\n![foo *bar*][]"), // "

\"foo

", // "should support “content” in images" // ); // To do: tags in images, attention, references. // assert_eq!( // micromark("[FOOBAR]: train.jpg \"train & tracks\"\n\n![foo *bar*][foobar]"), // "

\"foo

", // "should support “content” in images" // ); assert_eq!( micromark("![foo](train.jpg)"), "

\"foo\"

", "should support images w/o title" ); assert_eq!( micromark("My ![foo bar](/path/to/train.jpg \"title\" )"), "

My \"foo

", "should support images w/ lots of whitespace" ); assert_eq!( micromark("![foo]()"), "

\"foo\"

", "should support images w/ enclosed destinations" ); assert_eq!( micromark("![](/url)"), "

\"\"

", "should support images w/ empty labels" ); // To do: references. // assert_eq!( // micromark("[bar]: /url\n\n![foo][bar]"), // "

\"foo\"

", // "should support full references (1)" // ); // To do: references. // assert_eq!( // micromark("[BAR]: /url\n\n![foo][bar]"), // "

\"foo\"

", // "should support full references (2)" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n![foo][]"), // "

\"foo\"

", // "should support collapsed references (1)" // ); // To do: references, attention, tags in images. // assert_eq!( // micromark("[*foo* bar]: /url \"title\"\n\n![*foo* bar][]"), // "

\"foo

", // "should support collapsed references (2)" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n![Foo][]"), // "

\"Foo\"

", // "should support case-insensitive labels" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n![foo] \n[]"), // "

\"foo\"\n[]

", // "should not support whitespace between sets of brackets" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n![foo]"), // "

\"foo\"

", // "should support shortcut references (1)" // ); // To do: references, tags in images, attention. // assert_eq!( // micromark("[*foo* bar]: /url \"title\"\n\n![*foo* bar]"), // "

\"foo

", // "should support shortcut references (2)" // ); assert_eq!( micromark("[[foo]]: /url \"title\"\n\n![[foo]]"), "

[[foo]]: /url "title"

\n

![[foo]]

", "should not support link labels w/ unescaped brackets" ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n![Foo]"), // "

\"Foo\"

", // "should support case-insensitive label matching" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n!\\[foo]"), // "

![foo]

", // "should “support” an escaped bracket instead of an image" // ); // To do: references. // assert_eq!( // micromark("[foo]: /url \"title\"\n\n\\![foo]"), // "

!foo

", // "should support an escaped bang instead of an image, but still have a link" // ); // Extra assert_eq!( micromark("![foo]()"), "

\"foo\"

", "should support images w/o destination" ); assert_eq!( micromark("![foo](<>)"), "

\"foo\"

", "should support images w/ explicit empty destination" ); assert_eq!( micromark("![](example.png)"), "

\"\"

", "should support images w/o alt" ); assert_eq!( micromark("![alpha](bravo.png \"\")"), "

\"alpha\"

", "should support images w/ empty title (1)" ); assert_eq!( micromark("![alpha](bravo.png '')"), "

\"alpha\"

", "should support images w/ empty title (2)" ); assert_eq!( micromark("![alpha](bravo.png ())"), "

\"alpha\"

", "should support images w/ empty title (3)" ); assert_eq!( micromark("![&©&](example.com/&©& \"&©&\")"), "

\"&©&\"

", "should support character references in images" ); // Extra // See: assert_eq!( micromark("![](<> \"\")"), "

\"\"

", "should ignore an empty title" ); // To do: extensions // assert_eq!( // micromark("![x]()", {extensions: [{disable: {null: ["labelStartImage"]}}]}), // "

!x

", // "should support turning off label start (image)" // ); assert_eq!( micromark("![](javascript:alert(1))"), "

\"\"

", "should ignore non-http protocols by default" ); // To do: extensions // assert_eq!( // micromark("![](javascript:alert(1))", {allowDangerousProtocol: true}), // "

\"\"

", // "should allow non-http protocols w/ `allowDangerousProtocol`" // ); }