Skip to main content

Crate tuika_codeformatters

Crate tuika_codeformatters 

Source
Expand description

Tree-sitter syntax highlighting for tuika’s CodeBlock and Markdown components.

tuika owns the presentation of code (framing, background, language label, wrapping) but deliberately depends on no grammar. This crate fills the gap: a ready-made Highlighter backed by the same tree-sitter grammars a coding tool already carries, mapping token classes onto the host’s Theme’s code palette so highlighted code follows the theme.

use tuika::{CodeBlock, Theme};
use tuika_codeformatters::TreeSitterHighlighter;

let hl = TreeSitterHighlighter::new();
let _block = CodeBlock::new("rust", "fn main() {}").highlighter(&hl);
let _ = Theme::default();

Supported languages (with common aliases): Rust, Python, TypeScript/ JavaScript, TSX/JSX, Go, Java, Ruby, CSS, HTML, C#, PHP, Zig, Scala, and SQL. Anything else — or source that fails to parse — returns None, and the caller renders it as plain code.

Structs§

TreeSitterHighlighter
A tree-sitter-backed Highlighter.