1 | (function (Prism) {
|
2 | var unit = {
|
3 | pattern: /(\b\d+)(?:%|[a-z]+)/,
|
4 | lookbehind: true
|
5 | };
|
6 |
|
7 | var number = {
|
8 | pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,
|
9 | lookbehind: true
|
10 | };
|
11 |
|
12 | var inside = {
|
13 | 'comment': {
|
14 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
15 | lookbehind: true
|
16 | },
|
17 | 'url': {
|
18 | pattern: /\burl\((["']?).*?\1\)/i,
|
19 | greedy: true
|
20 | },
|
21 | 'string': {
|
22 | pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
23 | greedy: true
|
24 | },
|
25 | 'interpolation': null,
|
26 | 'func': null,
|
27 | 'important': /\B!(?:important|optional)\b/i,
|
28 | 'keyword': {
|
29 | pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s|$)|@[\w-]+)/,
|
30 | lookbehind: true
|
31 | },
|
32 | 'hexcode': /#[\da-f]{3,6}/i,
|
33 | 'color': [
|
34 | /\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i,
|
35 | {
|
36 | pattern: /\b(?:rgb|hsl)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:rgb|hsl)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,
|
37 | inside: {
|
38 | 'unit': unit,
|
39 | 'number': number,
|
40 | 'function': /[\w-]+(?=\()/,
|
41 | 'punctuation': /[(),]/
|
42 | }
|
43 | }
|
44 | ],
|
45 | 'entity': /\\[\da-f]{1,8}/i,
|
46 | 'unit': unit,
|
47 | 'boolean': /\b(?:true|false)\b/,
|
48 | 'operator': [
|
49 |
|
50 |
|
51 | /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.{2,3}|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/
|
52 | ],
|
53 | 'number': number,
|
54 | 'punctuation': /[{}()\[\];:,]/
|
55 | };
|
56 |
|
57 | inside['interpolation'] = {
|
58 | pattern: /\{[^\r\n}:]+\}/,
|
59 | alias: 'variable',
|
60 | inside: {
|
61 | 'delimiter': {
|
62 | pattern: /^\{|\}$/,
|
63 | alias: 'punctuation'
|
64 | },
|
65 | rest: inside
|
66 | }
|
67 | };
|
68 | inside['func'] = {
|
69 | pattern: /[\w-]+\([^)]*\).*/,
|
70 | inside: {
|
71 | 'function': /^[^(]+/,
|
72 | rest: inside
|
73 | }
|
74 | };
|
75 |
|
76 | Prism.languages.stylus = {
|
77 | 'atrule-declaration': {
|
78 | pattern: /(^[ \t]*)@.+/m,
|
79 | lookbehind: true,
|
80 | inside: {
|
81 | 'atrule': /^@[\w-]+/,
|
82 | rest: inside
|
83 | }
|
84 | },
|
85 | 'variable-declaration': {
|
86 | pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:\{[^{}]*\}|\S.*|$)/m,
|
87 | lookbehind: true,
|
88 | inside: {
|
89 | 'variable': /^\S+/,
|
90 | rest: inside
|
91 | }
|
92 | },
|
93 |
|
94 | 'statement': {
|
95 | pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t].+/m,
|
96 | lookbehind: true,
|
97 | inside: {
|
98 | 'keyword': /^\S+/,
|
99 | rest: inside
|
100 | }
|
101 | },
|
102 |
|
103 | // A property/value pair cannot end with a comma or a brace
|
104 | // It cannot have indented content unless it ended with a semicolon
|
105 | 'property-declaration': {
|
106 | pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)(?!\s)[^{\r\n]*(?:;|[^{\r\n,]$(?!(?:\r?\n|\r)(?:\{|\2[ \t])))/m,
|
107 | lookbehind: true,
|
108 | inside: {
|
109 | 'property': {
|
110 | pattern: /^[^\s:]+/,
|
111 | inside: {
|
112 | 'interpolation': inside.interpolation
|
113 | }
|
114 | },
|
115 | rest: inside
|
116 | }
|
117 | },
|
118 |
|
119 |
|
120 | // A selector can contain parentheses only as part of a pseudo-element
|
121 | // It can span multiple lines.
|
122 | // It must end with a comma or an accolade or have indented content.
|
123 | 'selector': {
|
124 | pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t])))/m,
|
125 | lookbehind: true,
|
126 | inside: {
|
127 | 'interpolation': inside.interpolation,
|
128 | 'comment': inside.comment,
|
129 | 'punctuation': /[{},]/
|
130 | }
|
131 | },
|
132 |
|
133 | 'func': inside.func,
|
134 | 'string': inside.string,
|
135 | 'comment': {
|
136 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
137 | lookbehind: true,
|
138 | greedy: true
|
139 | },
|
140 | 'interpolation': inside.interpolation,
|
141 | 'punctuation': /[{}()\[\];:.]/
|
142 | };
|
143 | }(Prism));
|
144 |
|
\ | No newline at end of file |