1 | (function (Prism) {
|
---|
2 |
|
---|
3 | var jsString = /"(?:\\.|[^\\"\r\n])*"|'(?:\\.|[^\\'\r\n])*'/.source;
|
---|
4 | var jsComment = /\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\//.source;
|
---|
5 |
|
---|
6 | var jsExpr = /(?:[^\\()[\]{}"'/]|<string>|\/(?![*/])|<comment>|\(<expr>*\)|\[<expr>*\]|\{<expr>*\}|\\[\s\S])/
|
---|
7 | .source.replace(/<string>/g, function () { return jsString; }).replace(/<comment>/g, function () { return jsComment; });
|
---|
8 |
|
---|
9 | // the pattern will blow up, so only a few iterations
|
---|
10 | for (var i = 0; i < 2; i++) {
|
---|
11 | jsExpr = jsExpr.replace(/<expr>/g, function () { return jsExpr; });
|
---|
12 | }
|
---|
13 | jsExpr = jsExpr.replace(/<expr>/g, '[^\\s\\S]');
|
---|
14 |
|
---|
15 |
|
---|
16 | Prism.languages.qml = {
|
---|
17 | 'comment': {
|
---|
18 | pattern: /\/\/.*|\/\*[\s\S]*?\*\//,
|
---|
19 | greedy: true
|
---|
20 | },
|
---|
21 | 'javascript-function': {
|
---|
22 | pattern: RegExp(/((?:^|;)[ \t]*)function\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*\(<js>*\)\s*\{<js>*\}/.source.replace(/<js>/g, function () { return jsExpr; }), 'm'),
|
---|
23 | lookbehind: true,
|
---|
24 | greedy: true,
|
---|
25 | alias: 'language-javascript',
|
---|
26 | inside: Prism.languages.javascript
|
---|
27 | },
|
---|
28 | 'class-name': {
|
---|
29 | pattern: /((?:^|[:;])[ \t]*)(?!\d)\w+(?=[ \t]*\{|[ \t]+on\b)/m,
|
---|
30 | lookbehind: true
|
---|
31 | },
|
---|
32 | 'property': [
|
---|
33 | {
|
---|
34 | pattern: /((?:^|[;{])[ \t]*)(?!\d)\w+(?:\.\w+)*(?=[ \t]*:)/m,
|
---|
35 | lookbehind: true
|
---|
36 | },
|
---|
37 | {
|
---|
38 | pattern: /((?:^|[;{])[ \t]*)property[ \t]+(?!\d)\w+(?:\.\w+)*[ \t]+(?!\d)\w+(?:\.\w+)*(?=[ \t]*:)/m,
|
---|
39 | lookbehind: true,
|
---|
40 | inside: {
|
---|
41 | 'keyword': /^property/,
|
---|
42 | 'property': /\w+(?:\.\w+)*/
|
---|
43 | }
|
---|
44 | }
|
---|
45 | ],
|
---|
46 | 'javascript-expression': {
|
---|
47 | pattern: RegExp(/(:[ \t]*)(?![\s;}[])(?:(?!$|[;}])<js>)+/.source.replace(/<js>/g, function () { return jsExpr; }), 'm'),
|
---|
48 | lookbehind: true,
|
---|
49 | greedy: true,
|
---|
50 | alias: 'language-javascript',
|
---|
51 | inside: Prism.languages.javascript
|
---|
52 | },
|
---|
53 | 'string': {
|
---|
54 | pattern: /"(?:\\.|[^\\"\r\n])*"/,
|
---|
55 | greedy: true
|
---|
56 | },
|
---|
57 | 'keyword': /\b(?:as|import|on)\b/,
|
---|
58 | 'punctuation': /[{}[\]:;,]/
|
---|
59 | };
|
---|
60 |
|
---|
61 | }(Prism));
|
---|