feat: highlight Markdown list markers

This commit is contained in:
2026-10-12 17:30:35 +02:00
parent 971866388c
commit 5e6b602127
4 changed files with 39 additions and 1 deletions
+29
View File
@@ -1730,6 +1730,35 @@ mod tests {
assert_eq!(kind_at(&cache, 10, 6), None);
}
#[test]
fn markdown_list_markers_color_bullets_and_numbers_without_coloring_plain_text() {
let source = "- item\n - nested\n 12. ordered\n\n+ item\n\n* item\n\n1. ordered\n2. next\n\n3) ordered\n\n> - quoted\n> 4. ordered\n\nplain - text and 1. text\n\n\\- escaped";
let mut cache = self::cache(source, "lists.md");
for (row, marker) in [
(0, "-"),
(1, "-"),
(2, "12."),
(4, "+"),
(6, "*"),
(8, "1."),
(9, "2."),
(11, "3)"),
(13, "-"),
(14, "4."),
] {
assert_token(&cache, source, row, marker, SyntaxKind::Markup);
}
assert_eq!(kind_at(&cache, 0, 2), None);
assert_eq!(kind_at(&cache, 16, 6), None);
assert_eq!(kind_at(&cache, 16, 17), None);
assert_ne!(kind_at(&cache, 18, 1), Some(SyntaxKind::Markup));
let edited = source.replacen("- item", "plain - item", 1);
cache.update(&lines(&edited), Some(Path::new("lists.md")), 1);
assert_eq!(kind_at(&cache, 0, 6), None);
assert_fresh(&cache, &edited, "lists.md");
}
#[test]
fn markdown_inline_and_fences_inject_known_languages_and_update_incrementally() {
let original = "A **bold** and `code` link.\n\n```rust\nfn main() { let n = 42; }\n```\n\n```python\ndef hello():\n return 7\n```\n\n```not-a-language\nfn not_rust() { 99; }\n```";