AvalonEdit XSHD-规则集(对于 tex)
我正在使用 AvalonEdit 控件,并且 xshd 规则集(对于 tex)有一个小问题:
原始文件“Mike Krueger 的 TeX 文档 2001 的语法定义(从 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条目处理。 << MarkFollowing ... 不用于“\\”,而是用于 < Span ...仍在对“\$”和“\%”进行突出显示。
我找到了,
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>
但它不起作用。 ..也许有问题,因为转义字符是
I'm using the AvalonEdit control in and I have a small problem with the xshd-ruleset (for tex):
There is a section in the original file 'syntaxdefinition for TeX document 2001 by Mike Krueger (gleaned from Jedit)' about special keywords and I'm wondering how to use them right.
<!-- some commands must be handled specially -->
<KeyWords name = "Keyword1" bold = "false" italic = "false" color = "Blue">
<Key word = "\$" />
<Key word = "\\" />
<Key word = "\%" />
</KeyWords>
I though that keywords will be colored blue and are handled only by this, but other rules are handling parts these keywords, too. e.g.
<Span name = "LineComment" color = "SlateGray" stopateol = "true">
<Begin>%</Begin>
</Span>
So if you have "\%" in your text everything beyond the '\' will be colored gray...
It would be very nice, if that keywords forbid the rules e.g. for '$' and '%' if there is a '\' before.
What I have to do? Or didn't I understand the rulesets...
EDIT:
"\\" is handled by the keyword1 entry. The < MarkFollowing ... is not used for "\\" but the < Span ... are still doing its highlighting for "\$" and "\%".
I found
escapecharacter="\"
but it's not working.
EDIT2:
With the new syntax highlighting definition the problem is the same I think. I compared my tex highlighting with the c# highlighting. In c# we have:
<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
</RuleSet>
</Span>
I don't use sharpdevelop, but I think it's working, that the highlighting doesn't fail, if I'm escaping characters like ". So in my file it's similar to that, like
<Span foreground="#FF708090" fontWeight="normal" fontStyle="italic">
<Begin>%</Begin>
<RuleSet>
<Span begin="\\" end="." />
</RuleSet>
</Span>
but it's not working... Maybe there is a problem, because the escape-character is a < Rule > ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将文件移植为新格式,请参阅 http://community.sharpdevelop .net/forums/p/10468/28886.aspx#28886 了解详细信息。
在新格式中,您可以在规则中使用正则表达式,这应该比尝试使用 keywords/MarkFollowing 伪造 TeX 结构要好得多。
在你的 EDIT2 上:
如果您希望 \ 成为 TeX 代码内的转义序列(在注释前面,而不是作为字符串/注释内的转义符号),则在主规则集中使用转义范围:
Try porting the file to the new format, see http://community.sharpdevelop.net/forums/p/10468/28886.aspx#28886 for details.
In the new format, you can use regular expression in rules, which should work a lot better than trying to fake TeX constructs using Keywords/MarkFollowing.
On your EDIT2:
If you want the \ to be an escape sequence inside TeX code (in front of the comment, as opposed to being an escape symbol inside the string/comment), then use the escaping span inside the main ruleset: