Andrew Thorp

Rainbow.js - Simple syntax highlighting library written in JavaScript

Craig Campbell, an employee at Vimeo, has created a very easy to use, lightweight (~3k) code syntax highlighting library written in JavaScript. Out of the box, Rainbow supports syntax highlighting for the following languages:

  • JavaScript, HTML, CSS, PHP, Python, Ruby, C, Shell, Scheme, Lua, C#

Adding support for your own languages is very easy, however, and theming is done entirely with CSS. If you don’t want to sweat the details of theming, you can use one of their many built-in themes (like the very popular solarized theme).

Getting started is easy:

<pre><code data-language="ruby">def greeting(name)
  puts "Hello there #(name)"

Then include your CSS theme in the <head> and rainbow.js (as well as whichever language[s] you want) before the closing </body>.

Checkout the demo or browse the source at GitHub. While you’re at it, feel free to fork the project and add support for your favorite language!


Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00