#syntax-highlighting #multi-language #code-highlighting

nightly oak-highlight

A lightweight syntax highlighter for Rust with support for multiple programming languages and customizable themes

7 releases

Uses new Rust 2024

new 0.0.6 Mar 4, 2026
0.0.5 Mar 3, 2026
0.0.4 Feb 15, 2026
0.0.2 Jan 30, 2026
0.0.0 Oct 20, 2025

#1163 in Text processing

Download history 182/week @ 2025-11-11 140/week @ 2025-11-18 135/week @ 2025-11-25 145/week @ 2025-12-02 104/week @ 2025-12-09 164/week @ 2025-12-16 170/week @ 2025-12-23 123/week @ 2025-12-30 64/week @ 2026-01-06 71/week @ 2026-01-13 157/week @ 2026-01-20 231/week @ 2026-01-27 124/week @ 2026-02-03 276/week @ 2026-02-10 150/week @ 2026-02-17 196/week @ 2026-02-24

786 downloads per month
Used in 124 crates (123 directly)

MPL-2.0 license

335KB
5.5K SLoC

🚀 oak-highlight

Crates.io Documentation

Multi-Format Syntax Highlighting for Oak Languages — A flexible highlighting library with support for ANSI, HTML, CSS, and JSON output formats.

🎯 Why oak-highlight?

Syntax highlighting transforms code from plain text into visually structured, readable content. oak-highlight provides a unified highlighting infrastructure that works across all Oak language parsers.

✨ Key Features

  • 🎨 Multiple Export Formats — ANSI, HTML, CSS classes, and JSON
  • 🔤 Token-Based Highlighting — Fast, accurate highlighting from token streams
  • 🎭 Theme Support — Pluggable theming with predefined and custom themes
  • ⚡ Zero-Allocation Design — Highlight results borrow from source text
  • 🧩 Language Agnostic — Works with any Oak language parser

🏗️ Architecture

  • OakHighlighter — Main highlighter processing source into segments
  • HighlightResult — Collection of highlighted segments with style
  • Exporter trait — Convert results to various output formats

Available Exporters

Exporter Output Format Use Case
AnsiExporter ANSI escape codes Terminal, CLI tools
HtmlExporter HTML with inline styles Web applications
CssExporter HTML with CSS classes Custom styling
JsonExporter JSON array Tooling integration

🔗 Ecosystem Integration

Used by oak-repl for terminal highlighting, oak-lsp for semantic tokens, and language-specific parsers for preview generation.

📖 Documentation

For usage examples and API details, see the API documentation.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Dependencies

~5.5–8MB
~73K SLoC