fix(highlight): complete markdown syntax highlighting with injections

Fix markdown code block highlighting to properly support both markdown
structure (headings, frontmatter) and language injection (rust, bash).

The key fix uses `#set! injection.include-children` in the injection
query to override tree-sitter-md's internal tokenization, enabling
proper highlighting of embedded languages within code fences.

Changes:
- Use crate's HIGHLIGHT_QUERY_BLOCK for base markdown highlighting
- Add custom injection query with include-children directive
- Add YAML/TOML frontmatter and HTML block injection rules
- Add text.* highlight names (title, literal, uri, reference)
- Add string.escape highlight name
- Add CSS styles for new highlight classes
- Remove unused custom md-highlights.scm
This commit is contained in:
Timothy DeHerrera
2026-01-31 17:24:27 -07:00
parent 352b3c1941
commit 905897b3c4
4 changed files with 52 additions and 37 deletions

View File

@@ -1,7 +1,24 @@
; Markdown injection queries - testing include-children directive
; Markdown injection queries with include-children directive
; Enables proper highlighting of embedded languages in code blocks and frontmatter
; Fenced code blocks - inject language specified in info string
(fenced_code_block
(info_string
(language) @injection.language)
(code_fence_content) @injection.content
(#set! injection.include-children))
; YAML frontmatter (--- delimited at start of document)
((minus_metadata) @injection.content
(#set! injection.language "yaml")
(#set! injection.include-children))
; TOML frontmatter (+++ delimited)
((plus_metadata) @injection.content
(#set! injection.language "toml")
(#set! injection.include-children))
; HTML blocks
((html_block) @injection.content
(#set! injection.language "html")
(#set! injection.include-children))