19 from pygments.util import iteritems |
19 from pygments.util import iteritems |
20 |
20 |
21 __all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer'] |
21 __all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer'] |
22 |
22 |
23 |
23 |
|
24 # List of vendor prefixes obtained from: |
|
25 # https://www.w3.org/TR/CSS21/syndata.html#vendor-keyword-history |
|
26 _vendor_prefixes = ( |
|
27 '-ms-', 'mso-', '-moz-', '-o-', '-xv-', '-atsc-', '-wap-', '-khtml-', |
|
28 '-webkit-', 'prince-', '-ah-', '-hp-', '-ro-', '-rim-', '-tc-', |
|
29 ) |
|
30 |
|
31 # List of CSS properties obtained from: |
|
32 # https://www.w3.org/Style/CSS/all-properties.en.html |
|
33 # Note: handle --* separately |
|
34 _css_properties = ( |
|
35 'align-content', 'align-items', 'align-self', 'alignment-baseline', 'all', |
|
36 'animation', 'animation-delay', 'animation-direction', |
|
37 'animation-duration', 'animation-fill-mode', 'animation-iteration-count', |
|
38 'animation-name', 'animation-play-state', 'animation-timing-function', |
|
39 'appearance', 'azimuth', 'backface-visibility', 'background', |
|
40 'background-attachment', 'background-blend-mode', 'background-clip', |
|
41 'background-color', 'background-image', 'background-origin', |
|
42 'background-position', 'background-repeat', 'background-size', |
|
43 'baseline-shift', 'bookmark-label', 'bookmark-level', 'bookmark-state', |
|
44 'border', 'border-bottom', 'border-bottom-color', |
|
45 'border-bottom-left-radius', 'border-bottom-right-radius', |
|
46 'border-bottom-style', 'border-bottom-width', 'border-boundary', |
|
47 'border-collapse', 'border-color', 'border-image', 'border-image-outset', |
|
48 'border-image-repeat', 'border-image-slice', 'border-image-source', |
|
49 'border-image-width', 'border-left', 'border-left-color', |
|
50 'border-left-style', 'border-left-width', 'border-radius', 'border-right', |
|
51 'border-right-color', 'border-right-style', 'border-right-width', |
|
52 'border-spacing', 'border-style', 'border-top', 'border-top-color', |
|
53 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', |
|
54 'border-top-width', 'border-width', 'bottom', 'box-decoration-break', |
|
55 'box-shadow', 'box-sizing', 'box-snap', 'box-suppress', 'break-after', |
|
56 'break-before', 'break-inside', 'caption-side', 'caret', 'caret-animation', |
|
57 'caret-color', 'caret-shape', 'chains', 'clear', 'clip', 'clip-path', |
|
58 'clip-rule', 'color', 'color-interpolation-filters', 'column-count', |
|
59 'column-fill', 'column-gap', 'column-rule', 'column-rule-color', |
|
60 'column-rule-style', 'column-rule-width', 'column-span', 'column-width', |
|
61 'columns', 'content', 'counter-increment', 'counter-reset', 'counter-set', |
|
62 'crop', 'cue', 'cue-after', 'cue-before', 'cursor', 'direction', 'display', |
|
63 'dominant-baseline', 'elevation', 'empty-cells', 'filter', 'flex', |
|
64 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', |
|
65 'flex-wrap', 'float', 'float-defer', 'float-offset', 'float-reference', |
|
66 'flood-color', 'flood-opacity', 'flow', 'flow-from', 'flow-into', 'font', |
|
67 'font-family', 'font-feature-settings', 'font-kerning', |
|
68 'font-language-override', 'font-size', 'font-size-adjust', 'font-stretch', |
|
69 'font-style', 'font-synthesis', 'font-variant', 'font-variant-alternates', |
|
70 'font-variant-caps', 'font-variant-east-asian', 'font-variant-ligatures', |
|
71 'font-variant-numeric', 'font-variant-position', 'font-weight', |
|
72 'footnote-display', 'footnote-policy', 'glyph-orientation-vertical', |
|
73 'grid', 'grid-area', 'grid-auto-columns', 'grid-auto-flow', |
|
74 'grid-auto-rows', 'grid-column', 'grid-column-end', 'grid-column-gap', |
|
75 'grid-column-start', 'grid-gap', 'grid-row', 'grid-row-end', |
|
76 'grid-row-gap', 'grid-row-start', 'grid-template', 'grid-template-areas', |
|
77 'grid-template-columns', 'grid-template-rows', 'hanging-punctuation', |
|
78 'height', 'hyphenate-character', 'hyphenate-limit-chars', |
|
79 'hyphenate-limit-last', 'hyphenate-limit-lines', 'hyphenate-limit-zone', |
|
80 'hyphens', 'image-orientation', 'image-resolution', 'initial-letter', |
|
81 'initial-letter-align', 'initial-letter-wrap', 'isolation', |
|
82 'justify-content', 'justify-items', 'justify-self', 'left', |
|
83 'letter-spacing', 'lighting-color', 'line-break', 'line-grid', |
|
84 'line-height', 'line-snap', 'list-style', 'list-style-image', |
|
85 'list-style-position', 'list-style-type', 'margin', 'margin-bottom', |
|
86 'margin-left', 'margin-right', 'margin-top', 'marker-side', |
|
87 'marquee-direction', 'marquee-loop', 'marquee-speed', 'marquee-style', |
|
88 'mask', 'mask-border', 'mask-border-mode', 'mask-border-outset', |
|
89 'mask-border-repeat', 'mask-border-slice', 'mask-border-source', |
|
90 'mask-border-width', 'mask-clip', 'mask-composite', 'mask-image', |
|
91 'mask-mode', 'mask-origin', 'mask-position', 'mask-repeat', 'mask-size', |
|
92 'mask-type', 'max-height', 'max-lines', 'max-width', 'min-height', |
|
93 'min-width', 'mix-blend-mode', 'motion', 'motion-offset', 'motion-path', |
|
94 'motion-rotation', 'move-to', 'nav-down', 'nav-left', 'nav-right', |
|
95 'nav-up', 'object-fit', 'object-position', 'offset-after', 'offset-before', |
|
96 'offset-end', 'offset-start', 'opacity', 'order', 'orphans', 'outline', |
|
97 'outline-color', 'outline-offset', 'outline-style', 'outline-width', |
|
98 'overflow', 'overflow-style', 'overflow-wrap', 'overflow-x', 'overflow-y', |
|
99 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', |
|
100 'page', 'page-break-after', 'page-break-before', 'page-break-inside', |
|
101 'page-policy', 'pause', 'pause-after', 'pause-before', 'perspective', |
|
102 'perspective-origin', 'pitch', 'pitch-range', 'play-during', 'polar-angle', |
|
103 'polar-distance', 'position', 'presentation-level', 'quotes', |
|
104 'region-fragment', 'resize', 'rest', 'rest-after', 'rest-before', |
|
105 'richness', 'right', 'rotation', 'rotation-point', 'ruby-align', |
|
106 'ruby-merge', 'ruby-position', 'running', 'scroll-snap-coordinate', |
|
107 'scroll-snap-destination', 'scroll-snap-points-x', 'scroll-snap-points-y', |
|
108 'scroll-snap-type', 'shape-image-threshold', 'shape-inside', 'shape-margin', |
|
109 'shape-outside', 'size', 'speak', 'speak-as', 'speak-header', |
|
110 'speak-numeral', 'speak-punctuation', 'speech-rate', 'stress', 'string-set', |
|
111 'tab-size', 'table-layout', 'text-align', 'text-align-last', |
|
112 'text-combine-upright', 'text-decoration', 'text-decoration-color', |
|
113 'text-decoration-line', 'text-decoration-skip', 'text-decoration-style', |
|
114 'text-emphasis', 'text-emphasis-color', 'text-emphasis-position', |
|
115 'text-emphasis-style', 'text-indent', 'text-justify', 'text-orientation', |
|
116 'text-overflow', 'text-shadow', 'text-space-collapse', 'text-space-trim', |
|
117 'text-spacing', 'text-transform', 'text-underline-position', 'text-wrap', |
|
118 'top', 'transform', 'transform-origin', 'transform-style', 'transition', |
|
119 'transition-delay', 'transition-duration', 'transition-property', |
|
120 'transition-timing-function', 'unicode-bidi', 'user-select', |
|
121 'vertical-align', 'visibility', 'voice-balance', 'voice-duration', |
|
122 'voice-family', 'voice-pitch', 'voice-range', 'voice-rate', 'voice-stress', |
|
123 'voice-volume', 'volume', 'white-space', 'widows', 'width', 'will-change', |
|
124 'word-break', 'word-spacing', 'word-wrap', 'wrap-after', 'wrap-before', |
|
125 'wrap-flow', 'wrap-inside', 'wrap-through', 'writing-mode', 'z-index', |
|
126 ) |
|
127 |
|
128 # List of keyword values obtained from: |
|
129 # http://cssvalues.com/ |
|
130 _keyword_values = ( |
|
131 'absolute', 'alias', 'all', 'all-petite-caps', 'all-scroll', |
|
132 'all-small-caps', 'allow-end', 'alpha', 'alternate', 'alternate-reverse', |
|
133 'always', 'armenian', 'auto', 'avoid', 'avoid-column', 'avoid-page', |
|
134 'backwards', 'balance', 'baseline', 'below', 'blink', 'block', 'bold', |
|
135 'bolder', 'border-box', 'both', 'bottom', 'box-decoration', 'break-word', |
|
136 'capitalize', 'cell', 'center', 'circle', 'clip', 'clone', 'close-quote', |
|
137 'col-resize', 'collapse', 'color', 'color-burn', 'color-dodge', 'column', |
|
138 'column-reverse', 'compact', 'condensed', 'contain', 'container', |
|
139 'content-box', 'context-menu', 'copy', 'cover', 'crisp-edges', 'crosshair', |
|
140 'currentColor', 'cursive', 'darken', 'dashed', 'decimal', |
|
141 'decimal-leading-zero', 'default', 'descendants', 'difference', 'digits', |
|
142 'disc', 'distribute', 'dot', 'dotted', 'double', 'double-circle', 'e-resize', |
|
143 'each-line', 'ease', 'ease-in', 'ease-in-out', 'ease-out', 'edges', |
|
144 'ellipsis', 'end', 'ew-resize', 'exclusion', 'expanded', 'extra-condensed', |
|
145 'extra-expanded', 'fantasy', 'fill', 'fill-box', 'filled', 'first', 'fixed', |
|
146 'flat', 'flex', 'flex-end', 'flex-start', 'flip', 'force-end', 'forwards', |
|
147 'from-image', 'full-width', 'geometricPrecision', 'georgian', 'groove', |
|
148 'hanging', 'hard-light', 'help', 'hidden', 'hide', 'horizontal', 'hue', |
|
149 'icon', 'infinite', 'inherit', 'initial', 'ink', 'inline', 'inline-block', |
|
150 'inline-flex', 'inline-table', 'inset', 'inside', 'inter-word', 'invert', |
|
151 'isolate', 'italic', 'justify', 'large', 'larger', 'last', 'left', |
|
152 'lighten', 'lighter', 'line-through', 'linear', 'list-item', 'local', |
|
153 'loose', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman', |
|
154 'lowercase', 'ltr', 'luminance', 'luminosity', 'mandatory', 'manipulation', |
|
155 'manual', 'margin-box', 'match-parent', 'medium', 'mixed', 'monospace', |
|
156 'move', 'multiply', 'n-resize', 'ne-resize', 'nesw-resize', |
|
157 'no-close-quote', 'no-drop', 'no-open-quote', 'no-repeat', 'none', 'normal', |
|
158 'not-allowed', 'nowrap', 'ns-resize', 'nw-resize', 'nwse-resize', 'objects', |
|
159 'oblique', 'off', 'on', 'open', 'open-quote', 'optimizeLegibility', |
|
160 'optimizeSpeed', 'outset', 'outside', 'over', 'overlay', 'overline', |
|
161 'padding-box', 'page', 'pan-down', 'pan-left', 'pan-right', 'pan-up', |
|
162 'pan-x', 'pan-y', 'paused', 'petite-caps', 'pixelated', 'pointer', |
|
163 'preserve-3d', 'progress', 'proximity', 'relative', 'repeat', |
|
164 'repeat no-repeat', 'repeat-x', 'repeat-y', 'reverse', 'ridge', 'right', |
|
165 'round', 'row', 'row-resize', 'row-reverse', 'rtl', 'ruby', 'ruby-base', |
|
166 'ruby-base-container', 'ruby-text', 'ruby-text-container', 'run-in', |
|
167 'running', 's-resize', 'sans-serif', 'saturation', 'scale-down', 'screen', |
|
168 'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate', |
|
169 'serif', 'sesame', 'show', 'sideways', 'sideways-left', 'sideways-right', |
|
170 'slice', 'small', 'small-caps', 'smaller', 'smooth', 'snap', 'soft-light', |
|
171 'solid', 'space', 'space-around', 'space-between', 'spaces', 'square', |
|
172 'start', 'static', 'step-end', 'step-start', 'sticky', 'stretch', 'strict', |
|
173 'stroke-box', 'style', 'sw-resize', 'table', 'table-caption', 'table-cell', |
|
174 'table-column', 'table-column-group', 'table-footer-group', |
|
175 'table-header-group', 'table-row', 'table-row-group', 'text', 'thick', |
|
176 'thin', 'titling-caps', 'to', 'top', 'triangle', 'ultra-condensed', |
|
177 'ultra-expanded', 'under', 'underline', 'unicase', 'unset', 'upper-alpha', |
|
178 'upper-latin', 'upper-roman', 'uppercase', 'upright', 'use-glyph-orientation', |
|
179 'vertical', 'vertical-text', 'view-box', 'visible', 'w-resize', 'wait', |
|
180 'wavy', 'weight', 'weight style', 'wrap', 'wrap-reverse', 'x-large', |
|
181 'x-small', 'xx-large', 'xx-small', 'zoom-in', 'zoom-out', |
|
182 ) |
|
183 |
|
184 # List of extended color keywords obtained from: |
|
185 # https://drafts.csswg.org/css-color/#named-colors |
|
186 _color_keywords = ( |
|
187 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', |
|
188 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', |
|
189 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', |
|
190 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', |
|
191 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', |
|
192 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', |
|
193 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', |
|
194 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', |
|
195 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', |
|
196 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', |
|
197 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', |
|
198 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', |
|
199 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', |
|
200 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', |
|
201 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', |
|
202 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', |
|
203 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', |
|
204 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', |
|
205 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', |
|
206 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', |
|
207 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', |
|
208 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', |
|
209 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', |
|
210 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', |
|
211 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', |
|
212 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', |
|
213 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', |
|
214 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen', |
|
215 ) + ('transparent',) |
|
216 |
|
217 # List of other keyword values from other sources: |
|
218 _other_keyword_values = ( |
|
219 'above', 'aural', 'behind', 'bidi-override', 'center-left', 'center-right', |
|
220 'cjk-ideographic', 'continuous', 'crop', 'cross', 'embed', 'far-left', |
|
221 'far-right', 'fast', 'faster', 'hebrew', 'high', 'higher', 'hiragana', |
|
222 'hiragana-iroha', 'katakana', 'katakana-iroha', 'landscape', 'left-side', |
|
223 'leftwards', 'level', 'loud', 'low', 'lower', 'message-box', 'middle', |
|
224 'mix', 'narrower', 'once', 'portrait', 'right-side', 'rightwards', 'silent', |
|
225 'slow', 'slower', 'small-caption', 'soft', 'spell-out', 'status-bar', |
|
226 'super', 'text-bottom', 'text-top', 'wider', 'x-fast', 'x-high', 'x-loud', |
|
227 'x-low', 'x-soft', 'yes', 'pre', 'pre-wrap', 'pre-line', |
|
228 ) |
|
229 |
|
230 # List of functional notation and function keyword values: |
|
231 _functional_notation_keyword_values = ( |
|
232 'attr', 'blackness', 'blend', 'blenda', 'blur', 'brightness', 'calc', |
|
233 'circle', 'color-mod', 'contrast', 'counter', 'cubic-bezier', 'device-cmyk', |
|
234 'drop-shadow', 'ellipse', 'gray', 'grayscale', 'hsl', 'hsla', 'hue', |
|
235 'hue-rotate', 'hwb', 'image', 'inset', 'invert', 'lightness', |
|
236 'linear-gradient', 'matrix', 'matrix3d', 'opacity', 'perspective', |
|
237 'polygon', 'radial-gradient', 'rect', 'repeating-linear-gradient', |
|
238 'repeating-radial-gradient', 'rgb', 'rgba', 'rotate', 'rotate3d', 'rotateX', |
|
239 'rotateY', 'rotateZ', 'saturate', 'saturation', 'scale', 'scale3d', |
|
240 'scaleX', 'scaleY', 'scaleZ', 'sepia', 'shade', 'skewX', 'skewY', 'steps', |
|
241 'tint', 'toggle', 'translate', 'translate3d', 'translateX', 'translateY', |
|
242 'translateZ', 'whiteness', |
|
243 ) |
|
244 # Note! Handle url(...) separately. |
|
245 |
|
246 # List of units obtained from: |
|
247 # https://www.w3.org/TR/css3-values/ |
|
248 _angle_units = ( |
|
249 'deg', 'grad', 'rad', 'turn', |
|
250 ) |
|
251 _frequency_units = ( |
|
252 'Hz', 'kHz', |
|
253 ) |
|
254 _length_units = ( |
|
255 'em', 'ex', 'ch', 'rem', |
|
256 'vh', 'vw', 'vmin', 'vmax', |
|
257 'px', 'mm', 'cm', 'in', 'pt', 'pc', 'q', |
|
258 ) |
|
259 _resolution_units = ( |
|
260 'dpi', 'dpcm', 'dppx', |
|
261 ) |
|
262 _time_units = ( |
|
263 's', 'ms', |
|
264 ) |
|
265 _all_units = _angle_units + _frequency_units + _length_units + \ |
|
266 _resolution_units + _time_units |
|
267 |
|
268 |
24 class CssLexer(RegexLexer): |
269 class CssLexer(RegexLexer): |
25 """ |
270 """ |
26 For CSS (Cascading Style Sheets). |
271 For CSS (Cascading Style Sheets). |
27 """ |
272 """ |
28 |
273 |
58 (r'\}', Punctuation, '#pop:2'), |
303 (r'\}', Punctuation, '#pop:2'), |
59 ], |
304 ], |
60 'content': [ |
305 'content': [ |
61 (r'\s+', Text), |
306 (r'\s+', Text), |
62 (r'\}', Punctuation, '#pop'), |
307 (r'\}', Punctuation, '#pop'), |
63 (r'url\(.*?\)', String.Other), |
308 (r';', Punctuation), |
64 (r'^@.*?$', Comment.Preproc), |
309 (r'^@.*?$', Comment.Preproc), |
65 (words(( |
310 |
66 'azimuth', 'background-attachment', 'background-color', |
311 (words(_vendor_prefixes,), Keyword.Pseudo), |
67 'background-image', 'background-position', 'background-repeat', |
312 (r'('+r'|'.join(_css_properties)+r')(\s*)(\:)', |
68 'background', 'border-bottom-color', 'border-bottom-style', |
313 bygroups(Keyword, Text, Punctuation), 'value-start'), |
69 'border-bottom-width', 'border-left-color', 'border-left-style', |
314 (r'([a-zA-Z_][\w-]*)(\s*)(\:)', bygroups(Name, Text, Punctuation), |
70 'border-left-width', 'border-right', 'border-right-color', |
315 'value-start'), |
71 'border-right-style', 'border-right-width', 'border-top-color', |
316 |
72 'border-top-style', 'border-top-width', 'border-bottom', |
317 (r'/\*(?:.|\n)*?\*/', Comment), |
73 'border-collapse', 'border-left', 'border-width', 'border-color', |
318 ], |
74 'border-spacing', 'border-style', 'border-top', 'border', 'caption-side', |
319 'value-start': [ |
75 'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', |
320 (r'\s+', Text), |
76 'cue-after', 'cue-before', 'cue', 'cursor', 'direction', 'display', |
321 (words(_vendor_prefixes,), Name.Builtin.Pseudo), |
77 'elevation', 'empty-cells', 'float', 'font-family', 'font-size', |
322 include('urls'), |
78 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', |
323 (r'('+r'|'.join(_functional_notation_keyword_values)+r')(\()', |
79 'font-weight', 'font', 'height', 'letter-spacing', 'line-height', |
324 bygroups(Name.Builtin, Punctuation), 'function-start'), |
80 'list-style-type', 'list-style-image', 'list-style-position', |
325 (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'), |
81 'list-style', 'margin-bottom', 'margin-left', 'margin-right', |
326 (words(_keyword_values, suffix=r'\b'), Keyword.Constant), |
82 'margin-top', 'margin', 'marker-offset', 'marks', 'max-height', 'max-width', |
327 (words(_other_keyword_values, suffix=r'\b'), Keyword.Constant), |
83 'min-height', 'min-width', 'opacity', 'orphans', 'outline-color', |
328 (words(_color_keywords, suffix=r'\b'), Keyword.Constant), |
84 'outline-style', 'outline-width', 'outline', 'overflow', 'overflow-x', |
329 (words(_css_properties, suffix=r'\b'), Keyword), # for transition-property etc. |
85 'overflow-y', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', |
|
86 'padding', 'page', 'page-break-after', 'page-break-before', 'page-break-inside', |
|
87 'pause-after', 'pause-before', 'pause', 'pitch-range', 'pitch', |
|
88 'play-during', 'position', 'quotes', 'richness', 'right', 'size', |
|
89 'speak-header', 'speak-numeral', 'speak-punctuation', 'speak', |
|
90 'speech-rate', 'stress', 'table-layout', 'text-align', 'text-decoration', |
|
91 'text-indent', 'text-shadow', 'text-transform', 'top', 'unicode-bidi', |
|
92 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', |
|
93 'widows', 'width', 'word-spacing', 'z-index', 'bottom', |
|
94 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline', |
|
95 'behind', 'below', 'bidi-override', 'blink', 'block', 'bolder', 'bold', 'both', |
|
96 'capitalize', 'center-left', 'center-right', 'center', 'circle', |
|
97 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', |
|
98 'crop', 'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero', |
|
99 'decimal', 'default', 'digits', 'disc', 'dotted', 'double', 'e-resize', 'embed', |
|
100 'extra-condensed', 'extra-expanded', 'expanded', 'fantasy', 'far-left', |
|
101 'far-right', 'faster', 'fast', 'fixed', 'georgian', 'groove', 'hebrew', 'help', |
|
102 'hidden', 'hide', 'higher', 'high', 'hiragana-iroha', 'hiragana', 'icon', |
|
103 'inherit', 'inline-table', 'inline', 'inset', 'inside', 'invert', 'italic', |
|
104 'justify', 'katakana-iroha', 'katakana', 'landscape', 'larger', 'large', |
|
105 'left-side', 'leftwards', 'left', 'level', 'lighter', 'line-through', 'list-item', |
|
106 'loud', 'lower-alpha', 'lower-greek', 'lower-roman', 'lowercase', 'ltr', |
|
107 'lower', 'low', 'medium', 'message-box', 'middle', 'mix', 'monospace', |
|
108 'n-resize', 'narrower', 'ne-resize', 'no-close-quote', 'no-open-quote', |
|
109 'no-repeat', 'none', 'normal', 'nowrap', 'nw-resize', 'oblique', 'once', |
|
110 'open-quote', 'outset', 'outside', 'overline', 'pointer', 'portrait', 'px', |
|
111 'relative', 'repeat-x', 'repeat-y', 'repeat', 'rgb', 'ridge', 'right-side', |
|
112 'rightwards', 's-resize', 'sans-serif', 'scroll', 'se-resize', |
|
113 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'silent', |
|
114 'slower', 'slow', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid', |
|
115 'spell-out', 'square', 'static', 'status-bar', 'super', 'sw-resize', |
|
116 'table-caption', 'table-cell', 'table-column', 'table-column-group', |
|
117 'table-footer-group', 'table-header-group', 'table-row', |
|
118 'table-row-group', 'text-bottom', 'text-top', 'text', 'thick', 'thin', |
|
119 'transparent', 'ultra-condensed', 'ultra-expanded', 'underline', |
|
120 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', |
|
121 'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud', |
|
122 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'), |
|
123 Name.Builtin), |
|
124 (words(( |
|
125 'indigo', 'gold', 'firebrick', 'indianred', 'yellow', 'darkolivegreen', |
|
126 'darkseagreen', 'mediumvioletred', 'mediumorchid', 'chartreuse', |
|
127 'mediumslateblue', 'black', 'springgreen', 'crimson', 'lightsalmon', 'brown', |
|
128 'turquoise', 'olivedrab', 'cyan', 'silver', 'skyblue', 'gray', 'darkturquoise', |
|
129 'goldenrod', 'darkgreen', 'darkviolet', 'darkgray', 'lightpink', 'teal', |
|
130 'darkmagenta', 'lightgoldenrodyellow', 'lavender', 'yellowgreen', 'thistle', |
|
131 'violet', 'navy', 'orchid', 'blue', 'ghostwhite', 'honeydew', 'cornflowerblue', |
|
132 'darkblue', 'darkkhaki', 'mediumpurple', 'cornsilk', 'red', 'bisque', 'slategray', |
|
133 'darkcyan', 'khaki', 'wheat', 'deepskyblue', 'darkred', 'steelblue', 'aliceblue', |
|
134 'gainsboro', 'mediumturquoise', 'floralwhite', 'coral', 'purple', 'lightgrey', |
|
135 'lightcyan', 'darksalmon', 'beige', 'azure', 'lightsteelblue', 'oldlace', |
|
136 'greenyellow', 'royalblue', 'lightseagreen', 'mistyrose', 'sienna', |
|
137 'lightcoral', 'orangered', 'navajowhite', 'lime', 'palegreen', 'burlywood', |
|
138 'seashell', 'mediumspringgreen', 'fuchsia', 'papayawhip', 'blanchedalmond', |
|
139 'peru', 'aquamarine', 'white', 'darkslategray', 'ivory', 'dodgerblue', |
|
140 'lemonchiffon', 'chocolate', 'orange', 'forestgreen', 'slateblue', 'olive', |
|
141 'mintcream', 'antiquewhite', 'darkorange', 'cadetblue', 'moccasin', |
|
142 'limegreen', 'saddlebrown', 'darkslateblue', 'lightskyblue', 'deeppink', |
|
143 'plum', 'aqua', 'darkgoldenrod', 'maroon', 'sandybrown', 'magenta', 'tan', |
|
144 'rosybrown', 'pink', 'lightblue', 'palevioletred', 'mediumseagreen', |
|
145 'dimgray', 'powderblue', 'seagreen', 'snow', 'mediumblue', 'midnightblue', |
|
146 'paleturquoise', 'palegoldenrod', 'whitesmoke', 'darkorchid', 'salmon', |
|
147 'lightslategray', 'lawngreen', 'lightgreen', 'tomato', 'hotpink', |
|
148 'lightyellow', 'lavenderblush', 'linen', 'mediumaquamarine', 'green', |
|
149 'blueviolet', 'peachpuff'), suffix=r'\b'), |
|
150 Name.Builtin), |
|
151 (r'\!important', Comment.Preproc), |
330 (r'\!important', Comment.Preproc), |
152 (r'/\*(?:.|\n)*?\*/', Comment), |
331 (r'/\*(?:.|\n)*?\*/', Comment), |
153 (r'\#[a-zA-Z0-9]{1,6}', Number), |
332 |
154 (r'[.-]?[0-9]*[.]?[0-9]+(em|px|pt|pc|in|mm|cm|ex|s)\b', Number), |
333 include('numeric-values'), |
155 # Separate regex for percentages, as can't do word boundaries with % |
334 |
156 (r'[.-]?[0-9]*[.]?[0-9]+%', Number), |
335 (r'[~^*!%&<>|+=@:./?-]+', Operator), |
157 (r'-?[0-9]+', Number), |
336 (r'[\[\](),]+', Punctuation), |
158 (r'[~^*!%&<>|+=@:,./?-]+', Operator), |
|
159 (r'[\[\]();]+', Punctuation), |
|
160 (r'"(\\\\|\\"|[^"])*"', String.Double), |
337 (r'"(\\\\|\\"|[^"])*"', String.Double), |
161 (r"'(\\\\|\\'|[^'])*'", String.Single), |
338 (r"'(\\\\|\\'|[^'])*'", String.Single), |
162 (r'[a-zA-Z_]\w*', Name) |
339 (r'[a-zA-Z_][\w-]*', Name), |
163 ] |
340 (r';', Punctuation, '#pop'), |
|
341 (r'\}', Punctuation, '#pop:2'), |
|
342 ], |
|
343 'function-start': [ |
|
344 (r'\s+', Text), |
|
345 include('urls'), |
|
346 (words(_vendor_prefixes,), Keyword.Pseudo), |
|
347 (words(_keyword_values, suffix=r'\b'), Keyword.Constant), |
|
348 (words(_other_keyword_values, suffix=r'\b'), Keyword.Constant), |
|
349 (words(_color_keywords, suffix=r'\b'), Keyword.Constant), |
|
350 |
|
351 # function-start may be entered recursively |
|
352 (r'(' + r'|'.join(_functional_notation_keyword_values) + r')(\()', |
|
353 bygroups(Name.Builtin, Punctuation), 'function-start'), |
|
354 (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'), |
|
355 |
|
356 (r'/\*(?:.|\n)*?\*/', Comment), |
|
357 include('numeric-values'), |
|
358 (r'[*+/-]', Operator), |
|
359 (r'[,]', Punctuation), |
|
360 (r'"(\\\\|\\"|[^"])*"', String.Double), |
|
361 (r"'(\\\\|\\'|[^'])*'", String.Single), |
|
362 (r'[a-zA-Z_-]\w*', Name), |
|
363 (r'\)', Punctuation, '#pop'), |
|
364 ], |
|
365 'urls': [ |
|
366 (r'(url)(\()(".*?")(\))', bygroups(Name.Builtin, Punctuation, |
|
367 String.Double, Punctuation)), |
|
368 (r"(url)(\()('.*?')(\))", bygroups(Name.Builtin, Punctuation, |
|
369 String.Single, Punctuation)), |
|
370 (r'(url)(\()(.*?)(\))', bygroups(Name.Builtin, Punctuation, |
|
371 String.Other, Punctuation)), |
|
372 ], |
|
373 'numeric-values': [ |
|
374 (r'\#[a-zA-Z0-9]{1,6}', Number.Hex), |
|
375 (r'[+\-]?[0-9]*[.][0-9]+', Number.Float, 'numeric-end'), |
|
376 (r'[+\-]?[0-9]+', Number.Integer, 'numeric-end'), |
|
377 ], |
|
378 'numeric-end': [ |
|
379 (words(_all_units, suffix=r'\b'), Keyword.Type), |
|
380 (r'%', Keyword.Type), |
|
381 default('#pop'), |
|
382 ], |
164 } |
383 } |
165 |
384 |
166 |
385 |
167 common_sass_tokens = { |
386 common_sass_tokens = { |
168 'value': [ |
387 'value': [ |
169 (r'[ \t]+', Text), |
388 (r'[ \t]+', Text), |
170 (r'[!$][\w-]+', Name.Variable), |
389 (r'[!$][\w-]+', Name.Variable), |
171 (r'url\(', String.Other, 'string-url'), |
390 (r'url\(', String.Other, 'string-url'), |
172 (r'[a-z_-][\w-]*(?=\()', Name.Function), |
391 (r'[a-z_-][\w-]*(?=\()', Name.Function), |
173 (words(( |
392 (words(_css_properties + ( |
174 'azimuth', 'background-attachment', 'background-color', |
|
175 'background-image', 'background-position', 'background-repeat', |
|
176 'background', 'border-bottom-color', 'border-bottom-style', |
|
177 'border-bottom-width', 'border-left-color', 'border-left-style', |
|
178 'border-left-width', 'border-right', 'border-right-color', |
|
179 'border-right-style', 'border-right-width', 'border-top-color', |
|
180 'border-top-style', 'border-top-width', 'border-bottom', |
|
181 'border-collapse', 'border-left', 'border-width', 'border-color', |
|
182 'border-spacing', 'border-style', 'border-top', 'border', 'caption-side', |
|
183 'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', |
|
184 'cue-after', 'cue-before', 'cue', 'cursor', 'direction', 'display', |
|
185 'elevation', 'empty-cells', 'float', 'font-family', 'font-size', |
|
186 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', |
|
187 'font-weight', 'font', 'height', 'letter-spacing', 'line-height', |
|
188 'list-style-type', 'list-style-image', 'list-style-position', |
|
189 'list-style', 'margin-bottom', 'margin-left', 'margin-right', |
|
190 'margin-top', 'margin', 'marker-offset', 'marks', 'max-height', 'max-width', |
|
191 'min-height', 'min-width', 'opacity', 'orphans', 'outline', 'outline-color', |
|
192 'outline-style', 'outline-width', 'overflow', 'padding-bottom', |
|
193 'padding-left', 'padding-right', 'padding-top', 'padding', 'page', |
|
194 'page-break-after', 'page-break-before', 'page-break-inside', |
|
195 'pause-after', 'pause-before', 'pause', 'pitch', 'pitch-range', |
|
196 'play-during', 'position', 'quotes', 'richness', 'right', 'size', |
|
197 'speak-header', 'speak-numeral', 'speak-punctuation', 'speak', |
|
198 'speech-rate', 'stress', 'table-layout', 'text-align', 'text-decoration', |
|
199 'text-indent', 'text-shadow', 'text-transform', 'top', 'unicode-bidi', |
|
200 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', |
|
201 'widows', 'width', 'word-spacing', 'z-index', 'bottom', 'left', |
|
202 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline', |
393 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline', |
203 'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both', |
394 'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both', |
204 'capitalize', 'center-left', 'center-right', 'center', 'circle', |
395 'capitalize', 'center-left', 'center-right', 'center', 'circle', |
205 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', |
396 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', |
206 'crop', 'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero', |
397 'crop', 'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero', |
227 'transparent', 'ultra-condensed', 'ultra-expanded', 'underline', |
418 'transparent', 'ultra-condensed', 'ultra-expanded', 'underline', |
228 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', |
419 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', |
229 'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud', |
420 'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud', |
230 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'), |
421 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'), |
231 Name.Constant), |
422 Name.Constant), |
232 (words(( |
423 (words(_color_keywords, suffix=r'\b'), Name.Entity), |
233 'indigo', 'gold', 'firebrick', 'indianred', 'darkolivegreen', |
|
234 'darkseagreen', 'mediumvioletred', 'mediumorchid', 'chartreuse', |
|
235 'mediumslateblue', 'springgreen', 'crimson', 'lightsalmon', 'brown', |
|
236 'turquoise', 'olivedrab', 'cyan', 'skyblue', 'darkturquoise', |
|
237 'goldenrod', 'darkgreen', 'darkviolet', 'darkgray', 'lightpink', |
|
238 'darkmagenta', 'lightgoldenrodyellow', 'lavender', 'yellowgreen', 'thistle', |
|
239 'violet', 'orchid', 'ghostwhite', 'honeydew', 'cornflowerblue', |
|
240 'darkblue', 'darkkhaki', 'mediumpurple', 'cornsilk', 'bisque', 'slategray', |
|
241 'darkcyan', 'khaki', 'wheat', 'deepskyblue', 'darkred', 'steelblue', 'aliceblue', |
|
242 'gainsboro', 'mediumturquoise', 'floralwhite', 'coral', 'lightgrey', |
|
243 'lightcyan', 'darksalmon', 'beige', 'azure', 'lightsteelblue', 'oldlace', |
|
244 'greenyellow', 'royalblue', 'lightseagreen', 'mistyrose', 'sienna', |
|
245 'lightcoral', 'orangered', 'navajowhite', 'palegreen', 'burlywood', |
|
246 'seashell', 'mediumspringgreen', 'papayawhip', 'blanchedalmond', |
|
247 'peru', 'aquamarine', 'darkslategray', 'ivory', 'dodgerblue', |
|
248 'lemonchiffon', 'chocolate', 'orange', 'forestgreen', 'slateblue', |
|
249 'mintcream', 'antiquewhite', 'darkorange', 'cadetblue', 'moccasin', |
|
250 'limegreen', 'saddlebrown', 'darkslateblue', 'lightskyblue', 'deeppink', |
|
251 'plum', 'darkgoldenrod', 'sandybrown', 'magenta', 'tan', |
|
252 'rosybrown', 'pink', 'lightblue', 'palevioletred', 'mediumseagreen', |
|
253 'dimgray', 'powderblue', 'seagreen', 'snow', 'mediumblue', 'midnightblue', |
|
254 'paleturquoise', 'palegoldenrod', 'whitesmoke', 'darkorchid', 'salmon', |
|
255 'lightslategray', 'lawngreen', 'lightgreen', 'tomato', 'hotpink', |
|
256 'lightyellow', 'lavenderblush', 'linen', 'mediumaquamarine', |
|
257 'blueviolet', 'peachpuff'), suffix=r'\b'), |
|
258 Name.Entity), |
|
259 (words(( |
424 (words(( |
260 'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', |
425 'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', |
261 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'), suffix=r'\b'), |
426 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'), suffix=r'\b'), |
262 Name.Builtin), |
427 Name.Builtin), |
263 (r'\!(important|default)', Name.Exception), |
428 (r'\!(important|default)', Name.Exception), |