feat: highlight Markdown list markers
This commit is contained in:
@@ -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```";
|
||||
|
||||
@@ -60,6 +60,14 @@ static MD_HIGHLIGHTS: LazyLock<String> = LazyLock::new(|| {
|
||||
(setext_h1_underline)
|
||||
(setext_h2_underline)
|
||||
] @text.title
|
||||
|
||||
[
|
||||
(list_marker_minus)
|
||||
(list_marker_plus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
] @markup.list
|
||||
",
|
||||
]
|
||||
.join("\n")
|
||||
|
||||
Reference in New Issue
Block a user