Take the 2-minute tour ×

I'm looking for a general purpose syntax highlighting library, to output to html.

It's for use within a ruby app, so a ruby library would be good, but an excellent utility which can be piped in and out of would do

Also needs to guess the appropriate language to highlightsy by itself

share|improve this question
add comment

6 Answers

up vote 16 down vote accepted

HTML/CSS/JavaScript based syntax highlighter solutions are the most popular and work well with different server technologies including Ruby.


  • Syntax highlighting library for various languages at Rubyforge.org. Has built-in support for converting source code to syntax-highlighted HTML.

  • SyntaxHighlighter for WordPress. It allows you to easily post syntax highlighted code all without losing its formatting or making an manual changes.

  • Prettify. A Javascript module and CSS file that allows syntax highlighting of source code snippets in an html page.

  • GeSHi - Generic Syntax Highlighter. GeSHi started as an idea to create a generic syntax highlighter for the phpBB forum system, but has been generalised to this project. GeSHi aims to be a simple but powerful highlighting class, with the following goals: (1) Support for a wide range of popular languages (2) Easy to add a new language for highlighting (3) Highly customisable output formats


  • SyntaxHighlighter for Windows Live Writer at CodePlex.com (just in case :)

And here a few blog posts on the subject:

share|improve this answer
add comment

Have you looked at Google's syntax highlighter? I believe SO uses it?


Edit: Actually I believe it is Prettify:


share|improve this answer
add comment

Some options are:

  • Syntax - Its really broad, but I think it has some licensing concerns (Syntax is GPL)

  • Coderay - I use this on my blog, it's pretty limited, but is functional

  • Ultraviolet which support a ton of languages (anything that textmate can do)

  • If you are willing to bridge into Python there is Pygments, which supports a ton of languages

share|improve this answer
add comment

Try rouge. It's pure ruby, compatible with pygments, and actively developed.

share|improve this answer
add comment

You might want to take a look at Colorer. It doesn't seem to have bindings for Ruby, but there are for Perl and PHP, maybe one would be able to hack a binding together for Ruby on that basis.

share|improve this answer
add comment

Scintilla can be used with C++ code. I don't know about is there a way to use C++ applications in Ruby.

share|improve this answer
add comment

Your Answer


