To make the following text a bit more clear the following terms are used:
A syntax highlighting configuration contains a list of highlighters to use. The order in which the highlighters are listed is important, there are a few exceptions.
A configuration starts with a <highlighters> element. Within in element <highlighter> elements are used for each highlighter that needs to be used. In xslthl 1.x there was also the <wholehighlighter> element, but starting from 2.x <highlighter> and <wholehighlighter> are considered to be the same.</wholehighlighter></highlighter></wholehighlighter></highlighter></highlighters>
<highlighters>
<!-- highlighters to use -->
</highlighters>
A <highlighter> element contains a single attribute: type, which defines the highlighter to use. Within the <highlighter> the parameters for the highlighter are defined. Parameters are simply elements often with text content for the value. Some parameters are switches and do not take any parameters. Whitespace is stripped from the text content of the parameters. If whitespace should be preserved in the value, enclose it within a CDATA section.</highlighter></highlighter>
For example <param> text has the value 'text'. And <param><![CDATA[ text ]]> has the value ' text '.
On this page you'll find all known highlighters and the parameters they take.
style: all highlighters accept the style parameter, it defines which style is applied to the highlighted part. The style parameter is absolutely required, however, most highlighters have a default style so it is often not needed to include this parameter unless you want to apply a different style. The style name must be a valid XML name because the style will be used as the name of the element in the return of the highlight function (see processing xslthl results for more information). There are two special style names:
none: the matched part is not highlighted. This can be used to prevent the next highlighter to add a style.
The next few sections will discuss the available highlighters, the italic part in the section name is the name of the highlighter as you can use in the type attribute.
This highlighter is used for highlighting keywords of a language. Keywords start with a letter or underscore, followed by a sequence of letters, numbers, or underscores. A key word is at least 2 characters long.
Default style: keyword
<highlighter type="keyword">
<keyword>begin</keyword>
<keyword>end</keyword>
<keyword>if</keyword>
<keyword>then</keyword>
<keyword>else</keyword>
<ignoreCase />
</highlighter>
This highlighter is used for comments which can span multiple lines. Everything between the start and end is considered to be part of the comment.
Default style: comment
<highlighter type="multiline-comment">
<start>/**</start>
</end>*/<end>
<style>doccomment</style>
</highlighter>
Just like the multiline-comment except that multiline comments can be nested. For example:
/* multine comment
/* nested comment
*/
*/
This is accepted as a while by this highlighter where the normal multiline-comment highlighter will stop at the first occurance of "*/".
Accepts the same parameters as the multiline-comment highlighter.
This highlighter is used for comments that end at a new line.
Default style: comment
#define foo(a,b) \
doStuff(a); \
doStuff(b);
<highlighter type="oneline-comment">
<start>#</start>
<lineBreakEscape>\</lineBreakEscape>
<style>directive</style>
</highlighter>
<highlighter type="oneline-comment">
//
</highlighter>
This highlighter is used for string recognition.
Default style: string
<nowiki>'string with an escape '' character'</nowiki><highlighter type="string">
<string>@"</string>
<endString>"</string>
<escape>\</escape>
<spanNewLines/>
</highlighter>
This highlighter is used for highlighting HEREDOC constructions.
Default style: string
<<-FOO. In this case '-' would be a flag.<highlighter type="heredoc">
<start>&lt;&lt;&lt;</start>
</highlighter>
A highlighter used to recognize annotations (or attributes as they are called in .NET).
Default style: annotation
<highlighter type="annotation">
<start>[</start>
<end>]</end>
<valueStart>(</valueStart>
<valueEnd>)</valueEnd>
</highlighter>
A highlighter that recognizes arbitrary words. It behaves much like the keyword highlighter except that it does not enforce any rules on the content of the word, even embedded white space is allowed (but not leading and trailing). This highlighter is quite slow because each entry in the list of words is evaluated with the current buffer. So avoid this highlighter when possible.
Default style: none
<highlighter type="word">
<word>&lt;?php</word>
<word>&lt;?=</word>
<word>?&gt;</word>
<style>directive</style>
</highlighter>
Performs highlighting based on regular expressions. In the 1.x branch of xslthl this was a so called "whole highlighter". Starting from version 2.0.0 beta 2 this highlighter is a normal highlighter. This means that it follows the normal ordering guidelines for highlighters.
Default style: none
<highlighter type="regex">
<pattern>^(.+)(?==)</pattern>
<flags>MULTILINE</flags>
<style>attribute</style>
</highlighter>
A highlighter that recognizes numbers, this includes integers and floating points (depending on the settings). Only the characters between 0 and 9 are considered to be numbers. There are not other special requirements or limitations. For example 0123 is usually an octal, this is simply recognized.
Default style: number
123kg will not be seen as a number. This was the default before version 2.1<highlighter type="number">
<point>.</point>
<pointStarts />
<exponent>e</exponent>
<suffix>ul</suffix>
<suffix>lu</suffix>
<suffix>u</suffix>
<suffix>f</suffix>
<suffix>l</suffix>
<ignoreCase />
</highlighter>
A subclass of the number highlighter. It works exactly the same except that it recognizes the characters 0 to 9 and A to F as numbers (case insensitive).
<highlighter type="hexnumber">
<prefix>0x</prefix>
<suffix>ul</suffix>
<suffix>lu</suffix>
<suffix>u</suffix>
<suffix>l</suffix>
<ignoreCase />
</highlighter>
The XML highlighter is a special highlighter. It is executed separately from the all other highlighters (and the very end). The XML highlighter recognizes both XML and SGML syntax, in fact it does not require well formed content.
This highlighter assigns the following styles to the following XML/SGML elements:
CDATA sections are also recognized. CDATA tags will be highlighted as tag, the actual content will not be highlighted.
The style parameter is not used for this highlighter.
elementSet: allows you to override the style for certain elements based on their name. This parameter contains 3 sub-parameters:
element: the name of an element, can be used multiple times
ignoreCase: a switch, when set the tag names are case insensitive, useful in case of HTML tags
elementPrefix: allows you to override the style for certain elements based on their prefix. This paremeter contains two sub-parameters:
prefix: the prefix of an element
<highlighter type="xml">
<elementPrefix>
<style>xslt</style>
<prefix>xsl:</prefix>
<prefix>xslt:</prefix>
</elementPrefix>
</highlighter>
Additional highlighters can be loaded via plugin mechanism. For example:
<highlighter type="java:net.sf.xslthl.plugins.AltOnelineComment" classpath="plugins/plugins.jar">##</highlighter>
For an example implementation see: http://xslthl.svn.sourceforge.net/viewvc/xslthl/trunk/xslthl/examples/sources/plugins/