Avalon Edit Highlighting within Highlighting

Issue

With Avalon Edit, I’m looking for a way to provide a highlighting format while inside something that is already formatted.

That is, I’d like to highlight thing inside quotes, but within those quotes I have another syntax that can be added that starts with ${ and ends with }.

By default, it seems that the syntax highlighting stops once it enters a ‘begin’ and doesn’t look for any others until the end is reached.

<Span color="ParamName">
  <Begin>"</Begin>
  <End>(?=:)</End>
</Span>
<Span color="Variable" multiline="false">
  <Begin>\${</Begin>
  <End>}</End>
</Span>

So here the ${ syntax is only colorized if it is not within a ParamName ("). is there a way to allow my Variable highlighting to work even if it is in a ParamName (yes ParamName is from JSON formatting, I’d like my highlighting to work no matter where it shows in the JSON syntax)?

Full Highlighter code:

<Keywords color="Digits" >
  <Word>true</Word>
  <Word>false</Word>
</Keywords>

<Span color="Value" multiline="true">
  <Begin>
    (?&lt;=:)\040?"[^"]*
  </Begin>
  <End>"</End>
</Span>
<Span color="ParamName">
  <Begin>"</Begin>
  <End>(?=:)</End>
</Span>
<Span color="Variable" multiline="false">
  <Begin>\${</Begin>
  <End>}</End>
</Span>
<Rule color="Digits">\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?</Rule>

Solution

A <Span> switches to another <RuleSet> that is active within the span. By default, that’s an empty rule set, so nothing else is active.

If you want a rule to apply within a span, move it to the nested ruleset:

<Span color="ParamName">
  <Begin>"</Begin>
  <End>(?=:)</End>

  <RuleSet>
    <Span color="Variable" multiline="false">
     <Begin>\${</Begin>
     <End>}</End>
    </Span>
  </RuleSet>
</Span>

Answered By – Daniel

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.