Skip to content

Commit 240a682

Browse files
david-szabo97Giannis Karagiannis
authored andcommitted
Add golang
1 parent 32569fa commit 240a682

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 =
20+
SyntaxHighlighter ||
21+
(typeof require !== "undefined"
22+
? require("shCore").SyntaxHighlighter
23+
: null);
24+
25+
function Brush() {
26+
var keywords =
27+
"bool break byte case chan complex128 complex64 const continue default defer else " +
28+
"fallthrough float32 float64 for func go goto if import int int16 int32 int64 int8 " +
29+
"interface map package range return rune select string struct switch type uint " +
30+
"uint16 uint32 uint64 uint8 uintptr var";
31+
var funcs =
32+
"append cap close complex copy imag len make new panic print println real recover delete";
33+
var special = "true false iota nil";
34+
35+
this.regexList = [
36+
{
37+
regex: SyntaxHighlighter.regexLib.singleLineCComments,
38+
css: "comments",
39+
}, // one line comments
40+
{ regex: /\/\*([^\*][\s\S]*?)?\*\//gm, css: "comments" }, // multiline comments
41+
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: "preprocessor" }, // documentation comments
42+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: "string" }, // strings
43+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: "string" }, // strings
44+
{ regex: XRegExp("`([^\\\\`]|\\\\.)*`", "gs"), css: "string" }, // strings
45+
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: "value" }, // numbers
46+
{ regex: new RegExp(this.getKeywords(keywords), "gm"), css: "keyword" }, // keywords
47+
{ regex: new RegExp(this.getKeywords(funcs), "gmi"), css: "functions" }, // built-in functions
48+
{ regex: new RegExp(this.getKeywords(special), "gm"), css: "color1" }, // literals
49+
];
50+
51+
this.forHtmlScript({
52+
left: /(&lt;|<)%[@!=]?/g,
53+
right: /%(&gt;|>)/g,
54+
});
55+
}
56+
57+
Brush.prototype = new SyntaxHighlighter.Highlighter();
58+
Brush.aliases = ["go", "golang"];
59+
60+
SyntaxHighlighter.brushes.Go = Brush;
61+
62+
// CommonJS
63+
typeof exports != "undefined" ? (exports.Brush = Brush) : null;
64+
})();

0 commit comments

Comments
 (0)