Posted May 1, 2008 and filed under    tags:  , ,

I have been struggling with adding code to my blog entries, never really finding anything that just worked.  Yes I know, there are various code formatting solutions out in the wild but I finally found one that has some exceptional features: SyntaxHighlighter. 

image

Several people have blogged about it's capabilities: popup view of plain text, copy to clipboard link, and many other features help to make this an exceptional code formatter. Here's an example of what the result looks like:

image

I found a cool article by Scott Dougherty that outlined how to implement SyntaxHighlighter into BlogEngine.NET and even update and update the tiny_MCE to allow for online editing.  There was just one problem...  I detest adding blog entries using the online editor.  I prefer Windows Live Writer and having to switch over to the HTML view in WLW for adding the necessary tags was not really an viable option.  So after a little looking I ran into the best thing since sliced bread (well, close anyway)...  Enter SyntaxHighlighter for Windows Live Writer

image

With this handy little plug-in you can simply click the menu option, select your code type, and then insert your code!

image

Nothing too fancy, just a simple interface that adds the necessary tags to support the SyntaxHighlighter formatting. 

So what's left?  Well to make life a little easier for everyone I decided to build a quick extension that will add the necessary items to your blog so that it's plug and play...  Just drop this extension into your blog and you don't have to bother adding any of the javascript and style sheet tags on your pages.

So now implementing this is as simple as it could be (is it really?)... Follow these steps:

  1. Download the SyntaxHighlighter code
  2. Copy the folder dp.SyntaxHighlighter into your root folder (ex. ~/dp.SyntaxHighlighter)
  3. Copy the SyntaxHighlighter.cs file into ~/App_Code/Extension folder
  4. That's it!

Let me know if this works out for you or if you have any questions and I will try and help out as best as possible.

UPDATE 7/14/08: After having trouble with the BlogEngine.NET v1.4 Javascript Handler I updated the extension to not use the handler but to serve the script directly.

UPDATE 8/16/08: Corrected an issue where this extension prevented the Widgets from allowing drag-n-drop. 

Comments

Add comment


(Will show your Gravatar icon)

biuquote
Loading