Skip to content

Commit

Permalink
css: fix lexing numbers inside function calls
Browse files Browse the repository at this point in the history
Fixes #2382
  • Loading branch information
birkenfeld committed Mar 19, 2023
1 parent 11ef5aa commit 3080991
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pygments/lexers/css.py
Expand Up @@ -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),
Expand Down
51 changes: 51 additions & 0 deletions 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

0 comments on commit 3080991

Please sign in to comment.