A pure Ruby syntax highlighter compatible with Pygments, supporting over 200 languages and outputting HTML or ANSI 256-color text.
Rouge is a pure Ruby syntax highlighter that formats source code into HTML or ANSI-colored text for display in documentation, blogs, or terminals. It supports over 200 languages and is designed to be a drop-in replacement for Pygments, offering compatibility with existing stylesheets and seamless integration into Ruby ecosystems.
Ruby developers, technical writers, and maintainers of documentation sites (especially Jekyll-based blogs) who need a reliable, dependency-free syntax highlighter.
Developers choose Rouge for its pure Ruby implementation, eliminating external dependencies, and its full compatibility with Pygments stylesheets, making migration effortless. Its extensible formatter system and wide language support make it versatile for various output needs.
A pure Ruby code highlighter that is compatible with Pygments
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Highlights over 200 programming and markup languages, as listed in the documentation, making it versatile for diverse codebases in documentation or blogs.
Outputs HTML compatible with stylesheets designed for Pygments, allowing seamless migration from Python-based highlighters without redesigning styles.
Supports multiple formatters including HTML, ANSI 256-color for terminals, and TeX, catering to various presentation needs from web to print.
Works out-of-the-box with Ruby frameworks like Jekyll (default highlighter), Rails via gems, and has command-line tools for quick usage.
Runs on pure Ruby 3.0+, eliminating external libraries, which simplifies deployment and reduces setup complexity in Ruby environments.
Requires Ruby 3.0 or higher, which can be a barrier in non-Ruby projects or serverless setups where Ruby isn't installed.
The README encourages writing custom formatters for specific needs, which involves subclassing and understanding token streams, adding development overhead.
Only supports UTF-8 strings, so code in other encodings must be converted first, an extra step that can introduce errors or complexity.
Lexer debug mode requires calling `Rouge::Lexer.enable_debug!` first, making troubleshooting less intuitive compared to always-available options.
Rouge is an open-source alternative to the following products: