arborium-docsrs-demo

Crates.ioarborium-docsrs-demo
lib.rsarborium-docsrs-demo
version2.12.4
created_at2025-12-09 09:35:35.697853+00
updated_at2026-01-18 11:08:32.978513+00
descriptionDemo crate showcasing arborium syntax highlighting on docs.rs
homepage
repositoryhttps://github.com/bearcove/arborium
max_upload_size
id1975159
size9,524
Amos Wenger (fasterthanlime)

documentation

README

arborium-docsrs-demo

This crate demonstrates arborium syntax highlighting on docs.rs.

docs.rs highlights Rust code natively, but leaves other languages (TOML, shell, JSON, YAML, SQL, etc.) unhighlighted. This crate uses arborium's IIFE script via --html-in-header to highlight everything else.

How it works

  1. Create arborium-header.html:

    <script defer src="https://cdn.jsdelivr.net/npm/@arborium/arborium@2.12.4/dist/arborium.iife.js"></script>
    
  2. Add to Cargo.toml:

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

That's it! The IIFE automatically:

  • Detects code blocks by class="language-*"
  • Skips Rust blocks (they have semantic <a> links from rustdoc)
  • Highlights everything else with tree-sitter grammars

See the demo

Visit the module documentation to see highlighted TOML, shell, JSON, YAML, SQL, and more.

Commit count: 402

cargo fmt