Colorizer File Format details

Contents

Contributed colorization format

<!-- this example will show how the colorization used for a subset of CSS -->
<colorizer
    xmlns="http://www.aptana.com/2007/colorizer/1.0"
    language="text/css">

    <group name="default">

        <!-- declare default token colorization for all categories -->
        <token type="*" category="literal" style="literal_default" />
        <token type="*" category="whitespace" style="ws_default" />
        <token type="*" category="keyword" style="literal_default" />
        <token type="*" category="punctuator" style="punct_default" />
        <token type="*" category="error" style="red_style" />

        <!-- declare all keywords that start with '@' have different style for @ symbol -->
        <token type="*" category="keyword" >
                <subtoken type="at" style="at_style" />
        </token>
        
        <!-- declare angle tokens have different styling for angle suffix (e.g deg,rad,grad) -->
        <token type="time" category="literal" >
                <subtoken type="time_suffix" style="time_style" />
        </token>
        
        <!-- declare quoted string to have their first and last character (quotes) colored differently -->
        <token type="string" category="literal" >
                <region offset="0" length="1" style="quote" />
                <region offset="-1" length="-1" style="quote" />
        </token>
        
        <!-- style integers -->
        <token type="integer" category="literal" style="int_style" />
        
        <!-- style floating point number with different styling for left of decimal, right of decimal, and decimal itself -->
        <token type="floating_point" category=literal" >
                <subtoken type="int" index="0" style="leftside_int" />
                <subtoken type="point" style="punct_default" />
                <sbutoken type="int" index="1" style="rightside_int" />
        </token>
        
        <!-- declare styles used -->
        <style id="punct_default"
              foreground="rgb(0,255,0)"
              background="rgb(100,0,100)"
        <style id="ws_default"
              foreground="rgb(255,255,255)"
              background="rgb(255,255,255)" />
        <style id="red_style"
              foreground="rgb(255,0,0)"
              background="rgb(255,255,255)" />
        <style id="leftside_int"
              foreground="rgb(255,255,255)"
              background="rgb(0,0,255)" />
        <style id="rightside_int"
              foreground="rgb(255,255,255)"
              background="rgb(0,255,0)" />
        <style id="literal_default"
              foreground="rgb(100,200,100)"
              background="rgb(0,0,0)" />
        <style id="quote"
              foreground="rgb(0,0,200)"
              background="rgb(200,200,0)"
              font-weight="bold" />
        <style id="time_style"
              foreground="rgb(0,0,0)"
              background="rgb(255,0,255)"
              font-style="italic" />
        <style id="at_style"
              foreground="rgb(0,0,255)"
              background="rgb(255,255,0)"
              font-weight="bold" />
        
    </group>
</colorizer>

This file would generate the following code colorization:

Image:Colorization_sample.jpg

Common Colorization patterns

Matcher Documentation

File Format

Elements

Note that all matcher elements may include an optional type and category attribute. Any matcher that contains these attributes will emit a token for the given category/type pair. The category value is inheritable which allows, for example, a category group element to define a category for all its descendent matchers while allowing each descendant matcher to define its own type. A matcher may override the inherited category value simply by defining its own category attribute.

In addition to the type and category attributes, matchers also include the name attribute. When the given element matches successfully, the matched text will be associated with the matcher's name. These name/value pairs are stored at the group level allowing all matchers to provide and consume names and values within their group. If two matchers define that same name attribute, then the last successfully matching matcher's value will overwrite any preceding values. Values may be referenced via the UseElement. This allows for matcher definitions to be redefined based on matches ocurring at runtime.