You're reading a blog post from the Blog Updates project - this post forms part of a series where I'm progressively improving the infrastructure and functionality this blog, one step at a time, and documenting the rationale and approach behind each step as I go.

I'm working backwards from an existing, stock WordPress theme, gradually gutting it and tailoring it to be fit for purpose. If you'd like to start from the beginning, you can find the first post here.

Change 4: New Plugin – SyntaxHighlighter Evolved

As part of this blog, and my plan to continually update the template and theme code, there'll be a number of occasions when I'll want to publish and share code examples and the modifications I'm making.

Frustratingly, this is hard to do in a user-friendly and helpful way without the addition of a plugin to render and present the code in an aesthetically and easily shared copyable manner.

As such, I've installed SyntaxHighlighter Evolved, one of many 'Syntax Highlighter' plugins available in the repository (which tend to be based upon Alex Gorbatchev's JavaScript package). The plugin allows me to easily add wrapping tags to code which I enter in the post editor, which results in nicely formatted, functionally enriched and shareable code snippets - producing something like this:

session_start();
if (!isset($_SESSION['count'])) {
  $_SESSION['count'] = 0;
} else {
  $_SESSION['count']++;
}

I'll be using this plugin periodically to reference the code for changes or additions I'm making to the site. At some point, I'd like to review other solutions and to potentially develop my own, as I'm not keen on it outputting two script files, a css file and a significant amount of inline code into my blog's header!

This entry was posted in Blog Updates. Bookmark the permalink.

Leave a reply