Rouge is a pure Ruby syntax highlighter that can output HTML or ANSI 256-color text and is compatible with Pygments stylesheets.
The tool solves the problem of syntax highlighting code snippets in Ruby applications without external dependencies. It works by parsing source code and tokenizing it according to language-specific lexers, then applying formatting rules to produce colored output. The approach is language-agnostic, supporting over two hundred different languages through individual lexer implementations.
Rouge suits projects that need syntax highlighting as a library component, particularly those already using Ruby. It integrates directly into Jekyll as the default syntax highlighter and can be used as a command-line tool via the rougify command. The tool's Pygments compatibility means existing stylesheets designed for Pygments can be reused without modification. Developers should choose it when they want to avoid external highlighter dependencies or need fine-grained control over output formatting through custom formatters.
The project maintains active development with regular updates to language support and formatter options. The codebase uses standard Ruby testing and linting practices to ensure code quality. The tool provides multiple built-in formatters for different use cases, from simple HTML class-based styling to complex table layouts with line numbering and highlighting, allowing users to extend functionality through custom formatter implementations.