Arnold Matusz’s created a great live writer plugin that uses the excellent syntax highlighter from Alex Gorbatchev. Great Stuff!!
sample:
public object Lookup(string tblName, string returnField, string where)
{
SqlCommand s = new SqlCommand();
s.Connection = conn;
s.CommandText = "SELECT " + returnField + " FROM " + tblName + " WHERE " + where;
return (object) s.ExecuteScalar();
}
hmm, it doesn’t look very nice inside writer. let’s see what it looks like published.
Update: Looks like the syntax highlighting won’t show up inside live writer itself.
How it works: The code is put inside a pre (preformatted text) tag and a css class attribute is added to it. The class specifies what language syntax highlighting to use. For example, to get the C# highlighting above, you would use class="brush: csharp;". You can find style brushes for most languages in use today. You can create a custom one if there’s not one for your language. The plugin for live writer from Arnold takes care of putting the correct class.
To get everything working, I ended up modifying the PageTemplate.ascx file for this skin to add the link tags to the required javascript files. There must be some better way to do this because if I decide to change skins, then I will lose all the syntax highlighting.
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shCore.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="http://nithinthomas.com/syntax/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="http://nithinthomas.com/syntax/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="http://nithinthomas.com/syntax/styles/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'http://nithinthomas.com/syntax/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
It might probably help to post the javascript files on google code and link to them instead.