Skip to content

Commit

Permalink
Propertly match JSX tags with dots and spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 23, 2024
1 parent 4d05318 commit 6a3782a
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions site/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,17 @@ export const tokenProvider = {

jsxReady: [
[/<>/, 'delimiter.html', '@jsxText.FRAGMENT'],
[/(<)([a-zA-Z_$][.\w$]*)/, ['delimiter.html', {
cases: {
'[A-Z].*': { token: 'type.identifier', next: '@jsxOpen.$2' },
'': { token: 'constant', next: '@jsxOpen.$2' },
}
}]],
[/(<)(\s*)([\w$])/, ['delimiter.html', '',
{ token: '@rematch', next: '@jsxIdent.jsxOpen.' },
]],
],

jsxIdent: [
[/\s/, ''],
[/\./, { token: 'delimiter', switchTo: '$S0^' }],
[/[A-Z][\w$]*/, { token: 'type.delimiter', switchTo: '$S0$0' }],
[/[\w$]+/, { token: 'constant', switchTo: '$S0$0' }],
[/.+/, { token: '@rematch', switchTo: '@$S2.$S3.$S4' }],
],

jsxOpen: [
Expand All @@ -214,20 +219,20 @@ export const tokenProvider = {
'@default': { token: 'invalid', next: '@pop' },
}
}],
[/(<\/)([a-zA-Z_$][.\w$]*)(>)/, {
[/(<\/)(\s*)([\w$])/, ['delimiter.html', '',
{ token: '@rematch', switchTo: '@jsxIdent.jsxClose.$S2.' },
]],
{ include: 'jsxReady' },
[/./, 'string'],
],

jsxClose: [
[/>/, {
cases: {
'$2==$S2': ['delimiter.html', {
cases: {
'[A-Z].*': 'type.identifier',
'@default': 'constant',
}
}, { token: 'delimiter.html', next: '@pop' }],
'$S2==$S3': { token: 'delimiter.html', next: '@pop' },
'@default': { token: 'invalid', next: '@pop' },
}
}
],
{ include: 'jsxReady' },
[/./, 'string'],
}],
],

whitespace: [
Expand Down

0 comments on commit 6a3782a

Please sign in to comment.