Google Blogoscoped

Thursday, March 22, 2007

Google’s Code Prettifier

Google released a neat client-side code prettifier. What you do is include their JavaScript and CSS files in your HTML page, trigger execution with an onload="prettyPrint()” event, and then find everything in your <pre class="prettyprint">...</pre> elements be nicely colored – see the sample output. (At 44 KB, the JavaScript is a bit too heavy to include in just any page if you don’t need it everywhere, though you can get rid of several KB by trimming the code from whitespace and comments.)

Which languages does this tool prettify? According to its author Mike Samuel this...

... should work on a number of languages including 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.

[Via Google Code’s featured projects.]

Advertisement

 
Blog  |  Forum     more >> Archive | Feed | Google's blogs | About
Advertisement

 

This site unofficially covers Google™ and more with some rights reserved. Join our forum!