feat(highlight): add markdown syntax highlighting with injection
Add tree-sitter-md for markdown parsing with injection support for fenced code blocks. Code inside markdown code fences (```rust, ```bash, etc.) is now fully syntax highlighted. Key fix: Use `#set! injection.include-children` directive in the injection query to override tree-sitter-md's internal tokenization of code_fence_content, allowing proper language injection. - Add tree-sitter-md v0.5.2 dependency - Add Markdown variant to Language enum (md, markdown aliases) - Create queries/md-highlights.scm (minimal markdown highlights) - Create queries/md-injections.scm (with include-children directive) - Add test: test_markdown_injection_rust
This commit is contained in:
35
queries/md-highlights.scm
Normal file
35
queries/md-highlights.scm
Normal file
@@ -0,0 +1,35 @@
|
||||
; Minimal markdown block highlighting - only capture outside code blocks
|
||||
; Removed all captures that could match inside code_fence_content
|
||||
|
||||
(atx_heading (inline) @text.title)
|
||||
(setext_heading (paragraph) @text.title)
|
||||
|
||||
[
|
||||
(atx_h1_marker)
|
||||
(atx_h2_marker)
|
||||
(atx_h3_marker)
|
||||
(atx_h4_marker)
|
||||
(atx_h5_marker)
|
||||
(atx_h6_marker)
|
||||
(setext_h1_underline)
|
||||
(setext_h2_underline)
|
||||
] @punctuation.special
|
||||
|
||||
(fenced_code_block_delimiter) @punctuation.delimiter
|
||||
(info_string (language) @string)
|
||||
|
||||
(link_title) @string
|
||||
(link_destination) @text.uri
|
||||
(link_label) @text.reference
|
||||
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
(thematic_break)
|
||||
] @punctuation.special
|
||||
|
||||
(block_quote_marker) @punctuation.special
|
||||
(backslash_escape) @string.escape
|
||||
7
queries/md-injections.scm
Normal file
7
queries/md-injections.scm
Normal file
@@ -0,0 +1,7 @@
|
||||
; Markdown injection queries - testing include-children directive
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language)
|
||||
(code_fence_content) @injection.content
|
||||
(#set! injection.include-children))
|
||||
Reference in New Issue
Block a user