Skip to content

Commit cc1b7e7

Browse files
authored
Merge pull request #194 from Automattic/add/golang
Add golang
2 parents 32569fa + a0b3058 commit cc1b7e7

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

syntaxhighlighter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
136136
wp_register_script( 'syntaxhighlighter-brush-delphi', plugins_url( $this->shfolder . '/scripts/shBrushDelphi.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
137137
wp_register_script( 'syntaxhighlighter-brush-diff', plugins_url( $this->shfolder . '/scripts/shBrushDiff.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
138138
wp_register_script( 'syntaxhighlighter-brush-erlang', plugins_url( $this->shfolder . '/scripts/shBrushErlang.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
139+
wp_register_script( 'syntaxhighlighter-brush-go', plugins_url( $this->shfolder . '/scripts/shBrushGo.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
139140
wp_register_script( 'syntaxhighlighter-brush-groovy', plugins_url( $this->shfolder . '/scripts/shBrushGroovy.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
140141
wp_register_script( 'syntaxhighlighter-brush-java', plugins_url( $this->shfolder . '/scripts/shBrushJava.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
141142
wp_register_script( 'syntaxhighlighter-brush-javafx', plugins_url( $this->shfolder . '/scripts/shBrushJavaFX.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
@@ -197,6 +198,8 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
197198
'erl' => 'erlang',
198199
'erlang' => 'erlang',
199200
'fsharp' => 'fsharp',
201+
'go' => 'go',
202+
'golang' => 'go',
200203
'groovy' => 'groovy',
201204
'java' => 'java',
202205
'jfx' => 'javafx',
@@ -251,6 +254,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
251254
'diff' => __( 'diff / patch', 'syntaxhighlighter' ),
252255
'erlang' => __( 'Erlang', 'syntaxhighlighter' ),
253256
'fsharp' => __( 'F#', 'syntaxhighlighter' ),
257+
'go' => __( 'Go', 'syntaxhighlighter' ),
254258
'groovy' => __( 'Groovy', 'syntaxhighlighter' ),
255259
'java' => __( 'Java', 'syntaxhighlighter' ),
256260
'javafx' => __( 'JavaFX', 'syntaxhighlighter' ),
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* SyntaxHighlighter
3+
* http://alexgorbatchev.com/SyntaxHighlighter
4+
*
5+
* SyntaxHighlighter is donationware. If you are using it, please donate.
6+
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
7+
*
8+
* @version
9+
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
10+
*
11+
* @copyright
12+
* Copyright (C) 2004-2013 Alex Gorbatchev.
13+
*
14+
* @license
15+
* Dual licensed under the MIT and GPL licenses.
16+
*/
17+
(function () {
18+
// CommonJS
19+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
20+
21+
function Brush() {
22+
var keywords =
23+
'bool break byte case chan complex128 complex64 const continue default defer else ' +
24+
'fallthrough float32 float64 for func go goto if import int int16 int32 int64 int8 ' +
25+
'interface map package range return rune select string struct switch type uint ' +
26+
'uint16 uint32 uint64 uint8 uintptr var';
27+
var funcs =
28+
'append cap close complex copy imag len make new panic print println real recover delete';
29+
var special = 'true false iota nil';
30+
31+
this.regexList = [
32+
{
33+
regex: SyntaxHighlighter.regexLib.singleLineCComments,
34+
css: 'comments',
35+
}, // one line comments
36+
{ regex: /\/\*([^\*][\s\S]*?)?\*\//gm, css: 'comments' }, // multiline comments
37+
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' }, // documentation comments
38+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
39+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
40+
{ regex: XRegExp('`([^\\\\`]|\\\\.)*`', 'gs'), css: 'string' }, // strings
41+
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
42+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
43+
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // built-in functions
44+
{ regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' }, // literals
45+
];
46+
47+
this.forHtmlScript({
48+
left: /(&lt;|<)%[@!=]?/g,
49+
right: /%(&gt;|>)/g,
50+
});
51+
}
52+
53+
Brush.prototype = new SyntaxHighlighter.Highlighter();
54+
Brush.aliases = ['go', 'golang'];
55+
56+
SyntaxHighlighter.brushes.Go = Brush;
57+
58+
// CommonJS
59+
typeof exports != 'undefined' ? (exports.Brush = Brush) : null;
60+
})();

0 commit comments

Comments
 (0)