Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for go.mod files #3209

Merged
merged 4 commits into from Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
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
@@ -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
@@ -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
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
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