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:

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

cp ./ /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

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

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

vim /etc/websvn/
# 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 to include naming and start rules for ruby if you'd like. e.g.

vim /usr/share/enscript/hl/
# 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: