summaryrefslogtreecommitdiff
path: root/pygments/lexers/css.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/css.py')
-rw-r--r--pygments/lexers/css.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/pygments/lexers/css.py b/pygments/lexers/css.py
index eeb0a4af..6f7e5be8 100644
--- a/pygments/lexers/css.py
+++ b/pygments/lexers/css.py
@@ -5,7 +5,7 @@
Lexers for CSS and related stylesheet formats.
- :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -13,12 +13,12 @@ import re
import copy
from pygments.lexer import ExtendedRegexLexer, RegexLexer, include, bygroups, \
- default, words
+ default, words, inherit
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation
from pygments.util import iteritems
-__all__ = ['CssLexer', 'SassLexer', 'ScssLexer']
+__all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer']
class CssLexer(RegexLexer):
@@ -475,8 +475,9 @@ class ScssLexer(RegexLexer):
(r'(@media)(\s+)', bygroups(Keyword, Text), 'value'),
(r'@[\w-]+', Keyword, 'selector'),
(r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
- (r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
- (r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
+ # TODO: broken, and prone to infinite loops.
+ #(r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
+ #(r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
default('selector'),
],
@@ -484,6 +485,7 @@ class ScssLexer(RegexLexer):
(r'[^\s:="\[]+', Name.Attribute),
(r'#\{', String.Interpol, 'interpolation'),
(r'[ \t]*:', Operator, 'value'),
+ default('#pop'),
],
'inline-comment': [
@@ -496,3 +498,27 @@ class ScssLexer(RegexLexer):
tokens[group] = copy.copy(common)
tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')])
tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, '#pop')])
+
+
+class LessCssLexer(CssLexer):
+ """
+ For `LESS <http://lesscss.org/>`_ styleshets.
+
+ .. versionadded:: 2.1
+ """
+
+ name = 'LessCss'
+ aliases = ['less']
+ filenames = ['*.less']
+ mimetypes = ['text/x-less-css']
+
+ tokens = {
+ 'root': [
+ (r'@\w+', Name.Variable),
+ inherit,
+ ],
+ 'content': [
+ (r'{', Punctuation, '#push'),
+ inherit,
+ ],
+ }