开发者

AvalonEdit XSHD-Ruleset (for tex)

开发者 https://www.devze.com 2023-01-24 18:17 出处:网络
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 (glea

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 开发者_JS百科... 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 > ?


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:

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

精彩评论

暂无评论...
验证码 换一张
取 消