MacRabbit

Itemizers

Itemizers group syntax zones into hierarchical blocks and allow Espresso to provide code folding and a hierarchical representation of the document in the Navigator.

XML syntax

The XML files in your Itemizers folder define your Sugar’s itemizer definitions. Files can be named anything you like, although by convention they are usually named after the syntax they are itemizing (PHP.xml, CSS.xml, etc.).

Itemizers group code blocks into recipes:

<?xml version="1.0"?>
<itemizer>
    <!-- 
Targeting a single selector is the simplest type of itemizer possible -->
    <
recipe name="js.comment">
        <class>
ESCommentItem</class>
        <
selector>js comment</selector>
    </
recipe>
    
    <!-- 
You can also construct more complicated itemizers with start and end selectors -->
    <
recipe name="js.function.anonymous">
        <class>
ESJSAnonymousFunctionItem</class>
        <
start-selector>js function.definition.anonymous brace.round.open brace.round.close brace.curly.open</start-selector>
        <
end-selector>js brace.curly.close</end-selector>
        <
subrecipes>
            <include-
root-recipes/>
        </
subrecipes>
    </
recipe>
    
</
itemizer

The <class> element is optional, and specifies the name of the compiled code classname that will control how your recipe is displayed in the Navigator. Documentation for available class names forthcoming; they are still in flux.

For a simple recipe, the <selector> element is where you specify the syntax zone that represents the itemizer’s content.

For more complicated recipes, <start-selector> and <end-selector> specify the syntax zones that delimit the itemizer. This allows you to construct itemizer recipes for things like groups, tag hierarchies, and similar.

Code folding automatically folds everything except for the start-selector and end-selector to continue to provide context in the code about what is folded.

Note that you can use :has-child() and other niceties of Selectors to get very fine-grained control over your itemizers.

The <subrecipes> element specifies what itemizer recipes will be interpreted inside of this recipe. The special <include-root-recipes> element will include all itemizer recipes or you can define additional recipe elements here that will only be active inside of this recipe.