1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Advanced API for custom highlighting implementations.
//!
//! This module re-exports low-level types from `arborium-highlight` for users who need:
//!
//! - Direct access to [`CompiledGrammar`] and [`ParseContext`] for custom workflows
//! - Raw [`Span`] data for custom rendering
//! - Building browser/WASM highlighters with dynamic grammar loading
//!
//! # Architecture
//!
//! The highlighting system is built around separating shareable and per-thread state:
//!
//! - [`CompiledGrammar`]: Thread-safe compiled queries (share via `Arc`)
//! - [`ParseContext`]: Per-thread parser state (cheap to create)
//!
//! # Example: Direct Grammar Usage
//!
//! ```rust,ignore
//! use std::sync::Arc;
//! use arborium::advanced::{CompiledGrammar, ParseContext, GrammarConfig};
//!
//! // Compile grammar (expensive, do once)
//! let config = GrammarConfig {
//! language: arborium::lang_rust::language().into(),
//! highlights_query: &arborium::lang_rust::HIGHLIGHTS_QUERY,
//! injections_query: arborium::lang_rust::INJECTIONS_QUERY,
//! locals_query: arborium::lang_rust::LOCALS_QUERY,
//! };
//! let grammar = Arc::new(CompiledGrammar::new(config)?);
//!
//! // Create parse context (cheap, per-thread)
//! let mut ctx = ParseContext::for_grammar(&grammar)?;
//!
//! // Parse
//! let result = grammar.parse(&mut ctx, "fn main() {}");
//! println!("Found {} spans", result.spans.len());
//! ```
// Core tree-sitter types
pub use ;
// Data types
pub use ;
// Low-level rendering utilities
pub use ;
// ANSI rendering options
pub use AnsiOptions;