Tuesday, September 9, 2008

How to highlight code in a blog

When you want to include a Code Snippet in your blog, it looks better like this:

Dim dt As New DataTable
With dt.Columns
.Add("Title")
.Add("Start", Type.GetType("System.DateTime"))
.Add("End", Type.GetType("System.DateTime"))
.Add("Content")
.Add("Location")
End With

You can do this by:
Step 1
Obtain the syntax highlighter from here
Step 2
Copy the compressed js and the css files to some friendly WWW site
Step 3
Change your Blogger HTML template to include a css link just after the head tag

Step 3

You then copy the following JavaScript links after the outer wrapper

Step 4
You then add the following javascript:

All done!

Now when you include a snippet in your a blog, just surround it with pre tags as follows:


NB: Push past this error message, but check that your blog still displays.

No comments: