Source Code Syntax Highlighting For Fun and Profit

March 5th, 2009

I use wp-syntax for syntax highlighting on Wordpress, but I changed the code to use:

<pre class="sh_html">

instead of:

<pre lang="html">

I did this for future xhtml compliance. I also did it for shjs, which uses class too. Ultimately I think that syntax highlighting should be a client side process, especially for code snibbets which are embedded in other markup. Complete files are much easier to send through a web server filter (like source-highlighter) for faster processing and cacheable content. Wordpress does some wacky internal formatting and filtering like changing quotes and such, and thankfully wp-syntax avoids all that, so I'm sticking with it for as long as I use Wordpress for rendering output.

I would also like to use <code> tags along with <pre>, but that makes some of my transformations with XSL a little more difficult to use them together. I may end up switching to only using <code> - in that case I'll have a lot of tags to change over!

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022