Skip to content

Commit

Permalink
Merge pull request #31 from janisz/master
Browse files Browse the repository at this point in the history
Add Go support
  • Loading branch information
ajmath committed Apr 1, 2013
2 parents 43424f6 + 3c8f90f commit 5c7b364
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions langs/go.js
@@ -0,0 +1 @@
window.brushAlias = "go";
8 changes: 7 additions & 1 deletion manifest.json
Expand Up @@ -162,6 +162,11 @@
"matches": [ "*://*/*.cs",
"*://*/*.cs?*" ],
"run_at": "document_end"
}, {
"js": [ "scripts/shCore.js", "scripts/shBrushGo.js", "langs/go.js", "content_script.js" ],
"matches": [ "*://*/*.go", "file:///*/*.go",
"*://*/*.go?*" ],
"run_at": "document_end"
}, {
"js": [ "scripts/shCore.js", "scripts/shBrushPython.js", "langs/py.js", "content_script.js" ],
"matches": [ "*://*/*.py",
Expand Down Expand Up @@ -196,6 +201,7 @@
"tabs",
"http://*/*",
"https://*/*",
"ftp://*/*"
"ftp://*/*",
"file:///*/*"
]
}
46 changes: 46 additions & 0 deletions scripts/shBrushGo.js
@@ -0,0 +1,46 @@
;(function()
{
// CommonJS
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);

function Brush()
{
// Copyright 2006 Shin, YoungJin

var datatypes = 'chan map bool string error ' +
'int int8 int16 int32 int64 rune ' +
'byte uint uint8 uint16 uint32 uint64 uintptr '
'float32 float64 '
'complex64 complex128 ';

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 ';

var functions = 'append cap close complex copy delete imag len' +
'make new panic print println real recover nil';

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' }, // strings
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' },
{ regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' },
{ regex: new RegExp(this.getKeywords(keywords), 'g'), css: 'keyword bold' },
{ regex: /\s+[A-Z_]+[\s=]/g, css: 'constants' },
{ regex: /\s+[+-]?\d+([Ee.][+-]?\d+)?/g, css: 'color2' },
{ regex: /\s+0[Xx][\dA-Fa-f]+/g, css: 'color2' },
];
}

Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['go'];

SyntaxHighlighter.brushes.Go = Brush;

// CommonJS
typeof(exports) !== 'undefined' ? exports.Brush = Brush : null;
})();

0 comments on commit 5c7b364

Please sign in to comment.