Wordpress Syntax Highlighting (It’s About Time!)
November 19th, 2008
For years, I’ve been using tidy (and perltidy) to clean up and pretty-print source code. I’ve also used the HTML output switches to produce markup that I can cut/paste into this blog. For short snippets, it was often faster to just hack the markup myself. Believe me, that gets boring pretty fast. Plus, as an author, it’s pretty tough to be a proponent of code reuse when you’ve been reduced to manually adding a bunch of <span> tags to your own blog posts.
Five seconds of searching led me to WP-Syntax. Installing was literally as easy as unzipping it in the wp-content/plugins directory and Activating the plugin from the WP Admin interface. Now, syntax highlighting is as automatic as it should be.
WP-Syntax will turn this:
<pre lang="c">
#include <stdio.h>
int
main(void)
{
printf("Hello world!"); /* A comment */
exit 0;
}
</pre>
into this:
#include <stdio.h> int main(void) { printf("Hello world!"); /* A comment */ exit 0; }
I really have no excuse for not doing this much sooner.