ShowOff is great if you are fed up with the bloated presentation applications that make a mess of your source code. Text files means that presentations can be properly version controlled. It’s easy to re-arrange slides and sections. ShowOff uses SHJS to highlight code blocks. It supports many languages, but currently not Clojure. Searching around for a while revealed a Gist of SHJS styling code that I wanted to try out:
# Clojure syntax highlighting for GNU source-highlight
# rocks with SHJS
comment start ";"
vardef SPECIALCHAR = '\.'
environment string delim """ """ begin
specialchar = $SPECIALCHAR
type = "int|byte|boolean|char|long|float|double|short|void"
vardef FUNCTION = '(([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*)'
function = $FUNCTION
This is what I did on my MacOSX Snow Leopard to get ShowOff to high-light Clojure source code:
1. Install some pre-requisites. I use HomeBrew, but you can use MacPorts or whatever package manager you prefer.
gem install showoff
brew install yuicompressor
brew install source-highlight
brew install unix2dos
2. Download the shjs source distro.
3. Unzip shjs-0.6-src.zip somewhere which we will call SHJS_HOME
4. cd SHJS_HOME
5. touch source-highlight-lang/clojure.lang
6. Edit source-highlight-lang/clojure.lang and paste this Clojure source code high-lighting spec (that’s the same as displayed above).
7. My Perl installation needed a recursive descent parser, so I did this:
cpan install Parse::RecDescent