Creating a rule XML file

The rules that ChromaCode uses to decide what words, characters, groups etc are highlighted is contained within an XML file.

The following rules can be defined. Click on each one to find out more information abot that particular type of rule:
The following is an example of an XML file that contains all possible rule definitions showing how the file is constructed:

<?xml version="1.0" encoding="utf-8" ?>
<rules>
  <!--These rules will be applied to key words. These rules are applied first-->
  <wordRules>
    <rule acitve="true" bold="false" underline="true" italic="true" color="blue">
      <words>
        <!--space seperated list of words-->
        <![CDATA[the quick brown fox jumped over the lazy dog]]>
      </words>
    </rule>
  </wordRules>

  <!--These rules will be applied to individual characters. These rules are applied second-->
  <characterRules>
    <rule active="true" color="red">
      <characters>
        <!--space seperated list of chars-->
        <![CDATA[+ - / * =]]>
      </characters>
    </rule>

    <rule active="true" color="lightblue">
      <characters>
        <!--space seperated list of chars-->
        <![CDATA[( ) [ ] { }]]>
      </characters>
    </rule>
  </characterRules>

  <!--These rules will be applied according to a regular expression search string. These rules will be applied thrid-->
  <!--Having too many regular expression rules may hurt perfomance in large documents-->
  <regExpRules>
    <rule active="true" bold="true">
      <regExp>
        <![CDATA[\b(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2}\b]]>
      </regExp>
    </rule>
  </regExpRules>

  <!--These rules are applied to all text between the start and ending strings, or the starting string and the end of a line
  if the end string is blank. These rules are applied last of all-->
  <groupRules>
    <rule active="true" color="green" startString="/*" endString="*/"/>
    <rule active="true" color="darkred" startString="'" endString="'" />
    <rule active="true" color="green" startString="--" />
  </groupRules>
</rules>

Last edited May 3, 2011 at 9:44 PM by NybbleUK, version 1

Comments

No comments yet.