panache-parser 0.5.0

Lossless CST parser and syntax wrappers for Pandoc markdown, Quarto, and RMarkdown
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
use super::helpers::{
    assert_block_kinds, count_children, find_all, find_first, parse_blocks,
    parse_blocks_with_config,
};
use crate::options::{Extensions, Flavor, ParserOptions};
use crate::syntax::SyntaxKind;

#[test]
fn simple_bullet_list() {
    let input = "* one\n* two\n* three\n";
    let config = ParserOptions {
        flavor: Flavor::Quarto,
        extensions: Extensions::for_flavor(Flavor::Quarto),
        ..Default::default()
    };
    assert!(
        config.extensions.fenced_divs,
        "fenced_divs should be enabled for this test"
    );
    let tree = parse_blocks_with_config(input, &config);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn bullet_list_requires_space_after_marker() {
    let input = "*one\n*two\n";
    let tree = parse_blocks(input);
    // Should not parse as list
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn bullet_list_with_different_markers() {
    let input = "* item\n+ item\n- item\n";
    let tree = parse_blocks(input);
    // Should create ONE list (bullet markers are all equivalent per Pandoc)
    let lists = find_all(&tree, SyntaxKind::LIST);
    assert_eq!(lists.len(), 1);
}

#[test]
fn bullet_list_indented_1_to_3_spaces() {
    let input = " * one space\n  * two spaces\n   * three spaces\n";
    let tree = parse_blocks(input);
    // All should be valid list items
    let list_items = find_all(&tree, SyntaxKind::LIST_ITEM);
    assert_eq!(list_items.len(), 3);
}

#[test]
fn bullet_list_indented_4_spaces_is_code() {
    let input = "    * not a list\n";
    let tree = parse_blocks(input);
    // Should be code block, not list
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn bullet_list_with_continuation() {
    let input = "* here is my first\n  list item.\n* and my second.\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn bullet_list_lazy_continuation() {
    let input = "* here is my first\nlist item.\n* and my second.\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn list_item_can_start_with_atx_heading() {
    let input = "- # Heading\n";
    let tree = parse_blocks(input);

    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    let list_item = list
        .children()
        .find(|n| n.kind() == SyntaxKind::LIST_ITEM)
        .expect("should find list item");

    assert!(
        find_first(&list_item, SyntaxKind::HEADING).is_some(),
        "list item should contain HEADING"
    );
    assert!(
        find_first(&list_item, SyntaxKind::PLAIN).is_none(),
        "heading-only list item should not be parsed as PLAIN"
    );
}

#[test]
fn nested_bullet_lists() {
    let input = "* fruits\n  + apples\n  + pears\n* vegetables\n";
    let tree = parse_blocks(input);
    let outer_list = find_first(&tree, SyntaxKind::LIST).expect("should find outer list");
    assert_eq!(count_children(&outer_list, SyntaxKind::LIST_ITEM), 2);

    // Should have nested list inside first item
    let nested_lists = find_all(&tree, SyntaxKind::LIST);
    assert!(
        nested_lists.len() >= 2,
        "should have at least 2 lists (outer + nested)"
    );
}

#[test]
fn outdented_item_after_nested_list_returns_to_outer_level() {
    let input = "* Item 1\n  + Nested item\n      *  Deeply nested\n +  Item 2\n";
    let tree = parse_blocks(input);
    let lists = find_all(&tree, SyntaxKind::LIST);

    let outer_list = lists.first().expect("should have an outer list");
    assert_eq!(count_children(outer_list, SyntaxKind::LIST_ITEM), 2);

    let top_level_items: Vec<_> = outer_list
        .children()
        .filter(|n| n.kind() == SyntaxKind::LIST_ITEM)
        .collect();
    let first_item = top_level_items
        .first()
        .expect("should have first list item");
    let second_item = top_level_items
        .get(1)
        .expect("should have second list item");

    assert!(
        find_first(first_item, SyntaxKind::LIST).is_some(),
        "first item should keep nested list"
    );
    assert!(
        find_first(second_item, SyntaxKind::LIST).is_none(),
        "second item should be at outer level, not nested"
    );
}

#[test]
fn fancy_list_continuation_with_nested_list_is_not_indented_code() {
    use crate::options::{Extensions, ParserOptions};

    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(2) begins with 2\n(3) and now 3\n\n    with a continuation\n\n    iv. sublist with roman numerals,\n        starting with 4\n    v.  more items\n        (A)  a subsublist\n        (B)  a subsublist\n";

    let tree = crate::parser::Parser::new(input, &config).parse();

    assert!(
        find_first(&tree, SyntaxKind::CODE_BLOCK).is_none(),
        "continuation content should not parse as indented code"
    );

    let lists = find_all(&tree, SyntaxKind::LIST);
    assert!(
        lists.len() >= 3,
        "should contain outer, nested roman, and nested alpha lists"
    );
}

#[test]
fn loose_list_with_blank_lines() {
    let input = "* one\n\n* two\n\n* three\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn simple_ordered_list() {
    let input = "1. one\n2. two\n3. three\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn ordered_list_numbers_ignored() {
    let input = "5. one\n7. two\n1. three\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn ordered_list_with_hash_marker() {
    let input = "#. one\n#. two\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn ordered_list_requires_space_after_marker() {
    let input = "1.one\n2.two\n";
    let tree = parse_blocks(input);
    // Should not parse as list
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn mixed_markers_create_separate_lists() {
    let input = "(2) Two\n(5) Three\n1. Four\n* Five\n";
    let tree = parse_blocks(input);
    // Should create separate lists for each marker type
    let lists = find_all(&tree, SyntaxKind::LIST);
    assert!(lists.len() >= 3, "should have at least 3 separate lists");
}

#[test]
fn parenthesized_decimal_with_only_closer_text_does_not_interrupt_list_item() {
    let input = "- outer\n  4) )\n  continued\n";
    let tree = parse_blocks(input);

    let lists = find_all(&tree, SyntaxKind::LIST);
    assert_eq!(lists.len(), 1, "should keep a single outer list");
    let outer = lists.first().expect("outer list");
    assert_eq!(count_children(outer, SyntaxKind::LIST_ITEM), 1);
}

#[test]
fn task_list_unchecked() {
    let input = "- [ ] unchecked task\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 1);
}

#[test]
fn task_list_checked() {
    let input = "- [x] checked task\n- [X] also checked\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn list_with_multiple_paragraphs() {
    let input = "* First paragraph.\n\n  Continued.\n\n* Second item.\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn list_after_blank_line() {
    let input = "\n* item\n";
    let tree = parse_blocks(input);
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list after blank");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 1);
}

#[test]
fn list_after_paragraph() {
    let input = "Not a list.\n\n* Now a list\n";
    assert_block_kinds(
        input,
        &[
            SyntaxKind::PARAGRAPH,
            SyntaxKind::BLANK_LINE,
            SyntaxKind::LIST,
        ],
    );
}

#[test]
fn list_item_with_valid_fenced_divs_parses_as_fenced_div_nodes() {
    let input = "2.  Once your repository is created, clone it to your local computer.\n\n    ::: {.content-visible unless-meta=\"tool.is_rstudio\"}\n    You can do this any way you are comfortable, for instance in the Terminal, it might look like:\n\n    ``` {.bash filename=\"Terminal\"}\n    git clone git@github.com:<username>/<repo-name>.git\n    ```\n\n    Where you use your own user name and repo name.\n    :::\n\n    ::: {.content-visible when-meta=\"tool.is_rstudio\"}\n    You can do this any way you are comfortable, but one approach is to use **File** > **New Project**. In the **New Project** dialog, select **From Version Control**, then **Git**, and copy and paste the repo URL from GitHub.\n    :::\n";
    let tree = parse_blocks(input);
    let list_item = find_first(&tree, SyntaxKind::LIST_ITEM).expect("list item");
    let fenced_divs = find_all(&list_item, SyntaxKind::FENCED_DIV);
    assert_eq!(
        fenced_divs.len(),
        2,
        "expected two fenced divs inside list item"
    );
}

// Fancy lists tests - require fancy_lists extension

#[test]
fn fancy_list_lower_alpha_period() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "a. first\nb. second\nc. third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_lower_alpha_right_paren() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "a) first\nb) second\nc) third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_lower_alpha_parens() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(a) first\n(b) second\n(c) third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_upper_alpha_period() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "A.  first\nB.  second\nC.  third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_upper_alpha_period_requires_two_spaces() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    // One space should NOT parse as list (to avoid false positives like "B. Russell")
    let input = "A. first\nB. second\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());

    // Two spaces SHOULD parse as list
    let input_valid = "A.  first\nB.  second\n";
    let tree_valid = crate::parser::Parser::new(input_valid, &config).parse();
    let list = find_first(&tree_valid, SyntaxKind::LIST).expect("should find list with 2 spaces");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn fancy_list_lower_roman_period() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "i. first\nii. second\niii. third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_lower_roman_right_paren() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "i) first\nii) second\niii) third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_lower_roman_parens() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(i) first\n(ii) second\n(iii) third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_upper_roman_period() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "I. first\nII. second\nIII. third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_upper_roman_right_paren() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "I) first\nII) second\nIII) third\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn fancy_list_disabled_when_extension_off() {
    // With fancy_lists disabled, alphabetic markers should not parse as lists
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: false,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "a. first\nb. second\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn fancy_list_hash_marker_disabled_when_extension_off() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: false,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "#. first\n#. second\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn fancy_list_right_paren_decimal_disabled_when_extension_off() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: false,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "1) first\n2) second\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn fancy_list_parens_decimal_disabled_when_extension_off() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: false,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(1) first\n(2) second\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn fancy_list_complex_roman() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            fancy_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input =
        "iv. fourth\nv. fifth\nvi. sixth\nvii. seventh\nviii. eighth\nix. ninth\nx. tenth\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 7);
}

// Example lists tests - require example_lists extension

#[test]
fn example_list_basic() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(@) First example\n(@) Second example\n(@) Third example\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn example_list_with_labels() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(@good) This is a good example\n(@bad) This is a bad example\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn example_list_mixed_labeled_unlabeled() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(@) First example\n(@foo) Labeled example\n(@) Another example\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 3);
}

#[test]
fn example_list_separated_by_text() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    // According to spec, example lists can be separated and continue numbering
    let input = "(@) First example\n\nSome text.\n\n(@) Second example\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let lists = find_all(&tree, SyntaxKind::LIST);
    // Should have 2 separate lists
    assert_eq!(lists.len(), 2);
    // Each should have 1 item
    assert_eq!(count_children(&lists[0], SyntaxKind::LIST_ITEM), 1);
    assert_eq!(count_children(&lists[1], SyntaxKind::LIST_ITEM), 1);
}

#[test]
fn example_list_disabled_when_extension_off() {
    // With example_lists disabled, (@) should not parse as a list
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: false,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(@) example\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    assert!(find_first(&tree, SyntaxKind::LIST).is_none());
}

#[test]
fn example_list_with_underscores_and_hyphens() {
    use crate::options::{Extensions, ParserOptions};
    let config = ParserOptions {
        extensions: Extensions {
            example_lists: true,
            ..Default::default()
        },
        ..Default::default()
    };
    let input = "(@my_label) Example with underscore\n(@my-label) Example with hyphen\n";
    let tree = crate::parser::Parser::new(input, &config).parse();
    let list = find_first(&tree, SyntaxKind::LIST).expect("should find list");
    assert_eq!(count_children(&list, SyntaxKind::LIST_ITEM), 2);
}

#[test]
fn nested_lower_roman_with_uneven_marker_width_stays_single_nested_list() {
    let input = "a. retain.\n\n     i. short;\n    ii. short;\n   iii. short;\n";
    let tree = parse_blocks(input);

    let outer = find_first(&tree, SyntaxKind::LIST).expect("should find outer list");
    assert_eq!(count_children(&outer, SyntaxKind::LIST_ITEM), 1);

    let outer_item = outer
        .children()
        .find(|n| n.kind() == SyntaxKind::LIST_ITEM)
        .expect("outer list should contain one item");

    let nested_lists: Vec<_> = outer_item
        .children()
        .filter(|n| n.kind() == SyntaxKind::LIST)
        .collect();
    assert_eq!(
        nested_lists.len(),
        1,
        "nested roman items should stay in one nested list"
    );
    assert_eq!(count_children(&nested_lists[0], SyntaxKind::LIST_ITEM), 3);
}