Delphi Programming

and software in general.

Wednesday, July 23, 2008

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:

<pre name="code" class="delphi">
program Demo;
begin
// Say hi
Writeln('Hello World');
end.
</pre>

... and it shows up as:

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