pygmalion
Syntax highlighting using the pygments.com "web service".
WHY?
I have historically used ultraviolet for any syntax highlighting. However, in order to use ultraviolet, you need to be able to use the oniguruma library. Unfortunately, some hosting services (like the Media Temple grid service) do not support this library. I needed another solution, and it seemed like something that could be outsourced.
Installation
Run the following if you haven't already:
$ gem sources -a http://gems.github.com
Install the gem(s):
$ sudo gem install -r sbfaulkner-pygmalion
Usage
In ruby...
require 'pygmalion'
...
string.highlight
string.highlight(:language => 'js')
string.highlight(:language => 'rb', :line_numbers => true)
From the command-line...
Usage: pygmalion [options] [file ...]
Options:
-h, --help Display this message.
-l, --language=name The language for the code to be highlighted.
-n, --line-numbers Include line numbers.
Example
File.read('hello.rb').highlight
Results in...
<div class="highlight"><pre><span class="k">def</span> <span class="nf">hello</span>
<span class="n">puts</span> <span class="s">"hello"</span>
<span class="n">end</span>
</pre></div>'
Legal
Author: S. Brent Faulkner brentf@unwwwired.net
License: Copyright © 2008 unwwwired.net, released under the MIT license