Tuesday, July 01, 2008

Code highlighting in blogs

I've looked around a bit for a utility for highlighting my code samples here on BlogSpot, and found a couple of useful tools.

The first is code2html, which has been around for some time, and turns your perl, python and other types into pretty, formatted html. It works well, is CGI, but has some limits to its' implementation.

Then I found a great swiss-army knife of a utility, called highlight.js. It will automatically detect code blocks, and highlight them for you. It does have issues with too much code, or intermixed code on one page, but does a nice job. If it fails to correctly identify your code, a sample export page is included with the package that allows you to manually format your code to html.

Happy highlighting!

1 comment:

John Croson said...

Well, I have to say that while I still use hightlight.js for dos batch, I've switched to Google Code's SyntaxHighlighter @ http://code.google.com/p/syntaxhighlighter/

It is now available as a Google Blogger Widget here: http://fazibear.blogspot.com/2007/09/blogger-syntax-higlighter.html