| OLD | NEW |
| 1 Prism.languages.groovy = Prism.languages.extend('clike', { | 1 Prism.languages.groovy = Prism.languages.extend('clike', { |
| 2 'keyword': /\b(as|def|in|abstract|assert|boolean|break|byte|case|catch|c
har|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/, | 2 'keyword': /\b(as|def|in|abstract|assert|boolean|break|byte|case|catch|c
har|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]
)*?\/\$/, | 3 'string': /("""|''')[\W\w]*?\1|("|'|\/)(?:\\?.)*?\2|(\$\/)(\$\/\$|[\W\w]
)*?\/\$/, |
| 4 » 'number': /\b0b[01_]+\b|\b0x[\da-f_]+(\.[\da-f_p\-]+)?\b|\b[\d_]+(\.[\d_
]+[e]?[\d]*)?[glidf]\b|[\d_]+(\.[\d_]+)?\b/i, | 4 » 'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]
+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i, |
| 5 'operator': { | 5 'operator': { |
| 6 » » pattern: /(^|[^.])(={0,2}~|\?\.|\*?\.@|\.&|\.{1,2}(?!\.)|\.{2}<?
(?=\w)|->|\?:|[-+]{1,2}|!|<=>|>{1,3}|<{1,2}|={1,2}|&{1,2}|\|{1,2}|\?|\*{1,2}|\/|
\^|%)/, | 6 » » pattern: /(^|[^.])(~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<
|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/
=?|\^=?|%=?)/, |
| 7 lookbehind: true | 7 lookbehind: true |
| 8 }, | 8 }, |
| 9 'punctuation': /\.+|[{}[\];(),:$]/ | 9 'punctuation': /\.+|[{}[\];(),:$]/ |
| 10 }); | 10 }); |
| 11 | 11 |
| 12 Prism.languages.insertBefore('groovy', 'string', { | 12 Prism.languages.insertBefore('groovy', 'string', { |
| 13 'shebang': { | 13 'shebang': { |
| 14 pattern: /#!.+/, | 14 pattern: /#!.+/, |
| 15 alias: 'comment' | 15 alias: 'comment' |
| 16 } | 16 } |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 Prism.languages.insertBefore('groovy', 'punctuation', { | 19 Prism.languages.insertBefore('groovy', 'punctuation', { |
| 20 'spock-block': /\b(setup|given|when|then|and|cleanup|expect|where):/ | 20 'spock-block': /\b(setup|given|when|then|and|cleanup|expect|where):/ |
| 21 }); | 21 }); |
| 22 | 22 |
| 23 Prism.languages.insertBefore('groovy', 'function', { | 23 Prism.languages.insertBefore('groovy', 'function', { |
| 24 'annotation': { | 24 'annotation': { |
| 25 pattern: /(^|[^.])@\w+/, | 25 pattern: /(^|[^.])@\w+/, |
| 26 lookbehind: true | 26 lookbehind: true |
| 27 } | 27 } |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 // Handle string interpolation |
| 30 Prism.hooks.add('wrap', function(env) { | 31 Prism.hooks.add('wrap', function(env) { |
| 31 if (env.language === 'groovy' && env.type === 'string') { | 32 if (env.language === 'groovy' && env.type === 'string') { |
| 32 var delimiter = env.content[0]; | 33 var delimiter = env.content[0]; |
| 33 | 34 |
| 34 if (delimiter != "'") { | 35 if (delimiter != "'") { |
| 35 var pattern = /([^\\])(\$(\{.*?\}|[\w\.]+))/; | 36 var pattern = /([^\\])(\$(\{.*?\}|[\w\.]+))/; |
| 36 if (delimiter === '$') { | 37 if (delimiter === '$') { |
| 37 pattern = /([^\$])(\$(\{.*?\}|[\w\.]+))/; | 38 pattern = /([^\$])(\$(\{.*?\}|[\w\.]+))/; |
| 38 } | 39 } |
| 39 env.content = Prism.highlight(env.content, { | 40 env.content = Prism.highlight(env.content, { |
| 40 'expression': { | 41 'expression': { |
| 41 pattern: pattern, | 42 pattern: pattern, |
| 42 lookbehind: true, | 43 lookbehind: true, |
| 43 inside: Prism.languages.groovy | 44 inside: Prism.languages.groovy |
| 44 } | 45 } |
| 45 }); | 46 }); |
| 46 | 47 |
| 47 env.classes.push(delimiter === '/' ? 'regex' : 'gstring'
); | 48 env.classes.push(delimiter === '/' ? 'regex' : 'gstring'
); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 }); | 51 }); |
| OLD | NEW |