Monday, December 15, 2008

Trying out PreCode and SyntaxHighlighter

Per Scott Hanselman's recent blog post on the best code syntax highlighter for your blog, I'm giving his suggestion a try, which is to use the PreCode plug-in for Live Writer (a free blog writing GUI from Microsoft), which renders your code snippets so they use the SyntaxHighlighter JavaScript library. 

I host my blog on Google's Blogger and so I don't have an easy way to host the necessary JavaScript files to make SyntaxHighlighter work.  But I do have a Google Pages account, so I was able to upload them there and modify my blog's HTML Template in Blogger to include the necessary <link> and <script> tags to make the magic happen.  I used tips from this blog post to get it working.

I wanted to get this set up since I'm about to post three (yes three!) blog entries on CSLA.NET which will probably contain a fair amount of code.

Anyway, without further adieu, here's my first SyntaxHighlighter code snippet, generated by the PreCode plug-in:

public interface IFoo
void Bar();

public class MyFoo
: IFoo
public Bar()
//do something

NOTE: If you're using a feed reader like Google Reader, this code won't look like anything special.  You'll have to open the blog page directly to see the full effect.


Anonymous said...

Finally, a good example of CSLA library usage w/out having to purchase the books. Too bad there is not a page to show how to upgrade CSLA for ASP 1.1 to 2.0 :P

Pete said...

Did you mean to leave this comment for one my posts on CSLA.NET?

Also, Rocky lets you download the ProjectTracker sample CSLA.NET application for free (without having to purchase his book), although I highly recommend the book anyway.