lib/css_parser/regexps.rb in css_parser-1.9.0 vs lib/css_parser/regexps.rb in css_parser-1.10.0
- old
+ new
@@ -56,9 +56,25 @@
RE_BACKGROUND_SIZE = Regexp.new("\\s*/\\s*((((#{RE_LENGTH_OR_PERCENTAGE})|auto|cover|contain|initial|inherit)[\\s]*){1,2})", Regexp::IGNORECASE | Regexp::EXTENDED)
FONT_UNITS_RX = /((x+-)*small|medium|larger*|auto|inherit|([0-9]+|[0-9]*\.[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|%)*)/i.freeze
RE_BORDER_STYLE = /(\s*^)?(none|hidden|dotted|dashed|solid|double|dot-dash|dot-dot-dash|wave|groove|ridge|inset|outset)(\s*$)?/imx.freeze
RE_BORDER_UNITS = Regexp.union(BOX_MODEL_UNITS_RX, /(thin|medium|thick)/i)
+ # Functions like calc, var, clamp, etc.
+ RE_FUNCTIONS = /
+ (
+ [a-z0-9-]+ # function name
+ )
+ (?>
+ \( # opening parenthesis
+ (?:
+ ([^()]+)
+ | # recursion via subexpression
+ \g<0>
+ )*
+ \) # closing parenthesis
+ )
+ /imx.freeze
+
# Patterns for specificity calculations
NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX_NC = /
(?:\.\w+) # classes
|
\[(?:\w+) # attributes