Skip to content

Commit 8476a9a

Browse files
Added support for go.mod files (#3209)
1 parent 969f152 commit 8476a9a

15 files changed

+241
-3
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+5
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@
495495
"require": "clike",
496496
"owner": "arnehormann"
497497
},
498+
"go-module": {
499+
"title": "Go module",
500+
"alias": "go-mod",
501+
"owner": "RunDevelopment"
502+
},
498503
"graphql": {
499504
"title": "GraphQL",
500505
"optional": "markdown",

components/prism-go-module.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// https://go.dev/ref/mod#go-mod-file-module
2+
3+
Prism.languages['go-mod'] = Prism.languages['go-module'] = {
4+
'comment': {
5+
pattern: /\/\/.*/,
6+
greedy: true
7+
},
8+
'version': {
9+
pattern: /(^|[\s()[\],])v\d+\.\d+\.\d+(?:[+-][-+.\w]*)?(?![^\s()[\],])/,
10+
lookbehind: true,
11+
alias: 'number'
12+
},
13+
'go-version': {
14+
pattern: /((?:^|\s)go\s+)\d+(?:\.\d+){1,2}/,
15+
lookbehind: true,
16+
alias: 'number'
17+
},
18+
'keyword': {
19+
pattern: /^([ \t]*)(?:exclude|go|module|replace|require|retract)\b/m,
20+
lookbehind: true
21+
},
22+
'operator': /=>/,
23+
'punctuation': /[()[\],]/
24+
};

components/prism-go-module.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-go-module.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Full example</h2>
2+
<pre><code>// Source: https://go.dev/doc/modules/gomod-ref#example
3+
4+
module example.com/mymodule
5+
6+
go 1.14
7+
8+
require (
9+
example.com/othermodule v1.2.3
10+
example.com/thismodule v1.2.3
11+
example.com/thatmodule v1.2.3
12+
)
13+
14+
replace example.com/thatmodule => ../thatmodule
15+
exclude example.com/thismodule v1.3.0</code></pre>

plugins/autoloader/prism-autoloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
"xls": "excel-formula",
198198
"gamemakerlanguage": "gml",
199199
"gni": "gn",
200+
"go-mod": "go-module",
200201
"hbs": "handlebars",
201202
"hs": "haskell",
202203
"idr": "idris",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
"glsl": "GLSL",
9999
"gn": "GN",
100100
"gni": "GN",
101+
"go-module": "Go module",
102+
"go-mod": "Go module",
101103
"graphql": "GraphQL",
102104
"hbs": "Handlebars",
103105
"hs": "Haskell",

0 commit comments

Comments
 (0)