mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
editor/pybricksMicroPython: improve f-string highlighting
Fixes: https://github.com/pybricks/support/issues/875
This commit is contained in:
committed by
David Lechner
parent
5bef7e2637
commit
43a6f63eaf
@@ -229,9 +229,43 @@ export const language = <monaco.languages.IMonarchLanguage>{
|
||||
// Recognize strings, including those broken across lines with \ (but not without)
|
||||
strings: [
|
||||
[/'$/, 'string.escape', '@popall'],
|
||||
[/'/, 'string.escape', '@stringBody'],
|
||||
[/([fF]|[fF][rR]|[rR][fF])?'/, 'string.escape', '@fStringBody'],
|
||||
[/[rRuUbB]?'/, 'string.escape', '@stringBody'],
|
||||
[/"$/, 'string.escape', '@popall'],
|
||||
[/"/, 'string.escape', '@dblStringBody'],
|
||||
[/([fF]|[fF][rR]|[rR][fF])?"/, 'string.escape', '@dblFStringBody'],
|
||||
[/[rRuUbB]?"/, 'string.escape', '@dblStringBody'],
|
||||
],
|
||||
fStringBody: [
|
||||
[/([^\\'{}]|\{\{|\}\}(?!\}[^}]))+$/, 'string', '@popall'],
|
||||
[/([^\\'{}]|\{\{|\}\}(?!\}[^}]))+/, 'string'],
|
||||
[/\\./, 'string'],
|
||||
[/'/, 'string.escape', '@popall'],
|
||||
[/\\$/, 'string'],
|
||||
[
|
||||
/\{/,
|
||||
{
|
||||
token: 'delimiter.curly',
|
||||
next: '@fStringReplacement',
|
||||
nextEmbedded: pybricksMicroPythonId,
|
||||
},
|
||||
],
|
||||
[/\}/, 'delimiter.curly'],
|
||||
],
|
||||
dblFStringBody: [
|
||||
[/([^\\"{}]|\{\{|\}\}(?!\}[^}]))+$/, 'string', '@popall'],
|
||||
[/([^\\"{}]|\{\{|\}\}(?!\}[^}]))+/, 'string'],
|
||||
[/\\./, 'string'],
|
||||
[/"/, 'string.escape', '@popall'],
|
||||
[/\\$/, 'string'],
|
||||
[
|
||||
/\{/,
|
||||
{
|
||||
token: 'delimiter.curly',
|
||||
next: '@fStringReplacement',
|
||||
nextEmbedded: pybricksMicroPythonId,
|
||||
},
|
||||
],
|
||||
[/\}/, 'delimiter.curly'],
|
||||
],
|
||||
stringBody: [
|
||||
[/[^\\']+$/, 'string', '@popall'],
|
||||
@@ -247,6 +281,9 @@ export const language = <monaco.languages.IMonarchLanguage>{
|
||||
[/"/, 'string.escape', '@popall'],
|
||||
[/\\$/, 'string'],
|
||||
],
|
||||
fStringReplacement: [
|
||||
[/\}/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
|
||||
],
|
||||
|
||||
operators: [
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user