Colourising code

If anyone is interesting in colourising Haskell code to paste into HTML on your blog (as in my previous entry below), it was done with a simple Haskell program (of course). HsColour is a little script I knocked up a few years back. It uses an intermediate mini-language of highlighting styles, and currently has two backends, one for HTML and another for ANSI terminal screen codes. I'm sure it would be simple to add other backend rendering formats - maybe CSS - with a tiny bit of effort. If you do modify it, or otherwise find it useful, please let me know.

The history of HsColour is vaguely interesting, because it was essentially a spin-off of my (winning) entry in the 0th International Obfuscated Haskell Contest - remorse. If you haven't seen remorse before, I'll try not to spoil the fun of discovering it, but suffice to say, it requires a mini-lexer for Haskell code, which I ripped out and re-used in HsColour. Don't worry - that isn't the obfuscated bit.

This page is powered by Blogger. Isn't yours?