«« Next » « Previous
«« Next » « Previous

Link Details

You don't even have to leave your chair. Login and vote now.
Link 16723 thumbnail

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.
  • 19
  • 0
  • 2317
  • 571

Comments

Add your comment
User 205047 avatar

Lowell Heddings replied ago:

0 votes Vote down Vote up Reply

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?

User 209881 avatar

pcx99 replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.