1 | (function (Prism) {
|
2 | Prism.languages.puppet = {
|
3 | 'heredoc': [
|
4 |
|
5 | {
|
6 | pattern: /(@\("([^"\r\n\/):]+)"(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
|
7 | lookbehind: true,
|
8 | alias: 'string',
|
9 | inside: {
|
10 |
|
11 | 'punctuation': /(?=\S).*\S(?= *$)/
|
12 |
|
13 | }
|
14 | },
|
15 |
|
16 | {
|
17 | pattern: /(@\(([^"\r\n\/):]+)(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
|
18 | lookbehind: true,
|
19 | greedy: true,
|
20 | alias: 'string',
|
21 | inside: {
|
22 |
|
23 | 'punctuation': /(?=\S).*\S(?= *$)/
|
24 | }
|
25 | },
|
26 |
|
27 | {
|
28 | pattern: /@\("?(?:[^"\r\n\/):]+)"?(?:\/[nrts$uL]*)?\)/,
|
29 | alias: 'string',
|
30 | inside: {
|
31 | 'punctuation': {
|
32 | pattern: /(\().+?(?=\))/,
|
33 | lookbehind: true
|
34 | }
|
35 | }
|
36 | }
|
37 | ],
|
38 | 'multiline-comment': {
|
39 | pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
|
40 | lookbehind: true,
|
41 | greedy: true,
|
42 | alias: 'comment'
|
43 | },
|
44 | 'regex': {
|
45 |
|
46 | pattern: /((?:\bnode\s+|[~=\(\[\{,]\s*|[=+]>\s*|^\s*))\/(?:[^\/\\]|\\[\s\S])+\/(?:[imx]+\b|\B)/,
|
47 | lookbehind: true,
|
48 | greedy: true,
|
49 | inside: {
|
50 |
|
51 | 'extended-regex': {
|
52 | pattern: /^\/(?:[^\/\\]|\\[\s\S])+\/[im]*x[im]*$/,
|
53 | inside: {
|
54 | 'comment': /#.*/
|
55 | }
|
56 | }
|
57 | }
|
58 | },
|
59 | 'comment': {
|
60 | pattern: /(^|[^\\])#.*/,
|
61 | lookbehind: true,
|
62 | greedy: true,
|
63 | },
|
64 | 'string': {
|
65 |
|
66 | pattern: /(["'])(?:\$\{(?:[^'"}]|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}|\$(?!\{)|(?!\1)[^\\$]|\\[\s\S])*\1/,
|
67 | greedy: true,
|
68 | inside: {
|
69 | 'double-quoted': {
|
70 | pattern: /^"[\s\S]*"$/,
|
71 | inside: {
|
72 |
|
73 | }
|
74 | }
|
75 | }
|
76 | },
|
77 | 'variable': {
|
78 | pattern: /\$(?:::)?\w+(?:::\w+)*/,
|
79 | inside: {
|
80 | 'punctuation': /::/
|
81 | }
|
82 | },
|
83 | 'attr-name': /(?:\w+|\*)(?=\s*=>)/,
|
84 | 'function': [
|
85 | {
|
86 | pattern: /(\.)(?!\d)\w+/,
|
87 | lookbehind: true
|
88 | },
|
89 | /\b(?:contain|debug|err|fail|include|info|notice|realize|require|tag|warning)\b|\b(?!\d)\w+(?=\()/
|
90 | ],
|
91 | 'number': /\b(?:0x[a-f\d]+|\d+(?:\.\d+)?(?:e-?\d+)?)\b/i,
|
92 | 'boolean': /\b(?:true|false)\b/,
|
93 |
|
94 | 'keyword': /\b(?:application|attr|case|class|consumes|default|define|else|elsif|function|if|import|inherits|node|private|produces|type|undef|unless)\b/,
|
95 | 'datatype': {
|
96 | pattern: /\b(?:Any|Array|Boolean|Callable|Catalogentry|Class|Collection|Data|Default|Enum|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|String|Struct|Tuple|Type|Undef|Variant)\b/,
|
97 | alias: 'symbol'
|
98 | },
|
99 | 'operator': /=[=~>]?|![=~]?|<(?:<\|?|[=~|-])?|>[>=]?|->?|~>|\|>?>?|[*\/%+?]|\b(?:and|in|or)\b/,
|
100 | 'punctuation': /[\[\]{}().,;]|:+/
|
101 | };
|
102 |
|
103 | var interpolation = [
|
104 | {
|
105 |
|
106 | pattern: /(^|[^\\])\$\{(?:[^'"{}]|\{[^}]*\}|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}/,
|
107 | lookbehind: true,
|
108 | inside: {
|
109 | 'short-variable': {
|
110 |
|
111 | pattern: /(^\$\{)(?!\w+\()(?:::)?\w+(?:::\w+)*/,
|
112 | lookbehind: true,
|
113 | alias: 'variable',
|
114 | inside: {
|
115 | 'punctuation': /::/
|
116 | }
|
117 | },
|
118 | 'delimiter': {
|
119 | pattern: /^\$/,
|
120 | alias: 'variable'
|
121 | },
|
122 | rest: Prism.languages.puppet
|
123 | }
|
124 | },
|
125 | {
|
126 | pattern: /(^|[^\\])\$(?:::)?\w+(?:::\w+)*/,
|
127 | lookbehind: true,
|
128 | alias: 'variable',
|
129 | inside: {
|
130 | 'punctuation': /::/
|
131 | }
|
132 | }
|
133 | ];
|
134 | Prism.languages.puppet['heredoc'][0].inside.interpolation = interpolation;
|
135 | Prism.languages.puppet['string'].inside['double-quoted'].inside.interpolation = interpolation;
|
136 | }(Prism));
|