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:
Timothy DeHerrera
2026-01-31 16:41:11 -07:00
parent 69cd81621f
commit 8c54882118
6 changed files with 92 additions and 1 deletions

35
queries/md-highlights.scm Normal file
View 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