gpt4 book ai didi

textmate - 如何在 TextMate 中为 Markdown 启用代码折叠?

转载 作者:行者123 更新时间:2023-12-04 06:35:56 28 4
gpt4 key购买 nike

我想在 textmate 中为 markdown 启用代码折叠。

具体来说,我希望任何标题(前面有一个或多个“#”字符的文本)成为在它与下一个标题和/或水平线之间切换块的行。例子:

# Level 1 Heading - I'd like the block below to fold

The text I'd like to fold away

## Level 2 Heading

More text...

BBEdit 似乎可以很好地进行 Markdown 。 TextMate 支持代码折叠,非常适合用成对(和相同缩进)花括号表示块的语言。

我知道 TextMate 提供了两个您可以在语言语法文件中设置的变量,但是我需要更多的正则表达式人才来弄清楚它。以下是代码折叠设置当前驻留在 Markdown 语言语法中的内容:
foldingStartMarker = '(?x)
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?>
|<!--(?!.*-->)
|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/)))
)';
foldingStopMarker = '(?x)
(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)>
|^\s*-->
|(^|\s)\}
)';

非常感谢任何帮助!

最佳答案

TextMate 完全无法做到这一点。

TextMate 的语言解析器逐行读取文件。这意味着为了折叠代码,需要一个开始标记和一个结束标记。赞 <ul></ul> .在这种情况下,由于除了下一部分的开头之外没有其他任何东西标记节的结尾,逐行解析器不能返回并说空行应该标记代码折叠块的结尾。

那有意义吗?

关于textmate - 如何在 TextMate 中为 Markdown 启用代码折叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4880484/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com