Debian Codegraph @

src/tests/header_id_prefix.rs

raw
1 use super::*;
2
3 #[test]
4 fn header_id_prefix() {
5 html_opts_i(
6 concat!(
7 "# Hi.\n",
8 "## Hi 1.\n",
9 "### Hi.\n",
10 "#### Hello.\n",
11 "##### Hi.\n",
12 "###### Hello.\n",
13 "# Isn't it grand?"
14 ),
15 concat!(
16 "<h1 id=\"user-content-hi\">Hi.<a href=\"#hi\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h1>\n",
17 "<h2 id=\"user-content-hi-1\">Hi 1.<a href=\"#hi-1\" aria-label=\"Link to heading 'Hi 1.'\" data-heading-content=\"Hi 1.\" class=\"anchor\"></a></h2>\n",
18 "<h3 id=\"user-content-hi-2\">Hi.<a href=\"#hi-2\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h3>\n",
19 "<h4 id=\"user-content-hello\">Hello.<a href=\"#hello\" aria-label=\"Link to heading 'Hello.'\" data-heading-content=\"Hello.\" class=\"anchor\"></a></h4>\n",
20 "<h5 id=\"user-content-hi-3\">Hi.<a href=\"#hi-3\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h5>\n",
21 "<h6 id=\"user-content-hello-1\">Hello.<a href=\"#hello-1\" aria-label=\"Link to heading 'Hello.'\" data-heading-content=\"Hello.\" class=\"anchor\"></a></h6>\n",
22 "<h1 id=\"user-content-isnt-it-grand\">Isn't it grand?<a href=\"#isnt-it-grand\" aria-label=\"Link to heading 'Isn't it grand?'\" data-heading-content=\"Isn't it grand?\" class=\"anchor\"></a></h1>\n"
23 ),
24 true,
25 |opts| opts.extension.header_id_prefix = Some("user-content-".to_owned()),
26 );
27 }
28
29 #[test]
30 fn header_ids_prefix_in_href() {
31 html_opts_i(
32 concat!(
33 "# Hi.\n",
34 "## Hi 1.\n",
35 "### Hi.\n",
36 "#### Hello.\n",
37 "##### Hi.\n",
38 "###### Hello.\n",
39 "# Isn't it grand?"
40 ),
41 concat!(
42 "<h1 id=\"user-content-hi\">Hi.<a href=\"#user-content-hi\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h1>\n",
43 "<h2 id=\"user-content-hi-1\">Hi 1.<a href=\"#user-content-hi-1\" aria-label=\"Link to heading 'Hi 1.'\" data-heading-content=\"Hi 1.\" class=\"anchor\"></a></h2>\n",
44 "<h3 id=\"user-content-hi-2\">Hi.<a href=\"#user-content-hi-2\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h3>\n",
45 "<h4 id=\"user-content-hello\">Hello.<a href=\"#user-content-hello\" aria-label=\"Link to heading 'Hello.'\" data-heading-content=\"Hello.\" class=\"anchor\"></a></h4>\n",
46 "<h5 id=\"user-content-hi-3\">Hi.<a href=\"#user-content-hi-3\" aria-label=\"Link to heading 'Hi.'\" data-heading-content=\"Hi.\" class=\"anchor\"></a></h5>\n",
47 "<h6 id=\"user-content-hello-1\">Hello.<a href=\"#user-content-hello-1\" aria-label=\"Link to heading 'Hello.'\" data-heading-content=\"Hello.\" class=\"anchor\"></a></h6>\n",
48 "<h1 id=\"user-content-isnt-it-grand\">Isn't it grand?<a href=\"#user-content-isnt-it-grand\" aria-label=\"Link to heading 'Isn't it grand?'\" data-heading-content=\"Isn't it grand?\" class=\"anchor\"></a></h1>\n"
49 ),
50 true,
51 |opts| {
52 opts.extension.header_id_prefix = Some("user-content-".to_owned());
53 opts.extension.header_id_prefix_in_href = true;
54 },
55 );
56 }
57
58 #[test]
59 fn header_id_prefix_in_href_without_prefix() {
60 // When header_id_prefix is None, header_id_prefix_in_href has no effect
61 html_opts_i("# Hi.\n", "<h1>Hi.</h1>\n", true, |opts| {
62 opts.extension.header_id_prefix_in_href = true;
63 });
64 }