Skip to content

Commit 5e4291b

Browse files
committed
feat(parser): new style parser * 7
1 parent 35576fe commit 5e4291b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/parser/classify.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export function classify(
1616
const token = raw.trim();
1717
if (!token) return { bucket: Bucket.Mod, processed: '' };
1818

19+
// Quoted string literals should be treated as value tokens (e.g., "" for content)
20+
if (
21+
(token.startsWith('"') && token.endsWith('"')) ||
22+
(token.startsWith("'") && token.endsWith("'"))
23+
) {
24+
return { bucket: Bucket.Value, processed: token };
25+
}
26+
1927
// 0. Direct var(--*-color) token
2028
const varColorMatch = token.match(/^var\(--([a-z0-9-]+)-color\)$/);
2129
if (varColorMatch) {

src/parser/parser.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,17 @@ describe('StyleProcessor', () => {
173173
const r = parser.process('#dark-02');
174174
expect(r.groups[0].colors).toEqual(['var(--dark-02-color)']);
175175
});
176+
177+
test('parses empty string literal', () => {
178+
const res = parser.process('""');
179+
expect(res.groups[0].values).toEqual(['""']);
180+
});
181+
182+
test('parses calc with custom props inside parentheses', () => {
183+
const expr = '(@slider-range-end - @slider-range-start)';
184+
const res = parser.process(expr);
185+
expect(res.groups[0].values).toEqual([
186+
'calc(var(--slider-range-end) - var(--slider-range-start))',
187+
]);
188+
});
176189
});

0 commit comments

Comments
 (0)