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:
@@ -1,35 +0,0 @@
|
||||
; 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
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user