I was browsing around today and came across the “google-code-prettify” Javascript and CSS code prettifier (download page) on Google Code. If you cant be bothered to look, it seems to be a fairly accomplished code-highlighting script - this is the description of the langauges supported from the Google Code site:
C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, because of commenting conventions, doesn’t work on Smalltalk, Lisp-like, or CAML-like languages.
You can see how it well it copes with these languages by looking at some examples on their prettifier test page.
I was interested to see how the author had gone about displaying code listings in HTML in a pleasing way as I have just recently been tackling the same issue for listings on this very blog; here are some of my thoughts on this effort:
- The Javascript and CSS combined is over 40K!
- There is no semantic markup included (i.e. there are no <code> tags).
- It doesn’t bother with using the <ol> tag to get line numbering “for free”.
I was a little surprised to see them not bother with <code> tags, as semantics seems to be gaining a lot of mind share recently (especially amongst search engines), and the 40K size strikes me as a bit hefty, especially for use on blogs and the like.
I am not entirely sure if this is an actual “Google effort” as it were - as far as I know the Google Code service is a SourceForge-style site available to anyone, but the code listing has a Google copyright message in it … anyone know the details here?
I guess if it really is from a Google employee you cant really complain about the (open source) script apparently flying in the face of what a lot of people consider Google to “stand for” (i.e. small & efficient with an emphasis on semantics) - it just seems a little bit out of character! Kudos for what seems to be a pretty cool script though!