Snippet Script Format

The snippet script INI file format allows you to define the automation of snippet insertion.

The snippet script is an INI format file named snippetscript.ini. It contains one “SnipMap” section, which defines an association between each snippet insertion description and the element/attribute. For each entry in the SnipMap section is an additional section named using the key from the SnipMap.

The syntax of each SnipMap entry is as follows:

<snipDescriptor>=<elemSelector>

Where:

<snipDescriptor>

An alpha-numeric name.

<elemSelector>

An XPath-like description of the element to process. This value specifies both an element name and attribute value as follows:

<elemName>/@<attrName>='<attrValue>'

Where:

  • <elemName> - a valid element name or “*” (for any element)

  • <attrName> - a valid attribute name (no wild cards)

  • <attrValue> - the attribute value to match (full string). (Let us know if a substring match would be useful here.)

Each snippet descriptor section contains the following keys:

SnipName

The name of the snippet

SnipType

“Local” or “Remote”

InsertElem

The name of the element being inserted by the snippet

InsertType

The action to preform on insertion. Valid values are “Replace”, “Before”, or “After”. Refer to the documentation for information on use of the “%:SEL:%” code in a snippet to specify the location where the selected content is used.

The following is a sample snippet script that applies two snippets, snip1 and snip2. The snip1 descriptor applies a snippet called “notetable” which is a <simpletable> element applied to note elements that have no value assigned to the @type attribute. The snip2 descriptor applies a snippet called “admin-flag” which is a <p> element inserted before all elements that have the @audience attribute set to “admin”.

[SnipMap] 
snip1=note/@type='' 
snip2=*/@audience='admin' 
 
[snip1] 
SnipName=notetable 
SnipType=Local 
InsertElem=simpletable 
InsertType=Replace 
 
[snip2] 
SnipName=admin-flag 
SnipType=Local 
InsertElem=p 
InsertType=Before