1
Prism.languages.groovy = Prism.languages.extend('clike', {
2
'keyword': /\b(as|def|in|abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|trait|transient|try|void|volatile|while)\b/,
3
'string': /("""|''')[\W\w]*?\1|("|'|\/)(?:\\?.)*?\2|(\$\/)(\$\/\$|[\W\w])*?\/\$/,
4
'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
6
pattern: /(^|[^.])(~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
9
'punctuation': /\.+|[{}[\];(),:$]/
12
Prism.languages.insertBefore('groovy', 'string', {
19
Prism.languages.insertBefore('groovy', 'punctuation', {
20
'spock-block': /\b(setup|given|when|then|and|cleanup|expect|where):/
23
Prism.languages.insertBefore('groovy', 'function', {
25
pattern: /(^|[^.])@\w+/,
30
// Handle string interpolation
31
Prism.hooks.add('wrap', function(env) {
32
if (env.language === 'groovy' && env.type === 'string') {
33
var delimiter = env.content[0];
35
if (delimiter != "'") {
36
var pattern = /([^\\])(\$(\{.*?\}|[\w\.]+))/;
37
if (delimiter === '$') {
38
pattern = /([^\$])(\$(\{.*?\}|[\w\.]+))/;
40
env.content = Prism.highlight(env.content, {
44
inside: Prism.languages.groovy
48
env.classes.push(delimiter === '/' ? 'regex' : 'gstring');