1pub fn highlight(&self, lang: &str, source: &str) -> Option<Result<Str2 let config = self.config_for(lang)?;3 Some(self.render(config, source))4}56/// Render one block. Inlined here (rather than in `render`) so the in7/// callback and the host config share the `&self` lifetime — the borr8/// checker resolves the highlighter's internal lifetime locally, mirr9/// tree-sitter-highlight's own C binding.10fn render(&self, config: &HighlightConfiguration, source: &str) -> Res11 let mut highlighter = Highlighter::new();12 let events = highlighter13 .highlight(config, source.as_bytes(), None, |name: &str| {14 // Resolve embedded languages only among grammars already15 // injection never loads a new grammar. Disabled when `inj16 // off, so a misbehaving sub-grammar can be switched out e17 self.inject.then(|| self.config_for(name)).flatten()18 })
CAPTURE / RENDER
@type
@function.call
@variable.parameter
mdbook-tsitter
Structural Tree-sitter syntax highlighting for technical mdBooks.
- Rust
- mdBook
- Tree-sitter
Loading documentation