Google Blogoscoped


Google's Code Prettifier  (View post)

Adrian [PersonRank 0]

Thursday, March 22, 2007
17 years ago5,675 views

I still prefer, but it is a nice prettifier in any case!

Ryan [PersonRank 0]

17 years ago #

I was actually looking for something like this last week.

I've always wondered why languages php, python, ruby, etc don't have a built in function (or module) that automatically highlights a string of it's own source code and outputs HTML.

Most websites that talk about a scripting language are written in that scripting language, and it'd probably be more efficient to have a compiled-in function do it instead of relying on client side javascript.

Tue Abrahamsen [PersonRank 7]

17 years ago #

[put at-character here]Ryan

PHP actually does. The highlight_file() and highlight_string() functions :)

Ryan [PersonRank 0]

17 years ago #

Tue, so it does. Thanks!

I don't like that it requires you to put the <? and ?> tags in anything you pass it though :'(

Is prettifier the wrong word though? Should they have used highlighter?

When I think of prettifying, I think of making sure all my = signs line up vertically, everything is nicely tabbed like in Python, all my brackets line up, etc.

Pamela Fox [PersonRank 2]

17 years ago #

I must say that I love the prettifier. I discovered it being used in the Maps documentation a month ago and immediately started using it anywhere I show code samples. It has worked for me for PHP, mySQL, and javascript, and only takes a few minutes to plug-in.
It makes my code feel pretty, oh so prettttty...

Hong Xiaowan [PersonRank 10]

17 years ago #

Good, simple and really can work well. [PersonRank 1]

17 years ago #

Just squeezed it through dojo's shrinksafe (, a neat online javascript code obfuscator. The file size after obfuscation was 18 KB, much better than the original 44 KB...


[Link fixed – Tony]

shane [PersonRank 0]

17 years ago #

Surely you are better off doing this 'offline' on the server and caching the markup. No sense in re-processing the code on the client end every single time when its just generating the same results over and over.

The only practical use I see for this is when writing code through the browser, eg something like 'writely' or when submitting code to a forum etc where the markup might need to be done before submission to the server.

Andrew Hitchcock [PersonRank 10]

17 years ago #

SubEthaEdit, which I use a lot, has a "Copy as XHTML" feature which copies the highlighted code and inserts the necessary HTML to make it look like it does in the editor.

Forum home


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


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