One - One Code All

Blog Content

高亮插件:syntaxhighlighter-golang-brush

前端相关   2016-10-14 20:58:46

参考URL:https://github.com/mshockwave/syntaxhighlighter-golang-brush

插件下载:https://github.com/syntaxhighlighter/syntaxhighlighter/releases 


高亮插件:syntaxhighlighter-golang-brush脚本

/**
 * SyntaxHighlighter
 * http://alexgorbatchev.com/SyntaxHighlighter
 *
 * SyntaxHighlighter is donationware. If you are using it, please donate.
 * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
 *
 * @version
 * 3.0.83 (July 02 2010)
 *
 * @copyright
 * Copyright (C) 2004-2010 Alex Gorbatchev.
 *
 * @license
 * Dual licensed under the MIT and GPL licenses.
 */
;(function()
{
    // CommonJS
    typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
 
    function Brush()
    {
        var funcs   =   'make';
 
        var keywords =  'break case chan const continue default defer else fallthrough for func go ' +
                        'goto if import interface map package range return select struct switch type var ';
 
        this.regexList = [
            { regex: SyntaxHighlighter.regexLib.singleLineCComments,    css: 'comments' },          // one line comments
            { regex: SyntaxHighlighter.regexLib.multiLineCComments,     css: 'comments' },          // multiline comments
            { regex: SyntaxHighlighter.regexLib.doubleQuotedString,     css: 'string' },            // double quoted strings
            { regex: SyntaxHighlighter.regexLib.singleQuotedString,     css: 'string' },            // single quoted strings
            { regex: /^var \w+/g,                                       css: 'variable' },          // variables
            { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi,             css: 'value' },         // numbers
            { regex: new RegExp(this.getKeywords(funcs), 'gmi'),        css: 'functions' },         // common functions
            { regex: new RegExp(this.getKeywords(keywords), 'gm'),      css: 'keyword' }            // keyword
            ];
 
        this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags);
    };
 
    Brush.prototype = new SyntaxHighlighter.Highlighter();
    Brush.aliases   = ['golang'];
 
    SyntaxHighlighter.brushes.Golang = Brush;
 
    // CommonJS
    typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();


将上述代码添加进 shCore.js中,可以搜索Groovy,在其前面添加。

老版本修改方法:

ueditor编辑器修改:

ueditor.all.js中找到:insertcode.js部分,添加:'golang':'Golang', ueditor.all.min.js搜索Groovy,在其前面添加:'golang':'Golang'。

 me.setOpt('insertcode',{
            'as3':'ActionScript3',
            'bash':'Bash/Shell',
            'cpp':'C/C++',
            'css':'Css',
            'cf':'CodeFunction',
            'c#':'C#',
            'delphi':'Delphi',
            'diff':'Diff',
            'erlang':'Erlang',
            'golang':'Golang',
            'groovy':'Groovy',
            'html':'Html',
            'java':'Java',
            'jfx':'JavaFx',
            'js':'Javascript',
            'pl':'Perl',
            'php':'Php',
            'plain':'Plain Text',
            'ps':'PowerShell',
            'python':'Python',
            'ruby':'Ruby',
            'scala':'Scala',
            'sql':'Sql',
            'vb':'Vb',
            'xml':'Xml'
    });


最新版本布局改了,参考最新源码:https://github.com/Automattic/syntaxhighlighter 


上一篇:href超链接a标签点击触发函数发送请求
下一篇:selenium webdriver启动Chrome浏览器后报错unknown error

The minute you think of giving up, think of the reason why you held on so long.