WordPress Killed My Code

…but that’s okay – WP-Syntax resurrected it.

After looking at one of my earlier posts I noticed that all the backslashes were gone from my code examples, most notably my regular expressions. I had the code wrapped in <pre></pre> tags. As some searching revealed, this seems to be a recurrent bug in WordPress 2.2.1 (I upgraded a few days ago). Somewhere inside the WP code there’s probably an unneeded call to stripslashes(), meaning I’d have to double each backshlash to have them display correctly.

Since I was already manually escaping all the < > brackets and &amp;’s, the perspective of worrying about yet another special character that could break my copy-pasted code didn’t appeal to me. So I decided to finally look for a code highlighter plugin to do this for me and hopefully avoid the backslash bug, too.

That’s how I found WP-Syntax – a syntax highlighting plugin. It fixes the aforementioned problems and makes the code look a bit better – though the default color scheme isn’t that great IMHO. With some stylesheet editing I even managed to make my <pre> blocks to become horizontally scroll-able when a line is too long to fit inside my post’s content.

I’m not saying this is the greatest syntax highlighting plugin ever – I didn’t really try out a lot of them. Still, WP-Syntax works for me and is worth a look if you’re not already using some kind of code prettifier on your blog.

Related posts :

Leave a Reply