add Kap support

This commit is contained in:
Mathium05 committed 2026-09-05 13:09:08 -05:00
1 parent 0d5340950c
commit ce7f80185a
2 files changed
+20

No files matched your search

+11
View File
@@ -93,5 +93,16 @@
"hashComments": true,
"doubleSlashComments": false,
"multilineSlashComments": false
},
{
"names":["kap"],
"keywords":["!", "#", "%", "&", "*", "+", ",", "-", "/", "<", "=", ">", "?", "^", "|",
"~", "¨", "×", "÷", "↑", "→", "↓", "∊", "∘", "∧", "∨", "∩", "∪", "∼", "≠", "≡",
"≢", "≤", "≥", "⊂", "⊃", "⊖", "⊢", "⊣", "⊤", "⊥", "⋆", "⌈", "⌊", "⌶", "⌷", "⌹",
"⌻", "⌽", "⌿", "⍀", "⍉", "⍋", "⍎", "⍒", "⍕", "⍞", "⍟", "⍠", "⍣", "⍤",
"⍨", "⍪", "⍫", "⍱", "⍲", "⍳", "⍴", "⍵", "⍶", "⍷", "⍸", "⍹", "⍺", "◊",
"○", "$", "¥", "χ", "\\", "∵", "⍓", "⫽", "⑊", "⊆", "⊇", "⍥", "∥", "⍛", "˝",
"⍢", "√", "∙", "⌸", "≬", "⍮", "⫇", "…", "⍰","and","or","while", "if", "else", "when", "⋄"],
"customComment":"⍝"
}
]
+9
View File
@@ -9,6 +9,7 @@ interface clikeConf {
multilineSlashComments?: boolean;
JSLikeTemplateStrings?: boolean;
multiLine?: string;
customComment?: string;
}
function regex(config: clikeConf): RegExp {
const conds = [] as string[];
@@ -30,6 +31,9 @@ function regex(config: clikeConf): RegExp {
if (config.hashComments) {
conds.push("#.*");
}
if (config.customComment) {
conds.push(config.customComment + ".*");
}
if (config.doubleSlashComments) {
conds.push("\\/\\/.*");
}
@@ -143,6 +147,11 @@ function* lex(code: string, config: clikeConf) {
type: hcolors.comment,
content: lex,
};
} else if (config.customComment && lex.startsWith(config.customComment)) {
yield {
type: hcolors.comment,
content: lex,
};
} else if (lex.startsWith("`") && config.JSLikeTemplateStrings) {
yield {
type: hcolors.string,