Code coloring examples
The following code coloring examples illustrate the code coloring schemes for a cascading style document and a JavaScript document. The lists of keywords in the JavaScript example are abbreviated for the sake of keeping the example short.
CSS code coloring
<scheme name="CSS" id="CSS" doctypes="CSS" priority="50"> <ignoreCase>Yes</ignoreCase> <ignoreTags>Yes</ignoreTags> <blockStart doctypes="ASP-JS,ASP-VB,ASP.NET_CSharp,ASP.NET_VB,ColdFusion,CFC,HTML,JSP,LibraryItem,DWTemplate,PHP_MySQL" scheme="outerTag"><![CDATA[<style>]]></blockStart> <blockEnd><![CDATA[</style>]]></blockEnd> <blockStart doctypes="ASP-JS,ASP-VB,ASP.NET_CSharp,ASP.NET_VB,ColdFusion,CFC,HTML,JSP,LibraryItem,DWTemplate,PHP_MySQL" scheme="outerTag"><![CDATA[<style\s+\*>]]></blockStart> <blockEnd><![CDATA[</style>]]></blockEnd> <commentStart name="Comment" id="CodeColor_CSSComment"><![CDATA[/*]]></commentStart> <commentEnd><![CDATA[*/]]></commentEnd> <endOfLineComment><![CDATA[<!--]]></endOfLineComment> <endOfLineComment><![CDATA[-->]]></endOfLineComment> <stringStart name="String" id="CodeColor_CSSString"><![CDATA["]]></stringStart> <stringEnd><![CDATA["]]></stringEnd> <stringStart><![CDATA[']]></stringStart> <stringEnd><![CDATA[']]></stringEnd> <stringEsc><![CDATA[\]]></stringEsc> <cssSelector name="Selector" id="CodeColor_CSSSelector" /> <cssProperty name="Property" id="CodeColor_CSSProperty" /> <cssValue name="Value" id="CodeColor_CSSValue" /> <sampleText doctypes="CSS"><![CDATA[/* Comment */H2, .head2 { font-family : 'Sans-Serif'; font-weight : bold; color : #339999; }]]> </sampleText> </scheme>
CSS sample text
The following sample text for the CSS scheme illustrates the CSS code coloring scheme:
/* Comment */H2, .head2 { font-family : 'Sans-Serif'; font-weight : bold; color : #339999;
}
The following lines from the Colors.xml file provide the color and style values that are seen in the sample text and were assigned by the code coloring scheme:
<syntaxColor id="CodeColor_CSSSelector" text="#FF00FF" /><syntaxColor id="CodeColor_CSSProperty" text="#000099" /><syntaxColor id="CodeColor_CSSValue" text="#0000FF" />
JavaScript code coloring
<scheme name="JavaScript" id="JavaScript" doctypes="JavaScript" priority="50"> <ignoreCase>No</ignoreCase> <ignoreTags>Yes</ignoreTags> <blockStart doctypes="ASP-JS,ASP-VB,ASP.NET_CSharp,ASP.NET_VB,ColdFusion,CFC,HTML,JSP,LibraryItem,DWTemplate,PHP_MySQL" scheme="outerTag"><![CDATA[<script>]]></blockStart> <blockEnd><![CDATA[</script>]]></blockEnd> <blockStart doctypes="ASP-JS,ASP-VB,ASP.NET_CSharp,ASP.NET_VB,ColdFusion,CFC,HTML,JSP,LibraryItem,DWTemplate,PHP_MySQL" scheme="outerTag"><![CDATA[<script\s+\*>]]></blockStart> <blockEnd><![CDATA[</script>]]></blockEnd> <commentStart name="Comment" id="CodeColor_JavascriptComment"><![CDATA[/*]]></commentStart> <commentEnd><![CDATA[*/]]></commentEnd> <endOfLineComment><![CDATA[//]]></endOfLineComment> <endOfLineComment><![CDATA[<!--]]></endOfLineComment> <endOfLineComment><![CDATA[-->]]></endOfLineComment> <stringStart name="String" id="CodeColor_JavascriptString"><![CDATA["]]></stringStart> <stringEnd><![CDATA["]]></stringEnd> <stringStart><![CDATA[']]></stringStart> <stringEnd><![CDATA[']]></stringEnd> <stringEsc><![CDATA[\]]></stringEsc> <brackets name="Bracket" id="CodeColor_JavascriptBracket"><![CDATA[{[()]}]]></brackets> <operators name="Operator" id="CodeColor_JavascriptOperator"><![CDATA[+-*/%<>!?:=&|^]]></operators> <numbers name="Number" id="CodeColor_JavascriptNumber" /> <regexp name="RegExp" id="CodeColor_JavascriptRegexp" delimiter="/" escape="\\"> <searchPattern><![CDATA[(\s*/\e*\\/]]></searchPattern> <searchPattern><![CDATA[=\s*/\e*\\/]]></searchPattern> </regexp> <idChar1>_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</idChar1> <idCharRest name="Identifier" id="CodeColor_JavascriptIdentifier">_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</idCharRest> <functionKeyword name="Function Keyword" id="CodeColor_JavascriptFunction">function</functionKeyword> <keywords name="Reserved Keywords" id="CodeColor_JavascriptReserved"> <keyword>break</keyword>. . . </keywords> <keywords name="Native Keywords" id="CodeColor_JavascriptNative"> <keyword>abs</keyword>. . . </keywords> <keywords id="CodeColor_JavascriptNumber"> <keyword>Infinity</keyword> <keyword>Nan</keyword> </keywords> <keywords name="Client Keywords" id="CodeColor_JavascriptClient"> <keyword>alert</keyword>. . . </keywords> <sampleText><![CDATA[/* JavaScript */function displayWords(arrayWords) { for (i=0; i < arrayWords.length(); i++) { // inline comment alert("Word " + i + " is " + arrayWords[i]); }}var tokens = new Array("Hello", "world");displayWords(tokens);]]></sampleText> </scheme>
JavaScript sample text
The sample text for the JavaScript scheme illustrates the JavaScript code coloring scheme as follows:
* JavaScript */function displayWords(arrayWords) { for (i=0; i < arrayWords.length(); i++) { // inline comment alert("Word " + i + " is " + arrayWords[i]); }}var tokens = new Array("Hello
", "world
");displayWords(tokens);
The following lines from the Colors.xml file provide the color and style values that are seen in the sample text and were assigned by the code coloring scheme:
<syntaxColor id="CodeColor_JavascriptComment" text="#999999" italic="true" /><syntaxColor id="CodeColor_JavascriptFunction" text="#000000" bold="true" /><syntaxColor id="CodeColor_JavascriptBracket" text="#000099" bold="true" /><syntaxColor id="CodeColor_JavascriptNumber" text="#FF0000" /><syntaxColor id="CodeColor_JavascriptClient" text="#990099" /><syntaxColor id="CodeColor_JavascriptNative" text="#009999" />