@getmateo/highlight 0.0.0-stage → 0.19.7
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/LICENSE +211 -0
- package/dist/astro/parser.d.ts +11 -0
- package/dist/astro/parser.js +129 -0
- package/dist/budgeted-highlighter.d.ts +12 -0
- package/dist/budgeted-highlighter.js +48 -0
- package/dist/colors.d.ts +4 -0
- package/dist/colors.js +45 -0
- package/dist/csharp/highlight.d.ts +2 -0
- package/dist/csharp/highlight.js +22 -0
- package/dist/csharp/language.d.ts +3 -0
- package/dist/csharp/language.js +21 -0
- package/dist/csharp/parser.d.ts +3 -0
- package/dist/csharp/parser.js +150 -0
- package/dist/csharp/terms.d.ts +7 -0
- package/dist/csharp/terms.js +12 -0
- package/dist/csharp/tokens.d.ts +4 -0
- package/dist/csharp/tokens.js +73 -0
- package/dist/highlighter.d.ts +6 -0
- package/dist/highlighter.js +125 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/js-scanner.d.ts +2 -0
- package/dist/js-scanner.js +104 -0
- package/dist/nix/highlight.d.ts +2 -0
- package/dist/nix/highlight.js +21 -0
- package/dist/nix/language.d.ts +3 -0
- package/dist/nix/language.js +32 -0
- package/dist/nix/parser.d.ts +3 -0
- package/dist/nix/parser.js +45 -0
- package/dist/nix/terms.d.ts +9 -0
- package/dist/nix/terms.js +14 -0
- package/dist/nix/tokens.d.ts +4 -0
- package/dist/nix/tokens.js +70 -0
- package/dist/parsers.d.ts +7 -0
- package/dist/parsers.js +104 -0
- package/dist/svelte/highlight.d.ts +2 -0
- package/dist/svelte/highlight.js +54 -0
- package/dist/svelte/nesting.d.ts +9 -0
- package/dist/svelte/nesting.js +97 -0
- package/dist/svelte/parser.d.ts +3 -0
- package/dist/svelte/parser.js +204 -0
- package/dist/svelte/terms.d.ts +24 -0
- package/dist/svelte/terms.js +24 -0
- package/dist/svelte/tokens.d.ts +16 -0
- package/dist/svelte/tokens.js +509 -0
- package/dist/syntax-roles.d.ts +10 -0
- package/dist/syntax-roles.js +50 -0
- package/dist/themes.d.ts +12 -0
- package/dist/themes.js +235 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +2 -0
- package/dist/vue/parser.d.ts +2 -0
- package/dist/vue/parser.js +121 -0
- package/package.json +54 -4
- package/src/astro/LICENSE +21 -0
- package/README.md +0 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { highlightTree } from "@lezer/highlight";
|
|
2
|
+
import { getParserForFile } from "./parsers.js";
|
|
3
|
+
import { staticSyntaxHighlighter } from "./syntax-roles.js";
|
|
4
|
+
export function highlightCode(code, filename) {
|
|
5
|
+
const parser = getParserForFile(filename);
|
|
6
|
+
if (!parser) {
|
|
7
|
+
return code.split("\n").map((line) => [{ text: line, style: null }]);
|
|
8
|
+
}
|
|
9
|
+
const tree = parser.parse(code);
|
|
10
|
+
const lines = code.split("\n");
|
|
11
|
+
const result = [];
|
|
12
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13
|
+
result.push([]);
|
|
14
|
+
}
|
|
15
|
+
// Build a map of character positions to styles
|
|
16
|
+
const styleMap = Array.from({ length: code.length }, () => null);
|
|
17
|
+
highlightTree(tree, staticSyntaxHighlighter, (from, to, classes) => {
|
|
18
|
+
for (let i = from; i < to && i < styleMap.length; i++) {
|
|
19
|
+
styleMap[i] = classes;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// Convert style map to tokens per line
|
|
23
|
+
let pos = 0;
|
|
24
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
25
|
+
const line = lines[lineIndex];
|
|
26
|
+
if (line.length === 0) {
|
|
27
|
+
result[lineIndex].push({ text: "", style: null });
|
|
28
|
+
pos++; // skip newline
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
let currentToken = { text: "", style: styleMap[pos] };
|
|
32
|
+
for (let i = 0; i < line.length; i++) {
|
|
33
|
+
const charStyle = styleMap[pos + i];
|
|
34
|
+
if (charStyle === currentToken.style) {
|
|
35
|
+
currentToken.text += line[i];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (currentToken.text) {
|
|
39
|
+
result[lineIndex].push(currentToken);
|
|
40
|
+
}
|
|
41
|
+
currentToken = { text: line[i], style: charStyle };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (currentToken.text) {
|
|
45
|
+
result[lineIndex].push(currentToken);
|
|
46
|
+
}
|
|
47
|
+
pos += line.length + 1; // +1 for newline
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/** Cooperatively parses and highlights without changing the synchronous consumers. */
|
|
52
|
+
export function* highlightCodeInSteps(code, filename) {
|
|
53
|
+
const lines = code.split("\n");
|
|
54
|
+
const parser = getParserForFile(filename);
|
|
55
|
+
if (!parser)
|
|
56
|
+
return lines.map((line) => [{ text: line, style: null }]);
|
|
57
|
+
const parse = parser.startParse(code);
|
|
58
|
+
let tree = null;
|
|
59
|
+
for (let step = 1; !tree; step++) {
|
|
60
|
+
tree = parse.advance();
|
|
61
|
+
if (!tree && step % 200 === 0)
|
|
62
|
+
yield;
|
|
63
|
+
}
|
|
64
|
+
const result = lines.map(() => []);
|
|
65
|
+
const tokens = new LineTokenWriter(code, lines, result);
|
|
66
|
+
let chunkFrom = 0;
|
|
67
|
+
for (let first = 0; first < lines.length; first += 200) {
|
|
68
|
+
const last = Math.min(first + 200, lines.length);
|
|
69
|
+
let chunkTo = chunkFrom;
|
|
70
|
+
for (let line = first; line < last; line++)
|
|
71
|
+
chunkTo += lines[line].length + 1;
|
|
72
|
+
chunkTo = Math.min(chunkTo, code.length);
|
|
73
|
+
let cursor = chunkFrom;
|
|
74
|
+
highlightTree(tree, staticSyntaxHighlighter, (from, to, classes) => {
|
|
75
|
+
tokens.write(cursor, from, null);
|
|
76
|
+
tokens.write(from, to, classes);
|
|
77
|
+
cursor = to;
|
|
78
|
+
}, chunkFrom, chunkTo);
|
|
79
|
+
tokens.write(cursor, chunkTo, null);
|
|
80
|
+
chunkFrom = chunkTo;
|
|
81
|
+
yield;
|
|
82
|
+
}
|
|
83
|
+
for (const line of result) {
|
|
84
|
+
if (line.length === 0)
|
|
85
|
+
line.push({ text: "", style: null });
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
/** Splits ordered syntax ranges into tokens without a full-source per-character style map. */
|
|
90
|
+
class LineTokenWriter {
|
|
91
|
+
constructor(code, lines, result) {
|
|
92
|
+
this.code = code;
|
|
93
|
+
this.lines = lines;
|
|
94
|
+
this.result = result;
|
|
95
|
+
this.line = 0;
|
|
96
|
+
this.lineFrom = 0;
|
|
97
|
+
}
|
|
98
|
+
write(from, to, style) {
|
|
99
|
+
while (from < to) {
|
|
100
|
+
let lineEnd = this.lineFrom + this.lines[this.line].length;
|
|
101
|
+
while (from > lineEnd) {
|
|
102
|
+
this.line++;
|
|
103
|
+
this.lineFrom = lineEnd + 1;
|
|
104
|
+
lineEnd = this.lineFrom + this.lines[this.line].length;
|
|
105
|
+
}
|
|
106
|
+
const end = Math.min(to, lineEnd);
|
|
107
|
+
if (end > from)
|
|
108
|
+
this.append(this.code.slice(from, end), style);
|
|
109
|
+
from = end === lineEnd ? lineEnd + 1 : end;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
append(text, style) {
|
|
113
|
+
const tokens = this.result[this.line];
|
|
114
|
+
const last = tokens[tokens.length - 1];
|
|
115
|
+
if (last && last.style === style)
|
|
116
|
+
last.text += text;
|
|
117
|
+
else
|
|
118
|
+
tokens.push({ text, style });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function highlightLine(line, filename) {
|
|
122
|
+
const result = highlightCode(line, filename);
|
|
123
|
+
return result[0] ?? [{ text: line, style: null }];
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=highlighter.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { HighlightStyle, HighlightToken } from "./types.js";
|
|
2
|
+
export { getLanguageForFile, getParserForFile, isLanguageSupported, getSupportedExtensions, } from "./parsers.js";
|
|
3
|
+
export { createCodeMirrorHighlightStyle } from "./syntax-roles.js";
|
|
4
|
+
export { highlightCode, highlightLine } from "./highlighter.js";
|
|
5
|
+
export { highlightCodeWithBudget, HIGHLIGHT_MAX_SOURCE_BYTES } from "./budgeted-highlighter.js";
|
|
6
|
+
export { darkHighlightColors, lightHighlightColors } from "./colors.js";
|
|
7
|
+
export type { SyntaxThemeId, SyntaxThemeOption, SyntaxColors } from "./themes.js";
|
|
8
|
+
export { SYNTAX_THEME_IDS, SYNTAX_THEME_OPTIONS, isSyntaxThemeId, resolveSyntaxColors, } from "./themes.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getLanguageForFile, getParserForFile, isLanguageSupported, getSupportedExtensions, } from "./parsers.js";
|
|
2
|
+
export { createCodeMirrorHighlightStyle } from "./syntax-roles.js";
|
|
3
|
+
export { highlightCode, highlightLine } from "./highlighter.js";
|
|
4
|
+
export { highlightCodeWithBudget, HIGHLIGHT_MAX_SOURCE_BYTES } from "./budgeted-highlighter.js";
|
|
5
|
+
export { darkHighlightColors, lightHighlightColors } from "./colors.js";
|
|
6
|
+
export { SYNTAX_THEME_IDS, SYNTAX_THEME_OPTIONS, isSyntaxThemeId, resolveSyntaxColors, } from "./themes.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Scans JavaScript embedded in a template (Astro `{ }` expressions, Vue `{{ }}`
|
|
2
|
+
// interpolations) for the brace that closes it, without parsing the code.
|
|
3
|
+
function isSpace(code) {
|
|
4
|
+
return code === 32 || code === 9 || code === 10 || code === 13;
|
|
5
|
+
}
|
|
6
|
+
function isRegexStart(text, position) {
|
|
7
|
+
let previous = position - 1;
|
|
8
|
+
while (previous >= 0 && isSpace(text.charCodeAt(previous)))
|
|
9
|
+
previous--;
|
|
10
|
+
if (previous < 0)
|
|
11
|
+
return true;
|
|
12
|
+
const character = text[previous];
|
|
13
|
+
if (/[)\]}<"'`\d]/.test(character))
|
|
14
|
+
return false;
|
|
15
|
+
const code = text.charCodeAt(previous);
|
|
16
|
+
if (code === 62)
|
|
17
|
+
return previous > 0 && text.charCodeAt(previous - 1) === 61;
|
|
18
|
+
if (!/[A-Za-z_$]/.test(character))
|
|
19
|
+
return true;
|
|
20
|
+
let start = previous;
|
|
21
|
+
while (start >= 0 && /[A-Za-z0-9_$]/.test(text[start]))
|
|
22
|
+
start--;
|
|
23
|
+
const keyword = text.slice(start + 1, previous + 1);
|
|
24
|
+
return /^(return|typeof|instanceof|in|of|new|void|delete|yield|await|case|do|else|throw|extends|assert|with)$/.test(keyword);
|
|
25
|
+
}
|
|
26
|
+
// Template strings nested deeper than this are treated as running to the end.
|
|
27
|
+
const MAX_TEMPLATE_NESTING = 32;
|
|
28
|
+
function skipQuotedText(text, opening, nesting = 0) {
|
|
29
|
+
const quote = text.charCodeAt(opening);
|
|
30
|
+
for (let position = opening + 1; position < text.length; position++) {
|
|
31
|
+
const code = text.charCodeAt(position);
|
|
32
|
+
if (code === 92)
|
|
33
|
+
position++;
|
|
34
|
+
else if (code === quote)
|
|
35
|
+
return position;
|
|
36
|
+
else if (quote === 96 && code === 36 && text.charCodeAt(position + 1) === 123) {
|
|
37
|
+
position = skipTemplateSubstitution(text, position + 2, nesting);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return text.length - 1;
|
|
41
|
+
}
|
|
42
|
+
function skipTemplateSubstitution(text, start, nesting) {
|
|
43
|
+
if (nesting >= MAX_TEMPLATE_NESTING)
|
|
44
|
+
return text.length - 1;
|
|
45
|
+
const closing = findClosingBrace(text, start, () => true, nesting + 1);
|
|
46
|
+
return closing >= 0 ? closing : text.length - 1;
|
|
47
|
+
}
|
|
48
|
+
function skipLineComment(text, opening) {
|
|
49
|
+
const newline = text.indexOf("\n", opening + 2);
|
|
50
|
+
return newline >= 0 ? newline : text.length - 1;
|
|
51
|
+
}
|
|
52
|
+
function skipBlockComment(text, opening) {
|
|
53
|
+
const closing = text.indexOf("*/", opening + 2);
|
|
54
|
+
return closing >= 0 ? closing + 1 : text.length - 1;
|
|
55
|
+
}
|
|
56
|
+
function skipRegex(text, opening) {
|
|
57
|
+
let isInCharacterClass = false;
|
|
58
|
+
for (let position = opening + 1; position < text.length; position++) {
|
|
59
|
+
const code = text.charCodeAt(position);
|
|
60
|
+
if (code === 10 || code === 13)
|
|
61
|
+
return position;
|
|
62
|
+
if (code === 92)
|
|
63
|
+
position++;
|
|
64
|
+
else if (isInCharacterClass && code === 93)
|
|
65
|
+
isInCharacterClass = false;
|
|
66
|
+
else if (!isInCharacterClass && code === 91)
|
|
67
|
+
isInCharacterClass = true;
|
|
68
|
+
else if (!isInCharacterClass && code === 47)
|
|
69
|
+
return position;
|
|
70
|
+
}
|
|
71
|
+
return text.length - 1;
|
|
72
|
+
}
|
|
73
|
+
// Finds the first `}` outside nested braces, strings, comments, and regexes
|
|
74
|
+
// for which `isEnd` holds.
|
|
75
|
+
export function findClosingBrace(text, start, isEnd = () => true, nesting = 0) {
|
|
76
|
+
let depth = 0;
|
|
77
|
+
for (let position = start; position < text.length; position++) {
|
|
78
|
+
const code = text.charCodeAt(position);
|
|
79
|
+
if (code === 47 && text.charCodeAt(position + 1) === 47) {
|
|
80
|
+
position = skipLineComment(text, position);
|
|
81
|
+
}
|
|
82
|
+
else if (code === 47 && text.charCodeAt(position + 1) === 42) {
|
|
83
|
+
position = skipBlockComment(text, position);
|
|
84
|
+
}
|
|
85
|
+
else if (code === 47 && isRegexStart(text, position)) {
|
|
86
|
+
position = skipRegex(text, position);
|
|
87
|
+
}
|
|
88
|
+
else if (code === 34 || code === 39 || code === 96) {
|
|
89
|
+
position = skipQuotedText(text, position, nesting);
|
|
90
|
+
}
|
|
91
|
+
else if (code === 123) {
|
|
92
|
+
depth++;
|
|
93
|
+
}
|
|
94
|
+
else if (code === 125 && depth === 0) {
|
|
95
|
+
if (isEnd(position))
|
|
96
|
+
return position;
|
|
97
|
+
}
|
|
98
|
+
else if (code === 125) {
|
|
99
|
+
depth--;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return -1;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=js-scanner.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { styleTags, tags as t } from "@lezer/highlight";
|
|
2
|
+
export const nixHighlighting = styleTags({
|
|
3
|
+
Identifier: t.propertyName,
|
|
4
|
+
Boolean: t.bool,
|
|
5
|
+
String: t.string,
|
|
6
|
+
IndentedString: t.string,
|
|
7
|
+
LineComment: t.lineComment,
|
|
8
|
+
BlockComment: t.blockComment,
|
|
9
|
+
Float: t.float,
|
|
10
|
+
Integer: t.integer,
|
|
11
|
+
Null: t.null,
|
|
12
|
+
URI: t.url,
|
|
13
|
+
SPath: t.literal,
|
|
14
|
+
Path: t.literal,
|
|
15
|
+
"( )": t.paren,
|
|
16
|
+
"{ }": t.brace,
|
|
17
|
+
"[ ]": t.squareBracket,
|
|
18
|
+
"if then else": t.controlKeyword,
|
|
19
|
+
"import with let in rec builtins inherit assert or": t.keyword,
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=highlight.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { continuedIndent, delimitedIndent, foldInside, foldNodeProp, indentNodeProp, LRLanguage, } from "@codemirror/language";
|
|
2
|
+
import { parser } from "./parser.js";
|
|
3
|
+
export const nixLanguage = LRLanguage.define({
|
|
4
|
+
name: "Nix",
|
|
5
|
+
parser: parser.configure({
|
|
6
|
+
props: [
|
|
7
|
+
indentNodeProp.add({
|
|
8
|
+
Parenthesized: delimitedIndent({ closing: ")" }),
|
|
9
|
+
AttrSet: delimitedIndent({ closing: "}" }),
|
|
10
|
+
List: delimitedIndent({ closing: "]" }),
|
|
11
|
+
Let: continuedIndent({ except: /^\s*in\b/ }),
|
|
12
|
+
}),
|
|
13
|
+
foldNodeProp.add({
|
|
14
|
+
AttrSet: foldInside,
|
|
15
|
+
List: foldInside,
|
|
16
|
+
Let(node) {
|
|
17
|
+
const first = node.getChild("let");
|
|
18
|
+
const last = node.getChild("in");
|
|
19
|
+
if (!first || !last)
|
|
20
|
+
return null;
|
|
21
|
+
return { from: first.to, to: last.from };
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
languageData: {
|
|
27
|
+
commentTokens: { line: "#", block: { open: "/*", close: "*/" } },
|
|
28
|
+
closeBrackets: { brackets: ["(", "[", "{", "''", '"'] },
|
|
29
|
+
indentOnInput: /^\s*(in|\}|\)|\])$/,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Generated by lezer-generator, taken from @replit/codemirror-lang-nix@6.0.1.
|
|
2
|
+
// Vendored so the daemon never loads the editor-only runtime those packages
|
|
3
|
+
// pull in at import time (@codemirror/autocomplete, view, state). Only pure
|
|
4
|
+
// Lezer primitives are used here. See packages/highlight/src/svelte for the
|
|
5
|
+
// same treatment applied to Svelte.
|
|
6
|
+
import { LRParser } from "@lezer/lr";
|
|
7
|
+
import { nixHighlighting } from "./highlight.js";
|
|
8
|
+
import { scanIndString, scanString } from "./tokens.js";
|
|
9
|
+
const spec_Identifier = new Map([
|
|
10
|
+
["assert", 22],
|
|
11
|
+
["with", 26],
|
|
12
|
+
["let", 30],
|
|
13
|
+
["inherit", 42],
|
|
14
|
+
["in", 48],
|
|
15
|
+
["if", 52],
|
|
16
|
+
["then", 54],
|
|
17
|
+
["else", 56],
|
|
18
|
+
["builtins", 70],
|
|
19
|
+
["null", 214],
|
|
20
|
+
["true", 216],
|
|
21
|
+
["false", 216],
|
|
22
|
+
["rec", 100],
|
|
23
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![!]!f!p!w#O#R#p#q#r#t$V$h!f`OUVdeghsv}!P!Q!R!S!T!U!V!W!X!Y!Z![!]!f!p!w#O#R#p#q#r#t$V$hS!gZ!hQ!l_T$g$[$n!j]OUV_deghsv}!P!Q!R!S!T!U!V!W!X!Y!Z![!]!f!p!w#O#R#p#q#r#t$V$[$hV!jZ!h$nT!cY!d",
|
|
30
|
+
nodeNames: "⚠ LineComment BlockComment Program Function Identifier { } Formal Ellipses Assert assert With with Let let Bind AttrPath String Interpolation Interpolation inherit ( ) in IfExpr if then else BinaryExpr < > UnaryExpr App Select builtins Null Integer Float Boolean IndentedString Interpolation Path HPath SPath URI Parenthesized AttrSet LetAttrSet RecAttrSet rec ] [ List or",
|
|
31
|
+
maxTerm: 110,
|
|
32
|
+
nodeProps: [
|
|
33
|
+
["closedBy", 6, "}", 22, ")", 52, "]"],
|
|
34
|
+
["openedBy", 7, "{", 23, "(", 51, "["],
|
|
35
|
+
],
|
|
36
|
+
skippedNodes: [0, 1, 2],
|
|
37
|
+
repeatNodeCount: 7,
|
|
38
|
+
tokenData: ">P~RtXY#cYZ#c]^#cpq#cqr#trs$Rst$Wtu$ovw$zwx%Vxy%byz%gz{%l{|%q|})]}!O)b!O!P*X!P!Q.r!Q!R0l!R![2e![!]3S!]!^3X!^!_3^!_!`5_!`!a5l!a!b5y!b!c6O!c!}6T!}#O;g#P#Q;l#R#S:u#T#o6T#o#p;q#p#q;v#q#r<R#r#s<W~#hS!j~XY#cYZ#c]^#cpq#cV#yP#ZP!_!`#|U$RO#VU~$WO!s~~$]SP~OY$WZ;'S$W;'S;=`$i<%lO$W~$lP;=`<%l$W~$rP#o#p$u~$zO!u~~$}Pvw%Q~%VO#W~~%YPwx%]~%bO#a~~%gOf~~%lOg~~%qO!}~~%vW#P~{|&`}!O&}!O!P&}!P!Q'j!Q![&}!c!}&}#R#S&}#T#o&}~&eW!|~{|&}}!O&}!O!P&}!P!Q'j!Q![&}!c!}&}#R#S&}#T#o&}T'QW{|&}}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~~3cWn~{|3{}!O3{!O!P3{!Q![3{!_!`5Y!c!}3{#R#S3{#T#o3{~4OX{|3{}!O3{!O!P3{!P!Q4k!Q![3{!`!a5T!c!}3{#R#S3{#T#o3{~4nV{|3{}!O3{!O!P3{!Q![3{!c!}3{#R#S3{#T#o3{~5YO|~~5_O#S~V5dP!wP!_!`5gU5lO#UU~5qPo~!_!`5t~5yO#T~~6OO!n~~6TO!p~~6YYT~wx6x{|7a}!O6T!O!P7a!P!Q'j!Q![6T![!]8P!c!}6T#R#S:u#T#o6T~6}UT~wx6x}!O6x!Q![6x!c!}6x#R#S6x#T#o6x~7dX{|7a}!O7a!O!P7a!P!Q'j!Q![7a![!]8P!c!}7a#R#S&}#T#o7a~8Sdqr9btu9buv9bvw9bwx9bz{9b{|9b|}9b}!O9b!O!P9b!P!Q9b!Q![9b![!]9b!_!`9b!a!b9b!b!c9b!c!}9b#R#S9b#T#o9b#r#s9b~9gd}~qr9btu9buv9bvw9bwx9bz{9b{|9b|}9b}!O9b!O!P9b!P!Q9b!Q![9b![!]9b!_!`9b!a!b9b!b!c9b!c!}9b#R#S9b#T#o9b#r#s9b~:zXT~wx6x{|&}}!O:u!O!P&}!P!Q'j!Q![:u!c!}:u#R#S:u#T#o:u~;lO!U~~;qO!T~~;vOU~~;yP#p#q;|~<RO#X~~<WOV~~<ZP!P!Q<^~<aV{|<v}!O<v!O!P<v!Q![<v!c!}<v#R#S<v#T#o<v~<{W{~{|<v}!O<v!O!P<v!P!Q=e!Q![<v!c!}<v#R#S<v#T#o<v~=jV{~{|<v}!O<v!O!P<v!Q![<v!c!}<v#R#S<v#T#o<v",
|
|
39
|
+
tokenizers: [scanString, scanIndString, 0, 1, 2],
|
|
40
|
+
topRules: { Program: [0, 3] },
|
|
41
|
+
specialized: [{ term: 5, get: (value) => spec_Identifier.get(value) ?? -1 }],
|
|
42
|
+
propSources: [nixHighlighting],
|
|
43
|
+
tokenPrec: 2290,
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const strContent = 63;
|
|
2
|
+
export declare const strDollarBrace = 64;
|
|
3
|
+
export declare const strEnd = 65;
|
|
4
|
+
export declare const escapeSequence = 66;
|
|
5
|
+
export declare const indStrContent = 67;
|
|
6
|
+
export declare const indStrDollarBrace = 68;
|
|
7
|
+
export declare const indStrEnd = 69;
|
|
8
|
+
export declare const indEscapeSequence = 70;
|
|
9
|
+
//# sourceMappingURL=terms.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by lezer-generator, taken from @replit/codemirror-lang-nix@6.0.1.
|
|
2
|
+
// Vendored so the daemon never loads the editor-only runtime those packages
|
|
3
|
+
// pull in at import time (@codemirror/autocomplete, view, state). Only pure
|
|
4
|
+
// Lezer primitives are used here. See packages/highlight/src/svelte for the
|
|
5
|
+
// same treatment applied to Svelte.
|
|
6
|
+
export const strContent = 63;
|
|
7
|
+
export const strDollarBrace = 64;
|
|
8
|
+
export const strEnd = 65;
|
|
9
|
+
export const escapeSequence = 66;
|
|
10
|
+
export const indStrContent = 67;
|
|
11
|
+
export const indStrDollarBrace = 68;
|
|
12
|
+
export const indStrEnd = 69;
|
|
13
|
+
export const indEscapeSequence = 70;
|
|
14
|
+
//# sourceMappingURL=terms.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Generated by lezer-generator, taken from @replit/codemirror-lang-nix@6.0.1.
|
|
2
|
+
// Vendored so the daemon never loads the editor-only runtime those packages
|
|
3
|
+
// pull in at import time (@codemirror/autocomplete, view, state). Only pure
|
|
4
|
+
// Lezer primitives are used here. See packages/highlight/src/svelte for the
|
|
5
|
+
// same treatment applied to Svelte.
|
|
6
|
+
import { ExternalTokenizer } from "@lezer/lr";
|
|
7
|
+
import { escapeSequence, indEscapeSequence, indStrContent, indStrDollarBrace, indStrEnd, strContent, strDollarBrace, strEnd, } from "./terms.js";
|
|
8
|
+
const quote = 34, backslack = 92, braceL = 123, dollar = 36, apostrophe = 39;
|
|
9
|
+
export const scanString = new ExternalTokenizer((input) => {
|
|
10
|
+
for (let afterDollar = false, i = 0;; i++) {
|
|
11
|
+
let { next } = input;
|
|
12
|
+
if (next < 0) {
|
|
13
|
+
if (i > 0)
|
|
14
|
+
input.acceptToken(strContent);
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
else if (next === quote) {
|
|
18
|
+
if (i > 0)
|
|
19
|
+
input.acceptToken(strContent);
|
|
20
|
+
else
|
|
21
|
+
input.acceptToken(strEnd, 1);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
else if (next === braceL && afterDollar) {
|
|
25
|
+
if (i == 1)
|
|
26
|
+
input.acceptToken(strDollarBrace, 1);
|
|
27
|
+
else
|
|
28
|
+
input.acceptToken(strContent, -1);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
else if (next === backslack) {
|
|
32
|
+
input.advance();
|
|
33
|
+
input.acceptToken(escapeSequence, 1);
|
|
34
|
+
}
|
|
35
|
+
afterDollar = next === dollar;
|
|
36
|
+
input.advance();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export const scanIndString = new ExternalTokenizer((input) => {
|
|
40
|
+
for (let afterDollar = false, afterApostrophe = false, i = 0;; i++) {
|
|
41
|
+
let { next } = input;
|
|
42
|
+
if (next < 0) {
|
|
43
|
+
if (i > 0)
|
|
44
|
+
input.acceptToken(indStrContent);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
else if (next === apostrophe && afterApostrophe) {
|
|
48
|
+
if (i > 1)
|
|
49
|
+
input.acceptToken(indStrContent, -1);
|
|
50
|
+
else
|
|
51
|
+
input.acceptToken(indStrEnd, 1);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
else if (next === braceL && afterDollar) {
|
|
55
|
+
if (i == 1)
|
|
56
|
+
input.acceptToken(indStrDollarBrace, 1);
|
|
57
|
+
else
|
|
58
|
+
input.acceptToken(indStrContent, -1);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
else if (next === backslack) {
|
|
62
|
+
input.advance();
|
|
63
|
+
input.acceptToken(indEscapeSequence, 1);
|
|
64
|
+
}
|
|
65
|
+
afterDollar = next === dollar;
|
|
66
|
+
afterApostrophe = next === apostrophe;
|
|
67
|
+
input.advance();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Language } from "@codemirror/language";
|
|
2
|
+
import type { Parser } from "@lezer/common";
|
|
3
|
+
export declare function getLanguageForFile(filename: string): Language | null;
|
|
4
|
+
export declare function getParserForFile(filename: string): Parser | null;
|
|
5
|
+
export declare function isLanguageSupported(filename: string): boolean;
|
|
6
|
+
export declare function getSupportedExtensions(): string[];
|
|
7
|
+
//# sourceMappingURL=parsers.d.ts.map
|
package/dist/parsers.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { defineLanguageFacet, Language, StreamLanguage } from "@codemirror/language";
|
|
2
|
+
import { dart } from "@codemirror/legacy-modes/mode/clike";
|
|
3
|
+
import { swift } from "@codemirror/legacy-modes/mode/swift";
|
|
4
|
+
import { parser as jsParser } from "@lezer/javascript";
|
|
5
|
+
import { parser as jsonParser } from "@lezer/json";
|
|
6
|
+
import { parser as cssParser } from "@lezer/css";
|
|
7
|
+
import { parser as cppParser } from "@lezer/cpp";
|
|
8
|
+
import { parser as goParser } from "@lezer/go";
|
|
9
|
+
import { parser as htmlParser } from "@lezer/html";
|
|
10
|
+
import { parser as javaParser } from "@lezer/java";
|
|
11
|
+
import { parser as pythonParser } from "@lezer/python";
|
|
12
|
+
import { parser as markdownParser } from "@lezer/markdown";
|
|
13
|
+
import { parser as phpParser } from "@lezer/php";
|
|
14
|
+
import { parser as rustParser } from "@lezer/rust";
|
|
15
|
+
import { parser as xmlParser } from "@lezer/xml";
|
|
16
|
+
import { parser as yamlParser } from "@lezer/yaml";
|
|
17
|
+
import { parser as elixirParser } from "lezer-elixir";
|
|
18
|
+
import { csharpLanguage } from "./csharp/language.js";
|
|
19
|
+
import { astroParser } from "./astro/parser.js";
|
|
20
|
+
import { vueParser } from "./vue/parser.js";
|
|
21
|
+
import { nixLanguage } from "./nix/language.js";
|
|
22
|
+
import { parser as svelteBaseParser } from "./svelte/parser.js";
|
|
23
|
+
import { configureNesting, defaultNesting } from "./svelte/nesting.js";
|
|
24
|
+
function language(parser) {
|
|
25
|
+
return new Language(defineLanguageFacet(), parser);
|
|
26
|
+
}
|
|
27
|
+
const languagesByExtension = {
|
|
28
|
+
// JavaScript/TypeScript
|
|
29
|
+
js: language(jsParser),
|
|
30
|
+
jsx: language(jsParser.configure({ dialect: "jsx" })),
|
|
31
|
+
ts: language(jsParser.configure({ dialect: "ts" })),
|
|
32
|
+
tsx: language(jsParser.configure({ dialect: "ts jsx" })),
|
|
33
|
+
mjs: language(jsParser),
|
|
34
|
+
cjs: language(jsParser),
|
|
35
|
+
// C / C++ / Objective-C
|
|
36
|
+
c: language(cppParser),
|
|
37
|
+
h: language(cppParser),
|
|
38
|
+
cc: language(cppParser),
|
|
39
|
+
cpp: language(cppParser),
|
|
40
|
+
cxx: language(cppParser),
|
|
41
|
+
hpp: language(cppParser),
|
|
42
|
+
hxx: language(cppParser),
|
|
43
|
+
m: language(cppParser),
|
|
44
|
+
mm: language(cppParser),
|
|
45
|
+
// JSON
|
|
46
|
+
json: language(jsonParser),
|
|
47
|
+
// CSS
|
|
48
|
+
css: language(cssParser),
|
|
49
|
+
scss: language(cssParser),
|
|
50
|
+
// HTML
|
|
51
|
+
html: language(htmlParser),
|
|
52
|
+
htm: language(htmlParser),
|
|
53
|
+
// Svelte
|
|
54
|
+
svelte: language(svelteBaseParser.configure({ wrap: configureNesting(defaultNesting) })),
|
|
55
|
+
// Astro
|
|
56
|
+
astro: language(astroParser),
|
|
57
|
+
// Vue
|
|
58
|
+
vue: language(vueParser),
|
|
59
|
+
// XML
|
|
60
|
+
xml: language(xmlParser),
|
|
61
|
+
// Java
|
|
62
|
+
java: language(javaParser),
|
|
63
|
+
// Python
|
|
64
|
+
py: language(pythonParser),
|
|
65
|
+
// Go
|
|
66
|
+
go: language(goParser),
|
|
67
|
+
// PHP
|
|
68
|
+
php: language(phpParser),
|
|
69
|
+
// YAML
|
|
70
|
+
yaml: language(yamlParser),
|
|
71
|
+
yml: language(yamlParser),
|
|
72
|
+
// Rust
|
|
73
|
+
rs: language(rustParser),
|
|
74
|
+
// Swift
|
|
75
|
+
swift: StreamLanguage.define(swift),
|
|
76
|
+
// Dart
|
|
77
|
+
dart: StreamLanguage.define(dart),
|
|
78
|
+
// C#
|
|
79
|
+
cs: csharpLanguage,
|
|
80
|
+
// Nix
|
|
81
|
+
nix: nixLanguage,
|
|
82
|
+
// Elixir
|
|
83
|
+
ex: language(elixirParser),
|
|
84
|
+
exs: language(elixirParser),
|
|
85
|
+
// Markdown
|
|
86
|
+
md: language(markdownParser),
|
|
87
|
+
mdx: language(markdownParser),
|
|
88
|
+
};
|
|
89
|
+
export function getLanguageForFile(filename) {
|
|
90
|
+
const ext = filename.split(".").pop()?.toLowerCase();
|
|
91
|
+
if (!ext)
|
|
92
|
+
return null;
|
|
93
|
+
return languagesByExtension[ext] ?? null;
|
|
94
|
+
}
|
|
95
|
+
export function getParserForFile(filename) {
|
|
96
|
+
return getLanguageForFile(filename)?.parser ?? null;
|
|
97
|
+
}
|
|
98
|
+
export function isLanguageSupported(filename) {
|
|
99
|
+
return getParserForFile(filename) !== null;
|
|
100
|
+
}
|
|
101
|
+
export function getSupportedExtensions() {
|
|
102
|
+
return Object.keys(languagesByExtension);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=parsers.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { styleTags, tags as t } from "@lezer/highlight";
|
|
2
|
+
export const svelteHighlighting = styleTags({
|
|
3
|
+
"Text RawText": t.content,
|
|
4
|
+
"StartTag StartCloseTag SelfClosingEndTag EndTag": t.angleBracket,
|
|
5
|
+
TagName: t.tagName,
|
|
6
|
+
"MismatchedCloseTag/TagName": [t.tagName, t.invalid],
|
|
7
|
+
AttributeName: t.attributeName,
|
|
8
|
+
UnquotedAttributeValue: t.attributeValue,
|
|
9
|
+
"DoubleQuote SingleQuote AttributeValueContent": t.attributeValue,
|
|
10
|
+
Is: t.definitionOperator,
|
|
11
|
+
"EntityReference CharacterReference": t.character,
|
|
12
|
+
Comment: t.blockComment,
|
|
13
|
+
ProcessingInst: t.processingInstruction,
|
|
14
|
+
DoctypeDecl: t.documentMeta,
|
|
15
|
+
"{ }": t.bracket,
|
|
16
|
+
"[ ]": t.squareBracket,
|
|
17
|
+
"( )": t.paren,
|
|
18
|
+
"| , :": t.punctuation,
|
|
19
|
+
"...": t.derefOperator,
|
|
20
|
+
ComponentName: t.className,
|
|
21
|
+
SvelteElementNamespace: t.namespace,
|
|
22
|
+
SvelteElementType: t.tagName,
|
|
23
|
+
StyleAttributeName: t.propertyName,
|
|
24
|
+
BlockType: t.controlKeyword,
|
|
25
|
+
BlockPrefix: t.typeOperator,
|
|
26
|
+
"UnknownBlock/BlockType": t.invalid,
|
|
27
|
+
UnknownBlockContent: t.invalid,
|
|
28
|
+
"if then catch": t.controlKeyword,
|
|
29
|
+
as: t.definitionOperator,
|
|
30
|
+
Variable: t.variableName,
|
|
31
|
+
Modifier: t.modifier,
|
|
32
|
+
DirectlyInterpolatedAttributeValue: t.attributeValue,
|
|
33
|
+
"DirectiveOn/DirectiveName": t.controlKeyword,
|
|
34
|
+
"DirectiveOn/DirectiveTarget": t.typeName,
|
|
35
|
+
"DirectiveUse/DirectiveName": t.controlKeyword,
|
|
36
|
+
"DirectiveUse/DirectiveTarget": t.function(t.variableName),
|
|
37
|
+
"DirectiveBind/DirectiveName": t.controlKeyword,
|
|
38
|
+
"DirectiveBind/DirectiveTarget": t.variableName,
|
|
39
|
+
"DirectiveLet/DirectiveName": t.definitionKeyword,
|
|
40
|
+
"DirectiveLet/DirectiveTarget": t.definition(t.variableName),
|
|
41
|
+
"DirectiveTransition/DirectiveName": t.operatorKeyword,
|
|
42
|
+
"DirectiveTransition/DirectiveTarget": t.function(t.variableName),
|
|
43
|
+
"DirectiveIn/DirectiveName": t.operatorKeyword,
|
|
44
|
+
"DirectiveIn/DirectiveTarget": t.function(t.variableName),
|
|
45
|
+
"DirectiveOut/DirectiveName": t.operatorKeyword,
|
|
46
|
+
"DirectiveOut/DirectiveTarget": t.function(t.variableName),
|
|
47
|
+
"DirectiveAnimate/DirectiveName": t.operatorKeyword,
|
|
48
|
+
"DirectiveAnimate/DirectiveTarget": t.function(t.variableName),
|
|
49
|
+
"DirectiveClass/DirectiveName": t.attributeName,
|
|
50
|
+
"DirectiveClass/DirectiveTarget": t.variableName,
|
|
51
|
+
"DirectiveStyle/DirectiveName": t.attributeName,
|
|
52
|
+
"DirectiveStyle/DirectiveTarget": t.propertyName,
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=highlight.js.map
|