Skip to content

Commit 3bdf399

Browse files
committed
Allow nested parentheses in values
1 parent b9cfa00 commit 3bdf399

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var _icssReplaceSymbols = require('icss-replace-symbols');
1717
var _icssReplaceSymbols2 = _interopRequireDefault(_icssReplaceSymbols);
1818

1919
var matchImports = /^(.+?)\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
20-
var matchValueDefinition = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|\w+\([^\)]+\)|[^,]+)\s?/g;
20+
var matchValueDefinition = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|\w+\(.+\)|[^,]+)\s?/g;
2121
var matchImport = /^([\w-]+)(?:\s+as\s+([\w-]+))?/;
2222
var options = {};
2323
var importIndex = 0;

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import postcss from 'postcss'
22
import replaceSymbols, {replaceAll} from 'icss-replace-symbols'
33

44
const matchImports = /^(.+?)\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/
5-
const matchValueDefinition = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|\w+\([^\)]+\)|[^,]+)\s?/g
5+
const matchValueDefinition = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|\w+\(.+\)|[^,]+)\s?/g
66
const matchImport = /^([\w-]+)(?:\s+as\s+([\w-]+))?/
77
let options = {}
88
let importIndex = 0

test/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,11 @@ describe('constants', () => {
120120
':export {\n named: red;\n 3char: #0f0;\n 6char: #00ff00;\n rgba: rgba(34, 12, 64, 0.3);\n hsla: hsla(220, 13.0%, 18.0%, 1);\n}\n' +
121121
'.foo { color: red; background-color: #0f0; border-top-color: #00ff00; border-bottom-color: rgba(34, 12, 64, 0.3); outline-color: hsla(220, 13.0%, 18.0%, 1); }')
122122
})
123+
124+
it('should allow values with nested parantheses', () => {
125+
test(
126+
'@value aaa: color(red lightness(50%));',
127+
':export {\n aaa: color(red lightness(50%))\n}'
128+
)
129+
})
123130
})

0 commit comments

Comments
 (0)