Adding automatic code highlighting to your blog

Update: PrismJS is a much better option now

One of the things I really liked about wp-svbtle is that it would automatically highlight any code samples I added. When I changed to Sparkling, the highlighting stopped.

Thankfully, it was an easy fix. To re-enable it, I added the following to my footer.php file in the theme:

jQuery("pre code").addClass("prettyprint");
<script src=""></script>

This enables all code blocks to be pretty printed, then includes Google’s pretty printer library. As you can see, it works like a dream.

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

Leave a comment?

Leave a Reply