Skip to content

Commit

Permalink
improve ValueParser, handle escaped characters
Browse files Browse the repository at this point in the history
Before this, `--width-1\/2` would be handled as:
```json
[
  { kind: 'word', value: '--width-\\' }
  { kind: 'separator', value: '/' }
  { kind: 'word', value: '2' }
]
```

But now it will be handled as:
```json
[
  { kind: 'word', value: '--width-\\/2' }
]
```
  • Loading branch information
RobinMalfait committed Feb 4, 2025
1 parent 9cd3d55 commit 8f74b3e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/tailwindcss/src/value-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ export function parse(input: string) {
let currentChar = input.charCodeAt(i)

switch (currentChar) {
// Current character is a `\` therefore the next character is escaped,
// consume it together with the next character and continue.
case BACKSLASH: {
buffer += input[i] + input[i + 1]
i++
break
}

// Space and commas are bundled into separators
//
// E.g.:
Expand Down

0 comments on commit 8f74b3e

Please sign in to comment.