by Lasse Soelberg
21. May 2009 21:36
I have added a new feature to the SyntaxHighlighter extension for BlogEngine.NET. And that is to see which aliases can be used for each brush. It will only show the aliases for the brushes that are selected in the Brushes section.

The aliases are retrieved from the actual brush JavaScript files . So if a new brush gets installed and selected, the aliases for it will show up in the list.
Download the Extension
I have added the extension to CodePlex, so the latest version can always be found there.
SyntaxHighlighter 2.0 For BlogEngine.NET
by Lasse Soelberg
20. May 2009 00:16
Alex Gorbatchev has made a fantastic piece of software called SyntaxHighlighter, that uses JavaScript to present formatted code posted on a blog. As an example here is a little code snippet formatted as C#
// Returns the sum
public int Add(int a, int b)
{
return a + b;
}
And here it is unformatted
// Returns the sum
public int Add(int a, int b)
{
return a + b;
}
To make the code use SyntaxHighlighter, it is put inside <pre> tags, where the brush to use is set. The example code including the tags looks like this:
<pre class="brush: csharp;">// Returns the sum
public int Add(int a, int b)
{
return a + b;
}</pre>
Before this functionality can be used however, one has to add some JavaScript and Css stuff to the headers of post pages. And in my search for how to add this to my blog, i stumbled upon this blog post by Chris Blankenship. He had made an extension to BlogEngine that automatically adds the necessary stuff. Very cool I think!
However, the extension is created for SyntaxHighlighter 1.5 and the one I have installed is version 2.0. And there are some differences. So I set out to modify the extension a little so it would support the new version of SyntaxHighlighter. Those small modifications soon turned out to be big ones, since i wanted dynamic recognition of available brushes. Version 2.0 also comes with styles that can be applied, and I wanted and easy way to change the style. So in the end the extension has gone through a complete rewrite and have got a custom made admin page added as well.
Extension Features
This is the list of features for the extension:
- Automatically imports SyntaxHighlighter JavaScript and Css files.
- The path to SyntaxHighlighters styles and scripts folders can be changed from the admin page.
- The brushes to load is configurable.
- If brushes gets uploaded or deleted, the list of brushes can be updated through the admin page.
- The style used can be set.
- The list of styles can be updated if more styles are added.
More...