Adam Stacoviak changelog.com/posts

Syntax highlighting now done with highlight.js

We shipped an update tonight that replaces the old cargo-culted Prettify syntax highlighter we’ve been using for years with highlight.js from Ivan Sagalaev – you can support his open source through Gittip.

Highlight.js has numerous themes to choose from (we’re using Tomorrow Night) and is a cinch to integrate. It automatically: finds blocks of code, detects the language, and highlights it.

Here are a few samples.

Ruby:

# Output "I LOVE RUBY"
say = "I love Ruby"
puts say.upcase

JavaScript:

function helloWorld () {
  // Log out to console
  console.log("Hello world!");  
}

helloWorld();

CSS:

.for-1 {
  width: 61px;
}

.for-2 {
  width: 62px;
}

.for-3 {
  width: 63px;
}

.for-4 {
  width: 64px;
}

No highlight:

$ gem install rails
$ rails new app
$ cd app
$ subl .

I’m still holding out for Sass/SCSS support – there’s this issue.

Check out the source on GitHub, the demo, or the developer docs if you want to add support for your favorite languages.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00