| 1 |
use super::*; |
| 2 |
|
| 3 |
#[test] |
| 4 |
fn description_lists_loose() { |
| 5 |
html_opts!( |
| 6 |
[extension.description_lists], |
| 7 |
concat!( |
| 8 |
"Term 1\n", |
| 9 |
"\n", |
| 10 |
": Definition 1\n", |
| 11 |
"\n", |
| 12 |
"Term 2 with *inline markup*\n", |
| 13 |
"\n", |
| 14 |
": Definition 2\n" |
| 15 |
), |
| 16 |
concat!( |
| 17 |
"<dl>\n", |
| 18 |
"<dt>Term 1</dt>\n", |
| 19 |
"<dd>\n", |
| 20 |
"<p>Definition 1</p>\n", |
| 21 |
"</dd>\n", |
| 22 |
"<dt>Term 2 with <em>inline markup</em></dt>\n", |
| 23 |
"<dd>\n", |
| 24 |
"<p>Definition 2</p>\n", |
| 25 |
"</dd>\n", |
| 26 |
"</dl>\n", |
| 27 |
), |
| 28 |
); |
| 29 |
|
| 30 |
html_opts!( |
| 31 |
[extension.description_lists], |
| 32 |
concat!( |
| 33 |
"* Nested\n", |
| 34 |
"\n", |
| 35 |
" Term 1\n\n", |
| 36 |
" : Definition 1\n\n", |
| 37 |
" Term 2 with *inline markup*\n\n", |
| 38 |
" : Definition 2\n\n" |
| 39 |
), |
| 40 |
concat!( |
| 41 |
"<ul>\n", |
| 42 |
"<li>\n", |
| 43 |
"<p>Nested</p>\n", |
| 44 |
"<dl>\n", |
| 45 |
"<dt>Term 1</dt>\n", |
| 46 |
"<dd>\n", |
| 47 |
"<p>Definition 1</p>\n", |
| 48 |
"</dd>\n", |
| 49 |
"<dt>Term 2 with <em>inline markup</em></dt>\n", |
| 50 |
"<dd>\n", |
| 51 |
"<p>Definition 2</p>\n", |
| 52 |
"</dd>\n", |
| 53 |
"</dl>\n", |
| 54 |
"</li>\n", |
| 55 |
"</ul>\n", |
| 56 |
), |
| 57 |
); |
| 58 |
} |
| 59 |
|
| 60 |
#[test] |
| 61 |
fn description_lists_tight() { |
| 62 |
html_opts!( |
| 63 |
[extension.description_lists], |
| 64 |
concat!( |
| 65 |
"Term 1\n", |
| 66 |
": Definition 1\n", |
| 67 |
"\n", |
| 68 |
"Term 2 with *inline markup*\n", |
| 69 |
": Definition 2\n" |
| 70 |
), |
| 71 |
concat!( |
| 72 |
"<dl>\n", |
| 73 |
"<dt>Term 1</dt>\n", |
| 74 |
"<dd>Definition 1</dd>\n", |
| 75 |
"<dt>Term 2 with <em>inline markup</em></dt>\n", |
| 76 |
"<dd>Definition 2</dd>\n", |
| 77 |
"</dl>\n", |
| 78 |
), |
| 79 |
no_roundtrip, |
| 80 |
); |
| 81 |
|
| 82 |
html_opts!( |
| 83 |
[extension.description_lists], |
| 84 |
concat!( |
| 85 |
"* Nested\n", |
| 86 |
"\n", |
| 87 |
" Term 1\n", |
| 88 |
" : Definition 1\n\n", |
| 89 |
" Term 2 with *inline markup*\n", |
| 90 |
" : Definition 2\n\n" |
| 91 |
), |
| 92 |
concat!( |
| 93 |
"<ul>\n", |
| 94 |
"<li>\n", |
| 95 |
"<p>Nested</p>\n", |
| 96 |
"<dl>\n", |
| 97 |
"<dt>Term 1</dt>\n", |
| 98 |
"<dd>Definition 1</dd>\n", |
| 99 |
"<dt>Term 2 with <em>inline markup</em></dt>\n", |
| 100 |
"<dd>Definition 2</dd>\n", |
| 101 |
"</dl>\n", |
| 102 |
"</li>\n", |
| 103 |
"</ul>\n", |
| 104 |
), |
| 105 |
no_roundtrip, |
| 106 |
); |
| 107 |
} |
| 108 |
#[test] |
| 109 |
fn description_lists_edge_cases() { |
| 110 |
html_opts!([extension.description_lists], ":", "<p>:</p>\n",); |
| 111 |
|
| 112 |
html_opts!([extension.description_lists], ": foo", "<p>: foo</p>\n",); |
| 113 |
|
| 114 |
html_opts!([extension.description_lists], "a\n:", "<p>a\n:</p>\n",); |
| 115 |
|
| 116 |
html_opts!( |
| 117 |
[extension.description_lists], |
| 118 |
concat!("- foo\n", "- : bar\n", " - baz\n",), |
| 119 |
concat!( |
| 120 |
"<ul>\n", |
| 121 |
"<li>foo</li>\n", |
| 122 |
"<li>: bar\n", |
| 123 |
"<ul>\n", |
| 124 |
"<li>baz</li>\n", |
| 125 |
"</ul>\n", |
| 126 |
"</li>\n", |
| 127 |
"</ul>\n", |
| 128 |
), |
| 129 |
); |
| 130 |
} |
| 131 |
|
| 132 |
#[test] |
| 133 |
fn sourcepos() { |
| 134 |
assert_ast_match!( |
| 135 |
[extension.description_lists], |
| 136 |
"ta\n" |
| 137 |
"\n" |
| 138 |
": da\n" |
| 139 |
"\n" |
| 140 |
"t*b*\n" |
| 141 |
"\n" |
| 142 |
": d*b*\n" |
| 143 |
"\n" |
| 144 |
"tc\n" |
| 145 |
"\n" |
| 146 |
": dc\n", |
| 147 |
(document (1:1-11:4) [ |
| 148 |
(description_list (1:1-11:4) [ |
| 149 |
(description_item (1:1-3:4) [ |
| 150 |
(description_term (1:1-1:2) [ |
| 151 |
(paragraph (1:1-1:2) [ |
| 152 |
(text (1:1-1:2) "ta") |
| 153 |
]) |
| 154 |
]) |
| 155 |
(description_details (3:1-3:4) [ |
| 156 |
(paragraph (3:3-3:4) [ |
| 157 |
(text (3:3-3:4) "da") |
| 158 |
]) |
| 159 |
]) |
| 160 |
]) |
| 161 |
(description_item (5:1-7:6) [ |
| 162 |
(description_term (5:1-5:4) [ |
| 163 |
(paragraph (5:1-5:4) [ |
| 164 |
(text (5:1-5:1) "t") |
| 165 |
(emph (5:2-5:4) [ |
| 166 |
(text (5:3-5:3) "b") |
| 167 |
]) |
| 168 |
]) |
| 169 |
]) |
| 170 |
(description_details (7:1-7:6) [ |
| 171 |
(paragraph (7:3-7:6) [ |
| 172 |
(text (7:3-7:3) "d") |
| 173 |
(emph (7:4-7:6) [ |
| 174 |
(text (7:5-7:5) "b") |
| 175 |
]) |
| 176 |
]) |
| 177 |
]) |
| 178 |
]) |
| 179 |
(description_item (9:1-11:4) [ |
| 180 |
(description_term (9:1-9:2) [ |
| 181 |
(paragraph (9:1-9:2) [ |
| 182 |
(text (9:1-9:2) "tc") |
| 183 |
]) |
| 184 |
]) |
| 185 |
(description_details (11:1-11:4) [ |
| 186 |
(paragraph (11:3-11:4) [ |
| 187 |
(text (11:3-11:4) "dc") |
| 188 |
]) |
| 189 |
]) |
| 190 |
]) |
| 191 |
]) |
| 192 |
]) |
| 193 |
); |
| 194 |
} |