My blog! Now with syntax highlighting!
I know you all have been waiting on the edge of your seat for this one! Of course, prior to this I didn’t have any JavaScript on the site at all.
I threw it all together using google-code-prettify and jQuery. The prettification code works pretty well, but it assumes you have your HTML in a form where the <pre>
tag has class='prettyprint'
on it. Because my blog post HTML is all generated using Markdown, it was easier to add the class dynamically with a little more JS and then kick off the prettification. Of course, wanting to do things correctly involved picking a JS library so I didn’t resort to using the onload attribute…you get the point.
Of course, rather than me telling you all of this, you can just look at the end result, which I think ends up looking pretty good. Enjoy!
Tags
See Also
- Why JS libraries are timesavers - May 10, 2009
- New blog theme - October 21, 2009
- ReadWriteWeb: hosters of unoriginal content - October 15, 2009
- Django Proxy Models - August 1, 2009
- PostgreSQL thoughts and experiences - May 11, 2009