Literal highlighting only within brackets?
Brought to you by:
marcel-boehme,
oliverhe
Hello,
I wonder if it is possible to restrict literal
highlighting to
space between brackets.
I tried to solve my problem with reg-expressions but it
did not work.
example:
In the following lines I want to apply the literal
highlighting
within the brackets
options = ('option1 ', 'option2 ', 'option3 ', parameter)
matrix = [ 'foo1' ; 'foo2' ]
But not in lines like this:
result = a'*b/c'
Does anybody has an idea how to solve that problem?
Is there a simple way to apply literal highlighting only
within brackets? To nest span rules?
Thanks a lot
More than six years later I can respond to the issue. :-)
This is just for documentation.
The following rules provides literal highlighting only within brackets:
<RULES>
<SPAN TYPE="NULL" DELEGATE="LISTS">
<BEGIN>(</BEGIN>
<END>)</END>
</SPAN>
<SPAN TYPE="NULL" DELEGATE="LISTS">
<BEGIN>[</BEGIN>
<END>]</END>
</SPAN>
</RULES>
<RULES SET="LISTS">
<SPAN TYPE="LITERAL1">
<BEGIN>'</BEGIN>
<END>'</END>
</SPAN>
</RULES>
However, to properly distinguish lists (with brackets) from mathematical expression (with brackets), some reg-exp magic is required.
The following simple RULE-set achives the same in a more robust way.
The idea behind the RULE-set is to exploit the fact that if the '-sign is an operator then it has to follow directly after an alpha-numerical character (also called "word character").
In order to achieve the desired effect one has to consider the ordering of the rules - and make sure that the '-sign is not highlighted in case it is an operator (i.e. it follows directly after a word-character).
<RULES>
<SEQ_REGEXP TYPE="NULL">\w'</SEQ_REGEXP>
<SPAN TYPE="LITERAL1">
<BEGIN>'</BEGIN>
<END>'</END>
</SPAN>
</RULES>