1 | (function (Prism) {
|
---|
2 |
|
---|
3 | var interpolation = /\\\((?:[^()]|\([^()]*\))*\)/.source;
|
---|
4 | var string = RegExp(/(^|[^\\])"(?:[^"\r\n\\]|\\[^\r\n(]|__)*"/.source.replace(/__/g, function () { return interpolation; }));
|
---|
5 | var stringInterpolation = {
|
---|
6 | 'interpolation': {
|
---|
7 | pattern: RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + interpolation),
|
---|
8 | lookbehind: true,
|
---|
9 | inside: {
|
---|
10 | 'content': {
|
---|
11 | pattern: /^(\\\()[\s\S]+(?=\)$)/,
|
---|
12 | lookbehind: true,
|
---|
13 | inside: null // see below
|
---|
14 | },
|
---|
15 | 'punctuation': /^\\\(|\)$/
|
---|
16 | }
|
---|
17 | }
|
---|
18 | };
|
---|
19 |
|
---|
20 | var jq = Prism.languages.jq = {
|
---|
21 | 'comment': /#.*/,
|
---|
22 | 'property': {
|
---|
23 | pattern: RegExp(string.source + /(?=\s*:(?!:))/.source),
|
---|
24 | lookbehind: true,
|
---|
25 | greedy: true,
|
---|
26 | inside: stringInterpolation
|
---|
27 | },
|
---|
28 | 'string': {
|
---|
29 | pattern: string,
|
---|
30 | lookbehind: true,
|
---|
31 | greedy: true,
|
---|
32 | inside: stringInterpolation
|
---|
33 | },
|
---|
34 |
|
---|
35 | 'function': {
|
---|
36 | pattern: /(\bdef\s+)[a-z_]\w+/i,
|
---|
37 | lookbehind: true
|
---|
38 | },
|
---|
39 |
|
---|
40 | 'variable': /\B\$\w+/,
|
---|
41 | 'property-literal': {
|
---|
42 | pattern: /\b[a-z_]\w*(?=\s*:(?!:))/i,
|
---|
43 | alias: 'property'
|
---|
44 | },
|
---|
45 | 'keyword': /\b(?:as|break|catch|def|elif|else|end|foreach|if|import|include|label|module|modulemeta|null|reduce|then|try|while)\b/,
|
---|
46 | 'boolean': /\b(?:false|true)\b/,
|
---|
47 | 'number': /(?:\b\d+\.|\B\.)?\b\d+(?:[eE][+-]?\d+)?\b/,
|
---|
48 |
|
---|
49 | 'operator': [
|
---|
50 | {
|
---|
51 | pattern: /\|=?/,
|
---|
52 | alias: 'pipe'
|
---|
53 | },
|
---|
54 | /\.\.|[!=<>]?=|\?\/\/|\/\/=?|[-+*/%]=?|[<>?]|\b(?:and|not|or)\b/
|
---|
55 | ],
|
---|
56 | 'c-style-function': {
|
---|
57 | pattern: /\b[a-z_]\w*(?=\s*\()/i,
|
---|
58 | alias: 'function'
|
---|
59 | },
|
---|
60 | 'punctuation': /::|[()\[\]{},:;]|\.(?=\s*[\[\w$])/,
|
---|
61 | 'dot': {
|
---|
62 | pattern: /\./,
|
---|
63 | alias: 'important'
|
---|
64 | }
|
---|
65 | };
|
---|
66 |
|
---|
67 | stringInterpolation.interpolation.inside.content.inside = jq;
|
---|
68 |
|
---|
69 | }(Prism));
|
---|