1 | (function (Prism) {
|
2 | var inside = {
|
3 | 'url': /url\((["']?).*?\1\)/i,
|
4 | 'string': {
|
5 | pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
6 | greedy: true
|
7 | },
|
8 | 'interpolation': null,
|
9 | 'func': null,
|
10 | 'important': /\B!(?:important|optional)\b/i,
|
11 | 'keyword': {
|
12 | pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|$)|@[\w-]+)/,
|
13 | lookbehind: true
|
14 | },
|
15 | 'hexcode': /#[\da-f]{3,6}/i,
|
16 | 'number': /\b\d+(?:\.\d+)?%?/,
|
17 | 'boolean': /\b(?:true|false)\b/,
|
18 | 'operator': [
|
19 |
|
20 |
|
21 | /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/
|
22 | ],
|
23 | 'punctuation': /[{}()\[\];:,]/
|
24 | };
|
25 |
|
26 | inside['interpolation'] = {
|
27 | pattern: /\{[^\r\n}:]+\}/,
|
28 | alias: 'variable',
|
29 | inside: {
|
30 | 'delimiter': {
|
31 | pattern: /^{|}$/,
|
32 | alias: 'punctuation'
|
33 | },
|
34 | rest: inside
|
35 | }
|
36 | };
|
37 | inside['func'] = {
|
38 | pattern: /[\w-]+\([^)]*\).*/,
|
39 | inside: {
|
40 | 'function': /^[^(]+/,
|
41 | rest: inside
|
42 | }
|
43 | };
|
44 |
|
45 | Prism.languages.stylus = {
|
46 | 'comment': {
|
47 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
48 | lookbehind: true
|
49 | },
|
50 | 'atrule-declaration': {
|
51 | pattern: /(^\s*)@.+/m,
|
52 | lookbehind: true,
|
53 | inside: {
|
54 | 'atrule': /^@[\w-]+/,
|
55 | rest: inside
|
56 | }
|
57 | },
|
58 | 'variable-declaration': {
|
59 | pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+)|$)/m,
|
60 | lookbehind: true,
|
61 | inside: {
|
62 | 'variable': /^\S+/,
|
63 | rest: inside
|
64 | }
|
65 | },
|
66 |
|
67 | 'statement': {
|
68 | pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+/m,
|
69 | lookbehind: true,
|
70 | inside: {
|
71 | 'keyword': /^\S+/,
|
72 | rest: inside
|
73 | }
|
74 | },
|
75 |
|
76 | // A property/value pair cannot end with a comma or a brace
|
77 | // It cannot have indented content unless it ended with a semicolon
|
78 | 'property-declaration': {
|
79 | pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(?:\r?\n|\r)(?:\{|\2[ \t]+)))/m,
|
80 | lookbehind: true,
|
81 | inside: {
|
82 | 'property': {
|
83 | pattern: /^[^\s:]+/,
|
84 | inside: {
|
85 | 'interpolation': inside.interpolation
|
86 | }
|
87 | },
|
88 | rest: inside
|
89 | }
|
90 | },
|
91 |
|
92 |
|
93 |
|
94 | // A selector can contain parentheses only as part of a pseudo-element
|
95 | // It can span multiple lines.
|
96 | // It must end with a comma or an accolade or have indented content.
|
97 | 'selector': {
|
98 | pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t]+)))/m,
|
99 | lookbehind: true,
|
100 | inside: {
|
101 | 'interpolation': inside.interpolation,
|
102 | 'punctuation': /[{},]/
|
103 | }
|
104 | },
|
105 |
|
106 | 'func': inside.func,
|
107 | 'string': inside.string,
|
108 | 'interpolation': inside.interpolation,
|
109 | 'punctuation': /[{}()\[\];:.]/
|
110 | };
|
111 | }(Prism));
|
112 |
|
\ | No newline at end of file |