v0.1.0

Initial public release

2 min read 393 words

Released: January 2, 2026

Initial public release of Rosettes, extracted from the Bengal static site generator.

Highlights

  • 55 language lexers — Hand-written state machines for Python, JavaScript, Rust, Go, and 51 more
  • O(n) guaranteed — Linear time complexity, zero ReDoS vulnerabilities
  • Python 3.14t optimized — Designed for free-threading (PEP 703) with declared GIL-free safety
  • Pygments compatible — Drop-in CSS class compatibility
  • Parallel APIhighlight_many()andtokenize_many()for concurrent processing

Features

Core API

  • highlight()— Generate formatted output with syntax highlighting
  • tokenize()— Get raw tokens for custom processing
  • highlight_many()— Parallel highlighting for multiple blocks
  • tokenize_many()— Parallel tokenization

Formatter Registry

  • get_formatter()— Get formatter by name or alias
  • list_formatters()— List all supported formatters
  • supports_formatter()— Check formatter support

Built-in formatters:

  • HTML — Semantic or Pygments-compatible CSS classes
  • Terminal — ANSI-colored terminal output
  • Null — No-op formatter for benchmarking

Lexer Registry

  • get_lexer()— Get lexer by name or alias
  • list_languages()— List all supported languages
  • supports_language()— Check language support

Styling

  • Semantic CSS classes (.syntax-keyword,.syntax-function, etc.)
  • Pygments-compatible classes (.k,.nf, etc.)
  • Line highlighting withhl_lines
  • Line numbers withshow_linenos

Languages

55 languages supported:

Category Languages
Core Python, JavaScript, TypeScript, JSON, YAML, TOML, Bash, HTML, CSS, Diff
Systems C, C++, Rust, Go, Zig, CUDA
JVM Java, Kotlin, Scala, Groovy, Clojure
Scripting Ruby, Perl, PHP, Lua, R, PowerShell
Functional Haskell, Elixir
Modern Dart, Julia, Nim, Gleam, V, Mojo, Triton
Config INI, Nginx, Dockerfile, Makefile, HCL, CUE, Pkl
And more... Swift, SQL, GraphQL, Markdown, XML, Protobuf, CSV, Stan, etc.

Installation

pip install rosettes

Requires Python 3.14+.

Quick Start

from rosettes import highlight

# HTML output (default)
html = highlight("def hello(): print('world')", "python")

# Terminal output
ansi = highlight("def hello(): print('world')", "python", formatter="terminal")

# Parallel processing
from rosettes import highlight_many

blocks = [
    ("def foo(): pass", "python"),
    ("const x = 1;", "javascript"),
]
results = highlight_many(blocks)

Known Limitations

  • 55 languages (vs Pygments' 500+)
  • Python 3.14+ required