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*)[-*\w\xA0-\uFFFF]*\|(?!=)/,
|
25 | lookbehind: true,
|
26 | inside: {
|
27 | 'punctuation': /\|$/
|
28 | }
|
29 | },
|
30 | 'attribute': {
|
31 | pattern: /^(\s*)[-\w\xA0-\uFFFF]+/,
|
32 | lookbehind: true
|
33 | },
|
34 | 'value': [
|
35 | string,
|
36 | {
|
37 | pattern: /(=\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 | 'punctuation': /[()]/
|
59 | }
|
60 | };
|
61 |
|
62 | Prism.languages.css['atrule'].inside['selector-function-argument'].inside = selectorInside;
|
63 |
|
64 | Prism.languages.insertBefore('css', 'property', {
|
65 | 'variable': {
|
66 | pattern: /(^|[^-\w\xA0-\uFFFF])--[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*/i,
|
67 | lookbehind: true
|
68 | }
|
69 | });
|
70 |
|
71 | var unit = {
|
72 | pattern: /(\d)(?:%|[a-z]+)/,
|
73 | lookbehind: true
|
74 | };
|
75 |
|
76 | var number = {
|
77 | pattern: /(^|[^\w.-])-?\d*\.?\d+/,
|
78 | lookbehind: true
|
79 | };
|
80 |
|
81 | Prism.languages.insertBefore('css', 'function', {
|
82 | 'operator': {
|
83 | pattern: /(\s)[+\-*\/](?=\s)/,
|
84 | lookbehind: true
|
85 | },
|
86 |
|
87 |
|
88 | 'hexcode': {
|
89 | pattern: /\B#(?:[\da-f]{1,2}){3,4}\b/i,
|
90 | alias: 'color'
|
91 | },
|
92 | 'color': [
|
93 | /\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,
|
94 | {
|
95 | 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,
|
96 | inside: {
|
97 | 'unit': unit,
|
98 | 'number': number,
|
99 | 'function': /[\w-]+(?=\()/,
|
100 | 'punctuation': /[(),]/
|
101 | }
|
102 | }
|
103 | ],
|
104 | 'entity': /\\[\da-f]{1,8}/i,
|
105 | 'unit': unit,
|
106 | 'number': number
|
107 | });
|
108 |
|
109 | })(Prism);
|