~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/prism/components/prism-groovy.js

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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,
 
5
        'operator': {
 
6
                pattern: /(^|[^.])(~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
 
7
                lookbehind: true
 
8
        },
 
9
        'punctuation': /\.+|[{}[\];(),:$]/
 
10
});
 
11
 
 
12
Prism.languages.insertBefore('groovy', 'string', {
 
13
        'shebang': {
 
14
                pattern: /#!.+/,
 
15
                alias: 'comment'
 
16
        }
 
17
});
 
18
 
 
19
Prism.languages.insertBefore('groovy', 'punctuation', {
 
20
        'spock-block': /\b(setup|given|when|then|and|cleanup|expect|where):/
 
21
});
 
22
 
 
23
Prism.languages.insertBefore('groovy', 'function', {
 
24
        'annotation': {
 
25
                pattern: /(^|[^.])@\w+/,
 
26
                lookbehind: true
 
27
        }
 
28
});
 
29
 
 
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];
 
34
 
 
35
                if (delimiter != "'") {
 
36
                        var pattern = /([^\\])(\$(\{.*?\}|[\w\.]+))/;
 
37
                        if (delimiter === '$') {
 
38
                                pattern = /([^\$])(\$(\{.*?\}|[\w\.]+))/;
 
39
                        }
 
40
                        env.content = Prism.highlight(env.content, {
 
41
                                'expression': {
 
42
                                        pattern: pattern,
 
43
                                        lookbehind: true,
 
44
                                        inside: Prism.languages.groovy
 
45
                                }
 
46
                        });
 
47
 
 
48
                        env.classes.push(delimiter === '/' ? 'regex' : 'gstring');
 
49
                }
 
50
        }
 
51
});