点击Brush name 有官方网站的详细介绍和Demo,有兴趣的童鞋可以去看看。对于技术类的博客来说,这种语法高亮插件是必不可少的。
Brush name | Brush aliases | File name |
---|---|---|
ActionScript3 | as3, actionscript3 | shBrushAS3.js |
Bash/shell | bash, shell | shBrushBash.js |
ColdFusion | cf, coldfusion | shBrushColdFusion.js |
C# | c-sharp, csharp | shBrushCSharp.js |
C++ | cpp, c | shBrushCpp.js |
CSS | css | shBrushCss.js |
Delphi | delphi, pas, pascal | shBrushDelphi.js |
Diff | diff, patch | shBrushDiff.js |
Erlang | erl, erlang | shBrushErlang.js |
Groovy | groovy | shBrushGroovy.js |
JavaScript | js, jscript, javascript | shBrushJScript.js |
Java | java | shBrushJava.js |
JavaFX | jfx, javafx | shBrushJavaFX.js |
Perl | perl, pl | shBrushPerl.js |
PHP | php | shBrushPhp.js |
Plain Text | plain, text | shBrushPlain.js |
PowerShell | ps, powershell | shBrushPowerShell.js |
Python | py, python | shBrushPython.js |
Ruby | rails, ror, ruby | shBrushRuby.js |
Scala | scala | shBrushScala.js |
SQL | sql | shBrushSql.js |
Visual Basic | vb, vbnet | shBrushVb.js |
XML | xml, xhtml, xslt, html, xhtml | shBrushXml.js |
<script class="javascript" src="Scripts/shCore.js"></script> <script class="javascript" src="Scripts/shBrushCSharp.js"></script> <script class="javascript" src="Scripts/shBrushPhp.js"></script> <script class="javascript" src="Scripts/shBrushJScript.js"></script> <script class="javascript" src="Scripts/shBrushJava.js"></script> <script class="javascript" src="Scripts/shBrushVb.js"></script> <script class="javascript" src="Scripts/shBrushSql.js"></script> <script class="javascript" src="Scripts/shBrushXml.js"></script> <script class="javascript" src="Scripts/shBrushDelphi.js"></script> <script class="javascript" src="Scripts/shBrushPython.js"></script> <script class="javascript" src="Scripts/shBrushRuby.js"></script> <script class="javascript" src="Scripts/shBrushCss.js"></script> <script class="javascript" src="Scripts/shBrushCpp.js"></script> <script class="javascript"> dp.SyntaxHighlighter.HighlightAll('code'); </script>一个页面里面可以包含任意多个需要着色的代码段;
<link type="text/css" rel="stylesheet" href="SyntaxHighlighter/Styles/SyntaxHighlighter.css"></link> <script language="javascript" src="SyntaxHighlighter/Scripts/shCore.js"></script> <script language="javascript" src="SyntaxHighlighter/Scripts/shBrushCSharp.js"></script> <script language="javascript" src="SyntaxHighlighter/Scripts/shBrushXml.js"></script> <script language="javascript"> window.onload = function () { dp.SyntaxHighlighter.ClipboardSwf = 'SyntaxHighlighter/Scripts/clipboard.swf'; dp.SyntaxHighlighter.HighlightAll('code'); } </script>2. 使用方法如下:
<pre name="code" class="c-sharp"> ... some code here ... </pre>方法二:使用textarea
<textarea name="code" class="c#" cols="60" rows="10"> ... some code here ... </textarea>另外,这里还有一些高级特性的设置方法可供参考,诸如代码折叠等。