extern crate micromark; use micromark::{micromark, micromark_with_options, Options}; const DANGER: &Options = &Options { allow_dangerous_html: true, allow_dangerous_protocol: true, default_line_ending: None, }; #[test] fn autolink() { assert_eq!( micromark("```\n<\n >\n```"), "
<\n >\n
",
"should support fenced code w/ grave accents"
);
assert_eq!(
micromark("http://foo.bar.baz/test?q=hello&id=22&boolean
", "should support protocol autolinks (2)" ); assert_eq!( micromark("<http://foo.bar/baz bim>
", "should not support protocol autolinks w/ spaces" ); assert_eq!( micromark("<foo+@bar.example.com>
", "should not support character escapes in email autolinks" ); assert_eq!( micromark("<>"), "<>
", "should not support empty autolinks" ); assert_eq!( micromark("< http://foo.bar >"), "< http://foo.bar >
", "should not support autolinks w/ space" ); assert_eq!( micromark("<m:abc>
", "should not support autolinks w/ a single character for a scheme" ); assert_eq!( micromark("<foo.bar.baz>
", "should not support autolinks w/o a colon or at sign" ); assert_eq!( micromark("http://example.com"), "http://example.com
", "should not support protocol autolinks w/o angle brackets" ); assert_eq!( micromark("foo@bar.example.com"), "foo@bar.example.com
", "should not support email autolinks w/o angle brackets" ); // Extra: assert_eq!( micromark("<*@example.com>"), "", "should support autolinks w/ atext (1)" ); assert_eq!( micromark(""), "", "should support autolinks w/ atext (2)" ); assert_eq!( micromark("<aaa©@example.com>
", "should support non-atext in email autolinks local part (1)" ); assert_eq!( micromark(""), "<a*a©@example.com>
", "should support non-atext in email autolinks local part (2)" ); assert_eq!( micromark("<asd@.example.com>
", "should not support a dot after an at sign in email autolinks" ); assert_eq!( micromark("<asd@e..xample.com>
", "should not support a dot after another dot in email autolinks" ); assert_eq!( micromark( "asd@012345678901234567890123456789012345678901234567890123456789012
", "should support 63 character in email autolinks domains" ); assert_eq!( micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123>
", "should not support 64 character in email autolinks domains" ); assert_eq!( micromark( "asd@012345678901234567890123456789012345678901234567890123456789012.a
", "should support a TLD after a 63 character domain in email autolinks" ); assert_eq!( micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123.a>
", "should not support a TLD after a 64 character domain in email autolinks" ); assert_eq!( micromark( "asd@a.012345678901234567890123456789012345678901234567890123456789012
", "should support a 63 character TLD in email autolinks" ); assert_eq!( micromark("<asd@a.0123456789012345678901234567890123456789012345678901234567890123>
", "should not support a 64 character TLD in email autolinks" ); assert_eq!( micromark("<asd@-example.com>
", "should not support a dash after `@` in email autolinks" ); assert_eq!( micromark("<asd@example-.com>
", "should not support a dash before a dot in email autolinks" ); // To do: turning things off. // assert_eq!( // micromark("", {extensions: [{disable: {null: ["autolink"]}}]}), // "<a@b.co>
", // "should support turning off autolinks" // ); }