@@ -93,6 +93,12 @@ private static function buildPatterns() {
93
93
$ patterns ['ident ' ] = "-? {$ patterns ['nmstart ' ]}{$ patterns ['nmchar ' ]}* " ;
94
94
$ patterns ['quantity ' ] = "{$ patterns ['num ' ]}(?:\s* {$ patterns ['unit ' ]}| {$ patterns ['ident ' ]})? " ;
95
95
$ patterns ['possibly_negative_quantity ' ] = "((?:-? {$ patterns ['quantity ' ]})|(?:inherit|auto)) " ;
96
+ $ patterns ['possibly_negative_simple_quantity ' ] = "(?:-? {$ patterns ['num ' ]}(?:\s* {$ patterns ['unit ' ]})?) " ;
97
+ $ patterns ['math_operator ' ] = '(?:\+|\-|\*|\/) ' ;
98
+ $ patterns ['allowed_chars ' ] = '(?:\(|\)|\t| ) ' ;
99
+ $ patterns ['calc_equation ' ] = "(?: {$ patterns ['allowed_chars ' ]}| {$ patterns ['possibly_negative_simple_quantity ' ]}| {$ patterns ['math_operator ' ]}){3,} " ;
100
+ $ patterns ['calc ' ] = "(?:calc\((?: {$ patterns ['calc_equation ' ]})\)) " ;
101
+ $ patterns ['possibly_negative_quantity_calc ' ] = "((?:-? {$ patterns ['quantity ' ]})|(?:inherit|auto)| {$ patterns ['calc ' ]}) " ;
96
102
$ patterns ['color ' ] = "(#? {$ patterns ['nmchar ' ]}+|(?:rgba?|hsla?)\([ \d.,%-]+\)) " ;
97
103
// Use "*+" instead of "*?" to avoid reaching the backtracking limit.
98
104
// <https://phabricator.wikimedia.org/T326481>, <https://phabricator.wikimedia.org/T215746#4944830>.
@@ -113,7 +119,7 @@ private static function buildPatterns() {
113
119
$ patterns ['cursor_east ' ] = "/ {$ patterns ['lookbehind_not_letter ' ]}([ns]?)e-resize/ " ;
114
120
$ patterns ['cursor_west ' ] = "/ {$ patterns ['lookbehind_not_letter ' ]}([ns]?)w-resize/ " ;
115
121
$ patterns ['four_notation_quantity_props ' ] = "((?:margin|padding|border-width)\s*:\s*) " ;
116
- $ patterns ['four_notation_quantity ' ] = "/ {$ patterns ['four_notation_quantity_props ' ]}{$ patterns ['possibly_negative_quantity ' ]}(\s+) {$ patterns ['possibly_negative_quantity ' ]}(\s+) {$ patterns ['possibly_negative_quantity ' ]}(\s+) {$ patterns ['possibly_negative_quantity ' ]}{$ patterns ['suffix ' ]}/i " ;
122
+ $ patterns ['four_notation_quantity ' ] = "/ {$ patterns ['four_notation_quantity_props ' ]}{$ patterns ['possibly_negative_quantity_calc ' ]}(\s+) {$ patterns ['possibly_negative_quantity_calc ' ]}(\s+) {$ patterns ['possibly_negative_quantity_calc ' ]}(\s+) {$ patterns ['possibly_negative_quantity_calc ' ]}{$ patterns ['suffix ' ]}/i " ;
117
123
$ patterns ['four_notation_color ' ] = "/((?:-color|border-style)\s*:\s*) {$ patterns ['color ' ]}(\s+) {$ patterns ['color ' ]}(\s+) {$ patterns ['color ' ]}(\s+) {$ patterns ['color ' ]}{$ patterns ['suffix ' ]}/i " ;
118
124
// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]
119
125
$ patterns ['border_radius ' ] = '/(border-radius\s*:\s*) ' . $ patterns ['possibly_negative_quantity ' ]
0 commit comments