Syntax Highlighting on WordPress
I've always wanted a cool syntax highlighter for source code on my blog, so when performing the latest revamp of my blog I decided to go hunting for a solution that would fit my needs.
Part of the ethos of my latest blog revamp is that I don't want to be editing configuration files, modifying templates or adding anything that can't be configured using the standard WordPress admin tools. For the last few years I've been unable to easily upgrade my template to make use of new WordPress features simply because I had implemented a lot of functionality by hacking at the various files within the template. This meant that although there are a number of JavaScript-only based solutions, I would need something that is packaged as a WordPress plugin to save me having to modify my template files.
A quick scan of the WordPress plugin gallery revealed SyntaxHighlighter MT to be a reasonable sounding option. It's based on Alex Gorbatchev's excellent SyntaxHighlighter, one of the afformentioned JavaScript-based solutions for formatting source code, and was based on the use of <pre> tags meaning I wouldn't have to worry about inserting HTML special entities all over my code whenever I needed to post something.
After installing and converting over several posts I started to notice two main issues that were effectively show stoppers:
- Anything that looked like an XML tag was being made lowercase
- Anything that looked like a start tag of an XML element that didn't have a corresponding end tag was having one automatically inserted
This may not sound like a huge deal, but the second point was especially painful when using non-XML-based languages. Take generics in C#, for instance. If I wanted to write a line of code like this:
IList<Customer> listOfActiveCustomers = customerService.GetActiveCustomers();
SyntaxHighlighter MT would spit out the following:
IList<customer> listOfActiveCustomers = customerService.GetActiveCustomers(); </customer>
Not only did it mess up the casing on the Customer type, it thought that the generic type parameter to IList was the start of an XML tag and thus needed to be closed.
Now, I'm guessing this has something to do with how WordPress in general processes text inside a <pre> tag and is probably not the fault of the plugin author, but that still didn't change the fact that I needed a solution.
The WordPress.com guide to posting source code noted that WordPress.com blogs have access to the "sourcecode" WordPress shortcode to accomplish the very same thing. Now I'm not using WordPress.com, I self-host my blog using the WordPress.org code, but they do mention at the bottom of the post also indicates that the same functionality is available through the SyntaxHighlighter Evolved plugin.
This plugin also uses Alex Gorbatchev's SyntaxHighlighter, but it uses WordPress shortcodes just like the functionality available through WordPress.com. I've now installed the new plugin and started converting old posts over to the new format with no issues whatsoever.
Full to the Brim
It seems that the recent capacity and load management problems being experienced by several social networking sites are self perpetuating.
Regardless of the application, users always have preconceived expectations with regards to performance, usability and availability. If those expectations aren't met, they like to let people know about it. Depending on the environment and target audience, you can always expect a disgruntled user to call, email or talk to someone with the express purpose of getting that person to:
- handle their support problem or;
- listen to them whine
More often than not, users will choose option 2, and proceed to use their communication medium of choice to tell as many people as possible that they are unhappy.
So what happens when it's a social networking application such as Twitter or Facebook that's having the problem? Well, as long as the system is partially up and running, users will continue to use the system to complain about it being too slow or partially unavailable, after all, it is the communication medium of choice for many of the users. Even in times of a total outage, users will often wait for the service to come back online and then start using it to tell all their friends about the outage, as if they didn't already know.
The recent Twitter replies tab outage is a great example of an outage that simply generated more user content, potentially exacerbating the problem. Minutes after the problem occurred, my twitter feed filled with people telling me all about it, and even more people chimed in with replies to those comments. I can't imagine that this helped whatever problem they were having, and any application that has a fan club for their "out of service" mascot certainly doesn't need to have it's performance problems inflamed in any way, shape or form.
Categories
- Consulting & Career (8)
- Information Technology (36)
- Linux (8)
- Social Networking (2)
- Software Development (27)
- Architecture (2)
- Development Tools (2)
- User Experience (5)
- Windows Server (1)
- Other Interests (13)
- Presentations (4)
- Projects (1)
@garry_stewart
- Just spent a few hours hunting for the schema behind a base64binary field in a XSD only to find out that it hasn't been defined yet. Awesome1 hour ago
- Having a schema for this web service is kind of pointless given they send the meat of the data as a Base64Binary encoded BLOB4 hours ago
- Superannuation application just recommended the "high risk" investment option for me… -10% growth is not selling me, guys.5 hours ago
- Is it Steel Panther time? I think it is.5 hours ago
- Does anyone actually use the "all my files" view in Finder?6 hours ago
Recent Comments
Headshot

About Garry
I'm a Solution Architect living in Perth, Western Australia. I work primarily with Microsoft technologies, but I have an open mind and like to branch out into other areas in my spare time. I'm also a Microsoft Virtual Technology Solutions Professional (VTSP) in the Integration space and like to stay active in the local development community.
Me On The Web
User Groups
Post Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Tags
Who's Online
6 visitors online now
0 guests, 6 bots, 0 members
Map of Visitors
Blogroll
- Coding Horror
- Cup(Of T)
- Haacked
- Joel On Software
- Otaku Software Blog
- Rands In Repose
- Scott Hanselman’s Computing Zen
Archives
- April 2011 (7)
- March 2011 (4)
- July 2010 (1)
- May 2010 (1)
- January 2010 (1)
- July 2009 (1)
- April 2009 (1)
- February 2009 (1)
- January 2009 (6)
- December 2008 (2)
- October 2008 (1)
- August 2008 (1)
- July 2008 (3)
- June 2008 (4)
- May 2008 (5)
- April 2008 (12)
