IT技术分享

通用美化代码高亮插件syntaxhighlighter_3.0.83

摘要:通用美化代码,用来高亮显示代码,使代码可读性更强,可用来美化织梦编辑器kindeditor及其他编辑器代码。多种显示效果可以自由选择。

syntaxhighlighter_3.0.83 下载

一、找到/kindeditor4/plugins/code/code.js

html = '<pre class="prettyprint' + cls + '">' + K.escape(code)'</pre>';


改为:

html = '<pre class="brush:' + type + ';">' + K.escape(code) +'</pre>';
修改为:


var lang = self.lang(name + '.'),
            html = ['<div style="padding:10px 20px;">',
                '<div class="ke-dialog-row">',
                '<select class="ke-code-type">',
                '<option value="js">JavaScript</option>',
                '<option value="html">HTML</option>',
                '<option value="css">CSS</option>',
                '<option value="php">PHP</option>',
                '<option value="pl">Perl</option>',
                '<option value="py">Python</option>',
                '<option value="ruby">Ruby</option>',
                '<option value="java">Java</option>',
                '<option value="vb">ASP/VB</option>',
                '<option value="cpp">C/C++</option>', 
                '<option value="c-sharp">C#</option>',
                '<option value="xml">XML</option>',
                '<option value="shell">Shell</option>',
                '<option value="as3">ActionScript3</option>',
                '<option value="cf">ColdFusion</option>',
                '<option value="delphi">Delphi</option>',
                '<option value="diff">diff</option>',
                '<option value="erl">Erlang</option>',
                '<option value="groovy">Groovy</option>',
                '<option value="jfx">JavaFX</option>',
                '<option value="plain">Plain Text</option>',
                '<option value="scala">Scala</option>',
                '<option value="sql">SQL</option>',
                '<option value="">Other</option>',
                '</select>',
                '</div>',
                '<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>',
                '</div>'].join(''),
二、在模板中添加


<link href="/Public/plugs/syntaxhighlighter/styles/shCore.css"  rel="stylesheet" type="text/css">
<link href="/Public/plugs/syntaxhighlighter/styles/shThemeDefault.css"  rel="stylesheet" type="text/css">
<script src="/Public/plugs/syntaxhighlighter/scripts/shCore.js"></script>
<script src="/Public/plugs/syntaxhighlighter/scripts/shAutoloader.js"></script>
<script>
function path() {
        var args = arguments,
        result = [];
        for (var i = 0; i < args.length; i++)
            result.push(args[i].replace('$', '/Public/plug/syntaxhighlighter/scripts/'));
        return result
    }
    $(function () {
        SyntaxHighlighter.autoloader.apply(null, path(
            'applescript            $shBrushAppleScript.js',
            'actionscript3 as3      $shBrushAS3.js',
            'bash shell             $shBrushBash.js',
            'coldfusion cf          $shBrushColdFusion.js',
            'cpp c                  $shBrushCpp.js',
            'c# c-sharp csharp      $shBrushCSharp.js',
            'css                    $shBrushCss.js',
            'delphi pascal          $shBrushDelphi.js',
            'diff patch pas         $shBrushDiff.js',
            'erl erlang             $shBrushErlang.js',
            'groovy                 $shBrushGroovy.js',
            'java                   $shBrushJava.js',
            'jfx javafx             $shBrushJavaFX.js',
            'js jscript javascript  $shBrushJScript.js',
            'perl pl                $shBrushPerl.js',
            'php                    $shBrushPhp.js',
            'text plain             $shBrushPlain.js',
            'py python              $shBrushPython.js',
            'ruby rails ror rb      $shBrushRuby.js',
            'sass scss              $shBrushSass.js',
            'scala                  $shBrushScala.js',
            'sql                    $shBrushSql.js',
            'vb vbnet               $shBrushVb.js',
            'xml xhtml xslt html    $shBrushXml.js'
        ));
        SyntaxHighlighter.all();
    });</script>
版权声明:本文为博主原创文章,未经博主允许不得转载。http://www.westdl.com/dedecourse/syntaxhighlighter.html
(0)
打赏 微信扫一扫 微信 扫码打赏
相关技术