WordPress Google Syntax Highlighting with XHTML

Well, I set up this blog and then wanted a code syntax highlighter, because those are nifty. I installed this plugin and all seemed well. Then though I noticed the little XHTML link on the right side of the blog that is installed there by default and I clicked on it and it went over to the W3C validator where my new blog validated improperly! And all due to my new syntax highlighting plugin.

Well, it seems that this plugin is based on an older version of the Google Syntax Highlighter which doesn’t conform to standards.

http://code.google.com/p/syntaxhighlighter/wiki/Usage

The new one apparently works a bit differently in how it selects DOM elements.

http://alexgorbatchev.com/wiki/SyntaxHighlighter:Usage

The old one uses a pre tag with a “name” attribute as the selector and XHTML 1.0 doesn’t know from a name attribute in a pre tag.

So I altered the selector code a little so it finds by the “title” attribute instead. Perhaps I’ll just update the plugin code to use the new version of the SyntaxHighlighter, but for now this seems to work fine.

Leave a Reply

Your email address will not be published. Required fields are marked *