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

Add support for Gradle #3443

Merged
merged 9 commits into from Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -554,6 +554,11 @@
"require": "clike",
"owner": "robfletcher"
},
"gradle": {
"title": "Gradle",
"require": "clike",
"owner": "zellat-boudis"
},
"haml": {
"title": "Haml",
"require": "ruby",
Expand Down
63 changes: 63 additions & 0 deletions components/prism-gradle.js
@@ -0,0 +1,63 @@
(function (Prism) {
var interpolation = {
pattern: /((?:^|[^\\$])(?:\\{2})*)\$(?:\w+|\{[^{}]*\})/,
lookbehind: true,
inside: {
"interpolation-punctuation": {
pattern: /^\$\{?|\}$/,
alias: "punctuation",
},
expression: {
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
pattern: /[\s\S]+/,
inside: null,
},
},
};

Prism.languages.gradle = Prism.languages.extend("clike", {
string: {
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
pattern: /'''(?:[^\\]|\\[\s\S])*?'''|'(?:\\.|[^\\'\r\n])*'/,
greedy: true,
},
keyword:
/\b(?:apply|def|dependencies|else|if|implementation|import|plugin|plugins|project|repositories|repository|sourceSets|tasks|val)\b/,
number: /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?\d+)?)[glidf]?\b/i,
operator: {
pattern:
/(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.\.(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
lookbehind: true,
},
punctuation: /\.+|[{}[\];(),:$]/,
});

Prism.languages.insertBefore("gradle", "string", {
shebang: {
pattern: /#!.+/,
alias: "comment",
greedy: true,
},
"interpolation-string": {
pattern:
/"""(?:[^\\]|\\[\s\S])*?"""|(["/])(?:\\.|(?!\1)[^\\\r\n])*\1|\$\/(?:[^/$]|\$(?:[/$]|(?![/$]))|\/(?!\$))*\/\$/,
greedy: true,
inside: {
interpolation: interpolation,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
string: /[\s\S]+/,
},
},
});

Prism.languages.insertBefore("gradle", "punctuation", {
"spock-block": /\b(?:and|cleanup|expect|given|setup|then|when|where):/,
});

Prism.languages.insertBefore("gradle", "function", {
annotation: {
pattern: /(^|[^.])@\w+/,
lookbehind: true,
alias: "punctuation",
},
});

interpolation.inside.expression.inside = Prism.languages.gradle;
})(Prism);
1 change: 1 addition & 0 deletions components/prism-gradle.min.js

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