extern crate micromark; use micromark::{micromark, micromark_with_options, Options}; #[test] fn image() { assert_eq!( micromark("[link](/uri \"title\")"), "
", "should support links" ); assert_eq!( micromark("![foo](/url \"title\")"), "", "should support image w/ resource" ); // To do: attention. // assert_eq!( // micromark("[foo *bar*]: train.jpg \"train & tracks\"\n\n![foo *bar*]"), // "", // "should support image as shortcut reference" // ); assert_eq!( micromark("![foo ![bar](/url)](/url2)"), "", "should “support” images in images" ); assert_eq!( micromark("![foo [bar](/url)](/url2)"), "", "should “support” links in images" ); // To do: attention. // assert_eq!( // micromark("[foo *bar*]: train.jpg \"train & tracks\"\n\n![foo *bar*][]"), // "", // "should support “content” in images" // ); // To do: attention. // assert_eq!( // micromark("[FOOBAR]: train.jpg \"train & tracks\"\n\n![foo *bar*][foobar]"), // "", // "should support “content” in images" // ); assert_eq!( micromark("![foo](train.jpg)"), "", "should support images w/o title" ); assert_eq!( micromark("My ![foo bar](/path/to/train.jpg \"title\" )"), "My
", "should support images w/ lots of whitespace" ); assert_eq!( micromark("![foo](\n[]
", "should not support whitespace between sets of brackets" ); assert_eq!( micromark("[foo]: /url \"title\"\n\n![foo]"), "", "should support shortcut references (1)" ); // To do: attention. // assert_eq!( // micromark("[*foo* bar]: /url \"title\"\n\n![*foo* bar]"), // "", // "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" ); assert_eq!( micromark("[foo]: /url \"title\"\n\n![Foo]"), "", "should support case-insensitive label matching" ); assert_eq!( micromark("[foo]: /url \"title\"\n\n!\\[foo]"), "![foo]
", "should “support” an escaped bracket instead of an image" ); 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]()"), "", "should support images w/o destination" ); assert_eq!( micromark("![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 \"\")"), "", "should support images w/ empty title (1)" ); assert_eq!( micromark("![alpha](bravo.png '')"), "", "should support images w/ empty title (2)" ); assert_eq!( micromark("![alpha](bravo.png ())"), "", "should support images w/ empty title (3)" ); assert_eq!( micromark("![&©&](example.com/&©& \"&©&\")"), "", "should support character references in images" ); // Extra // See:!x
", // "should support turning off label start (image)" // ); assert_eq!( micromark("![](javascript:alert(1))"), "", "should ignore non-http protocols by default" ); assert_eq!( micromark_with_options( "![](javascript:alert(1))", &Options { allow_dangerous_protocol: true, allow_dangerous_html: false, default_line_ending: None } ), "", "should allow non-http protocols w/ `allowDangerousProtocol`" ); }