diff options
author | Georg Brandl <georg@python.org> | 2019-11-26 06:53:00 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2019-11-26 06:53:00 +0100 |
commit | 731339d7654fa69d3eaa5ebe2a1d29b1cee6724e (patch) | |
tree | 9df0a0f926663324a8100c70a911beab7fef71b0 /pygments/lexers/python.py | |
parent | 03328cedc35d2d59f3560a35f61add9eb0954f9f (diff) | |
download | pygments-git-731339d7654fa69d3eaa5ebe2a1d29b1cee6724e.tar.gz |
Python: recognize "f" string prefix
Fixes #1156
Diffstat (limited to 'pygments/lexers/python.py')
-rw-r--r-- | pygments/lexers/python.py | 18 |
1 files changed, 10 insertions, 8 deletions
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'), |