-
Notifications
You must be signed in to change notification settings - Fork 0
/
languages.ts
48 lines (42 loc) · 1.08 KB
/
languages.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// * types
type Languages = Record<LanguageName, Language>;
type Language = { resolver: Resolver; stringLiterals?: string[] };
type LanguageName = 'JS' | 'CSS' | 'HTML' | 'CPP' | 'GO' | 'PYTHON' | 'PHP';
export type Resolver =
| string
| { block: string }
| { inline: string }
| { block: string; inline: string };
const DEFAULT_RESOLVER = { inline: '//.*', block: '/\\*(?:.|\n)*?\\*/' };
const DEFAULT_STRING_LITERALS = ["'", '"'];
const languages: Languages = {
JS: {
resolver: DEFAULT_RESOLVER,
stringLiterals: ["'", '"', '`'],
},
CSS: {
resolver: DEFAULT_RESOLVER.block,
stringLiterals: DEFAULT_STRING_LITERALS,
},
HTML: {
resolver: '<!--[\\s\\S]*?-->',
stringLiterals: DEFAULT_STRING_LITERALS,
},
CPP: {
resolver: DEFAULT_RESOLVER,
stringLiterals: ['"'],
},
GO: {
resolver: DEFAULT_RESOLVER,
stringLiterals: ['"'],
},
PYTHON: {
resolver: '#.*',
stringLiterals: ["'", '"', "'''", '"""'],
},
PHP: {
resolver: { inline: '(?:#|//).*' },
stringLiterals: DEFAULT_STRING_LITERALS,
},
};
export default languages;