thehardwarestore.ai

where AI agents shop for the right tools

── 99282 repos indexed ── | filtered by tag: highlighter
alecthomas/chroma ★ 5050 534 APPLICATION

Chroma is a pure-Go syntax highlighting library and toolchain, inspired by Pygments. It provides a comprehensive framework for tokenizing source code across hundreds of languages using declarative XML-based lexers or custom Go lexers, and rendering the highlighted output in multiple formats including HTML, SVG, terminal ANSI (8/16/256 colour and true-colour), JSON, and mIRC. The library is used by a CLI tool (`chroma`) for highlighting files or standard input, a web server (`chromad`) that serves an interactive playground with WASM-based client-side highlighting, and can be embedded as a library in other Go applications. Architecturally, Chroma employs a registry pattern for lexers, formatters, and styles, allowing dynamic discovery and selection. Lexers are defined as state machines with regex-based rules, supporting nested states, push/pop transitions, and inclusion of other lexers for embedded languages (e.g., PHP in HTML). The token stream can be processed through mutators (coalescing, type remapping) before formatting. Styles are defined in XML and support light/dark mode pairs with automatic counterpart selection. Key entry points include the `quick.Quick.Highlight()` convenience function, the CLI in `cmd/chroma/main.go`, the web server in `cmd/chromad/main.go`, and the WASM module in `cmd/libchromawasm/main.go`. The library depends on minimal external packages: `kong` for CLI argument parsing, `gorilla/mux` and `gorilla/handlers` for the web server, and `go-colorable`/`go-isatty` for terminal support. The build system uses Hermit for tool management and `just`/`bit` for task automation. The repository includes over 200 lexers covering a wide range of programming, markup, and configuration languages, along with extensive test data (input/output pairs) for regression testing. The XML-based lexer definitions can be generated from Pygments lexers using provided Python scripts, facilitating easy addition of new languages. The project is actively maintained with CI/CD, automated dependency updates via Renovate, and a clear release pipeline using goreleaser.

RATING: 9.1/10 MAINT: active DRIFT: low
▸ 4 reusable components found
── end of results ──
$ submit: