Code syntax highlighting in WordPress – take two
It turns out that the WordPress Syntax Highlighter plugin that I mentioned a couple of weeks ago has some rather nasty artifacts. One in particular is that when you try to display HTML — or any code containing HTML — WordPress tries to “fix” this by adding extra tags that you may not want to make it valid XHTML, and it b0rks your nice tidily formatted source code in the process. Another problem was that it converted emoticons to images — a big no-no when you’re writing source code.
Yeah, maybe I should have been using the rich text editor, but that caused other problems. Rich text editors generally wreak havoc with source code, so it’s best to turn them off when you’re doing anything of that nature.
This was the reason why I stuck with Code Auto Escape for so long. Entering source code is awkward, to be sure, but nevertheless the plugin is pretty robust and does a good job. I did try a few proper syntax highlighter plugins way back, but I didn’t find any of them all that satisfactory. However, Code Auto Escape is a plugin that Just Works™.
Sooo… why not combine the two approaches?
Over the Bank Holiday I’ve spent a few hours writing a new plugin that does precisely that. I took Code Auto Escape as the baseline, and added a whole bunch of extra code to plug in the syntax highlighter scripts.
Interested? Get Coder 1.0 alpha 1 here.
Fancy writing a C# version for BlogEngine.Net?
Please check the xhtml mod for syntaxhighlighter, which uses the CSS tags instead of name tags, this way it frees name tags, conforms to xhtml, prevents having duplicate names and allows space seperated class values. Supporting xhtml, it also can be used with blogger.com
The mod can be found at :