Sunday 4 April 2010

Ruby syntax highlighting within websvn

I'm assuming you are using GNU Enscript for syntax highlighting with your websvn install.

It seems that enscript does not come with a ruby syntax highlighting rules file by default.So the first thing to do is find one. This one works for me:

http://support.rubyforge.org/svn/trunk/support/ruby.st?ref=darwinports.com

Now copy this into your enscript highlight rules directory. e.g.

cp ./ruby.st /usr/share/enscript/hl/

OPTIONAL: Test if highlighting is working or not:

enscript --color --language=html -Eruby --output=hello_ruby.html ./hello_world.rb

Now for the websvn side of things:

First off edit the websvn setup.php file and add rb and erb extensions to the $extEnscript array

e.g.
vim /usr/share/websvn/include/setup.php
# SNIP - find the extEnscript array
$extEnscript = array
# SNIP - and add these two
'.rb' => 'ruby',
'.erb' => 'ruby',
# SNIP

Next, edit websvn's config.inc file. e.g.

vim /etc/websvn/config.inc
# SNIP - search for extEnscript and add the following two lines.
$extEnscript[".rb"] = "ruby";
$extEnscript[".erb"] = "ruby";

This should be enough to get ruby syntax highlighting working. You can also edit your enscript.st to include naming and start rules for ruby if you'd like. e.g.

vim /usr/share/enscript/hl/enscript.st
# SNIP - Search for namerules and add the following:
/\.(rb|erb)$/ ruby;
# SNIP - Search for startrules and add the following:
/-\*- [Rr][Uu][Bb][Yy] -\*-/ ruby;

No comments: