3 pygments.lexers.css |
3 pygments.lexers.css |
4 ~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for CSS and related stylesheet formats. |
6 Lexers for CSS and related stylesheet formats. |
7 |
7 |
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import re |
12 import re |
13 import copy |
13 import copy |
14 |
14 |
15 from pygments.lexer import ExtendedRegexLexer, RegexLexer, include, bygroups, \ |
15 from pygments.lexer import ExtendedRegexLexer, RegexLexer, include, bygroups, \ |
16 default, words, inherit |
16 default, words, inherit |
17 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
17 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
18 Number, Punctuation |
18 Number, Punctuation |
19 from pygments.util import iteritems |
|
20 |
19 |
21 __all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer'] |
20 __all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer'] |
22 |
21 |
23 |
22 |
24 # List of vendor prefixes obtained from: |
23 # List of vendor prefixes obtained from: |
610 (r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline), |
609 (r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline), |
611 (r'#\{', String.Interpol, 'interpolation'), |
610 (r'#\{', String.Interpol, 'interpolation'), |
612 (r"\*/", Comment, '#pop'), |
611 (r"\*/", Comment, '#pop'), |
613 ], |
612 ], |
614 } |
613 } |
615 for group, common in iteritems(common_sass_tokens): |
614 for group, common in common_sass_tokens.items(): |
616 tokens[group] = copy.copy(common) |
615 tokens[group] = copy.copy(common) |
617 tokens['value'].append((r'\n', Text, 'root')) |
616 tokens['value'].append((r'\n', Text, 'root')) |
618 tokens['selector'].append((r'\n', Text, 'root')) |
617 tokens['selector'].append((r'\n', Text, 'root')) |
619 |
618 |
620 |
619 |
660 (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline), |
659 (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline), |
661 (r'#\{', String.Interpol, 'interpolation'), |
660 (r'#\{', String.Interpol, 'interpolation'), |
662 (r"\*/", Comment, '#pop'), |
661 (r"\*/", Comment, '#pop'), |
663 ], |
662 ], |
664 } |
663 } |
665 for group, common in iteritems(common_sass_tokens): |
664 for group, common in common_sass_tokens.items(): |
666 tokens[group] = copy.copy(common) |
665 tokens[group] = copy.copy(common) |
667 tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')]) |
666 tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')]) |
668 tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')]) |
667 tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')]) |
669 |
668 |
670 |
669 |