Skip to content

Commit 6ebfffd

Browse files
committed
Fixes and improvements to string highlighting.
1 parent 89d33f9 commit 6ebfffd

File tree

10 files changed

+396
-171
lines changed

10 files changed

+396
-171
lines changed

grammars/MagicPython.YAML-tmLanguage

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,28 @@ repository:
4343
quote: single
4444
line: single
4545
marker: "\\'"
46+
guard: "|((?<!\\\\)\\n)"
4647

4748
- file: 'pystring.inc.yaml'
4849
vars:
4950
quote: single
5051
line: multi
5152
marker: "\\'\\'\\'"
53+
guard: ""
5254

5355
- file: 'pystring.inc.yaml'
5456
vars:
5557
quote: double
5658
line: single
5759
marker: '\"'
60+
guard: "|((?<!\\\\)\\n)"
5861

5962
- file: 'pystring.inc.yaml'
6063
vars:
6164
quote: double
6265
line: multi
6366
marker: '\"\"\"'
67+
guard: ""
6468

6569
comments:
6670
name: comment.line.number-sign.python
@@ -106,8 +110,8 @@ repository:
106110
- include: '#illegal-anno'
107111
- include: '#comments'
108112
- include: '#literal'
109-
- include: '#string'
110113
- include: '#regexp'
114+
- include: '#string'
111115
- include: '#lambda'
112116
- include: '#operator'
113117
- include: '#curly-braces'
@@ -427,20 +431,38 @@ repository:
427431
[diouxXeEfFgGcrsa%]
428432
429433
string-brace-formatting:
430-
name: constant.character.format.python
431-
match: |
432-
(?x)
433-
(?:
434-
{{ | }}
435-
| (?:
436-
{
437-
[^!:\.\[\]]*? (\.[[:alpha:]_]\w*? | \[[^\]]+\])*?
438-
(![rsa])?
439-
(:\w? [<>=^]? [-+ ]? \#? \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]?)?
440-
})
441-
)
442-
captures:
443-
'2': {name: storage.type.format.python}
434+
patterns:
435+
- name: constant.character.format.python
436+
match: |
437+
(?x)
438+
(?:
439+
{{ | }}
440+
| (?:
441+
{
442+
[^!:\.\[\]'"]*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*?
443+
(![rsa])?
444+
( : \w? [<>=^]? [-+ ]? \#?
445+
\d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )?
446+
})
447+
)
448+
captures:
449+
'2': {name: storage.type.format.python}
450+
'3': {name: support.other.format.python}
451+
- name: constant.character.format.python
452+
begin: |
453+
(?x)
454+
\{
455+
[^!:\.\[\]'"]*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*?
456+
(![rsa])?
457+
(:)
458+
(?=[^'"}\n]*\})
459+
end: \}
460+
beginCaptures:
461+
'2': {name: storage.type.format.python}
462+
'3': {name: support.other.format.python}
463+
patterns:
464+
- match: |
465+
(?x) \{ [^'"}\n]*? \} (?=.*?\})
444466
445467
class-declaration:
446468
patterns:

0 commit comments

Comments
 (0)