@codemirror/language 6.9.1 → 6.9.2
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 +6 -0
- package/dist/index.cjs +24 -19
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +24 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2485,31 +2485,36 @@ function warnForPart(part, msg) {
|
|
|
2485
2485
|
console.warn(msg);
|
|
2486
2486
|
}
|
|
2487
2487
|
function createTokenType(extra, tagStr) {
|
|
2488
|
-
let
|
|
2489
|
-
for (let
|
|
2490
|
-
let
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2488
|
+
let tags = [];
|
|
2489
|
+
for (let name of tagStr.split(" ")) {
|
|
2490
|
+
let found = [];
|
|
2491
|
+
for (let part of name.split(".")) {
|
|
2492
|
+
let value = (extra[part] || highlight.tags[part]);
|
|
2493
|
+
if (!value) {
|
|
2494
|
+
warnForPart(part, `Unknown highlighting tag ${part}`);
|
|
2495
|
+
}
|
|
2496
|
+
else if (typeof value == "function") {
|
|
2497
|
+
if (!found.length)
|
|
2498
|
+
warnForPart(part, `Modifier ${part} used at start of tag`);
|
|
2499
|
+
else
|
|
2500
|
+
found = found.map(value);
|
|
2501
|
+
}
|
|
2502
|
+
else {
|
|
2503
|
+
if (found.length)
|
|
2504
|
+
warnForPart(part, `Tag ${part} used as modifier`);
|
|
2505
|
+
else
|
|
2506
|
+
found = Array.isArray(value) ? value : [value];
|
|
2507
|
+
}
|
|
2505
2508
|
}
|
|
2509
|
+
for (let tag of found)
|
|
2510
|
+
tags.push(tag);
|
|
2506
2511
|
}
|
|
2507
|
-
if (!
|
|
2512
|
+
if (!tags.length)
|
|
2508
2513
|
return 0;
|
|
2509
2514
|
let name = tagStr.replace(/ /g, "_"), type = common.NodeType.define({
|
|
2510
2515
|
id: typeArray.length,
|
|
2511
2516
|
name,
|
|
2512
|
-
props: [highlight.styleTags({ [name]:
|
|
2517
|
+
props: [highlight.styleTags({ [name]: tags })]
|
|
2513
2518
|
});
|
|
2514
2519
|
typeArray.push(type);
|
|
2515
2520
|
return type.id;
|
package/dist/index.d.cts
CHANGED
|
@@ -1139,11 +1139,13 @@ interface StreamParser<State> {
|
|
|
1139
1139
|
Read one token, advancing the stream past it, and returning a
|
|
1140
1140
|
string indicating the token's style tag—either the name of one
|
|
1141
1141
|
of the tags in
|
|
1142
|
-
[`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags)
|
|
1143
|
-
or
|
|
1142
|
+
[`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags)
|
|
1143
|
+
or [`tokenTable`](https://codemirror.net/6/docs/ref/#language.StreamParser.tokenTable), or such a
|
|
1144
|
+
name suffixed by one or more tag
|
|
1144
1145
|
[modifier](https://lezer.codemirror.net/docs/ref#highlight.Tag^defineModifier)
|
|
1145
1146
|
names, separated by periods. For example `"keyword"` or
|
|
1146
|
-
"`variableName.constant"
|
|
1147
|
+
"`variableName.constant"`, or a space-separated set of such
|
|
1148
|
+
token types.
|
|
1147
1149
|
|
|
1148
1150
|
It is okay to return a zero-length token, but only if that
|
|
1149
1151
|
updates the state so that the next call will return a non-empty
|
|
@@ -1175,10 +1177,10 @@ interface StreamParser<State> {
|
|
|
1175
1177
|
/**
|
|
1176
1178
|
Extra tokens to use in this parser. When the tokenizer returns a
|
|
1177
1179
|
token name that exists as a property in this object, the
|
|
1178
|
-
corresponding
|
|
1180
|
+
corresponding tags will be assigned to the token.
|
|
1179
1181
|
*/
|
|
1180
1182
|
tokenTable?: {
|
|
1181
|
-
[name: string]: Tag;
|
|
1183
|
+
[name: string]: Tag | readonly Tag[];
|
|
1182
1184
|
};
|
|
1183
1185
|
}
|
|
1184
1186
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1139,11 +1139,13 @@ interface StreamParser<State> {
|
|
|
1139
1139
|
Read one token, advancing the stream past it, and returning a
|
|
1140
1140
|
string indicating the token's style tag—either the name of one
|
|
1141
1141
|
of the tags in
|
|
1142
|
-
[`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags)
|
|
1143
|
-
or
|
|
1142
|
+
[`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags)
|
|
1143
|
+
or [`tokenTable`](https://codemirror.net/6/docs/ref/#language.StreamParser.tokenTable), or such a
|
|
1144
|
+
name suffixed by one or more tag
|
|
1144
1145
|
[modifier](https://lezer.codemirror.net/docs/ref#highlight.Tag^defineModifier)
|
|
1145
1146
|
names, separated by periods. For example `"keyword"` or
|
|
1146
|
-
"`variableName.constant"
|
|
1147
|
+
"`variableName.constant"`, or a space-separated set of such
|
|
1148
|
+
token types.
|
|
1147
1149
|
|
|
1148
1150
|
It is okay to return a zero-length token, but only if that
|
|
1149
1151
|
updates the state so that the next call will return a non-empty
|
|
@@ -1175,10 +1177,10 @@ interface StreamParser<State> {
|
|
|
1175
1177
|
/**
|
|
1176
1178
|
Extra tokens to use in this parser. When the tokenizer returns a
|
|
1177
1179
|
token name that exists as a property in this object, the
|
|
1178
|
-
corresponding
|
|
1180
|
+
corresponding tags will be assigned to the token.
|
|
1179
1181
|
*/
|
|
1180
1182
|
tokenTable?: {
|
|
1181
|
-
[name: string]: Tag;
|
|
1183
|
+
[name: string]: Tag | readonly Tag[];
|
|
1182
1184
|
};
|
|
1183
1185
|
}
|
|
1184
1186
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2483,31 +2483,36 @@ function warnForPart(part, msg) {
|
|
|
2483
2483
|
console.warn(msg);
|
|
2484
2484
|
}
|
|
2485
2485
|
function createTokenType(extra, tagStr) {
|
|
2486
|
-
let
|
|
2487
|
-
for (let
|
|
2488
|
-
let
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2486
|
+
let tags$1 = [];
|
|
2487
|
+
for (let name of tagStr.split(" ")) {
|
|
2488
|
+
let found = [];
|
|
2489
|
+
for (let part of name.split(".")) {
|
|
2490
|
+
let value = (extra[part] || tags[part]);
|
|
2491
|
+
if (!value) {
|
|
2492
|
+
warnForPart(part, `Unknown highlighting tag ${part}`);
|
|
2493
|
+
}
|
|
2494
|
+
else if (typeof value == "function") {
|
|
2495
|
+
if (!found.length)
|
|
2496
|
+
warnForPart(part, `Modifier ${part} used at start of tag`);
|
|
2497
|
+
else
|
|
2498
|
+
found = found.map(value);
|
|
2499
|
+
}
|
|
2500
|
+
else {
|
|
2501
|
+
if (found.length)
|
|
2502
|
+
warnForPart(part, `Tag ${part} used as modifier`);
|
|
2503
|
+
else
|
|
2504
|
+
found = Array.isArray(value) ? value : [value];
|
|
2505
|
+
}
|
|
2503
2506
|
}
|
|
2507
|
+
for (let tag of found)
|
|
2508
|
+
tags$1.push(tag);
|
|
2504
2509
|
}
|
|
2505
|
-
if (!
|
|
2510
|
+
if (!tags$1.length)
|
|
2506
2511
|
return 0;
|
|
2507
2512
|
let name = tagStr.replace(/ /g, "_"), type = NodeType.define({
|
|
2508
2513
|
id: typeArray.length,
|
|
2509
2514
|
name,
|
|
2510
|
-
props: [styleTags({ [name]:
|
|
2515
|
+
props: [styleTags({ [name]: tags$1 })]
|
|
2511
2516
|
});
|
|
2512
2517
|
typeArray.push(type);
|
|
2513
2518
|
return type.id;
|