When users open any text-based file in the Diff Viewer and the Syntax Coloring option is enabled, Collaborator attempts to determine a computer language of this file and apply an appropriate syntax highlighting to it.
Collaborator has built-in support of syntax highlighting for most popular computer languages: C++, C#, Java, Ruby, Perl, ASP.Net, Python, SQL, HTML, XML, and many others. Additionally, Collaborator administrators can create custom syntax highlighting schemas to add syntax highlighting for any other computer language.
The Syntax Highlighting page of the Admin screen allows you to add, manage, and delete syntax highlighting schemas for various computer languages.
Syntax highlighting schema denotes what fragments of text should be highlighted as keywords, strings, constants, comments, and so forth. It also specifies a list of file extensions to which the scheme will be applied. All syntax highlighting schemas are completely configurable, that is, you can specify new file extensions, add or delete keywords, modify patterns for strings and comments, and so on.
|To see highlighting schema updates within existing review, users may have to clear the cache of their browser or upload new revisions of the review material.|
In the Schemas List section, there is a list of all available schemas, both predefined (default) and custom.
To create a syntax highlighting schema for a new computer language:
Scroll down to the Create New Schema section.
Specify a name for a new schema.
After that, a new blank schema will be created, which you can configure in accordance with your needs.
To delete a syntax highlighting schema, locate the desired schema in the list and click Delete next to it.
Reset Predefined Schemas
To reset predefined syntax highlighting schemas to their initial state, scroll to the Restore default highlighting schemas section and click Restore Defaults.
This action affects only predefined schemas – it does not alter custom schemas.
Click the name of the needed syntax highlighting schema in Schemas List. After that, the schema editor will appear.
On the General tab, you can specify general set of schema parameters.
|Schema Name||Defines a name of the syntax highlighting schema.|
|Schema Description||Defines a detailed description for the syntax highlighting schema.|
One computer language could be based on another computer language. For example, C++ and C# languages are based on C language and HTML is based on SGML.
Syntax highlighting schemas may inherit a number parameters from their parent schemas, so that you will not need to redefine the same parameters twice.
Select None if the desired computer language is not based on any other language. Otherwise select a schema of the parent language in the drop-down list.
|Language is case-sensitive||Specifies whether the computer language is case sensitive.|
Defines a list of extensions which may have source code files of the selected computer language. Specify each extension separated by semicolon, comma or space characters, or specify them on a separate line. Prefix each with a dot character.
Collaborator checks this list of file extensions to determine a syntax highlighting schema to apply for a file displayed in the Diff Viewer.
On the Keywords tab, you can specify a list of reserved identifiers and keywords used by the selected computer language.
In addition to reserving specific lists of words, some computer languages reserve entire ranges of words or notation formats. For example, HTML tags or CSS selectors have a specific notation format. Another example is C and C++ languages, where any identifiers that start with two underscore characters are reserved.
To apply syntax highlighting to a specific fragments of source code, Collaborator uses regular expression patterns. Each syntax highlighting schema allows specifying multiple patterns to highlight keywords, strings, constants, comments, embedded code, and other important fragments of source code.
Keyword Patterns tab
On the Keyword Patterns tab, you can specify a list of patterns to denote reserved identifiers and keywords used by the selected computer language.
Configure lexeme pattern data form
To edit an existing pattern, click its name in the list. To create a new pattern, click New Pattern. On any of these actions, the Configure lexeme pattern data form will appear.
|Title||Defines a name of the lexeme pattern.|
|Description||Defines a detailed description for the lexeme pattern.|
|Regular Expression||A Java-style regular expression that identifies the desired fragment of text.|
|Enable Unix lines mode||
When this flag is specified, then only the
|Enable case-insensitive matching||
When this flag is specified, then two characters will match even if they are in a different case.
By default, case insensitive matching assumes only characters in the US-ASCII char-set are being matched. To enable Unicode-aware case insensitive matching, enable both this and the Enable Unicode-aware case folding flags.
|Permit whitespace and comments in RegEx||
When this flag is specified, then white-spaces will be ignored, and embedded comments starting with
|Enable multiline mode||
In multiline mode, the
|Enable literal parsing of the regEx||Treat pattern string as a sequence of literal characters. In this case, metacharacters or escape sequences will not have any special meaning.|
|Enable dotall mode||
In dotall mode, the
|Enable Unicode-aware case folding||When this flag is specified, then case-insensitive matching (if enabled by the Enable case-insensitive matching flag) will be performed in a manner consistent with the Unicode standard. By default, case-insensitive matching assumes that only characters in the US-ASCII char-set are being matched.|
|Enable canonical equivalence||
When this flag is specified, then two characters will be considered to match if, and only if, their full canonical decompositions match. The
|Enable the Unicode version character classes||Enables the Unicode version of predefined character classes and POSIX character classes.|
Once specified the pattern data, click Save. You can add as many patterns as you need.
Other tabs of syntax highlighting schema editor have the same functionality, but deal with different syntactical elements:
On the Strings tab, you can specify a list of patterns to denote string literals within the selected computer language.
On the Constants tab you can specify a list of patterns to denote constants.
On the Comments tab you can specify a list of patterns to denote comments.
On the Embedded Code Patterns tab, you can specify the syntax highlighting schema for code fragments that are adopted from another computer languages.
On the Miscellaneous Patterns tab, you can specify a list of any other syntactical elements to be highlighted.
Diff Viewer Overview
Review Source Code and Text Files