summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2019-11-26 06:53:00 +0100
committerGeorg Brandl <georg@python.org>2019-11-26 06:53:00 +0100
commit731339d7654fa69d3eaa5ebe2a1d29b1cee6724e (patch)
tree9df0a0f926663324a8100c70a911beab7fef71b0
parent03328cedc35d2d59f3560a35f61add9eb0954f9f (diff)
downloadpygments-git-731339d7654fa69d3eaa5ebe2a1d29b1cee6724e.tar.gz
Python: recognize "f" string prefix
Fixes #1156
-rw-r--r--CHANGES1
-rw-r--r--pygments/lexers/python.py18
2 files changed, 11 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 568392f7..5aa72f03 100644
--- a/CHANGES
+++ b/CHANGES
@@ -58,6 +58,7 @@ Version 2.5.0
- Velocity: support silent reference syntax
- Agda: fix lambda highlighting
- Python: recognize ``.jy`` filenames (#976)
+- Python: recogniez ``f`` string prefix (#1156)
- Shell sessions: recognize Virtualenv prompt (PR#1266)
- Image formatter: actually respect ``line_number_separator`` option
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index 348d911c..5f700e7f 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -110,21 +110,23 @@ class PythonLexer(RegexLexer):
include('builtins'),
include('magicfuncs'),
include('magicvars'),
- ('([rR]|[uUbB][rR]|[rR][uUbB])(""")',
+ # raw strings
+ ('(?i)(rb|br|fr|rf|r)(""")',
bygroups(String.Affix, String.Double), 'tdqs'),
- ("([rR]|[uUbB][rR]|[rR][uUbB])(''')",
+ ("(?i)(rb|br|fr|rf|r)(''')",
bygroups(String.Affix, String.Single), 'tsqs'),
- ('([rR]|[uUbB][rR]|[rR][uUbB])(")',
+ ('(?i)(rb|br|fr|rf|r)(")',
bygroups(String.Affix, String.Double), 'dqs'),
- ("([rR]|[uUbB][rR]|[rR][uUbB])(')",
+ ("(?i)(rb|br|fr|rf|r)(')",
bygroups(String.Affix, String.Single), 'sqs'),
- ('([uUbB]?)(""")', bygroups(String.Affix, String.Double),
+ # non-raw strings
+ ('([uUbBfF]?)(""")', bygroups(String.Affix, String.Double),
combined('stringescape', 'tdqs')),
- ("([uUbB]?)(''')", bygroups(String.Affix, String.Single),
+ ("([uUbBfF]?)(''')", bygroups(String.Affix, String.Single),
combined('stringescape', 'tsqs')),
- ('([uUbB]?)(")', bygroups(String.Affix, String.Double),
+ ('([uUbBfF]?)(")', bygroups(String.Affix, String.Double),
combined('stringescape', 'dqs')),
- ("([uUbB]?)(')", bygroups(String.Affix, String.Single),
+ ("([uUbBfF]?)(')", bygroups(String.Affix, String.Single),
combined('stringescape', 'sqs')),
include('name'),
include('numbers'),