arborium 0.1.3

Tree-sitter syntax highlighting with HTML rendering and WASM support
Documentation

Arborium - Batteries-included tree-sitter grammar collection

This crate provides:

  • Re-exports of individual grammar crates via feature flags
  • HTML rendering with CSS classes for syntax highlighting
  • WASM support with custom allocator (automatically enabled on WASM targets)

Usage

Enable the languages you need via feature flags:

[dependencies]
arborium = { version = "0.1", features = ["lang-rust", "lang-python"] }

Or enable all languages:

[dependencies]
arborium = { version = "0.1", features = ["all-languages"] }

Example

use arborium::{html, lang_rust, HIGHLIGHT_NAMES};
use arborium::tree_sitter_highlight::{Highlighter, HighlightConfiguration};

// Create a highlight configuration for Rust
let mut config = HighlightConfiguration::new(
    lang_rust::language().into(),
    "rust",
    lang_rust::HIGHLIGHTS_QUERY,
    lang_rust::INJECTIONS_QUERY,
    lang_rust::LOCALS_QUERY,
).unwrap();
config.configure(&HIGHLIGHT_NAMES.iter().map(|s| s.to_string()).collect::<Vec<_>>());

// Render to HTML
let mut highlighter = Highlighter::new();
let mut output = Vec::new();
html::render(&mut output, &mut highlighter, &config, "fn main() {}", |_| None).unwrap();