Skip to content

Commit 475b51d

Browse files
committed
feat: add support for keyword mappers in custom mode JSON
When the value for the `token` key of a rule is an object, this will now get converted to a keyword mapper. The token object should contain the keys `map`, `defaultToken`, `ignoreCase`, and `splitChar`
1 parent 1e99b9a commit 475b51d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lit-ace.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,22 @@ class LitAce extends LitElement {
12711271
var customModeFunction = function () {
12721272
this.$rules = parsed.states;
12731273

1274+
// Convert objects to keyword mappers
1275+
for (let key in this.$rules) {
1276+
let state = this.$rules[key];
1277+
for (let rule of state) {
1278+
let token = rule.token;
1279+
if (typeof token === "object") {
1280+
rule.token = this.createKeywordMapper(
1281+
token.map,
1282+
token.defaultToken,
1283+
token.ignoreCase,
1284+
token.splitChar
1285+
)
1286+
}
1287+
}
1288+
}
1289+
12741290
this.normalizeRules();
12751291
}
12761292

0 commit comments

Comments
 (0)