diff options
author | Georg Brandl <georg@python.org> | 2023-03-19 07:48:58 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2023-03-19 07:49:21 +0100 |
commit | 30809916f2ae5462be7b64f0387203030cb40537 (patch) | |
tree | 5b31a846ba31cc0a120f4577aecb8d83b8fc0cb5 | |
parent | 11ef5aafc739202f823db79ca89e0c73e1db4e8f (diff) | |
download | pygments-git-2382-fix.tar.gz |
css: fix lexing numbers inside function calls2382-fix
Fixes #2382
-rw-r--r-- | pygments/lexers/css.py | 2 | ||||
-rw-r--r-- | tests/snippets/css/percent_in_func.txt | 51 |
2 files changed, 52 insertions, 1 deletions
diff --git a/pygments/lexers/css.py b/pygments/lexers/css.py index 4d7cb46f..71f27dc5 100644 --- a/pygments/lexers/css.py +++ b/pygments/lexers/css.py @@ -249,7 +249,7 @@ class CssLexer(RegexLexer): ], 'function-start': [ (r'\s+', Whitespace), - (r'[-]+([\w+]+[-]*)+', Name.Variable), + (r'[-]+([A-Za-z][\w+]*[-]*)+', Name.Variable), include('urls'), (words(_vendor_prefixes,), Keyword.Pseudo), (words(_keyword_values, suffix=r'\b'), Keyword.Constant), diff --git a/tests/snippets/css/percent_in_func.txt b/tests/snippets/css/percent_in_func.txt new file mode 100644 index 00000000..9fce9bde --- /dev/null +++ b/tests/snippets/css/percent_in_func.txt @@ -0,0 +1,51 @@ +---input--- +.target-img { + position: absolute; + top: 25%; + left: 50%; + transform: translate(-50%, -50%); +} + +---tokens--- +'.' Punctuation +'target-img' Name.Class +' ' Text.Whitespace +'{' Punctuation +'\n ' Text.Whitespace +'position' Keyword +':' Punctuation +' ' Text.Whitespace +'absolute' Keyword.Constant +';' Punctuation +' \n ' Text.Whitespace +'top' Keyword +':' Punctuation +' ' Text.Whitespace +'25' Literal.Number.Integer +'%' Keyword.Type +';' Punctuation +' \n ' Text.Whitespace +'left' Keyword +':' Punctuation +' ' Text.Whitespace +'50' Literal.Number.Integer +'%' Keyword.Type +';' Punctuation +' \n ' Text.Whitespace +'transform' Keyword +':' Punctuation +' ' Text.Whitespace +'translate' Name.Builtin +'(' Punctuation +'-50' Literal.Number.Integer +'%' Keyword.Type +',' Punctuation +' ' Text.Whitespace +'-50' Literal.Number.Integer +'%' Keyword.Type +')' Punctuation +';' Punctuation +'\n' Text.Whitespace + +'}' Punctuation +' \n' Text.Whitespace |