Adding automatic code highlighting to your blog

This article was published 5 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

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.

Thoughts on this post

Leave a comment?