【问题标题】:AvalonEdit XSHD-Ruleset (for tex)AvalonEdit XSHD-Ruleset (for tex)
【发布时间】:2011-05-07 06:53:50
【问题描述】:

我正在使用 AvalonEdit 控件,但我对 xshd-ruleset (for tex) 有一个小问题:

在原始文件 'syntaxdefinition for TeX document 2001 by Mike Krueger(从 Jedit 中收集)'中有一个关于特殊关键字的部分,我想知道如何正确使用它们。

  <!-- some commands must be handled specially -->
  <KeyWords name = "Keyword1" bold = "false" italic = "false" color = "Blue">
    <Key word = "\$" />
    <Key word = "\\" />
    <Key word = "\%" />
  </KeyWords>

虽然关键字将被涂成蓝色并且仅由它处理,但其他规则也在处理这些关键字的一部分。例如

  <Span name = "LineComment" color = "SlateGray" stopateol = "true">
    <Begin>%</Begin>
  </Span>

因此,如果您的文本中有“\%”,则“\”之外的所有内容都将变为灰色...

如果关键字禁止规则,那就太好了,例如'$' 和 '%' 如果前面有 '\'。

我必须做什么?还是我没看懂规则集...

编辑

"\\" 由keyword1 条目处理。

我找到了

  escapecharacter="\"

但它不起作用。

EDIT2

有了新的语法高亮定义,我认为问题是一样的。我将我的 tex 突出显示与 c# 突出显示进行了比较。在 c# 中,我们有:

<Span color="String">
    <Begin>"</Begin>
    <End>"</End>
    <RuleSet>
         <!-- span for escape sequences -->
         <Span begin="\\" end="."/>
    </RuleSet>
</Span>

我不使用sharpdevelop,但我认为它可以正常工作,如果我要转义“”之类的字符,突出显示不会失败。所以在我的文件中它类似于

<Span foreground="#FF708090" fontWeight="normal" fontStyle="italic">
    <Begin>%</Begin>
    <RuleSet>
        <Span begin="\\" end="." />
    </RuleSet>
</Span>

但它不起作用...也许有问题,因为转义字符是

【问题讨论】:

    标签: avalonedit


    【解决方案1】:

    尝试将文件移植到新格式,详情请参阅http://community.sharpdevelop.net/forums/p/10468/28886.aspx#28886

    在新格式中,您可以在规则中使用正则表达式,这应该比尝试使用关键字/MarkFollowing 伪造 TeX 构造更好。

    在您的 EDIT2 上: 如果您希望 \ 成为 TeX 代码中的转义序列(在注释前面,而不是作为字符串/注释中的转义符号),则在主规则集中使用转义范围:

    <Span begin="\\" end="."/>
    <Span foreground="#FF708090" fontWeight="normal" fontStyle="italic">
        <Begin>%</Begin>
    </Span>
    

    【讨论】:

    • 谢谢。现在我正在使用新的 xshd 文件,但我知道如何解决我的问题...
    猜你喜欢
    • 1970-01-01
    • 2016-01-22
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多