use markdown::AppExt as _;
fn spans(language: &str, code: &str) -> Option<Vec<(Range<usize>, HighlightKind)>> {
syntax::highlight(code, language) // source first, language second
}
syntax::grammars::install(); // once, before any highlight
cx.set_highlighter(spans, syntax::registry::ready());syntax::highlightreturnsNonefor a tag with no grammar in the registry, and that fence paints plain. Nothing has a grammar untilgrammars::installorregistry::registerruns.markdown::Highlightertakes the language first andsyntax::highlighttakes the source first. Both are&str, so swapping them compiles and colours nothing.- Build a grammar of your own against
syntax::tree_sitter_language. A second tree-sitter in the dependency graph is a different type, andLang::newrejects it. syntaxis not part of thebezelfacade, and it does not build forwasm32-unknown-unknown.
Make it yours
| call | what it decides |
|---|---|
features rust, python, typescript, json, go, bash, toml |
which grammars compile in; all on by default |
Lang::new, Grammar::Native |
a language of your own, as a static beside the built-in ones |
Lang::with_injections |
regions written in another registered language |
registry::register, registry::Entry |
which fence tags and file names reach a grammar |
registry::of_tag, registry::of_path |
what a tag or a path names, painted or not |
syntax = { package = "bezel-syntax", version = "0.2", default-features = false, features = ["rust", "toml"] }