53 lines
1.9 KiB
JavaScript

/**
* SyntaxHighlighter brush for the Go programming language (golang)
* by Allister Sanchez
* http://allistersanchez.com
*
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
*/
;(function()
{
// CommonJS
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
function Brush()
{
// Copyright 2006 Shin, YoungJin
var datatypes = 'bool byte complex64 complex128 error float32 float64 ' +
'int int8 int16 int32 int64 rune string ' +
'uint uint8 uint16 uint32 uint64 uintptr';
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';
var functions = 'append cap close complex copy delete imag len ' +
'make new panic print println real recover';
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: /^ *#.*/gm, css: 'preprocessor' },
//{ 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), 'gm'), css: 'keyword bold' }
];
};
Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['golang', 'go'];
SyntaxHighlighter.brushes.go = Brush;
// CommonJS
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();