@jesscss/less-parser 2.0.0-alpha.7 → 2.0.0-alpha.8
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/README.md +17 -32
- package/lib/builders.d.ts.map +1 -1
- package/lib/functional-parser.cjs +1 -0
- package/lib/functional-parser.js +1 -0
- package/lib/grammar.cjs +23821 -19385
- package/lib/grammar.d.ts.map +1 -1
- package/lib/grammar.js +23821 -19385
- package/package.json +6 -6
- package/src/builders.ts +7 -0
- package/src/grammar.ts +5 -4
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.0-alpha.
|
|
7
|
+
"version": "2.0.0-alpha.8",
|
|
8
8
|
"description": "Jess LESS parser",
|
|
9
9
|
"main": "lib/index.cjs",
|
|
10
10
|
"types": "lib/index.d.ts",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"chevrotain": "^12.0.0",
|
|
44
44
|
"known-css-properties": "~0.37.0",
|
|
45
|
-
"@jesscss/css-parser": "2.0.0-alpha.
|
|
45
|
+
"@jesscss/css-parser": "2.0.0-alpha.8"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@jesscss/core": "2.0.0-alpha.
|
|
48
|
+
"@jesscss/core": "2.0.0-alpha.8"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@jesscss/core": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^18.19.31",
|
|
57
57
|
"less": "^4.6.3",
|
|
58
|
-
"parseman": "
|
|
58
|
+
"parseman": "link:/Users/matthew/git/oss/parser-thing",
|
|
59
59
|
"tsx": "~4.21.0",
|
|
60
|
-
"@jesscss/
|
|
61
|
-
"@jesscss/
|
|
60
|
+
"@jesscss/core": "2.0.0-alpha.8",
|
|
61
|
+
"@jesscss/shared": "2.0.0-alpha.1"
|
|
62
62
|
},
|
|
63
63
|
"author": "Matthew Dean <matthew-dean@users.noreply.github.com>",
|
|
64
64
|
"license": "MIT",
|
package/src/builders.ts
CHANGED
|
@@ -245,6 +245,13 @@ export class LessGrammar extends CssParser {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
const valItems = items.slice(colonIdx + 1, end);
|
|
248
|
+
// A tolerated trailing comma (`@x: a, b, c,;`) is not a value item — Less 4.x
|
|
249
|
+
// drops it, so a comma-list value keeps N items, not N + 1 empty. (Plain
|
|
250
|
+
// declarations go through the CSS builder, which already filters empty
|
|
251
|
+
// segments; the Less var path assembles valItems directly, so strip it here.)
|
|
252
|
+
if (valItems.length > 0 && valItems[valItems.length - 1]!.comp === ',') {
|
|
253
|
+
valItems.pop();
|
|
254
|
+
}
|
|
248
255
|
if (valItems.length) {
|
|
249
256
|
const vText = this._source.slice(valItems[0]!.span.start, valItems[valItems.length - 1]!.span.end);
|
|
250
257
|
if (/(?:^|[\s,])\.-?[_a-zA-Z]/.test(vText)) {
|
package/src/grammar.ts
CHANGED
|
@@ -449,10 +449,11 @@ export const lessGrammar = compose([cssGrammar, rules({ trivia: rw }, (g: any) =
|
|
|
449
449
|
const declaration = choice(g.VarDeclaration, g.CustomDeclaration, g.Declaration);
|
|
450
450
|
|
|
451
451
|
// ── Values (Less: + Reference, NamedColor, EscapedValue) ────────────────────
|
|
452
|
-
// A comma
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
|
|
452
|
+
// A comma-separated value list, tolerating a single trailing comma (`a, b,`) as
|
|
453
|
+
// Less 4.x does — its `value` parser breaks out of the comma loop when no
|
|
454
|
+
// expression follows, silently dropping the dangling comma (the value builder's
|
|
455
|
+
// empty-segment filter mirrors this, so the trailing comma adds no list item).
|
|
456
|
+
const valueList = sequence(g.valueSequence, many(sequence(literal(','), g.valueSequence)), optional(literal(',')));
|
|
456
457
|
// A space-separated value sequence: each item is a full top-level EXPRESSION
|
|
457
458
|
// (topSum), so arithmetic folds into the grammar (`1 + 2` → one Operation) while
|
|
458
459
|
// non-operator items stay a list (`1px 2px 3px`). topSum collapses to the bare
|