use super::*; #[test] fn pointy_brace() { html_opts!( [render.r#unsafe], concat!( "URI autolink: \n", "\n", "Email autolink: \n", "\n", "* Inline tag **ha**.\n", "* Inline **ha**.\n", "* Inline **ha**.\n", "* Inline **ha**.\n", "* Inline **ha**.\n" ), concat!( "

URI autolink: https://www.pixiv.net

\n", "

Email autolink: bill@microsoft.com

\n", "\n" ), ); } #[test] fn no_control_characters_in_reference_links() { html( "[A]:\u{1b}\n\nX [A] Y\n", "

[A]:\u{1b}

\n

X [A] Y

\n", ) } #[test] fn link_entity_regression() { html( "[link](javascript:alert('XSS'))", "

link

\n", ); } #[test] fn regression_back_to_back_ranges() { html( "**bold*****bold+italic***", "

boldbold+italic

\n", ); } #[test] fn no_panic_on_empty_bookended_atx_headers() { html("# #", "

\n"); } #[test] fn no_stack_smash_html() { let s: String = ">".repeat(150_000); let arena = Arena::new(); let root = parse_document(&arena, &s, &Options::default()); let mut output = String::new(); html::format_document(root, &Options::default(), &mut output).unwrap() } #[test] fn no_stack_smash_cm() { let s: String = ">".repeat(150_000); let arena = Arena::new(); let root = parse_document(&arena, &s, &Options::default()); let mut output = String::new(); cm::format_document(root, &Options::default(), &mut output).unwrap() } #[test] fn cm_autolink_regression() { // Testing that the cm renderer handles this case without crashing html("", "

a+c:dd

\n"); } #[test] fn regression_424() { html( "*text* [link](#section)", "

text link

\n", ); } #[test] fn example_61() { html( r##" `Foo ---- ` "##, r##"

`Foo

`

<a title="a lot

of dashes"/>

"##, ); } #[test] fn nul_at_eof() { html("foo\0", "

foo\u{fffd}

\n"); html("foo\0nl", "

foo\u{fffd}nl

\n"); html("foo\0nl\0", "

foo\u{fffd}nl\u{fffd}

\n"); } #[test] fn sourcepos_para() { html_opts!( [render.sourcepos], "abc\ndef\n\nghi\n", "

abc\ndef

\n

ghi

\n", ); } #[test] #[cfg(feature = "shortcodes")] fn gemoji() { html_opts!([extension.shortcodes], ":x:", "

❌

\n"); } #[test] fn sourcepos_lone_backtick() { assert_ast_match!( [], "``\n", (document (1:1-1:2) [ (paragraph (1:1-1:2) [ (text (1:1-1:2) "``") ]) ]) ); } #[ignore] // This one will require a bit of thinking. #[test] fn sourcepos_link_items() { assert_ast_match!( [], "- ab\n" "- cdef\n" "\n" "\n" "g\n" , (document (1:1-5:1) [ (list (1:1-2:6) [ (item (1:1-1:4) [ (paragraph (1:3-1:4) [ (text (1:3-1:4) "ab") ]) ]) (item (2:1-2:6) [ (paragraph (2:3-2:6) [ (text (2:3-2:6) "cdef") ]) ]) ]) (paragraph (5:1-5:1) [ (text (5:1-5:1) "g") ]) ]) ); } #[test] fn assorted_links() { assert_ast_match!( [extension.autolink], r#"hello world hello [foo](https://example.com) world hello [foo] world hello [bar][bar] world hello https://example.com/foo world hello www.example.com world hello foo@example.com world [foo]: https://example.com [bar]: https://example.com"#, (document (1:1-10:26) [ (paragraph (1:1-7:27) [ (text (1:1-1:6) "hello ") (link (1:7-1:32) "https://example.com/fooo" [ (text (1:8-1:31) "https://example.com/fooo") ]) (text (1:33-1:38) " world") (softbreak (1:39-1:39)) (text (2:1-2:6) "hello ") (link (2:7-2:32) "https://example.com" [ (text (2:8-2:10) "foo") ]) (text (2:33-2:38) " world") (softbreak (2:39-2:39)) (text (3:1-3:6) "hello ") (link (3:7-3:11) "https://example.com" [ (text (3:8-3:10) "foo") ]) (text (3:12-3:17) " world") (softbreak (3:18-3:18)) (text (4:1-4:6) "hello ") (link (4:7-4:16) "https://example.com" [ (text (4:8-4:10) "bar") ]) (text (4:17-4:22) " world") (softbreak (4:23-4:23)) (text (5:1-5:6) "hello ") (link (5:7-5:29) "https://example.com/foo" [ (text (5:7-5:29) "https://example.com/foo") ]) (text (5:30-5:35) " world") (softbreak (5:36-5:36)) (text (6:1-6:6) "hello ") (link (6:7-6:21) "http://www.example.com" [ (text (6:7-6:21) "www.example.com") ]) (text (6:22-6:27) " world") (softbreak (6:28-6:28)) (text (7:1-7:6) "hello ") (link (7:7-7:21) "mailto:foo@example.com" [ (text (7:7-7:21) "foo@example.com") ]) (text (7:22-7:27) " world") ]) ]) ); } #[test] fn autolink_between_escaped_chars() { assert_ast_match!( [extension.autolink], "a.b-c\\_d@a.b\\_\n", (document (1:1-1:14) [ (paragraph (1:1-1:14) [ (text (1:1-1:7) "a.b-c_") (link (1:8-1:12) "mailto:d@a.b" [ (text (1:8-1:12) "d@a.b") ]) (text (1:14-1:14) "_") ]) ]) ); } #[test] fn sourcepos_newline_kinds() { assert_ast_match!( [], "LF\n" "CRLF\r\n" "CR\r" "end.", (document (1:1-4:4) [ (paragraph (1:1-4:4) [ (text (1:1-1:2) "LF") (softbreak (1:3-1:3)) (text (2:1-2:4) "CRLF") (softbreak (2:5-2:6)) (text (3:1-3:2) "CR") (softbreak (3:3-3:3)) (text (4:1-4:4) "end.") ]) ]) ); } #[test] fn hex_entity_digit_limit() { // 6 hex digits: valid html("A\n", "

A

\n"); // 7 hex digits: invalid, should be literal html("A\n", "

&#x0000041;

\n"); // 7 decimal digits: valid (decimal 100 = 'd') html("d\n", "

d

\n"); }