talira

A pure Ruby code highlighter that is compatible with Pygments

open sourceMIT AND BSD-2-Clausefree

Rouge is a pure Ruby syntax highlighter with lexers for over 200 languages, many adapted from Pygments. It outputs HTML (with standard class names, inline styles for email, line numbers, highlighted lines or table layouts), ANSI 256-colour or truecolor terminal text and TeX, and its HTML works with stylesheets made for Pygments. It's Jekyll's default highlighter, renders themes such as Monokai and Base16 as CSS, and comes with a rougify command. Jeanine Adkisson created it in 2012; a team of volunteers maintains it, and its development has moved to Codeberg.

Problems it solves

  • highlight code snippets on my Ruby-generated blog or docs site
  • colour source code in HTML using the Pygments stylesheets I already have
  • syntax highlighting without installing Python on our Ruby servers
  • show highlighted code in emails where external CSS doesn't work
  • print syntax-highlighted source files in the terminal
  • add line numbers and highlight specific lines in a code sample
  • generate a CSS theme like Monokai for highlighted code blocks
  • highlight code in a language the highlighter doesn't know yet by writing my own lexer
  • guess the language of a code snippet that came without a label
  • highlighted code listings in a LaTeX document from Ruby

Features

  • lexers for over 200 languages
  • HTML, inline-styled HTML, line table, linewise and line highlighter formatters
  • Pygments-compatible HTML output and wrapper
  • ANSI 256-colour and truecolor terminal output
  • TeX formatter
  • built-in themes rendered as CSS, such as Base16 and Monokai
  • rougify command to highlight files and print theme CSS
  • language guessing
  • plugins for extra lexers, and custom formatters
  • no external dependencies; Ruby 3.0 and later

Capabilities

Has an APIplan not known
Has a command line toolplan not known
Takes pluginsplan not known