@arborium/arborium
v2.16.0
Published
High-performance syntax highlighting powered by tree-sitter and WebAssembly
Downloads
860
Maintainers
Readme
@arborium/arborium
High-performance syntax highlighting powered by tree-sitter and WebAssembly.
Installation
npm install @arborium/arboriumUsage
Option 1: Drop-in Script (Easiest)
Add a single script tag and arborium auto-highlights all code blocks:
<script src="https://cdn.jsdelivr.net/npm/@arborium/arborium/dist/arborium.iife.js"></script>That's it! Arborium will:
- Auto-detect languages from
class="language-*"ordata-lang="*"attributes - Load grammar WASM plugins on-demand from jsDelivr CDN
- Inject the default theme CSS
Configuration via data attributes:
<script
src="https://cdn.jsdelivr.net/npm/@arborium/arborium/dist/arborium.iife.js"
data-theme="tokyo-night"
data-selector="pre code"
></script>Option 2: ESM Module (Programmatic)
import { loadGrammar, highlight } from '@arborium/arborium';
// Load a grammar (fetched from CDN on first use)
const grammar = await loadGrammar('rust');
// Highlight code
const html = grammar.highlight('fn main() { println!("Hello!"); }');
// Or use the convenience function
const html = await highlight('rust', code);Themes
This package includes 32 built-in themes. Import them individually:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@arborium/arborium/dist/themes/tokyo-night.css">Or import in JavaScript:
import '@arborium/arborium/themes/tokyo-night.css';Available Themes
Dark themes: catppuccin-mocha, catppuccin-macchiato, catppuccin-frappe, dracula, tokyo-night, nord, one-dark, github-dark, gruvbox-dark, monokai, kanagawa-dragon, rose-pine-moon, ayu-dark, solarized-dark, ef-melissa-dark, melange-dark, cobalt2, zenburn, desert256, rustdoc-dark, rustdoc-ayu
Light themes: catppuccin-latte, github-light, gruvbox-light, ayu-light, solarized-light, melange-light, light-owl, lucius-light, dayfox, alabaster, rustdoc-light
Theme Attribution
All themes are adaptations of color schemes from their original projects. We are grateful to the original theme authors:
| Theme | Source | |-------|--------| | Ayu | ayu-theme/ayu-colors | | Catppuccin | catppuccin/catppuccin | | Cobalt2 | wesbos/cobalt2-vscode | | Dayfox | EdenEast/nightfox.nvim | | Desert256 | vim-scripts/desert256.vim | | Dracula | draculatheme.com | | EF Melissa | protesilaos.com/emacs/ef-themes | | GitHub | primer/github-vscode-theme | | Gruvbox | morhetz/gruvbox | | Kanagawa | rebelot/kanagawa.nvim | | Light Owl | sdras/night-owl-vscode-theme | | Lucius | jonathanfilip/vim-lucius | | Melange | savq/melange-nvim | | Monokai | monokai.pro | | Nord | nordtheme.com | | One Dark | atom/one-dark-syntax | | Rosé Pine | rosepinetheme.com | | Rustdoc | rust-lang/rust | | Solarized | ethanschoonover.com/solarized | | Tokyo Night | enkia/tokyo-night-vscode-theme | | Zenburn | jnurmine/Zenburn | | Alabaster | tonsky/vscode-theme-alabaster |
Links
License
MIT OR Apache-2.0
The bundled themes are adaptations of color schemes from their respective projects. Please see each project's repository for their specific licensing terms.
