@lezer/css
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -0,1 +1,9 @@ | ||
## 1.1.4 (2023-11-09) | ||
### Bug fixes | ||
Fix parsing of `&` selectors in descendant selectors. | ||
Allow identifiers to contain backslash escapes. | ||
## 1.1.3 (2023-07-03) | ||
@@ -2,0 +10,0 @@ |
@@ -17,3 +17,3 @@ import { ExternalTokenizer, LRParser, LocalTokenGroup } from '@lezer/lr'; | ||
const colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46, | ||
hash = 35, percent = 37; | ||
hash = 35, percent = 37, ampersand = 38, backslash = 92, newline = 10; | ||
@@ -31,2 +31,6 @@ function isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 } | ||
input.advance(); | ||
} else if (next == backslash && input.peek(1) != newline) { | ||
input.advance(); | ||
if (input.next > -1) input.advance(); | ||
inside = true; | ||
} else { | ||
@@ -44,3 +48,3 @@ if (inside) | ||
if (isAlpha(next) || next == underscore || next == hash || next == period || | ||
next == bracketL || next == colon || next == dash) | ||
next == bracketL || next == colon || next == dash || next == ampersand) | ||
input.acceptToken(descendantOp); | ||
@@ -117,3 +121,3 @@ } | ||
topRules: {"StyleSheet":[0,4],"Styles":[1,84]}, | ||
specialized: [{term: 97, get: value => spec_callee[value] || -1},{term: 56, get: value => spec_AtKeyword[value] || -1},{term: 98, get: value => spec_identifier[value] || -1}], | ||
specialized: [{term: 97, get: (value) => spec_callee[value] || -1},{term: 56, get: (value) => spec_AtKeyword[value] || -1},{term: 98, get: (value) => spec_identifier[value] || -1}], | ||
tokenPrec: 1169 | ||
@@ -120,0 +124,0 @@ }); |
{ | ||
"name": "@lezer/css", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "lezer-based CSS grammar", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.cjs", | ||
"@lezer/generator": "^1.0.0", | ||
"mocha": "^9.0.1", | ||
"mocha": "^10.2.0", | ||
"rollup": "^2.52.2", | ||
@@ -20,0 +20,0 @@ "@rollup/plugin-node-resolve": "^9.0.0" |
@@ -25,4 +25,4 @@ // This file was generated by lezer-generator. You probably shouldn't edit it. | ||
topRules: {"StyleSheet":[0,4],"Styles":[1,84]}, | ||
specialized: [{term: 97, get: value => spec_callee[value] || -1},{term: 56, get: value => spec_AtKeyword[value] || -1},{term: 98, get: value => spec_identifier[value] || -1}], | ||
specialized: [{term: 97, get: (value) => spec_callee[value] || -1},{term: 56, get: (value) => spec_AtKeyword[value] || -1},{term: 98, get: (value) => spec_identifier[value] || -1}], | ||
tokenPrec: 1169 | ||
}) |
@@ -10,3 +10,3 @@ /* Hand-written tokenizers for CSS tokens that can't be | ||
const colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46, | ||
hash = 35, percent = 37 | ||
hash = 35, percent = 37, ampersand = 38, backslash = 92, newline = 10 | ||
@@ -24,2 +24,6 @@ function isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 } | ||
input.advance() | ||
} else if (next == backslash && input.peek(1) != newline) { | ||
input.advance() | ||
if (input.next > -1) input.advance() | ||
inside = true | ||
} else { | ||
@@ -37,3 +41,3 @@ if (inside) | ||
if (isAlpha(next) || next == underscore || next == hash || next == period || | ||
next == bracketL || next == colon || next == dash) | ||
next == bracketL || next == colon || next == dash || next == ampersand) | ||
input.acceptToken(descendantOp) | ||
@@ -40,0 +44,0 @@ } |
@@ -100,2 +100,3 @@ # Universal selectors | ||
& c {} | ||
c & {} | ||
& > d {} | ||
@@ -109,2 +110,3 @@ } | ||
RuleSet(DescendantSelector(NestingSelector,TagSelector(TagName)),Block), | ||
RuleSet(DescendantSelector(TagSelector(TagName), NestingSelector),Block), | ||
RuleSet(ChildSelector(NestingSelector,ChildOp,TagSelector(TagName)),Block)))) | ||
@@ -111,0 +113,0 @@ |
@@ -164,1 +164,13 @@ # Empty stylesheets | ||
StyleSheet(RuleSet(TagSelector(TagName),Block),Comment) | ||
# Escaped identifiers | ||
#foo\ bar { | ||
--weird\\var: 5px; | ||
width: var(--weird\\var); | ||
} | ||
==> | ||
StyleSheet(RuleSet(IdSelector(IdName),Block( | ||
Declaration(VariableName,NumberLiteral(Unit)), | ||
Declaration(PropertyName,CallExpression(Callee,ArgList(VariableName)))))) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65606
496