升华文本语法:Python 3.6 f-strings

升华文本语法:Python 3.6 f-strings,python,syntax,sublimetext3,syntax-highlighting,Python,Syntax,Sublimetext3,Syntax Highlighting,我正在尝试修改默认的Python.sublime_语法文件,以正确处理Python的f-string文本。我的目标是使插值字符串中的表达式被识别为: f"hello {person.name if person else 'there'}" -----------source.python---------- ------string.quoted.double.block.python------ 在f字符串中,单个{和另一个}之间的文本范围(但在格式说明符之前终止,例如!

我正在尝试修改默认的
Python.sublime_语法文件,以正确处理Python的f-string文本。我的目标是使插值字符串中的表达式被识别为:

f"hello {person.name if person else 'there'}"
         -----------source.python----------
------string.quoted.double.block.python------

在f字符串中,单个
{
和另一个
}
之间的文本范围(但在格式说明符之前终止,例如
!r}
:在构建3127中对语法突出显示进行了更新(其中包括:对Python语法突出显示的重大改进)

但是,一些用户表示,在构建3176中,语法高亮显示仍然没有设置为正确高亮显示位于f字符串中的Python表达式。根据@Jollywatt,它被设置为source.Python
f“string.quoted.double.block{constant.other.placeholder}”
,而不是
f”string.quoted.double.block{source.python}“


看起来升华使用了这个工具,“简化了为升华文本创建代码段、语法定义等。”

使用regex调试器,例如可能有助于解析日志regex模式现在在
Build 3127
中已修复,但实际上这似乎不是“修复”的。在Build 3176中,Python仍然被解释为
source.Python f“string.quoted.double.block{constant.other.placeholder}”
,而不是
source.Python f“string.quoted.double.block{source.python}”“
。我不知道后一种行为到底是否应该是理想的行为…@Jollywatt这可能是一个比我更好的答案。如果你想添加这些信息,我将答案切换到了一个社区wiki。我也在使用Build 3176,与Atom Editor不同,我在f字符串中没有看到任何普通Python语法高亮显示。
...
string:
 - match: "(?<=[^\{]\{)[^\{].*)(?=(!(s|r|a))?(:.*)?\})" # I'll need a better regex
   push: expressions