ExplicitPatternGroup and word separation

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Joachim Schwieren
Avatar
Hi,

I use a Dynamic Syntax Language to highlight HTML/XML code. I have defined a special state to highlight color names in tag attributes, e.g. <font color="red" id="myid">. So the word "red" is highlighted in another color than the other attributes like "myid" in this example.

Here is how I defined the color names as an ExplicitPatternGroup:

      <PatternGroups>
        <ExplicitPatternGroup TokenKey="ColorNameTokenW3C" TokenID="100">
          <ExplicitPatterns>
            aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal white yellow
          </ExplicitPatterns>
        </ExplicitPatternGroup>
This works fine so far but if I have the following HTML code in the Syntax Editor:

<object id="SilverlightPlugin1" width="300" height="300"
    data="data:application/x-silverlight-2," 
    type="application/x-silverlight-2" >
The word "Silver" in "SilverlightPlugin1" is also highlighted as color. How can I tell my language definition to only treat this as ColorNameTokenW3C when it is not inside another word?

Thanks for your help!

Joe

[Modified at 01/29/2010 04:39 AM]

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Joe,

You should set a LookAhead and maybe also LookBehind attribute on your ExplicitPatternGroup. Both attributes are regex-based so for the LookAhead for example, you could say something like:
LookAhead="{LineTerminatorWhitespaceMacro}* \&quot;"
This says, make sure there is optional whitespace followed by a quote character after the text being scanned. Otherwise, don't match. Similar for LookBehind:
LookAhead="\&quot; {LineTerminatorWhitespaceMacro}*"
Hope that helps.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.