You don't even have to leave your chair. Login and vote now.
By matt
via code.google.com
Published: Mar 22 2007 / 14:25
A Javascript module and CSS file that allows syntax highlighting of source code snippets in an html page.
SaveShareSend
Tags: css-html, javascript, open source
Comments
Lowell Heddings replied ago:
I like this... it's nice and simple, as opposed to some of the other highlighters that are bloated.
Anybody know how it handles posts in RSS feeds?
pcx99 replied ago:
Here's a very slightly modified version that lets you use your own classname (and it's not case sensitive)..
http://www.hunlock.com/prettifynomin.js
Download it to use it, don't include it -- or horrific things will happen to you, I promise :-P The filename is named prettifynomin.js because I minimized the production copy on my server, you can rename it back to prettify.js to be compatible with the google docs, or make your changes and run it through the minifier: http://fmarcia.info/jsmin/test.html
Anyway...
On line 49...
var prettyClass= new RegExp('code','i');
change 'code' to be whatever classname you want to be prettified. That's really the only thing that needed to be changed. It's very clean and elegant code.
This is useful if you already have production code and want to use this javascript. All you have to do is modify the classname to match your own usage.
Voters For This Link (19)
Voters Against This Link (0)