summaryrefslogtreecommitdiff
path: root/pygments/lexers/python.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/python.py')
-rw-r--r--pygments/lexers/python.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index f995d36f..8a9b7239 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -122,13 +122,17 @@ class PythonLexer(RegexLexer):
'expr': [
# raw f-strings
('(?i)(rf|fr)(""")',
- bygroups(String.Affix, String.Double), 'tdqf'),
+ bygroups(String.Affix, String.Double),
+ combined('rfstringescape', 'tdqf')),
("(?i)(rf|fr)(''')",
- bygroups(String.Affix, String.Single), 'tsqf'),
+ bygroups(String.Affix, String.Single),
+ combined('rfstringescape', 'tsqf')),
('(?i)(rf|fr)(")',
- bygroups(String.Affix, String.Double), 'dqf'),
+ bygroups(String.Affix, String.Double),
+ combined('rfstringescape', 'dqf')),
("(?i)(rf|fr)(')",
- bygroups(String.Affix, String.Single), 'sqf'),
+ bygroups(String.Affix, String.Single),
+ combined('rfstringescape', 'sqf')),
# non-raw f-strings
('([fF])(""")', bygroups(String.Affix, String.Double),
combined('fstringescape', 'tdqf')),
@@ -316,9 +320,12 @@ class PythonLexer(RegexLexer):
(uni_name, Name.Namespace),
default('#pop'),
],
- 'fstringescape': [
+ 'rfstringescape': [
(r'\{\{', String.Escape),
(r'\}\}', String.Escape),
+ ],
+ 'fstringescape': [
+ include('rfstringescape'),
include('stringescape'),
],
'stringescape': [