1

I need to highlight every whole block of code that is inside curly braces, so I created a rule:

<context id="action-body" style-ref="action-body" extend-parent="true">
   <start>{</start>
   <end>}</end>
   <include>
      <context ref="builtin-vars" />
      <context ref="keywords" />
   </include>
</context>

It highlights code, keywords and vars inside correctly, but it of course stops if there is another closing curly bracket inside. I know that it is not trivial for regular expressions to check level of recursion, but may be gtkSourceView syntax has something special for cases like these?

It is a serious thing, because a language (PegJS, in fact) I am making highlighting for can contain JavaScript code only inside curly braces, not outside. And I want to highlight them with one color exluding :)


Related:

Community
  • 1
  • 1
shaman.sir
  • 3,198
  • 3
  • 28
  • 36

1 Answers1

1

This way (from) highlights ok (gedit goes a little slow when cursor in braces) when such syntax is used on a single line, but not for multi-line:

<context id="action-body" style-ref="action-body">
   <match>(\{(?:[^{}]*|(?0))*\})</match>
   <!-- <include>
      <context ref="builtin-vars"/>
      <context ref="keywords"/>
   </include> -->
</context>

(and it do not allows me to use included contexts, but the spec says I can :( )

Community
  • 1
  • 1
shaman.sir
  • 3,198
  • 3
  • 28
  • 36
  • 2
    The spec only says you can use included contexts in a container context. A container context may contain `` and ``, but not ``. – ptomato Aug 23 '11 at 22:18