Skip to content

Commit

Permalink
Move special rules out of common.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 22, 2024
1 parent 1b75d6d commit 05f0fb3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions site/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ export const tokenProvider = {
tokenizer: {
root: [
[/[{}]/, 'delimiter.bracket'],
[/^\s*#?[\w$]+(?=\s*[;=:])/, 'variable.property'],
{ include: 'common' },
],

common: [
// highlight class field-properties
[/^\s*#?[\w$]+(?=\s*[;=:])/, 'variable.property'],

// highlight function/class defs nicely
// highlight function/class defs
[/((?:function|class)\s+)(#?[\w$]+\s*)([<(]?)/, [
{ token: 'keyword' },
{
Expand All @@ -97,14 +95,19 @@ export const tokenProvider = {
},
]],

// highlight var/const/let defs nicely
// highlight var/const/let defs
[/((?:const|let|var)\s+)(#?[\w$]+)/, ['keyword', {
cases: {
'$1~const\\s+': 'constant',
'@default': 'variable',
}
}]],

{ include: 'common' },
],

common: [

// identifiers and keywords
[/#?[a-z_$][\w$]*/, {
cases: {
Expand All @@ -113,8 +116,7 @@ export const tokenProvider = {
'@default': 'identifier',
}
}],
[/[A-Z][\w\$]*/, 'type.identifier'], // to show class names nicely
// [/[A-Z][\w\$]*/, 'identifier'],
[/[A-Z][\w\$]*/, 'type.identifier'],

// whitespace
{ include: '@whitespace' },
Expand Down

0 comments on commit 05f0fb3

Please sign in to comment.