CodeRay Syntax Highlighter As a Rails Plugin
by Jarrett Colby
First, you'll need the CodeRay source. The Gem is supposedly out-of-date, so I'd recommend checking CodeRay out of Subversion instead:
mkdir vendor/plugins/coderay cd vendor/plugins/coderay svn export svn://rubyforge.org//var/svn/coderay/trunk/coderay/trunk/lib/
CodeRay now resides in vendor/plugins/coderay/lib—just where we want it. Now create a very simple init.rb in vendor/plugins/coderay:
require 'coderay'Don't forget to restart your server.
The only thing left is to call CodeRay in your views. For that, I use Jerrett Taylor's helper. Note that this helper uses its fair share of CPU cycles, so you should probably use some form of caching if at all possible.
If you want to integrate it with Mephisto, read Code Syntax Highlighting in Mephisto with CodeRay.