区分 Textmate 中 Python 字符串与 Docstrings 的语法颜色?

发布于 2024-12-02 04:01:15 字数 349 浏览 7 评论 0原文

喜欢 TextMate,喜欢 Python,blah,blah,blah..

但是......我讨厌“Docstrings”,又名多行注释/Sphinx 的爱子 - 在语法上是彩色的 - 在在我前面提到的选择的编辑器中,与普通“字符串”的方式相同。这是两种类型的过度匹配服装的示例...

VISUAL AMBIGUITY lurking in python stringtypes in textmate

这种轻微的不便是否可以被正则表达式消除 - 以便在视觉上更轻松地区分两者?

Love TextMate, love Python, blah, blah, blah..

But.. i hate that "Docstrings", aka multiline-comments / Sphinx's lovechild - are colored syntactically - in the same manner as normal "Strings", in my aforementioned editor of choice. Here is an example of the two types in their overly matchy-matchy outfits...

VISUAL AMBIGUITY lurking in python stringtypes in textmate

Can this slight inconvenience be regexed-away - so as to differentiate the two more easily, visually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷→糖丶微凉 2024-12-09 04:01:15

如果您查看 Python 包的语言部分的第 560-1064 行,您将找到字符串的定义。简而言之,您可以找到三引号字符串的模式,并向捕获名称添加另一个组件。然后您需要做的就是将该捕获名称添加到当前样式中,然后三引号字符串应该具有不同的颜色。

If you look at lines 560-1064 of the language part of the Python bundle, you'll find the definitions for strings. Simply, you'd find the patterns for the triple-quote strings and add another component to the capture names. Then all you need to do is add that capture name to your current style and then triple-quote strings should be colored differently.

浪漫人生路 2024-12-09 04:01:15

将其添加到主题文件的代码中,以使文档字符串看起来与常规字符串不同。

    {   name = 'Pyton: Docstring';
        scope = 'string.quoted.double.block.python';
        settings = {
            foreground = '#A7C3CC’; //change color to your preference
            fontstyle = '';
        };
    },

如果您需要 XML 版本,就是:

<dict>
    <key>name</key>
    <string>Python: docstring</string>
    <key>scope</key>
    <string>string.quoted.double.block.python</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string/>
        <key>foreground</key>
        <!-- change color to your preference -->
        <string>#A7C3CC</string>
    </dict>
</dict>

Add this to code to your theme file to make doc strings appear different from regular strings.

    {   name = 'Pyton: Docstring';
        scope = 'string.quoted.double.block.python';
        settings = {
            foreground = '#A7C3CC’; //change color to your preference
            fontstyle = '';
        };
    },

If you need the XML version this is it:

<dict>
    <key>name</key>
    <string>Python: docstring</string>
    <key>scope</key>
    <string>string.quoted.double.block.python</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string/>
        <key>foreground</key>
        <!-- change color to your preference -->
        <string>#A7C3CC</string>
    </dict>
</dict>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文