Domanda

Does anyone know if there is a way to specify overlapping patterns in a GtkSourceView 3 XML language file? For example, in the text below, is there a way to highlight "some text..." between foo and bar in one color and "some more text..." between bar and baz in another color? The problem here is that bar is the end of one context and also the start of another, which means that the bar-baz context will never apply.

foo
some text...
bar
some more text...
baz
È stato utile?

Soluzione

I found a solution. The bar section can be included in the foo section:

<context id="bar" style-ref="bar" style-inside="true" extend-parent="false">
   <start>^bar\b</start>
</context>

<context id="foo" style-ref="foo" style-inside="true">
   <start>^foo\b</start>
   <end>^baz\b</end>
   <include>
      <context ref="bar"/>
   </include>
</context>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top