summaryrefslogtreecommitdiff
path: root/pygments/lexers/web.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/web.py')
-rw-r--r--pygments/lexers/web.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 452ef4ce..30429e4b 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -23,7 +23,7 @@ from pygments.lexers.agile import RubyLexer
__all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer',
'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer',
- 'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer',
+ 'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer',
'ObjectiveJLexer', 'CoffeeScriptLexer']
@@ -1558,6 +1558,51 @@ class SassLexer(ExtendedRegexLexer):
tokens['selector'].append((r'\n', Text, 'root'))
+class ScssLexer(RegexLexer):
+ """
+ For SCSS stylesheets.
+ """
+
+ name = 'SCSS'
+ aliases = ['scss']
+ filenames = ['*.scss']
+ mimetypes = ['text/x-scss']
+
+ flags = re.IGNORECASE | re.DOTALL
+ tokens = {
+ 'root': [
+ (r'\s+', Text),
+ (r'//.*?\n', Comment.Single),
+ (r'/\*.*?\*/', Comment.Multiline),
+ (r'@import', Keyword, 'value'),
+ (r'@for', Keyword, 'for'),
+ (r'@(debug|warn|if|while)', Keyword, 'value'),
+ (r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
+ (r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
+ (r'@extend', Keyword, 'selector'),
+ (r'@[a-z0-9_-]+', Keyword, 'selector'),
+ (r'(\$[\w-]\w*)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
+ (r'(?=[^\s:"\[]+\s*:([ \t]|$))', Name.Attribute, 'attr'),
+ (r'', Text, 'selector'),
+ ],
+
+ 'attr': [
+ (r'[^\s:="\[]+', Name.Attribute),
+ (r'#{', String.Interpol, 'interpolation'),
+ (r'[ \t]*:', Operator, 'value'),
+ ],
+
+ 'inline-comment': [
+ (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
+ (r'#\{', String.Interpol, 'interpolation'),
+ (r"\*/", Comment, '#pop'),
+ ],
+ }
+ tokens.update(copy.deepcopy(common_sass_tokens))
+ tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
+ tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
+
+
class CoffeeScriptLexer(RegexLexer):
"""
For `CoffeeScript`_ source code.