BlogEngine.NET - syntax higlighter

A quick reminder on how to use syntax highlighting in be 3.x (and some previous versions too).

It is pretty much down to adding the following in the raw html code view:

<pre class="brush: c-sharp; toolbar: false;">

bool itWorks = true;

</pre>

The output should be:

bool itWorks = true;

Inserting the code manually with the default editor of be3 may be annoing, but it is possible to change the editor to tinymce (through the web.config).

Alex Gorbatchev's syntax highlighter offers a few themes, and by default be uses the shThemeDefault. In order to change it just locate the following line in the theme's site.master


and change it to whatever you prefer (see the editors\tiny_mce_3_5_8\plugins\syntaxhighlighter\styles for a list of available css classes); below is a list from http://alexgorbatchev.com/SyntaxHighlighter/

NameFile
DefaultshThemeDefault.css
DjangoshThemeDjango.css
EclipseshThemeEclipse.css
EmacsshThemeEmacs.css
Fade To GreyshThemeFadeToGrey.css
MidnightshThemeMidnight.css
RDarkshThemeRDark.css


The following brushes are available:

Brush nameBrush aliasesFile name
ActionScript3as3, actionscript3shBrushAS3.js
Bash/shellbash, shellshBrushBash.js
ColdFusioncf, coldfusionshBrushColdFusion.js
C#c-sharp, csharpshBrushCSharp.js
C++cpp, cshBrushCpp.js
CSScssshBrushCss.js
Delphidelphi, pas, pascalshBrushDelphi.js
Diffdiff, patchshBrushDiff.js
Erlangerl, erlangshBrushErlang.js
GroovygroovyshBrushGroovy.js
JavaScriptjs, jscript, javascriptshBrushJScript.js
JavajavashBrushJava.js
JavaFXjfx, javafxshBrushJavaFX.js
Perlperl, plshBrushPerl.js
PHPphpshBrushPhp.js
Plain Textplain, textshBrushPlain.js
PowerShellps, powershellshBrushPowerShell.js
Pythonpy, pythonshBrushPython.js
Rubyrails, ror, rubyshBrushRuby.js
ScalascalashBrushScala.js
SQLsqlshBrushSql.js
Visual Basicvb, vbnetshBrushVb.js
XMLxml, xhtml, xslt, html, xhtmlshBrushXml.js
blog comments powered by Disqus