1 | (function (Prism) {
|
2 |
|
3 | var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
|
4 | var selectorInside;
|
5 |
|
6 | Prism.languages.css.selector = {
|
7 | pattern: Prism.languages.css.selector,
|
8 | inside: selectorInside = {
|
9 | 'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
|
10 | 'pseudo-class': /:[-\w]+/,
|
11 | 'class': /\.[-\w]+/,
|
12 | 'id': /#[-\w]+/,
|
13 | 'attribute': {
|
14 | pattern: RegExp('\\[(?:[^[\\]"\']|' + string.source + ')*\\]'),
|
15 | greedy: true,
|
16 | inside: {
|
17 | 'punctuation': /^\[|\]$/,
|
18 | 'case-sensitivity': {
|
19 | pattern: /(\s)[si]$/i,
|
20 | lookbehind: true,
|
21 | alias: 'keyword'
|
22 | },
|
23 | 'namespace': {
|
24 | pattern: /^(\s*)(?:(?!\s)[-*\w\xA0-\uFFFF])*\|(?!=)/,
|
25 | lookbehind: true,
|
26 | inside: {
|
27 | 'punctuation': /\|$/
|
28 | }
|
29 | },
|
30 | 'attr-name': {
|
31 | pattern: /^(\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+/,
|
32 | lookbehind: true
|
33 | },
|
34 | 'attr-value': [
|
35 | string,
|
36 | {
|
37 | pattern: /(=\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+(?=\s*$)/,
|
38 | lookbehind: true
|
39 | }
|
40 | ],
|
41 | 'operator': /[|~*^$]?=/
|
42 | }
|
43 | },
|
44 | 'n-th': [
|
45 | {
|
46 | pattern: /(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,
|
47 | lookbehind: true,
|
48 | inside: {
|
49 | 'number': /[\dn]+/,
|
50 | 'operator': /[+-]/
|
51 | }
|
52 | },
|
53 | {
|
54 | pattern: /(\(\s*)(?:even|odd)(?=\s*\))/i,
|
55 | lookbehind: true
|
56 | }
|
57 | ],
|
58 | 'combinator': />|\+|~|\|\|/,
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | 'punctuation': /[(),]/,
|
65 | }
|
66 | };
|
67 |
|
68 | Prism.languages.css['atrule'].inside['selector-function-argument'].inside = selectorInside;
|
69 |
|
70 | Prism.languages.insertBefore('css', 'property', {
|
71 | 'variable': {
|
72 | pattern: /(^|[^-\w\xA0-\uFFFF])--(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*/i,
|
73 | lookbehind: true
|
74 | }
|
75 | });
|
76 |
|
77 | var unit = {
|
78 | pattern: /(\b\d+)(?:%|[a-z]+\b)/,
|
79 | lookbehind: true
|
80 | };
|
81 |
|
82 | var number = {
|
83 | pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,
|
84 | lookbehind: true
|
85 | };
|
86 |
|
87 | Prism.languages.insertBefore('css', 'function', {
|
88 | 'operator': {
|
89 | pattern: /(\s)[+\-*\/](?=\s)/,
|
90 | lookbehind: true
|
91 | },
|
92 |
|
93 |
|
94 | 'hexcode': {
|
95 | pattern: /\B#(?:[\da-f]{1,2}){3,4}\b/i,
|
96 | alias: 'color'
|
97 | },
|
98 | 'color': [
|
99 | /\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,
|
100 | {
|
101 | 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,
|
102 | inside: {
|
103 | 'unit': unit,
|
104 | 'number': number,
|
105 | 'function': /[\w-]+(?=\()/,
|
106 | 'punctuation': /[(),]/
|
107 | }
|
108 | }
|
109 | ],
|
110 |
|
111 | 'entity': /\\[\da-f]{1,8}/i,
|
112 | 'unit': unit,
|
113 | 'number': number
|
114 | });
|
115 |
|
116 | })(Prism);
|