Seek and ye shall find. I posted yesterday about the trials and tribulations of code formatting. While I've solved the basic problems of displaying code, we spoiled programmers have gotten really used to syntax highlighting. Syntax highlighting offers a lot of visual differentiation of text which makes it a lot easer to read code.
Brennan posted a comment about adding syntax highlighting, possibly with Javascript. I thought that was a great idea and was all ready to jump in and write the code. As a precursor though (all good programmers are lazy remember) I decided to see if anything already existed.
And I nearly found perfection in dp.SyntaxHighlighter. It's a Javascript library for syntax highlighting code snipits in HTML. It's beautifully written code that takes advantage of cool javascript features like prototyping. Each language syntax is abstracted out into its own file with it's own keyword definitions and comment definitions. As I said, it's a beautifully engineered piece of code and really shows off the power and elegance of the much maligned Javascript language.
The only tweak I had to make to the code was that it had been hardcoded to work with
Anyway I'm going to start playing with this and see if I can implement it on my blog. Check back soon for an update.
Update: Well my little change didn't work so well after all. Things like generics don't work well within the <code> block. I think the browsers are trying to turn them into tags. Inside a