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 | |
parent | 03328cedc35d2d59f3560a35f61add9eb0954f9f (diff) | |
download | pygments-git-731339d7654fa69d3eaa5ebe2a1d29b1cee6724e.tar.gz |
Python: recognize "f" string prefix
Fixes #1156
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | pygments/lexers/python.py | 18 |
2 files changed, 11 insertions, 8 deletions
@@ -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'), |