Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Highguard’s high-profile mistakes should be a lesson for other developers | Opinion

    Sega records $200m impairment write-down for Rovio during Q3

    Ubisoft Q3 net bookings rise 12% to €338m, primarily driven by Assassin’s Creed franchise

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Read the extended transcript: President Donald Trump interviewed by ‘NBC Nightly News’ anchor Tom Llamas

      February 6, 2026

      Stocks and bitcoin sink as investors dump software company shares

      February 4, 2026

      AI, crypto and Trump super PACs stash millions to spend on the midterms

      February 2, 2026

      To avoid accusations of AI cheating, college students are turning to AI

      January 29, 2026

      ChatGPT can embrace authoritarian ideas after just one prompt, researchers say

      January 24, 2026
    • Business

      The HDD brand that brought you the 1.8-inch, 2.5-inch, and 3.5-inch hard drives is now back with a $19 pocket-sized personal cloud for your smartphones

      February 12, 2026

      New VoidLink malware framework targets Linux cloud servers

      January 14, 2026

      Nvidia Rubin’s rack-scale encryption signals a turning point for enterprise AI security

      January 13, 2026

      How KPMG is redefining the future of SAP consulting on a global scale

      January 10, 2026

      Top 10 cloud computing stories of 2025

      December 22, 2025
    • Crypto

      US Investors Might Be Leaving Bitcoin and Ethereum ETFs for International Markets

      February 14, 2026

      Binance France President Targeted in Armed Kidnapping Attempt

      February 14, 2026

      Binance Fires Investigators as $1 Billion Iran-Linked USDT Flows Surface

      February 14, 2026

      Aave Proposes 100% DAO Revenue Model, Yet Price Remains Under Pressure

      February 14, 2026

      A $3 Billion Credit Giant Is Testing Bitcoin in the Mortgage System — Here’s How

      February 14, 2026
    • Technology

      European Commission: TikTok’s addictive design breaches EU law

      February 14, 2026

      e& drives AI-first workforce transformation with Oracle Cloud

      February 14, 2026

      UK fintech investment slumped in 2025

      February 14, 2026

      College of Policing accounts ‘disclaimed’ by auditor for second year in wake of IT failure

      February 14, 2026

      CIOs discuss friction between legacy IT and innovation

      February 14, 2026
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Arborium: Tree-sitter code highlighting with Native and WASM targets
    Technology

    Arborium: Tree-sitter code highlighting with Native and WASM targets

    TechAiVerseBy TechAiVerseDecember 15, 2025No Comments7 Mins Read2 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    Arborium: Tree-sitter code highlighting with Native and WASM targets

    arborium

    Finding good tree-sitter grammars is hard. In arborium, every grammar:

    • Is generated with tree-sitter 0.26
    • Builds for WASM & native via cargo
    • Has working highlight queries

    We hand-picked grammars, added missing highlight queries, and updated them
    to the latest tree-sitter. Tree-sitter parsers compiled to WASM need libc
    symbols (especially a C allocator)—we provide
    arborium-sysroot
    which re-exports dlmalloc and other essentials for wasm32-unknown-unknown.

    Output formats

    HTML — custom elements like
    instead of
    . More compact markup. No
    JavaScript required.

    Traditional
    fn

    arborium
    fn

    ANSI — 24-bit true color for terminal applications.

    Platforms

    macOS, Linux, Windows — tree-sitter handles
    generating native crates for these platforms. Just add the
    dependency and go.

    WebAssembly — that one’s hard. Compiling Rust to
    WASM with C code that assumes a standard library is tricky. We
    provide a sysroot that makes this work, enabling
    Rust-on-the-frontend scenarios like this demo.

    Get Started

    Rust (native or WASM)

    Add to your Cargo.toml:

    arborium = { version = "2", features = ["lang-rust"] }

    Then highlight code:

    let html = arborium::highlight("rust", source)?;

    Script tag (zero config)

    Add this to your HTML and all

     blocks get highlighted
                                    automatically:
                                

    Your code blocks should look like this:

    fn main() {}

    fn main() {}

    fn main() {}

    Configure via data attributes:

           

    With data-manual, call
    window.arborium.highlightAll() when ready.

    See the IIFE demo →

    npm (ESM)

    For bundlers or manual control:

    import { loadGrammar, highlight } from '@arborium/arborium';
    
    const html = await highlight('rust', sourceCode);

    Grammars are loaded on-demand from jsDelivr (configurable).

    Integrations

    Your crate docs

    Highlight TOML, shell, and other languages in your rustdoc. Create
    arborium-header.html:

    Then in Cargo.toml:

    [package.metadata.docs.rs]
    rustdoc-args = ["--html-in-header", "arborium-header.html"]

    See it in action

    docs.rs team

    If you maintain docs.rs or rustdoc, you could integrate arborium
    directly! Either merge this PR
    for native rustdoc support, or use arborium-rustdoc as a
    post-processing step:

    # Process rustdoc output in-place
    arborium-rustdoc ./target/doc ./target/doc-highlighted

    It streams through HTML, finds

    
                                    blocks, and highlights them in-place. Works with rustdoc's theme system.
                                

    crates.io · docs.rs · See it in action!

    miette-arborium

    Syntax highlighting for miette error diagnostics. Beautiful, accurate highlighting in your CLI error messages.

    use miette::GraphicalReportHandler;
    use miette_arborium::ArboriumHighlighter;
    
    let handler = GraphicalReportHandler::new()
        .with_syntax_highlighting(ArboriumHighlighter::new());

    crates.io ·
    docs.rs

    dodeca

    An incremental static site generator with zero-reload live updates via
    WASM DOM patching, Sass/SCSS, image processing, font subsetting, and
    arborium-powered syntax highlighting.

    Nothing to configure—it just works. Arborium is built in
    and automatically highlights all code blocks.

    Website ·
    GitHub

    Languages

    96 languages included, each behind a
    feature flag. Enable only what you need, or use
    all-languages for everything.

    Each feature flag comment includes the grammar's license, so you always know
    what you're shipping.

    Theme support

    The highlighter supports themes for both HTML and
    ANSI output.

    Bundled themes:

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Alabaster

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Ayu Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Ayu Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Catppuccin Frappé

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Catppuccin Latte

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Catppuccin Macchiato

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Catppuccin Mocha

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Cobalt2

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Dayfox

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Desert256

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Dracula

    fn main() {
        let x = 42;
        println!("Hello");
    }

    EF Melissa Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    GitHub Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    GitHub Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Gruvbox Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Gruvbox Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Kanagawa Dragon

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Light Owl

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Lucius Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Melange Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Melange Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Monokai

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Nord

    fn main() {
        let x = 42;
        println!("Hello");
    }

    One Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Rosé Pine Moon

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Rustdoc Ayu

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Rustdoc Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Rustdoc Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Solarized Dark

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Solarized Light

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Tokyo Night

    fn main() {
        let x = 42;
        println!("Hello");
    }

    Zenburn

    Custom themes can be defined programmatically using RGB colors and style
    attributes (bold, italic, underline, strikethrough).

    Grammar Sizes

    Each grammar includes the full tree-sitter runtime embedded in its WASM module.
    This adds a fixed overhead to every grammar bundle, on top of the grammar-specific parser tables.

    Smallest
    -

    Average
    -

    Largest
    -

    Total
    -

    Language C Lines Size Distribution

    WASM Build Pipeline

    Every grammar is compiled to WASM with aggressive size optimizations. Here's the complete build pipeline:

    1. cargo build

    We compile with nightly Rust using -Zbuild-std to rebuild the standard library with our optimization flags:

    -Cpanic=immediate-abort
    Skip unwinding machinery

    -Copt-level=s
    Optimize for size, not speed

    -Clto=fat
    Full link-time optimization across all crates

    -Ccodegen-units=1
    Single codegen unit for maximum optimization

    -Cstrip=symbols
    Remove debug symbols

    2. wasm-bindgen

    Generate JavaScript bindings with --target web for ES module output.

    3. wasm-opt

    Final size optimization pass with Binaryen's optimizer:

    -Oz
    Aggressive size optimization

    --enable-bulk-memory
    Faster memory operations

    --enable-mutable-globals
    Required for wasm-bindgen

    --enable-simd
    SIMD instructions where applicable

    Despite all these optimizations, WASM bundles are still large because each one embeds the full tree-sitter runtime.
    We're exploring ways to share the runtime across grammars, but that's the architecture trade-off for now.

    FAQ

    Why not
    highlight.js or Shiki?

    Those use regex-based tokenization (TextMate grammars). Regexes
    can't count brackets, track scope, or understand structure—they just
    pattern-match.

    Tree-sitter actually parses your code into a syntax tree,
    so it knows that fn is a keyword only in the right
    context, handles deeply nested structures correctly, and recovers
    gracefully from syntax errors.

    IDEs with LSP support (like rust-analyzer) can do even better with
    semantic highlighting—they understand types and
    dependencies across files—but tree-sitter gets you 90% of the way
    there without needing a full language server.

    Why the name
    "arborium"?

    Arbor is Latin for tree (as in tree-sitter), and
    -ium denotes a place or collection (like aquarium,
    arboretum).

    It's a place where tree-sitter grammars live.

    I
    have a grammar that's not included. Can you add it?

    Yes!
    Open an issue
    on the repo with a link to the grammar.

    We'll review it and add it if the grammar and highlight queries are
    in good shape.

    Why not use the WASM builds from tree-sitter CLI?

    When doing full-stack Rust, it's nice to have exactly the
    same code on the frontend and the backend.

    Rust crates compile to both native and WASM, so you get one
    dependency that works everywhere.

    Why are
    tree-sitter parsers so large?

    Tree-sitter uses table-driven LR parsing. The grammar compiles down
    to massive state transition tables—every possible parser state and
    every possible token gets an entry.

    These tables are optimized for O(1) lookup speed, not size. A
    complex grammar like TypeScript can have tens of thousands of
    states.

    The tradeoff is worth it: you get real parsing (not regex hacks)
    that handles edge cases correctly and recovers gracefully from
    syntax errors.

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleIT Sustainability Think Tank: Perspectives on the print industry’s net-zero push in 2025
    Next Article The Whole App is a Blob
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    European Commission: TikTok’s addictive design breaches EU law

    February 14, 2026

    e& drives AI-first workforce transformation with Oracle Cloud

    February 14, 2026

    UK fintech investment slumped in 2025

    February 14, 2026
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025671 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 2025259 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 2025153 Views

    6 Best MagSafe Phone Grips (2025), Tested and Reviewed

    April 6, 2025112 Views
    Don't Miss
    Gaming February 14, 2026

    Highguard’s high-profile mistakes should be a lesson for other developers | Opinion

    Highguard’s high-profile mistakes should be a lesson for other developers | Opinion Wildlight’s game might…

    Sega records $200m impairment write-down for Rovio during Q3

    Ubisoft Q3 net bookings rise 12% to €338m, primarily driven by Assassin’s Creed franchise

    Clair Obscur wins Game of the Year at DICE Awards 2026

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    Highguard’s high-profile mistakes should be a lesson for other developers | Opinion

    February 14, 20262 Views

    Sega records $200m impairment write-down for Rovio during Q3

    February 14, 20262 Views

    Ubisoft Q3 net bookings rise 12% to €338m, primarily driven by Assassin’s Creed franchise

    February 14, 20262 Views
    Most Popular

    7 Best Kids Bikes (2025): Mountain, Balance, Pedal, Coaster

    March 13, 20250 Views

    VTOMAN FlashSpeed 1500: Plenty Of Power For All Your Gear

    March 13, 20250 Views

    This new Roomba finally solves the big problem I have with robot vacuums

    March 13, 20250 Views
    © 2026 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.