Tuesday 8 January 2013

Syntax on blogs

For a blog about coding, a good syntax highlighter is a must-have. I went out to search for the best one for me, and found Alex Gorbatchev's SyntaxHighlighter.

He first developed it in 2004, and since then it has been picked up by the internet. Wordpress and Joomla have it integrated nicely as plugins, and it's easily added to Blogger. There are very, VERY many websites and blogs out there that explain how to implement SyntaxHighlighter into Blogger, so I'll just thank Alex from the bottom of my 8bit heart and stick to the basics. Below is the code I have added to the html of this blog. You put this in the head of your code.


The creator of this script hosts all the necessary files a webmaster needs on his own server space, which is awesome if you have a blog but haven't set up your own server yet.

There's a whole lot of brushes - styles for different coding languages - you can use, and it's easy to create your own brush, or style, to fit your needs. In the snippet up above I've used the html brush, you do this like this:

Or like so:

To have the highlighter actually work, you'll need to have this snippet somewhere on your page:


Super easy, eh?

No comments:

Post a Comment