语法高亮插件SyntaxHighlighter的使用教程

1.下载
http://alexgorbatchev.com/SyntaxHighlighter/download/
2.引入(cakephp代码), 注意这里的问题: http://blog.blakesimpson.co.uk/read/5-installing-syntaxhighlighter-error-xregexp-not-defined

    echo $this->Html->css("/js/plugins/syntaxhighlighter/styles/shCore");//基础
    echo $this->Html->css("/js/plugins/syntaxhighlighter/styles/shCoreDefault");//可以换成其他样式
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shCore");//基础
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shAutoloader");//基础
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shLegacy");//基础
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shBrushCss");//支持的语言
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shBrushJava");//支持的语言
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shBrushJScript");//支持的语言
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shBrushPhp");//支持的语言
    echo $this->Html->script("plugins/syntaxhighlighter/scripts/shBrushXml");//支持的语言

3.定义要格式化的代码
<pre class='brush: java'>
@Override
public void init(FilterConfig cfg) throws ServletException {
super.init(cfg);
OnlineUserManager.init();
//this._dataInit();
}
</pre>

4.初始化
<script>$(document).ready(function(){
            SyntaxHighlighter.config.clipboardSwf = './clipboard.swf';
            SyntaxHighlighter.all();
        });</script>

你可能感兴趣的:(highlighter)