In preparation for an up-coming post1, I did a bit of extra legwork on syntax highlighting plugins for WordPress and wound up switching from Google Syntax Highlighter for WordPress (GSHW)2 to SyntaxHighlighterPro. Both of them are backed by Alex Gorbatchev’s Syntax Highlighter library. But more on that in a moment.
What prompted the switch was the fact that I noticed that GSHW was mangling some CSS syntax highlighting operations. The regex used to grab hex colors was getting greedy and highlighting
#id-selectors as if they were colors3. After a little digging, I came to discover that GSHW was using a quite-out-of-date version of Gorbatchev’s library.
Exploring the Syntax Highlighter site a bit, I found a couple of other plugins that appeared to be more up-to-date. I gave a crack at SyntaxHighlighter Evolved and the above mentioned SyntaxHighlighterPro. Both had more recent versions4 of the library baked in. Both seemed a step up in that regard, but I went with -Pro because it was going to require the fewest tweaks and changes5 in the code samples already posted6 and also because its control panel offered the ability to toggle specific syntaxes at will.
That said, the “Evolved” plugin has a nice suite of options.
This is likely just a temporary stop-gap measure, however. I may pull the plug on the plugins and just drop in Gorbatchev’s script directly—the latest version appears to offer on-demand loading of the “brush” scripts. Combine that with a minified version of the script and that may prove a better overall solution than the plugins can offer.
Nevertheless, the problem remains that the CSS highlighter “brush” script needs some work. It doesn’t really seem to recognize common selectors (
.class selectors, I’m looking at you)… and this bugs me.
But until then…
- Quite likely the next post… [↩]
- Which I’ve been using for a few months now. [↩]
- Meaning that it was only coloring the hash and the first six characters of
- Though neither was using the most recent version. [↩]
- I.e., it more gracefully relented to my efforts to kludge in the AppleScript and Sass support. [↩]
- I.e., -Pro recognized the
<pre>formatted blocks whereas Evolved was going to require changing all those to use BBCode-style
[bracket]syntax. Ick. [↩]