diff --git a/packages/less/lib/less/parser/parser.js b/packages/less/lib/less/parser/parser.js index 6a439fb89..23aa54d6b 100644 --- a/packages/less/lib/less/parser/parser.js +++ b/packages/less/lib/less/parser/parser.js @@ -2283,10 +2283,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) { parserInput.save(); // hsl or rgb or lch operand - const match = parserInput.$re(/^[lchrgbs]\s+/); + const match = parserInput.$re(/^([lchrgbs])(?=\s|[,/*)]|$)/); if (match) { parserInput.forget(); - return new tree.Keyword(match[0]); + return new tree.Keyword(match[1]); } parserInput.restore(); diff --git a/packages/test-data/tests-unit/color-functions/modern.css b/packages/test-data/tests-unit/color-functions/modern.css index ed84e9002..bdf2626a4 100644 --- a/packages/test-data/tests-unit/color-functions/modern.css +++ b/packages/test-data/tests-unit/color-functions/modern.css @@ -34,3 +34,9 @@ .color-rgb-div { background: rgb(from #0000FF calc(r / 2) g b); } +.color-rgb-sub-right-operand { + background: rgb(from blue calc(100 - r) g b); +} +.color-rgb-add-left-operand { + background: rgb(from blue calc(r + 100) g b); +} diff --git a/packages/test-data/tests-unit/color-functions/modern.less b/packages/test-data/tests-unit/color-functions/modern.less index cf04e2c9b..23445d125 100644 --- a/packages/test-data/tests-unit/color-functions/modern.less +++ b/packages/test-data/tests-unit/color-functions/modern.less @@ -46,3 +46,11 @@ .color-rgb-div { background: rgb(from #0000FF calc(r / 2) g b); } + +.color-rgb-sub-right-operand { + background: rgb(from blue calc(100 - r) g b); +} + +.color-rgb-add-left-operand { + background: rgb(from blue calc(r + 100) g b); +}