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
25 lines
795 B
Scheme
25 lines
795 B
Scheme
; 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))
|