UNPKG

1.61 kBJavaScriptView Raw
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 greedy: true,
25 inside: stringInterpolation
26 },
27 'string': {
28 pattern: string,
29 greedy: true,
30 inside: stringInterpolation
31 },
32
33 'function': {
34 pattern: /(\bdef\s+)[a-z_]\w+/i,
35 lookbehind: true
36 },
37
38 'variable': /\B\$\w+/,
39 'property-literal': {
40 pattern: /[a-z_]\w*(?=\s*:(?!:))/i,
41 alias: 'property'
42 },
43 'keyword': /\b(?:as|break|catch|def|elif|else|end|foreach|if|import|include|label|module|modulemeta|null|reduce|then|try|while)\b/,
44 'boolean': /\b(?:true|false)\b/,
45 'number': /(?:\b\d+\.|\B\.)?\d+(?:[eE][+-]?\d+)?\b/,
46
47 'operator': [
48 {
49 pattern: /\|=?/,
50 alias: 'pipe'
51 },
52 /\.\.|[!=<>]?=|\?\/\/|\/\/=?|[-+*/%]=?|[<>?]|\b(?:and|or|not)\b/
53 ],
54 'c-style-function': {
55 pattern: /\b[a-z_]\w*(?=\s*\()/i,
56 alias: 'function'
57 },
58 'punctuation': /::|[()\[\]{},:;]|\.(?=\s*[\[\w$])/,
59 'dot': {
60 pattern: /\./,
61 alias: 'important'
62 }
63 }
64
65 stringInterpolation.interpolation.inside.content.inside = jq;
66
67}(Prism));
68
\No newline at end of file