Skip to content

feat: highlight embedded languages via injection - #88

Open
MichaelHatherly wants to merge 1 commit into
masterfrom
mh/language-injection
Open

feat: highlight embedded languages via injection#88
MichaelHatherly wants to merge 1 commit into
masterfrom
mh/language-injection

Conversation

@MichaelHatherly

@MichaelHatherly MichaelHatherly commented Jul 10, 2026

Copy link
Copy Markdown
Member

Add an opt-in inject keyword to highlight. With inject=true, code embedded in the source is highlighted by its own grammar: the JavaScript and CSS inside an HTML document, command literals in Julia. Each injection layer is highlighted with its own queries, and the tokens merge into one stream where the shorter span wins on overlap. Default output is byte-identical and loads no embedded grammars, so existing callers are unaffected.

Colour the capture names markup and CSS grammars emit that previously fell through to the plain foreground and rendered as unstyled text: tag and tag.error for HTML tag names, property for CSS property names and selectors. Colouring property also colours object member access in languages that capture it.


Depends on MichaelHatherly/TreeSitter.jl#60, which adds the layered parse this builds on. CI here stays red until that merges and a TreeSitter release ships the injection API; the TreeSitter compat bound then needs bumping to that version.

Add an opt-in `inject` keyword to `highlight`. With `inject=true`, code
embedded in the source is highlighted by its own grammar: the JavaScript and
CSS inside an HTML document, command literals in Julia. Each injection layer
is highlighted with its own queries, and the tokens merge into one stream
where the shorter span wins on overlap. Default output is byte-identical and
loads no embedded grammars, so existing callers are unaffected.

Colour the capture names markup and CSS grammars emit that previously fell
through to the plain foreground and rendered as unstyled text: `tag` and
`tag.error` for HTML tag names, `property` for CSS property names and
selectors. Colouring `property` also colours object member access in
languages that capture it.

Injection needs the layered `parse` from TreeSitter.jl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant