limn-hl 0.1.1 → 0.2.0
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 +105 -174
- package/dist/detect.d.ts +7 -1
- package/dist/detect.js +592 -502
- package/dist/engine.js +45 -1
- package/dist/generated/detect.d.ts +11 -0
- package/dist/generated/detect.js +2434 -0
- package/dist/generated/grammars.d.ts +119 -0
- package/dist/generated/grammars.js +613 -0
- package/dist/generated/lang.d.ts +6 -0
- package/dist/{lang/index.js → generated/lang.js} +82 -56
- package/dist/{theme/generated.d.ts → generated/themes.d.ts} +1 -1
- package/dist/lang.d.ts +1 -0
- package/dist/lang.js +1 -0
- package/dist/render/ansi.d.ts +1 -1
- package/dist/render/html.d.ts +1 -1
- package/dist/{theme/index.d.ts → theme.d.ts} +1 -1
- package/dist/theme.js +1 -0
- package/dist/vm/compile.d.ts +4 -0
- package/dist/vm/compile.js +390 -0
- package/dist/vm/exec.d.ts +3 -0
- package/dist/vm/exec.js +218 -0
- package/dist/vm/format.d.ts +255 -0
- package/dist/vm/format.js +248 -0
- package/dist/vm/index.d.ts +2 -0
- package/dist/vm/index.js +2 -0
- package/dist/vm/pat.d.ts +4 -0
- package/dist/vm/pat.js +701 -0
- package/dist/vm/quoted.d.ts +8 -0
- package/dist/vm/quoted.js +190 -0
- package/dist/vm/scan.d.ts +3 -0
- package/dist/vm/scan.js +499 -0
- package/dist/wordtable.d.ts +8 -4
- package/dist/wordtable.js +107 -30
- package/package.json +6 -6
- package/dist/lang/clike.d.ts +0 -15
- package/dist/lang/clike.js +0 -35
- package/dist/lang/clike_helpers.d.ts +0 -8
- package/dist/lang/clike_helpers.js +0 -220
- package/dist/lang/code.d.ts +0 -45
- package/dist/lang/code.js +0 -779
- package/dist/lang/config.d.ts +0 -5
- package/dist/lang/config.js +0 -164
- package/dist/lang/css.d.ts +0 -5
- package/dist/lang/css.js +0 -125
- package/dist/lang/docs.d.ts +0 -12
- package/dist/lang/docs.js +0 -462
- package/dist/lang/formats.d.ts +0 -10
- package/dist/lang/formats.js +0 -295
- package/dist/lang/html.d.ts +0 -11
- package/dist/lang/html.js +0 -298
- package/dist/lang/index.d.ts +0 -20
- package/dist/lang/js.d.ts +0 -9
- package/dist/lang/js.js +0 -532
- package/dist/lang/js_helpers.d.ts +0 -7
- package/dist/lang/js_helpers.js +0 -308
- package/dist/lang/json.d.ts +0 -3
- package/dist/lang/json.js +0 -136
- package/dist/lang/markdown.d.ts +0 -3
- package/dist/lang/markdown.js +0 -249
- package/dist/lang/python.d.ts +0 -3
- package/dist/lang/python.js +0 -335
- package/dist/lang/scripting.d.ts +0 -7
- package/dist/lang/scripting.js +0 -216
- package/dist/lang/shell.d.ts +0 -7
- package/dist/lang/shell.js +0 -404
- package/dist/lang/specs_gen.d.ts +0 -66
- package/dist/lang/specs_gen.js +0 -381
- package/dist/lang/terminal.d.ts +0 -9
- package/dist/lang/terminal.js +0 -550
- package/dist/lang/yaml.d.ts +0 -4
- package/dist/lang/yaml.js +0 -176
- package/dist/theme/index.js +0 -1
- /package/dist/{theme/generated.js → generated/themes.js} +0 -0
package/dist/lang/config.d.ts
DELETED
package/dist/lang/config.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Cursor,
|
|
3
|
-
emitCommentWithTodo,
|
|
4
|
-
isDigit,
|
|
5
|
-
isIdentCont,
|
|
6
|
-
isIdentStart
|
|
7
|
-
} from "../cursor.js";
|
|
8
|
-
import { Grammar } from "../engine.js";
|
|
9
|
-
import { TokenKind } from "../token.js";
|
|
10
|
-
import { onceGrammar } from "./code.js";
|
|
11
|
-
import { looksLikeNumber } from "./yaml.js";
|
|
12
|
-
function isTOMLNumCont(c) {
|
|
13
|
-
return isDigit(c) || c === 46 || c === 95 || c === 45 || c === 58 || c === 84 || c === 90 || c === 43 || c === 120 || c === 111 || c === 98 || c >= 97 && c <= 102 || c >= 65 && c <= 70;
|
|
14
|
-
}
|
|
15
|
-
function scanTOML(src, e) {
|
|
16
|
-
const n = src.length;
|
|
17
|
-
let i = 0;
|
|
18
|
-
let lineStart = true;
|
|
19
|
-
let expectVal = false;
|
|
20
|
-
while (i < n && !e.stopped()) {
|
|
21
|
-
const ch = src.charCodeAt(i);
|
|
22
|
-
if (ch === 10) {
|
|
23
|
-
lineStart = true;
|
|
24
|
-
expectVal = false;
|
|
25
|
-
i++;
|
|
26
|
-
} else if (ch === 32 || ch === 9 || ch === 13) {
|
|
27
|
-
i++;
|
|
28
|
-
} else if (ch === 35) {
|
|
29
|
-
const nl = src.indexOf(`
|
|
30
|
-
`, i + 1);
|
|
31
|
-
const end = nl >= 0 ? nl : n;
|
|
32
|
-
emitCommentWithTodo(src, i, end, e);
|
|
33
|
-
i = end;
|
|
34
|
-
} else if (lineStart && !expectVal && ch === 91) {
|
|
35
|
-
let end = i + 1;
|
|
36
|
-
while (end < n && src.charCodeAt(end) !== 10 && src.charCodeAt(end) !== 35)
|
|
37
|
-
end++;
|
|
38
|
-
while (end > i && (src.charCodeAt(end - 1) === 32 || src.charCodeAt(end - 1) === 9))
|
|
39
|
-
end--;
|
|
40
|
-
e.emit(i, end, TokenKind.Section);
|
|
41
|
-
i = end;
|
|
42
|
-
lineStart = false;
|
|
43
|
-
} else if (ch === 34 || ch === 39) {
|
|
44
|
-
const raw = ch === 39;
|
|
45
|
-
const triple = i + 2 < n && src.charCodeAt(i + 1) === ch && src.charCodeAt(i + 2) === ch;
|
|
46
|
-
const start = i;
|
|
47
|
-
if (triple) {
|
|
48
|
-
const closeSeq = src.slice(start, start + 3);
|
|
49
|
-
const idx = src.indexOf(closeSeq, i + 3);
|
|
50
|
-
i = idx >= 0 ? idx + 3 : n;
|
|
51
|
-
} else {
|
|
52
|
-
const cur = new Cursor(src, i);
|
|
53
|
-
cur.scanQuoted(ch, false, raw);
|
|
54
|
-
i = cur.pos;
|
|
55
|
-
}
|
|
56
|
-
e.emit(start, i, expectVal ? TokenKind.String : TokenKind.Property);
|
|
57
|
-
lineStart = false;
|
|
58
|
-
} else if (ch === 61) {
|
|
59
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
60
|
-
i++;
|
|
61
|
-
expectVal = true;
|
|
62
|
-
lineStart = false;
|
|
63
|
-
} else if (ch === 123 || ch === 125 || ch === 91 || ch === 93 || ch === 44 || ch === 46) {
|
|
64
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
65
|
-
i++;
|
|
66
|
-
lineStart = false;
|
|
67
|
-
} else if (expectVal && isDigit(ch)) {
|
|
68
|
-
const s = i;
|
|
69
|
-
while (i < n && isTOMLNumCont(src.charCodeAt(i)))
|
|
70
|
-
i++;
|
|
71
|
-
e.emit(s, i, TokenKind.Number);
|
|
72
|
-
lineStart = false;
|
|
73
|
-
} else if (expectVal && (ch === 43 || ch === 45) && i + 1 < n && isDigit(src.charCodeAt(i + 1))) {
|
|
74
|
-
const s = i;
|
|
75
|
-
i++;
|
|
76
|
-
while (i < n) {
|
|
77
|
-
const b = src.charCodeAt(i);
|
|
78
|
-
if (isDigit(b) || b === 46 || b === 95 || b === 101 || b === 69)
|
|
79
|
-
i++;
|
|
80
|
-
else
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
e.emit(s, i, TokenKind.Number);
|
|
84
|
-
lineStart = false;
|
|
85
|
-
} else if (isIdentStart(ch) || !expectVal && isDigit(ch)) {
|
|
86
|
-
const s = i;
|
|
87
|
-
i++;
|
|
88
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
89
|
-
i++;
|
|
90
|
-
const w = src.slice(s, i);
|
|
91
|
-
if (!expectVal) {
|
|
92
|
-
e.emit(s, i, TokenKind.Property);
|
|
93
|
-
} else if (w === "true" || w === "false") {
|
|
94
|
-
e.emit(s, i, TokenKind.Constant);
|
|
95
|
-
} else if (w === "inf" || w === "nan") {
|
|
96
|
-
e.emit(s, i, TokenKind.Number);
|
|
97
|
-
}
|
|
98
|
-
lineStart = false;
|
|
99
|
-
} else {
|
|
100
|
-
i++;
|
|
101
|
-
lineStart = false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function scanINI(src, e) {
|
|
106
|
-
const n = src.length;
|
|
107
|
-
let pos = 0;
|
|
108
|
-
while (pos < n && !e.stopped()) {
|
|
109
|
-
const nl = src.indexOf(`
|
|
110
|
-
`, pos);
|
|
111
|
-
const end = nl >= 0 ? nl : n;
|
|
112
|
-
let i = pos;
|
|
113
|
-
while (i < end && (src.charCodeAt(i) === 32 || src.charCodeAt(i) === 9))
|
|
114
|
-
i++;
|
|
115
|
-
if (i < end) {
|
|
116
|
-
const ch = src.charCodeAt(i);
|
|
117
|
-
if (ch === 35 || ch === 59) {
|
|
118
|
-
emitCommentWithTodo(src, i, end, e);
|
|
119
|
-
} else if (ch === 91) {
|
|
120
|
-
e.emit(i, end, TokenKind.Section);
|
|
121
|
-
} else {
|
|
122
|
-
let sep = -1;
|
|
123
|
-
for (let k = i;k < end; k++) {
|
|
124
|
-
const c = src.charCodeAt(k);
|
|
125
|
-
if (c === 61 || c === 58) {
|
|
126
|
-
sep = k;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (sep > i) {
|
|
131
|
-
let keyEnd = sep;
|
|
132
|
-
while (keyEnd > i && (src.charCodeAt(keyEnd - 1) === 32 || src.charCodeAt(keyEnd - 1) === 9)) {
|
|
133
|
-
keyEnd--;
|
|
134
|
-
}
|
|
135
|
-
e.emit(i, keyEnd, TokenKind.Property);
|
|
136
|
-
e.emit(sep, sep + 1, TokenKind.Operator);
|
|
137
|
-
let val = sep + 1;
|
|
138
|
-
while (val < end && (src.charCodeAt(val) === 32 || src.charCodeAt(val) === 9))
|
|
139
|
-
val++;
|
|
140
|
-
if (val < end) {
|
|
141
|
-
const vc = src.charCodeAt(val);
|
|
142
|
-
if (vc === 34 || vc === 39) {
|
|
143
|
-
e.emit(val, end, TokenKind.String);
|
|
144
|
-
} else {
|
|
145
|
-
const w = src.slice(val, end).trim();
|
|
146
|
-
if (w === "true" || w === "false" || w === "yes" || w === "no" || w === "on" || w === "off") {
|
|
147
|
-
e.emit(val, val + w.length, TokenKind.Constant);
|
|
148
|
-
} else if (looksLikeNumber(w)) {
|
|
149
|
-
e.emit(val, val + w.length, TokenKind.Number);
|
|
150
|
-
} else {
|
|
151
|
-
e.emit(val, end, TokenKind.String);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (nl < 0)
|
|
159
|
-
break;
|
|
160
|
-
pos = end + 1;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
export const toml = /* @__PURE__ */ onceGrammar(() => new Grammar("toml", scanTOML));
|
|
164
|
-
export const ini = /* @__PURE__ */ onceGrammar(() => new Grammar("ini", scanINI, "conf", "cfg", "properties", "dotenv", "env"));
|
package/dist/lang/css.d.ts
DELETED
package/dist/lang/css.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Cursor,
|
|
3
|
-
isDigit,
|
|
4
|
-
isHexDigit,
|
|
5
|
-
isIdentCont,
|
|
6
|
-
isIdentStart
|
|
7
|
-
} from "../cursor.js";
|
|
8
|
-
import { Grammar } from "../engine.js";
|
|
9
|
-
import { TokenKind } from "../token.js";
|
|
10
|
-
import { onceGrammar } from "./code.js";
|
|
11
|
-
function isHexColor(src, start, end) {
|
|
12
|
-
const len = end - start;
|
|
13
|
-
if (len !== 3 && len !== 4 && len !== 6 && len !== 8)
|
|
14
|
-
return false;
|
|
15
|
-
for (let i = start;i < end; i++) {
|
|
16
|
-
if (!isHexDigit(src.charCodeAt(i)))
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
function lookaheadCSSColon(src, pos) {
|
|
22
|
-
const n = src.length;
|
|
23
|
-
while (pos < n && (src.charCodeAt(pos) === 32 || src.charCodeAt(pos) === 9))
|
|
24
|
-
pos++;
|
|
25
|
-
return pos < n && src.charCodeAt(pos) === 58 && (pos + 1 >= n || src.charCodeAt(pos + 1) !== 58);
|
|
26
|
-
}
|
|
27
|
-
function scanStylesheet(src, scssMode, e) {
|
|
28
|
-
const n = src.length;
|
|
29
|
-
let i = 0;
|
|
30
|
-
let braceDepth = 0;
|
|
31
|
-
while (i < n && !e.stopped()) {
|
|
32
|
-
const ch = src.charCodeAt(i);
|
|
33
|
-
if (ch === 32 || ch === 9 || ch === 10 || ch === 13) {
|
|
34
|
-
i++;
|
|
35
|
-
} else if (ch === 47 && i + 1 < n && src.charCodeAt(i + 1) === 42) {
|
|
36
|
-
const cur = new Cursor(src, i + 2);
|
|
37
|
-
cur.scanUntil("*/");
|
|
38
|
-
e.emit(i, cur.pos, TokenKind.Comment);
|
|
39
|
-
i = cur.pos;
|
|
40
|
-
} else if (scssMode && ch === 47 && i + 1 < n && src.charCodeAt(i + 1) === 47) {
|
|
41
|
-
const nl = src.indexOf(`
|
|
42
|
-
`, i + 2);
|
|
43
|
-
const end = nl >= 0 ? nl : n;
|
|
44
|
-
e.emit(i, end, TokenKind.Comment);
|
|
45
|
-
i = end;
|
|
46
|
-
} else if (ch === 34 || ch === 39) {
|
|
47
|
-
const cur = new Cursor(src, i);
|
|
48
|
-
cur.scanQuoted(ch, false, false);
|
|
49
|
-
e.emit(i, cur.pos, TokenKind.String);
|
|
50
|
-
i = cur.pos;
|
|
51
|
-
} else if (ch === 64) {
|
|
52
|
-
const s = i;
|
|
53
|
-
i++;
|
|
54
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
55
|
-
i++;
|
|
56
|
-
e.emit(s, i, TokenKind.Keyword);
|
|
57
|
-
} else if (scssMode && ch === 36) {
|
|
58
|
-
const s = i;
|
|
59
|
-
i++;
|
|
60
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
61
|
-
i++;
|
|
62
|
-
e.emit(s, i, TokenKind.Variable);
|
|
63
|
-
} else if (ch === 35) {
|
|
64
|
-
const s = i;
|
|
65
|
-
i++;
|
|
66
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
67
|
-
i++;
|
|
68
|
-
e.emit(s, i, braceDepth > 0 && isHexColor(src, s + 1, i) ? TokenKind.Number : TokenKind.Type);
|
|
69
|
-
} else if (ch === 123) {
|
|
70
|
-
braceDepth++;
|
|
71
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
72
|
-
i++;
|
|
73
|
-
} else if (ch === 125) {
|
|
74
|
-
if (braceDepth > 0)
|
|
75
|
-
braceDepth--;
|
|
76
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
77
|
-
i++;
|
|
78
|
-
} else if (ch === 40 || ch === 41 || ch === 91 || ch === 93 || ch === 44 || ch === 59 || ch === 58) {
|
|
79
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
80
|
-
i++;
|
|
81
|
-
} else if (isDigit(ch) || ch === 46 && i + 1 < n && isDigit(src.charCodeAt(i + 1))) {
|
|
82
|
-
const s = i;
|
|
83
|
-
if (ch === 46)
|
|
84
|
-
i++;
|
|
85
|
-
while (i < n && (isDigit(src.charCodeAt(i)) || src.charCodeAt(i) === 46))
|
|
86
|
-
i++;
|
|
87
|
-
while (i < n) {
|
|
88
|
-
const b = src.charCodeAt(i);
|
|
89
|
-
if (b >= 97 && b <= 122 || b === 37)
|
|
90
|
-
i++;
|
|
91
|
-
else
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
e.emit(s, i, TokenKind.Number);
|
|
95
|
-
} else if (ch === 33 && src.startsWith("!important", i)) {
|
|
96
|
-
e.emit(i, i + 10, TokenKind.Keyword);
|
|
97
|
-
i += 10;
|
|
98
|
-
} else if (ch === 46 && i + 1 < n && (isIdentStart(src.charCodeAt(i + 1)) || src.charCodeAt(i + 1) === 45)) {
|
|
99
|
-
const s = i;
|
|
100
|
-
i++;
|
|
101
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
102
|
-
i++;
|
|
103
|
-
e.emit(s, i, TokenKind.Type);
|
|
104
|
-
} else if (isIdentStart(ch) || ch === 45) {
|
|
105
|
-
const s = i;
|
|
106
|
-
i++;
|
|
107
|
-
while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
|
|
108
|
-
i++;
|
|
109
|
-
if (i < n && src.charCodeAt(i) === 40) {
|
|
110
|
-
e.emit(s, i, TokenKind.Func);
|
|
111
|
-
} else if (braceDepth > 0 && lookaheadCSSColon(src, i)) {
|
|
112
|
-
e.emit(s, i, TokenKind.Property);
|
|
113
|
-
} else {
|
|
114
|
-
const w = src.slice(s, i);
|
|
115
|
-
if (w === "inherit" || w === "initial" || w === "unset" || w === "none" || w === "auto") {
|
|
116
|
-
e.emit(s, i, TokenKind.Constant);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
i++;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
export const css = /* @__PURE__ */ onceGrammar(() => new Grammar("css", (src, e) => scanStylesheet(src, false, e)));
|
|
125
|
-
export const scss = /* @__PURE__ */ onceGrammar(() => new Grammar("scss", (src, e) => scanStylesheet(src, true, e), "sass", "less"));
|
package/dist/lang/docs.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Emitter, Grammar } from "../engine.js";
|
|
2
|
-
export declare function isASCIIAlpha(c: number): boolean;
|
|
3
|
-
export declare function isHyphenIdentCont(c: number): boolean;
|
|
4
|
-
export declare function nextCodePointEnd(src: string, pos: number): number;
|
|
5
|
-
export declare function emitCommentEOL(src: string, pos: number, e: Emitter): number;
|
|
6
|
-
export declare function scanQuotedEscaped(src: string, pos: number, quote: number, multiline: boolean, e: Emitter): number;
|
|
7
|
-
/** Returns the TeX / LaTeX grammar. */
|
|
8
|
-
export declare const tex: () => Grammar;
|
|
9
|
-
/** Returns the Typst markup grammar. */
|
|
10
|
-
export declare const typst: () => Grammar;
|
|
11
|
-
/** Returns the Mermaid diagram grammar. */
|
|
12
|
-
export declare const mermaid: () => Grammar;
|