This patch only works with patch [#122]. It augments the Python syntax highlighting to hightlight f-strings nicely. It handles nesting of f-strings and escapes and raw strings and all that. Try using it to hightlight the following:
x=2 print( f"""\\\{{{f'{{x}}=={ {x} }'}}}""") print(rf"""\\\{{{f'{{x}}=={ {x} }'}}}""") print( f"""\\\{{{f'{{f"{{x:02}}"}}=={ {f"{x:02}"} }'}}}""") # Output: # \\{{x}=={2}} # \\\{{x}=={2}} # \\{{f"{x:02}"}=={'02'}} # Syntax errors: f' { ' f' } '
Oops! I accidentally still had the call transitions call "pythonf()" instead of "python()".
Also, I added support for formatting options after the fstring expressions (following a ":") and highlight them as "Constant".
I'm uploading a new "fstrings.patch". I don't know if that overwrites the first one or creates a new entry, and if the latter, how you distinguish them. If it's unclear at all, I'll upload a patch with a different name.
Here's a new example, now with nested formatting options: