I’ve been working on Part 3 of my Creating a Web Page Tweaking Helper Tool and was trying to add some source code snippets to my post. I couldn’t get the source code to format properly. The visual editor was mangling it badly. It was adding lots of HTML CODE elements and the indentation was screwed up or lost completely.
So I Googled around for a plugin to help me out.
I found a gem in Google SyntaxHighlighter. Not only does it keep the code formatting, it highlights the code nicely also. It includes highlighting support for C++, C#, CSS, Delphi, Java, PHP, Python, Ruby, Sql, VB and XML/HTML.
Here is an example of the output.
void HelloWorld()
{
Console.WriteLine("Hello World");
}
As you can see it also displays line numbers which will be great for referencing specific lines of code in descriptions.
I also found that using the visual edit is bad for this kind of thing. So I went to my profile and turned it off. It isn’t worth the hassle and editing the HTML directly gives me more control of what my posts look like.



March 9th, 2008
Richard
Posted in Uncategorized
Tags: 


