@lezer/css 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.cjs +8 -3
- package/dist/index.js +8 -3
- package/package.json +3 -2
- package/src/css.grammar +2 -2
- package/src/parser.js +2 -1
- package/src/tokens.js +6 -2
- package/test/selector.txt +2 -0
- package/test/statements.txt +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 1.1.5 (2023-12-28)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Tag comments and strings as isolating for the purpose of bidirectional text.
|
|
6
|
+
|
|
7
|
+
## 1.1.4 (2023-11-09)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix parsing of `&` selectors in descendant selectors.
|
|
12
|
+
|
|
13
|
+
Allow identifiers to contain backslash escapes.
|
|
14
|
+
|
|
1
15
|
## 1.1.3 (2023-07-03)
|
|
2
16
|
|
|
3
17
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ const descendantOp = 96,
|
|
|
18
18
|
const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,
|
|
19
19
|
8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288];
|
|
20
20
|
const colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46,
|
|
21
|
-
hash = 35, percent = 37;
|
|
21
|
+
hash = 35, percent = 37, ampersand = 38, backslash = 92, newline = 10;
|
|
22
22
|
|
|
23
23
|
function isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 }
|
|
24
24
|
|
|
@@ -31,6 +31,10 @@ const identifiers = new lr.ExternalTokenizer((input, stack) => {
|
|
|
31
31
|
if (!inside && (next != dash || i > 0)) inside = true;
|
|
32
32
|
if (dashes === i && next == dash) dashes++;
|
|
33
33
|
input.advance();
|
|
34
|
+
} else if (next == backslash && input.peek(1) != newline) {
|
|
35
|
+
input.advance();
|
|
36
|
+
if (input.next > -1) input.advance();
|
|
37
|
+
inside = true;
|
|
34
38
|
} else {
|
|
35
39
|
if (inside)
|
|
36
40
|
input.acceptToken(next == parenL ? callee : dashes == 2 && stack.canShift(VariableName) ? VariableName : identifier);
|
|
@@ -43,7 +47,7 @@ const descendant = new lr.ExternalTokenizer(input => {
|
|
|
43
47
|
if (space.includes(input.peek(-1))) {
|
|
44
48
|
let {next} = input;
|
|
45
49
|
if (isAlpha(next) || next == underscore || next == hash || next == period ||
|
|
46
|
-
next == bracketL || next == colon || next == dash)
|
|
50
|
+
next == bracketL || next == colon || next == dash || next == ampersand)
|
|
47
51
|
input.acceptToken(descendantOp);
|
|
48
52
|
}
|
|
49
53
|
});
|
|
@@ -106,6 +110,7 @@ const parser = lr.LRParser.deserialize({
|
|
|
106
110
|
nodeNames: "⚠ Unit VariableName Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee CallLiteral CallTag ParenthesizedContent , PseudoClassName ArgList IdSelector # IdName ] AttributeSelector [ AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp } { Block Declaration PropertyName Important ; ImportStatement AtKeyword import KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports AtRule Styles",
|
|
107
111
|
maxTerm: 114,
|
|
108
112
|
nodeProps: [
|
|
113
|
+
["isolate", -2,3,24,""],
|
|
109
114
|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%^![!]Bt!];'S%^;'S;=`%o<%lO%^bB{S^Qo`Oy%^z;'S%^;'S;=`%o<%lO%^nC^S!W^Oy%^z;'S%^;'S;=`%o<%lO%^dCoSzSOy%^z;'S%^;'S;=`%o<%lO%^bDQU|QOy%^z!`%^!`!aDd!a;'S%^;'S;=`%o<%lO%^bDkS|Qo`Oy%^z;'S%^;'S;=`%o<%lO%^bDzWOy%^z!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bEk[!YQo`Oy%^z}%^}!OEd!O!Q%^!Q![Ed![!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bFfSxQOy%^z;'S%^;'S;=`%o<%lO%^lFwSv[Oy%^z;'S%^;'S;=`%o<%lO%^bGWUOy%^z#b%^#b#cGj#c;'S%^;'S;=`%o<%lO%^bGoUo`Oy%^z#W%^#W#XHR#X;'S%^;'S;=`%o<%lO%^bHYS!`Qo`Oy%^z;'S%^;'S;=`%o<%lO%^bHiUOy%^z#f%^#f#gHR#g;'S%^;'S;=`%o<%lO%^fIQS!RUOy%^z;'S%^;'S;=`%o<%lO%^nIcS!Q^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!PQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}",
|
|
116
121
|
tokenizers: [descendant, unitToken, identifiers, 1, 2, 3, 4, new lr.LocalTokenGroup("m~RRYZ[z{a~~g~aO#Z~~dP!P!Qg~lO#[~~", 28, 102)],
|
|
117
122
|
topRules: {"StyleSheet":[0,4],"Styles":[1,84]},
|
|
118
|
-
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}],
|
|
123
|
+
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}],
|
|
119
124
|
tokenPrec: 1169
|
|
120
125
|
});
|
|
121
126
|
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const descendantOp = 96,
|
|
|
14
14
|
const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,
|
|
15
15
|
8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288];
|
|
16
16
|
const colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46,
|
|
17
|
-
hash = 35, percent = 37;
|
|
17
|
+
hash = 35, percent = 37, ampersand = 38, backslash = 92, newline = 10;
|
|
18
18
|
|
|
19
19
|
function isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 }
|
|
20
20
|
|
|
@@ -27,6 +27,10 @@ const identifiers = new ExternalTokenizer((input, stack) => {
|
|
|
27
27
|
if (!inside && (next != dash || i > 0)) inside = true;
|
|
28
28
|
if (dashes === i && next == dash) dashes++;
|
|
29
29
|
input.advance();
|
|
30
|
+
} else if (next == backslash && input.peek(1) != newline) {
|
|
31
|
+
input.advance();
|
|
32
|
+
if (input.next > -1) input.advance();
|
|
33
|
+
inside = true;
|
|
30
34
|
} else {
|
|
31
35
|
if (inside)
|
|
32
36
|
input.acceptToken(next == parenL ? callee : dashes == 2 && stack.canShift(VariableName) ? VariableName : identifier);
|
|
@@ -39,7 +43,7 @@ const descendant = new ExternalTokenizer(input => {
|
|
|
39
43
|
if (space.includes(input.peek(-1))) {
|
|
40
44
|
let {next} = input;
|
|
41
45
|
if (isAlpha(next) || next == underscore || next == hash || next == period ||
|
|
42
|
-
next == bracketL || next == colon || next == dash)
|
|
46
|
+
next == bracketL || next == colon || next == dash || next == ampersand)
|
|
43
47
|
input.acceptToken(descendantOp);
|
|
44
48
|
}
|
|
45
49
|
});
|
|
@@ -102,6 +106,7 @@ const parser = LRParser.deserialize({
|
|
|
102
106
|
nodeNames: "⚠ Unit VariableName Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee CallLiteral CallTag ParenthesizedContent , PseudoClassName ArgList IdSelector # IdName ] AttributeSelector [ AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp } { Block Declaration PropertyName Important ; ImportStatement AtKeyword import KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports AtRule Styles",
|
|
103
107
|
maxTerm: 114,
|
|
104
108
|
nodeProps: [
|
|
109
|
+
["isolate", -2,3,24,""],
|
|
105
110
|
["openedBy", 17,"(",48,"{"],
|
|
106
111
|
["closedBy", 18,")",49,"}"]
|
|
107
112
|
],
|
|
@@ -111,7 +116,7 @@ const parser = LRParser.deserialize({
|
|
|
111
116
|
tokenData: "J^~R!^OX$}X^%u^p$}pq%uqr)Xrs.Rst/utu6duv$}vw7^wx7oxy9^yz9oz{9t{|:_|}?Q}!O?c!O!P@Q!P!Q@i!Q![Ab![!]B]!]!^CX!^!_$}!_!`Cj!`!aC{!a!b$}!b!cDw!c!}$}!}#OFa#O#P$}#P#QFr#Q#R6d#R#T$}#T#UGT#U#c$}#c#dHf#d#o$}#o#pH{#p#q6d#q#rI^#r#sIo#s#y$}#y#z%u#z$f$}$f$g%u$g#BY$}#BY#BZ%u#BZ$IS$}$IS$I_%u$I_$I|$}$I|$JO%u$JO$JT$}$JT$JU%u$JU$KV$}$KV$KW%u$KW&FU$}&FU&FV%u&FV;'S$};'S;=`JW<%lO$}`%QSOy%^z;'S%^;'S;=`%o<%lO%^`%cSo`Oy%^z;'S%^;'S;=`%o<%lO%^`%rP;=`<%l%^~%zh#W~OX%^X^'f^p%^pq'fq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`%o<%lO%^nIcS!Q^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!PQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}",
|
|
112
117
|
tokenizers: [descendant, unitToken, identifiers, 1, 2, 3, 4, new LocalTokenGroup("m~RRYZ[z{a~~g~aO#Z~~dP!P!Qg~lO#[~~", 28, 102)],
|
|
113
118
|
topRules: {"StyleSheet":[0,4],"Styles":[1,84]},
|
|
114
|
-
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}],
|
|
119
|
+
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}],
|
|
115
120
|
tokenPrec: 1169
|
|
116
121
|
});
|
|
117
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lezer/css",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "lezer-based CSS grammar",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@lezer/generator": "^1.0.0",
|
|
17
|
-
"mocha": "^
|
|
17
|
+
"mocha": "^10.2.0",
|
|
18
18
|
"rollup": "^2.52.2",
|
|
19
19
|
"@rollup/plugin-node-resolve": "^9.0.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@lezer/common": "^1.2.0",
|
|
22
23
|
"@lezer/lr": "^1.0.0",
|
|
23
24
|
"@lezer/highlight": "^1.0.0"
|
|
24
25
|
},
|
package/src/css.grammar
CHANGED
|
@@ -132,7 +132,7 @@ CallExpression {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
@skip {} {
|
|
135
|
-
Comment { "/*" (commentContent | commentLineBreak)* commentEnd }
|
|
135
|
+
Comment[isolate] { "/*" (commentContent | commentLineBreak)* commentEnd }
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
@local tokens {
|
|
@@ -192,7 +192,7 @@ commaSep<value> { "" | value ("," value)* }
|
|
|
192
192
|
|
|
193
193
|
@precedence { numberLiteralInner, BinOp, SiblingOp }
|
|
194
194
|
|
|
195
|
-
StringLiteral { "\"" (!["\n\\] | "\\" _)* "\"" | "'" (!['\n\\] | "\\" _)* "'" }
|
|
195
|
+
StringLiteral[isolate] { "\"" (!["\n\\] | "\\" _)* "\"" | "'" (!['\n\\] | "\\" _)* "'" }
|
|
196
196
|
|
|
197
197
|
"#"
|
|
198
198
|
|
package/src/parser.js
CHANGED
|
@@ -13,6 +13,7 @@ export const parser = LRParser.deserialize({
|
|
|
13
13
|
nodeNames: "⚠ Unit VariableName Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee CallLiteral CallTag ParenthesizedContent , PseudoClassName ArgList IdSelector # IdName ] AttributeSelector [ AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp } { Block Declaration PropertyName Important ; ImportStatement AtKeyword import KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports AtRule Styles",
|
|
14
14
|
maxTerm: 114,
|
|
15
15
|
nodeProps: [
|
|
16
|
+
["isolate", -2,3,24,""],
|
|
16
17
|
["openedBy", 17,"(",48,"{"],
|
|
17
18
|
["closedBy", 18,")",49,"}"]
|
|
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%o<%lO%^nC^S!W^Oy%^z;'S%^;'S;=`%o<%lO%^dCoSzSOy%^z;'S%^;'S;=`%o<%lO%^bDQU|QOy%^z!`%^!`!aDd!a;'S%^;'S;=`%o<%lO%^bDkS|Qo`Oy%^z;'S%^;'S;=`%o<%lO%^bDzWOy%^z!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bEk[!YQo`Oy%^z}%^}!OEd!O!Q%^!Q![Ed![!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bFfSxQOy%^z;'S%^;'S;=`%o<%lO%^lFwSv[Oy%^z;'S%^;'S;=`%o<%lO%^bGWUOy%^z#b%^#b#cGj#c;'S%^;'S;=`%o<%lO%^bGoUo`Oy%^z#W%^#W#XHR#X;'S%^;'S;=`%o<%lO%^bHYS!`Qo`Oy%^z;'S%^;'S;=`%o<%lO%^bHiUOy%^z#f%^#f#gHR#g;'S%^;'S;=`%o<%lO%^fIQS!RUOy%^z;'S%^;'S;=`%o<%lO%^nIcS!Q^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!PQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}",
|
|
23
24
|
tokenizers: [descendant, unitToken, identifiers, 1, 2, 3, 4, new LocalTokenGroup("m~RRYZ[z{a~~g~aO#Z~~dP!P!Qg~lO#[~~", 28, 102)],
|
|
24
25
|
topRules: {"StyleSheet":[0,4],"Styles":[1,84]},
|
|
25
|
-
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}],
|
|
26
|
+
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}],
|
|
26
27
|
tokenPrec: 1169
|
|
27
28
|
})
|
package/src/tokens.js
CHANGED
|
@@ -7,7 +7,7 @@ import {callee, identifier, VariableName, descendantOp, Unit} from "./parser.ter
|
|
|
7
7
|
const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,
|
|
8
8
|
8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288]
|
|
9
9
|
const colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46,
|
|
10
|
-
hash = 35, percent = 37
|
|
10
|
+
hash = 35, percent = 37, ampersand = 38, backslash = 92, newline = 10
|
|
11
11
|
|
|
12
12
|
function isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 }
|
|
13
13
|
|
|
@@ -20,6 +20,10 @@ export const identifiers = new ExternalTokenizer((input, stack) => {
|
|
|
20
20
|
if (!inside && (next != dash || i > 0)) inside = true
|
|
21
21
|
if (dashes === i && next == dash) dashes++
|
|
22
22
|
input.advance()
|
|
23
|
+
} else if (next == backslash && input.peek(1) != newline) {
|
|
24
|
+
input.advance()
|
|
25
|
+
if (input.next > -1) input.advance()
|
|
26
|
+
inside = true
|
|
23
27
|
} else {
|
|
24
28
|
if (inside)
|
|
25
29
|
input.acceptToken(next == parenL ? callee : dashes == 2 && stack.canShift(VariableName) ? VariableName : identifier)
|
|
@@ -32,7 +36,7 @@ export const descendant = new ExternalTokenizer(input => {
|
|
|
32
36
|
if (space.includes(input.peek(-1))) {
|
|
33
37
|
let {next} = input
|
|
34
38
|
if (isAlpha(next) || next == underscore || next == hash || next == period ||
|
|
35
|
-
next == bracketL || next == colon || next == dash)
|
|
39
|
+
next == bracketL || next == colon || next == dash || next == ampersand)
|
|
36
40
|
input.acceptToken(descendantOp)
|
|
37
41
|
}
|
|
38
42
|
})
|
package/test/selector.txt
CHANGED
|
@@ -97,6 +97,7 @@ StyleSheet(
|
|
|
97
97
|
a {
|
|
98
98
|
&.b {}
|
|
99
99
|
& c {}
|
|
100
|
+
c & {}
|
|
100
101
|
& > d {}
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -105,6 +106,7 @@ a {
|
|
|
105
106
|
StyleSheet(RuleSet(TagSelector(TagName),Block(
|
|
106
107
|
RuleSet(ClassSelector(NestingSelector,ClassName),Block),
|
|
107
108
|
RuleSet(DescendantSelector(NestingSelector,TagSelector(TagName)),Block),
|
|
109
|
+
RuleSet(DescendantSelector(TagSelector(TagName), NestingSelector),Block),
|
|
108
110
|
RuleSet(ChildSelector(NestingSelector,ChildOp,TagSelector(TagName)),Block))))
|
|
109
111
|
|
|
110
112
|
# Sibling selectors
|
package/test/statements.txt
CHANGED
|
@@ -161,3 +161,15 @@ div {}
|
|
|
161
161
|
==>
|
|
162
162
|
|
|
163
163
|
StyleSheet(RuleSet(TagSelector(TagName),Block),Comment)
|
|
164
|
+
|
|
165
|
+
# Escaped identifiers
|
|
166
|
+
|
|
167
|
+
#foo\ bar {
|
|
168
|
+
--weird\\var: 5px;
|
|
169
|
+
width: var(--weird\\var);
|
|
170
|
+
}
|
|
171
|
+
==>
|
|
172
|
+
|
|
173
|
+
StyleSheet(RuleSet(IdSelector(IdName),Block(
|
|
174
|
+
Declaration(VariableName,NumberLiteral(Unit)),
|
|
175
|
+
Declaration(PropertyName,CallExpression(Callee,ArgList(VariableName))))))
|