-
Notifications
You must be signed in to change notification settings - Fork 2
/
shBrushGo.js
46 lines (38 loc) · 2.01 KB
/
shBrushGo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;(function()
{
// CommonJS
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
function Brush()
{
var datatypes = 'bool byte complex64 complex128 error float32 float64 ' +
'int int8 int16 int32 int64 rune string ' +
'uint uint8 uint16 uint32 uint64 uintptr';
var constants = 'true false iota';
var zerovalue = 'nil';
var functions = 'append cap close complex copy delete imag len ' +
'make new panic print println real recover';
var keywords = 'break default func interface select ' +
'case defer go map struct ' +
'chan else goto package switch ' +
'const fallthrough if range type ' +
'continue for import return var';
this.regexList = [
{ regex: /^\/\/ *#.*$/gm, css: 'preprocessor' },
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
{ regex: XRegExp("`([^\\\\`]|\\\\.)*`", 'gs'), css: 'string' }, // strings
{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1' },
{ regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions' },
{ regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants' },
{ regex: new RegExp(this.getKeywords(zerovalue), 'gm'), css: 'constants' },
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
];
};
Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['go', 'golang'];
SyntaxHighlighter.brushes.Go = Brush;
// CommonJS
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();