| 1 |
use super::*; |
| 2 |
use pretty_assertions::assert_eq; |
| 3 |
|
| 4 |
#[test] |
| 5 |
fn tasklist() { |
| 6 |
html_opts!( |
| 7 |
[ |
| 8 |
render.r#unsafe, |
| 9 |
extension.tasklist, |
| 10 |
parse.relaxed_tasklist_matching |
| 11 |
], |
| 12 |
concat!( |
| 13 |
"* [ ] Red\n", |
| 14 |
"* [x] Green\n", |
| 15 |
"* [ ] `Blue`\n", |
| 16 |
"* [!] Papayawhip\n", |
| 17 |
"<!-- end list -->\n", |
| 18 |
"1. [ ] Bird\n", |
| 19 |
"2. [ ] McHale\n", |
| 20 |
"3. [x] Parish\n", |
| 21 |
"<!-- end list -->\n", |
| 22 |
"* [ ] Red\n", |
| 23 |
" * [x] Green\n", |
| 24 |
" * [ ] Blue\n" |
| 25 |
), |
| 26 |
concat!( |
| 27 |
"<ul>\n", |
| 28 |
"<li><input type=\"checkbox\" disabled=\"\" /> Red</li>\n", |
| 29 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Green</li>\n", |
| 30 |
"<li><input type=\"checkbox\" disabled=\"\" /> <code>Blue</code></li>\n", |
| 31 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Papayawhip</li>\n", |
| 32 |
"</ul>\n", |
| 33 |
"<!-- end list -->\n", |
| 34 |
"<ol>\n", |
| 35 |
"<li><input type=\"checkbox\" disabled=\"\" /> Bird</li>\n", |
| 36 |
"<li><input type=\"checkbox\" disabled=\"\" /> McHale</li>\n", |
| 37 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Parish</li>\n", |
| 38 |
"</ol>\n", |
| 39 |
"<!-- end list -->\n", |
| 40 |
"<ul>\n", |
| 41 |
"<li><input type=\"checkbox\" disabled=\"\" /> Red\n", |
| 42 |
"<ul>\n", |
| 43 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Green\n", |
| 44 |
"<ul>\n", |
| 45 |
"<li><input type=\"checkbox\" disabled=\"\" /> Blue</li>\n", |
| 46 |
"</ul>\n", |
| 47 |
"</li>\n", |
| 48 |
"</ul>\n", |
| 49 |
"</li>\n", |
| 50 |
"</ul>\n" |
| 51 |
), |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
#[test] |
| 56 |
fn tasklist_with_classes() { |
| 57 |
html_opts!( |
| 58 |
[ |
| 59 |
render.r#unsafe, |
| 60 |
extension.tasklist, |
| 61 |
render.tasklist_classes, |
| 62 |
parse.relaxed_tasklist_matching |
| 63 |
], |
| 64 |
concat!( |
| 65 |
"* [ ] Red\n", |
| 66 |
"* [x] Green\n", |
| 67 |
"* [ ] Blue\n", |
| 68 |
"* [!] Papayawhip\n", |
| 69 |
"<!-- end list -->\n", |
| 70 |
"1. [ ] Bird\n", |
| 71 |
"2. [ ] McHale\n", |
| 72 |
"3. [x] Parish\n", |
| 73 |
"<!-- end list -->\n", |
| 74 |
"* [ ] Red\n", |
| 75 |
" * [x] Green\n", |
| 76 |
" * [ ] Blue\n" |
| 77 |
), |
| 78 |
concat!( |
| 79 |
"<ul class=\"contains-task-list\">\n", |
| 80 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> Red</li>\n", |
| 81 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Green</li>\n", |
| 82 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> Blue</li>\n", |
| 83 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Papayawhip</li>\n", |
| 84 |
"</ul>\n", |
| 85 |
"<!-- end list -->\n", |
| 86 |
"<ol class=\"contains-task-list\">\n", |
| 87 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> Bird</li>\n", |
| 88 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> McHale</li>\n", |
| 89 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Parish</li>\n", |
| 90 |
"</ol>\n", |
| 91 |
"<!-- end list -->\n", |
| 92 |
"<ul class=\"contains-task-list\">\n", |
| 93 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> Red\n", |
| 94 |
"<ul class=\"contains-task-list\">\n", |
| 95 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Green\n", |
| 96 |
"<ul class=\"contains-task-list\">\n", |
| 97 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> Blue</li>\n", |
| 98 |
"</ul>\n", |
| 99 |
"</li>\n", |
| 100 |
"</ul>\n", |
| 101 |
"</li>\n", |
| 102 |
"</ul>\n" |
| 103 |
), |
| 104 |
); |
| 105 |
} |
| 106 |
|
| 107 |
#[test] |
| 108 |
fn tasklist_relaxed_regression() { |
| 109 |
html_opts!( |
| 110 |
[extension.tasklist, parse.relaxed_tasklist_matching], |
| 111 |
"* [!] Red\n", |
| 112 |
concat!( |
| 113 |
"<ul>\n", |
| 114 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Red</li>\n", |
| 115 |
"</ul>\n" |
| 116 |
), |
| 117 |
); |
| 118 |
|
| 119 |
html_opts!( |
| 120 |
[extension.tasklist], |
| 121 |
"* [!] Red\n", |
| 122 |
concat!("<ul>\n", "<li>[!] Red</li>\n", "</ul>\n"), |
| 123 |
); |
| 124 |
|
| 125 |
html_opts!( |
| 126 |
[extension.tasklist, parse.relaxed_tasklist_matching], |
| 127 |
"* [!] Red\n", |
| 128 |
concat!( |
| 129 |
"<ul>\n", |
| 130 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Red</li>\n", |
| 131 |
"</ul>\n" |
| 132 |
), |
| 133 |
); |
| 134 |
} |
| 135 |
|
| 136 |
#[test] |
| 137 |
fn tasklist_with_classes_relaxed_regression() { |
| 138 |
html_opts!( |
| 139 |
[ |
| 140 |
extension.tasklist, |
| 141 |
render.tasklist_classes, |
| 142 |
parse.relaxed_tasklist_matching |
| 143 |
], |
| 144 |
"* [!] Red\n", |
| 145 |
concat!( |
| 146 |
"<ul class=\"contains-task-list\">\n", |
| 147 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Red</li>\n", |
| 148 |
"</ul>\n" |
| 149 |
), |
| 150 |
); |
| 151 |
|
| 152 |
html_opts!( |
| 153 |
[extension.tasklist, render.tasklist_classes], |
| 154 |
"* [!] Red\n", |
| 155 |
concat!("<ul>\n", "<li>[!] Red</li>\n", "</ul>\n"), |
| 156 |
); |
| 157 |
|
| 158 |
html_opts!( |
| 159 |
[ |
| 160 |
extension.tasklist, |
| 161 |
render.tasklist_classes, |
| 162 |
parse.relaxed_tasklist_matching |
| 163 |
], |
| 164 |
"* [!] Red\n", |
| 165 |
concat!( |
| 166 |
"<ul class=\"contains-task-list\">\n", |
| 167 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> Red</li>\n", |
| 168 |
"</ul>\n" |
| 169 |
), |
| 170 |
); |
| 171 |
} |
| 172 |
|
| 173 |
#[test] |
| 174 |
fn tasklist_32() { |
| 175 |
html_opts!( |
| 176 |
[render.r#unsafe, extension.tasklist], |
| 177 |
concat!( |
| 178 |
"- [ ] List item 1\n", |
| 179 |
"- [ ] This list item is **bold**\n", |
| 180 |
"- [x] There is some `code` here\n" |
| 181 |
), |
| 182 |
concat!( |
| 183 |
"<ul>\n", |
| 184 |
"<li><input type=\"checkbox\" disabled=\"\" /> List item 1</li>\n", |
| 185 |
"<li><input type=\"checkbox\" disabled=\"\" /> This list item is <strong>bold</strong></li>\n", |
| 186 |
"<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> There is some <code>code</code> here</li>\n", |
| 187 |
"</ul>\n" |
| 188 |
), |
| 189 |
); |
| 190 |
} |
| 191 |
|
| 192 |
#[test] |
| 193 |
fn tasklist_32_with_classes() { |
| 194 |
html_opts!( |
| 195 |
[render.r#unsafe, extension.tasklist, render.tasklist_classes], |
| 196 |
concat!( |
| 197 |
"- [ ] List item 1\n", |
| 198 |
"- [ ] This list item is **bold**\n", |
| 199 |
"- [x] There is some `code` here\n" |
| 200 |
), |
| 201 |
concat!( |
| 202 |
"<ul class=\"contains-task-list\">\n", |
| 203 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> List item 1</li>\n", |
| 204 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"\" /> This list item is <strong>bold</strong></li>\n", |
| 205 |
"<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"\" disabled=\"\" /> There is some <code>code</code> here</li>\n", |
| 206 |
"</ul>\n" |
| 207 |
), |
| 208 |
); |
| 209 |
} |
| 210 |
|
| 211 |
#[test] |
| 212 |
fn tasklist_in_table() { |
| 213 |
html_opts!( |
| 214 |
[ |
| 215 |
extension.tasklist, |
| 216 |
extension.table, |
| 217 |
parse.tasklist_in_table, |
| 218 |
render.sourcepos |
| 219 |
], |
| 220 |
concat!( |
| 221 |
"| | name |\n", |
| 222 |
"| --- | ---- |\n", |
| 223 |
"| [ ] | Rell |\n", |
| 224 |
"| [x] | Kai |\n" |
| 225 |
), |
| 226 |
concat!( |
| 227 |
"<table data-sourcepos=\"1:1-4:14\">\n", |
| 228 |
"<thead>\n", |
| 229 |
"<tr data-sourcepos=\"1:1-1:14\">\n", |
| 230 |
"<th data-sourcepos=\"1:2-1:6\"></th>\n", |
| 231 |
"<th data-sourcepos=\"1:8-1:13\">name</th>\n", |
| 232 |
"</tr>\n", |
| 233 |
"</thead>\n", |
| 234 |
"<tbody>\n", |
| 235 |
"<tr data-sourcepos=\"3:1-3:14\">\n", |
| 236 |
"<td data-sourcepos=\"3:2-3:6\">\n", |
| 237 |
"<input type=\"checkbox\" data-sourcepos=\"3:3-3:5\" disabled=\"\" /> </td>\n", |
| 238 |
"<td data-sourcepos=\"3:8-3:13\">Rell</td>\n", |
| 239 |
"</tr>\n", |
| 240 |
"<tr data-sourcepos=\"4:1-4:14\">\n", |
| 241 |
"<td data-sourcepos=\"4:2-4:6\">\n", |
| 242 |
"<input type=\"checkbox\" data-sourcepos=\"4:3-4:5\" checked=\"\" disabled=\"\" /> </td>\n", |
| 243 |
"<td data-sourcepos=\"4:8-4:13\">Kai</td>\n", |
| 244 |
"</tr>\n", |
| 245 |
"</tbody>\n", |
| 246 |
"</table>\n", |
| 247 |
), |
| 248 |
); |
| 249 |
|
| 250 |
html_opts!( |
| 251 |
[ |
| 252 |
extension.tasklist, |
| 253 |
extension.table, |
| 254 |
parse.tasklist_in_table, |
| 255 |
parse.relaxed_tasklist_matching, |
| 256 |
render.sourcepos |
| 257 |
], |
| 258 |
concat!( |
| 259 |
"| | name |\n", |
| 260 |
"| ------- | ---- |\n", |
| 261 |
"| [~] | Rell |\n", |
| 262 |
"| [x] | Kai |\n", |
| 263 |
"| [x] No. | Ez |\n" |
| 264 |
), |
| 265 |
concat!( |
| 266 |
"<table data-sourcepos=\"1:1-5:18\">\n", |
| 267 |
"<thead>\n", |
| 268 |
"<tr data-sourcepos=\"1:1-1:18\">\n", |
| 269 |
"<th data-sourcepos=\"1:2-1:10\"></th>\n", |
| 270 |
"<th data-sourcepos=\"1:12-1:17\">name</th>\n", |
| 271 |
"</tr>\n", |
| 272 |
"</thead>\n", |
| 273 |
"<tbody>\n", |
| 274 |
"<tr data-sourcepos=\"3:1-3:18\">\n", |
| 275 |
"<td data-sourcepos=\"3:2-3:10\">\n", |
| 276 |
"<input type=\"checkbox\" data-sourcepos=\"3:3-3:5\" checked=\"\" disabled=\"\" /> </td>\n", |
| 277 |
"<td data-sourcepos=\"3:12-3:17\">Rell</td>\n", |
| 278 |
"</tr>\n", |
| 279 |
"<tr data-sourcepos=\"4:1-4:18\">\n", |
| 280 |
"<td data-sourcepos=\"4:2-4:10\">\n", |
| 281 |
"<input type=\"checkbox\" data-sourcepos=\"4:3-4:5\" checked=\"\" disabled=\"\" /> </td>\n", |
| 282 |
"<td data-sourcepos=\"4:12-4:17\">Kai</td>\n", |
| 283 |
"</tr>\n", |
| 284 |
"<tr data-sourcepos=\"5:1-5:18\">\n", |
| 285 |
"<td data-sourcepos=\"5:2-5:10\">[x] No.</td>\n", |
| 286 |
"<td data-sourcepos=\"5:12-5:17\">Ez</td>\n", |
| 287 |
"</tr>\n", |
| 288 |
"</tbody>\n", |
| 289 |
"</table>\n" |
| 290 |
), |
| 291 |
); |
| 292 |
} |
| 293 |
|
| 294 |
#[test] |
| 295 |
fn tasklist_in_table_fuzz() { |
| 296 |
html_opts!( |
| 297 |
[ |
| 298 |
extension.tasklist, |
| 299 |
extension.table, |
| 300 |
extension.autolink, |
| 301 |
parse.tasklist_in_table, |
| 302 |
parse.ignore_setext |
| 303 |
], |
| 304 |
"o\n-\t\r[ ] [email protected][ ] ", |
| 305 |
concat!( |
| 306 |
"<table>\n", |
| 307 |
"<thead>\n", |
| 308 |
"<tr>\n", |
| 309 |
"<th>o</th>\n", |
| 310 |
"</tr>\n", |
| 311 |
"</thead>\n", |
| 312 |
"<tbody>\n", |
| 313 |
"<tr>\n", |
| 314 |
"<td>[ ] <a href=\"mailto:[email protected]\">[email protected]</a>[ ]</td>\n", |
| 315 |
"</tr>\n", |
| 316 |
"</tbody>\n", |
| 317 |
"</table>\n", |
| 318 |
), |
| 319 |
); |
| 320 |
} |
| 321 |
|
| 322 |
#[test] |
| 323 |
fn sourcepos() { |
| 324 |
assert_ast_match!( |
| 325 |
[], |
| 326 |
"h\n" |
| 327 |
"- [ ] xy\n" |
| 328 |
" - [x] zw\n", |
| 329 |
(document (1:1-3:10) [ |
| 330 |
(paragraph (1:1-1:1) [ |
| 331 |
(text (1:1-1:1) "h") |
| 332 |
]) |
| 333 |
(list (2:1-3:10) [ |
| 334 |
(item (2:1-3:10) [ |
| 335 |
(paragraph (2:3-2:8) [ |
| 336 |
(text (2:3-2:8) "[ ] xy") |
| 337 |
]) |
| 338 |
(list (3:3-3:10) [ |
| 339 |
(item (3:3-3:10) [ |
| 340 |
(paragraph (3:5-3:10) [ |
| 341 |
(text (3:5-3:10) "[x] zw") |
| 342 |
]) |
| 343 |
]) |
| 344 |
]) |
| 345 |
]) |
| 346 |
]) |
| 347 |
]) |
| 348 |
); |
| 349 |
|
| 350 |
// https://github.github.com/gfm/#example-279 |
| 351 |
assert_ast_match!( |
| 352 |
[extension.tasklist], |
| 353 |
"- [ ] item\n", |
| 354 |
(document (1:1-1:10) [ |
| 355 |
(list (1:1-1:10) [ |
| 356 |
(taskitem (1:1-1:10) [ |
| 357 |
(paragraph (1:7-1:10) [ |
| 358 |
(text (1:7-1:10) "item") |
| 359 |
]) |
| 360 |
]) |
| 361 |
]) |
| 362 |
]) |
| 363 |
); |
| 364 |
|
| 365 |
assert_ast_match!( |
| 366 |
[extension.tasklist], |
| 367 |
"- [ ] item\n" |
| 368 |
"- [x] item2\n", |
| 369 |
(document (1:1-2:11) [ |
| 370 |
(list (1:1-2:11) [ |
| 371 |
(taskitem (1:1-1:10) [ |
| 372 |
(paragraph (1:7-1:10) [ |
| 373 |
(text (1:7-1:10) "item") |
| 374 |
]) |
| 375 |
]) |
| 376 |
(taskitem (2:1-2:11) [ |
| 377 |
(paragraph (2:7-2:11) [ |
| 378 |
(text (2:7-2:11) "item2") |
| 379 |
]) |
| 380 |
]) |
| 381 |
]) |
| 382 |
]) |
| 383 |
); |
| 384 |
|
| 385 |
// https://github.github.com/gfm/#example-280 |
| 386 |
assert_ast_match!( |
| 387 |
[extension.tasklist], |
| 388 |
"- [x] item\n" |
| 389 |
" - [ ] item2\n" |
| 390 |
" - [x] item3\n" |
| 391 |
"- [ ] item4\n", |
| 392 |
(document (1:1-4:11) [ |
| 393 |
(list (1:1-4:11) [ |
| 394 |
(taskitem (1:1-3:13) [ |
| 395 |
(paragraph (1:7-1:10) [ |
| 396 |
(text (1:7-1:10) "item") |
| 397 |
]) |
| 398 |
(list (2:3-3:13) [ |
| 399 |
(taskitem (2:3-2:13) [ |
| 400 |
(paragraph (2:9-2:13) [ |
| 401 |
(text (2:9-2:13) "item2") |
| 402 |
]) |
| 403 |
]) |
| 404 |
(taskitem (3:3-3:13) [ |
| 405 |
(paragraph (3:9-3:13) [ |
| 406 |
(text (3:9-3:13) "item3") |
| 407 |
]) |
| 408 |
]) |
| 409 |
]) |
| 410 |
]) |
| 411 |
(taskitem (4:1-4:11) [ |
| 412 |
(paragraph (4:7-4:11) [ |
| 413 |
(text (4:7-4:11) "item4") |
| 414 |
]) |
| 415 |
]) |
| 416 |
]) |
| 417 |
]) |
| 418 |
); |
| 419 |
|
| 420 |
assert_ast_match!( |
| 421 |
[extension.tasklist], |
| 422 |
"- [ ] bullet point one\n" |
| 423 |
"- bullet point two and some extra text\n" |
| 424 |
"- [x] bullet point three\n", |
| 425 |
(document (1:1-3:24) [ |
| 426 |
(list (1:1-3:24) [ |
| 427 |
(taskitem (1:1-1:22) [ |
| 428 |
(paragraph (1:7-1:22) [ |
| 429 |
(text (1:7-1:22) "bullet point one") |
| 430 |
]) |
| 431 |
]) |
| 432 |
(item (2:1-2:38) [ |
| 433 |
(paragraph (2:3-2:38) [ |
| 434 |
(text (2:3-2:38) "bullet point two and some extra text") |
| 435 |
]) |
| 436 |
]) |
| 437 |
(taskitem (3:1-3:24) [ |
| 438 |
(paragraph (3:7-3:24) [ |
| 439 |
(text (3:7-3:24) "bullet point three") |
| 440 |
]) |
| 441 |
]) |
| 442 |
]) |
| 443 |
]) |
| 444 |
); |
| 445 |
|
| 446 |
assert_ast_match!( |
| 447 |
[extension.tasklist], |
| 448 |
"- [ ] bullet point one\n" |
| 449 |
"- bullet point two and some extra text\n" |
| 450 |
"- [x] bullet point three\n" |
| 451 |
"\n" |
| 452 |
"hello world\n", |
| 453 |
(document (1:1-5:11) [ |
| 454 |
(list (1:1-3:24) [ |
| 455 |
(taskitem (1:1-1:22) [ |
| 456 |
(paragraph (1:7-1:22) [ |
| 457 |
(text (1:7-1:22) "bullet point one") |
| 458 |
]) |
| 459 |
]) |
| 460 |
(item (2:1-2:38) [ |
| 461 |
(paragraph (2:3-2:38) [ |
| 462 |
(text (2:3-2:38) "bullet point two and some extra text") |
| 463 |
]) |
| 464 |
]) |
| 465 |
(taskitem (3:1-3:24) [ |
| 466 |
(paragraph (3:7-3:24) [ |
| 467 |
(text (3:7-3:24) "bullet point three") |
| 468 |
]) |
| 469 |
]) |
| 470 |
]) |
| 471 |
(paragraph (5:1-5:11) [ |
| 472 |
(text (5:1-5:11) "hello world") |
| 473 |
]) |
| 474 |
]) |
| 475 |
); |
| 476 |
|
| 477 |
assert_ast_match!( |
| 478 |
[extension.tasklist], |
| 479 |
"h\n" |
| 480 |
"- [ ] xy\n" |
| 481 |
" - [x] zw\n", |
| 482 |
(document (1:1-3:10) [ |
| 483 |
(paragraph (1:1-1:1) [ |
| 484 |
(text (1:1-1:1) "h") |
| 485 |
]) |
| 486 |
(list (2:1-3:10) [ |
| 487 |
(taskitem (2:1-3:10) [ |
| 488 |
(paragraph (2:7-2:8) [ |
| 489 |
(text (2:7-2:8) "xy") |
| 490 |
]) |
| 491 |
(list (3:3-3:10) [ |
| 492 |
(taskitem (3:3-3:10) [ |
| 493 |
(paragraph (3:9-3:10) [ |
| 494 |
(text (3:9-3:10) "zw") |
| 495 |
]) |
| 496 |
]) |
| 497 |
]) |
| 498 |
]) |
| 499 |
]) |
| 500 |
]) |
| 501 |
); |
| 502 |
} |
| 503 |
|
| 504 |
#[test] |
| 505 |
fn tasklist_relaxed_unicode() { |
| 506 |
assert_ast_match!( |
| 507 |
[extension.tasklist, parse.relaxed_tasklist_matching], |
| 508 |
"- [あ] xy\n" // U+3042 |
| 509 |
" - [い] zw\n", // U+3044 |
| 510 |
(document (1:1-2:12) [ |
| 511 |
(list (1:1-2:12) [ |
| 512 |
(taskitem (1:1-2:12) [ |
| 513 |
(paragraph (1:9-1:10) [ |
| 514 |
(text (1:9-1:10) "xy") |
| 515 |
]) |
| 516 |
(list (2:3-2:12) [ |
| 517 |
(taskitem (2:3-2:12) [ |
| 518 |
(paragraph (2:11-2:12) [ |
| 519 |
(text (2:11-2:12) "zw") |
| 520 |
]) |
| 521 |
]) |
| 522 |
]) |
| 523 |
]) |
| 524 |
]) |
| 525 |
]) |
| 526 |
); |
| 527 |
} |
| 528 |
|
| 529 |
#[test] |
| 530 |
fn tasklist_symbol_sourcepos() { |
| 531 |
let mut options = Options::default(); |
| 532 |
options.extension.tasklist = true; |
| 533 |
|
| 534 |
let arena = Arena::new(); |
| 535 |
let md = r#"Henlo! |
| 536 |
|
| 537 |
> - [x] well |
| 538 |
> |
| 539 |
> 1. * > 3. [ ] true |
| 540 |
|
| 541 |
+ [x] ok |
| 542 |
"#; |
| 543 |
|
| 544 |
let root = parse_document(&arena, md, &options); |
| 545 |
let sourceposes = root |
| 546 |
.descendants() |
| 547 |
.filter_map(|n| { |
| 548 |
let NodeValue::TaskItem(ref nti) = n.data().value else { |
| 549 |
return None; |
| 550 |
}; |
| 551 |
Some(nti.symbol_sourcepos) |
| 552 |
}) |
| 553 |
.collect::<Vec<_>>(); |
| 554 |
assert_eq!( |
| 555 |
sourceposes, |
| 556 |
vec![ |
| 557 |
(3, 6, 3, 6).into(), |
| 558 |
(5, 16, 5, 16).into(), |
| 559 |
(7, 4, 7, 4).into() |
| 560 |
] |
| 561 |
); |
| 562 |
} |
| 563 |
|
| 564 |
#[test] |
| 565 |
fn tasklist_symbol_sourcepos_relaxed() { |
| 566 |
let mut options = Options::default(); |
| 567 |
options.extension.tasklist = true; |
| 568 |
options.extension.table = true; |
| 569 |
options.parse.relaxed_tasklist_matching = true; |
| 570 |
options.parse.tasklist_in_table = true; |
| 571 |
|
| 572 |
let arena = Arena::new(); |
| 573 |
let md = r#"Henlo! |
| 574 |
|
| 575 |
> - [あ] well |
| 576 |
> |
| 577 |
> 1. * > 3. [和] true |
| 578 |
|
| 579 |
| hm | | |
| 580 |
| ---- | -- | |
| 581 |
| [ワ] | ok | |
| 582 |
"#; |
| 583 |
|
| 584 |
let root = parse_document(&arena, md, &options); |
| 585 |
let sourceposes = root |
| 586 |
.descendants() |
| 587 |
.filter_map(|n| { |
| 588 |
let NodeValue::TaskItem(ref nti) = n.data().value else { |
| 589 |
return None; |
| 590 |
}; |
| 591 |
Some(nti.symbol_sourcepos) |
| 592 |
}) |
| 593 |
.collect::<Vec<_>>(); |
| 594 |
assert_eq!( |
| 595 |
sourceposes, |
| 596 |
vec![ |
| 597 |
(3, 6, 3, 8).into(), |
| 598 |
(5, 16, 5, 18).into(), |
| 599 |
(9, 4, 9, 6).into() |
| 600 |
] |
| 601 |
); |
| 602 |
} |