Source Code highlighting in Blogger

Oddly enough, Blogger don’t come with any tools to syntax highlight source code. A little web spelunking unearthed a nifty little java-script (syntaxhighlighter by Alex Gorbatchev) that support multiple languages (C++, C#, CSS, Delphi, JS, Java, PHP, Python, Ruby, SQL, VB, XML, HTML). It is fairly easy to add it to your Blogger template, although you need a place to host the scripts and styles.

When the scripts are in the template, all you need to put in Blogger is:



program Demo;
begin
// Say hi
Writeln('Hello World');
end.

… and it shows up as:


program Demo;
begin
// Say hi
Writeln('Hello World');
end.

2 thoughts on “Source Code highlighting in Blogger

  1. One weakness found. If you swap between html and compose modes, Blogger loves to add blank lines to your source code. If you stick with with html / preview – you are good though.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.