Skip to content

Commit

Permalink
Added support for go.mod files (#3209)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Dec 5, 2021
1 parent 969f152 commit 8476a9a
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@
"require": "clike",
"owner": "arnehormann"
},
"go-module": {
"title": "Go module",
"alias": "go-mod",
"owner": "RunDevelopment"
},
"graphql": {
"title": "GraphQL",
"optional": "markdown",
Expand Down
24 changes: 24 additions & 0 deletions components/prism-go-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://go.dev/ref/mod#go-mod-file-module

Prism.languages['go-mod'] = Prism.languages['go-module'] = {
'comment': {
pattern: /\/\/.*/,
greedy: true
},
'version': {
pattern: /(^|[\s()[\],])v\d+\.\d+\.\d+(?:[+-][-+.\w]*)?(?![^\s()[\],])/,
lookbehind: true,
alias: 'number'
},
'go-version': {
pattern: /((?:^|\s)go\s+)\d+(?:\.\d+){1,2}/,
lookbehind: true,
alias: 'number'
},
'keyword': {
pattern: /^([ \t]*)(?:exclude|go|module|replace|require|retract)\b/m,
lookbehind: true
},
'operator': /=>/,
'punctuation': /[()[\],]/
};
1 change: 1 addition & 0 deletions components/prism-go-module.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions examples/prism-go-module.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>Full example</h2>
<pre><code>// Source: https://go.dev/doc/modules/gomod-ref#example

module example.com/mymodule

go 1.14

require (
example.com/othermodule v1.2.3
example.com/thismodule v1.2.3
example.com/thatmodule v1.2.3
)

replace example.com/thatmodule => ../thatmodule
exclude example.com/thismodule v1.3.0</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"xls": "excel-formula",
"gamemakerlanguage": "gml",
"gni": "gn",
"go-mod": "go-module",
"hbs": "handlebars",
"hs": "haskell",
"idr": "idris",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
"glsl": "GLSL",
"gn": "GN",
"gni": "GN",
"go-module": "Go module",
"go-mod": "Go module",
"graphql": "GraphQL",
"hbs": "Handlebars",
"hs": "Haskell",
Expand Down
Loading

0 comments on commit 8476a9a

Please sign in to comment.