Prabir's Blog

where the tech matters...

Syntax Highlighter

May 20
by prabir 20. May 2009 18:40

You might have seen a few code snippets that I have been posting in my blog which is powered by BlogEngine.NET. In this article I am going to guide you through installation of Syntax Highlighter 1.5.1 in blog engine. (For Syntax Higlighter 2.0 click here)

First of all you need to download the syntax highlighter from its official site (version 1.5.1) from here and would also require you to install the installer from http://wlwsyntaxhighlighter.codeplex.com (tested with version 2.1.1).

Then you will need to upload the syntax highlighter files (Scripts and Style folder only) to your blog. Then login to your blog as a administrator and go to the settings tab in the control panel of blog engine. In your html head section paste the following code

<LINK rel=stylesheet type=text/css href="Styles/SyntaxHighlighter.css"></LINK>
<SCRIPT language=javascript src="Scripts/shCore.js">
</SCRIPT>
<SCRIPT language=javascript src="Scripts/shBrushCSharp.js">
</SCRIPT>
<SCRIPT language=javascript>
window.onload = function() {
 dp.SyntaxHighlighter.ClipboardSwf = 'Scripts/clipboard.swf';
 dp.SyntaxHighlighter.HighlightAll('code');
};
</SCRIPT>

At this moment only C# synatx is available. If you would like to support more languages please add the appropriate javascript file as shown below

<SCRIPT language=javascript src="Scripts/shBrushCpp.js">
</SCRIPT>

The list of available languages can be seen from Scripts folder that you just uploaded.

SyntaxHighlighter.msi (368.00 kb) [Downloads: 186]
SyntaxHighlighter_1.5.1.zip (41.16 kb) [Downloads: 173]

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,

BlogEngine.NET