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