Add JavaScript coloring

This commit is contained in:
Alex Dima 2018-08-08 11:19:05 +02:00
parent 4b1d2982ff
commit 3979a669f3
12 changed files with 711 additions and 21 deletions

View file

@ -527,7 +527,7 @@ testTokenization('typescript', [
[{
line: '`${5 + \'x\' + (<any>)3}`',
line: '`${5 + \'x\' + (<any>)3}a${4}`',
tokens: [
{ startIndex: 0, type: 'string.ts' },
{ startIndex: 1, type: 'delimiter.bracket.ts' },
@ -547,6 +547,10 @@ testTokenization('typescript', [
{ startIndex: 20, type: 'number.ts' },
{ startIndex: 21, type: 'delimiter.bracket.ts' },
{ startIndex: 22, type: 'string.ts' },
{ startIndex: 23, type: 'delimiter.bracket.ts' },
{ startIndex: 25, type: 'number.ts' },
{ startIndex: 26, type: 'delimiter.bracket.ts' },
{ startIndex: 27, type: 'string.ts' },
]
}]

View file

@ -67,7 +67,7 @@ export const conf: IRichLanguageConfiguration = {
}
};
export const language = <ILanguage>{
export const language = {
// Set defaultToken to invalid to see what you do not tokenize yet
defaultToken: 'invalid',
tokenPostfix: '.ts',
@ -190,7 +190,7 @@ export const language = <ILanguage>{
string_backtick: [
[/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
[/[^\\`]+/, 'string'],
[/[^\\`$]+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/`/, 'string', '@pop']