Tuesday 15 January 2008

Integrating SyntaxHighlighter with Blogger

I've just found a quick and easy way of integrating SyntaxHighlighter with Blogger. Go and check this blog entry and start posting coloured code snippets!

Two things to note though. If your theme uses background images for <li> elements, you will have to apply this patch to your CSS:

div.dp-highlighter li {
background-image: none;
}
Otherwise each line of your code snippets will start with a background image as it is coded with an <li> element.

Finally, if you copy and paste the whole javascript from step 2 your syntax highlighting will only support the following languages:
  • Cpp
  • CShapr
  • CSS
  • Java
  • JScript
  • Sql
  • Xml
Syntax Highlighter supports more, for example Ruby, Delphi or VB. If you want to use any of them, you can do this by adding an extra line like this (for Ruby):

<script src='http://[YOUR HOST]/shBrushRuby.js' type='text/javascript'/>