Smalto

Package Version Hex Docs conventional-commits Erlang Compatible JavaScript Compatible

A general-purpose syntax highlighting library for Gleam, with regex-based grammars for 30 languages.

Smalto tokenizes source code using Prism.js-inspired grammars and renders the result as HTML with CSS classes, ANSI terminal colors, or structured tokens for custom rendering.

Features

How it works

  1. You pick a language grammar (e.g., python.grammar())
  2. Smalto tokenizes the source code into a list of Token values using a Prism.js-faithful engine
  3. You choose an output format: HTML, ANSI, or raw tokens

Documentation

Guide Description
Getting started Installation, quick examples
Lustre integration Render highlighted tokens as Lustre elements
Tokens Token types, names, and values
Grammars Grammar structure, rules, and custom grammars
ANSI themes Configuring terminal color themes
Supported languages Full list of built-in language grammars

API reference

Full API documentation is available on HexDocs.