After trying various HTML based solutions for syntax highlighting, I decided to go with the javascript based SyntaxHighlighter to pretify source code on my blog.
SyntaxHighlighter runs in the browser, supports multiple languages, and has a LPGL licence (the author, Alex Gorbatchev, accepts donations via PayPal).
To install SyntaxHighlighter into Subtext, you need to link to the SyntaxHighlighter Javascript files in Subtext \DTP.ASPX.
You can either download the js files and copy them onto your webhost, or link to a free hosted version on the SyntaxHighlighter site.
If you want to host the js files yourself,
1. Download SyntaxHighlighter from here.
2. Extract the files from the SyntaxHighlighter zip file.
3. Copy the files in the SyntaxHighlighter\Styles and SyntaxHighlighter\Scripts directory to the Subtext Scripts directory on your webhost (you dont need every single javascript file – pick the javascript files that correspond to the languages you need).
4. Modify the Subtext \DTP.ASPX file to include the following tags,
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shCore.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushBash.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushPlain.js") %>"></script>
<link type="text/css" rel="stylesheet" href="scripts/shCore.css"/>
<link type="text/css" rel="stylesheet" href="scripts/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushCpp.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushCSharp.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushCss.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushDelphi.js") %></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushDiff.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushGroovy.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushJava.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushJScript.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushPhp.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushPython.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushRuby.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushScala.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushSql.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushVb.js") %>"></script>
<script type="text/javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Scripts/shBrushXml.js") %>"></script>
If you want to link to the hosted version (2.0.320), include the following markup in \DTP.ASPX,
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shCore.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="http://alexgorbatchev.com/pub/sh/2.0.320/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="http://alexgorbatchev.com/pub/sh/2.0.320/styles/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
Obviously you probably wont need to link to every javascript file – only the languages you will be posting about.
To format your code, surround it with a <pre> tag and set the css class to brush: [language] where language is one of the supported SyntaxHighlighter languages. For example,
<pre class="brush:js">
alert("Hello world");
</pre>
Alternatively, install Live Writer and use the PreCode Snippet plugin. Ive seen many complaints about LiveWriter on the tinternet, but, for simple blog editing, it works well enough.
There is also a SyntaxHighlighter plugin for the FCKEditor (which is the default online editor in Subtext). Not 100% sure how you would install this with Subtext but Im sure its not too hard.