|
Syntax Highlighting |
|
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 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, comments and so forth. Important. In order to see highlighting schema updates within existing reviews, end-users may need to clear their browser's cache or upload new revisions of the review material. The Schemas List provides a list of all available schemas, both predefined (default) and custom-created.
Creating a syntax highlighting schema To create a syntax highlighting schema for a new computer language, scroll to the Create New Schema section, specify name for a new schema and press Create. This will create a blank schema which you can configure as you like. Deleting a syntax highlighting schema To delete a syntax highlighting schema, locate the desired schema in the list and press Delete link next to it. Resetting predefined syntax highlighting schemas To reset predefined syntax highlighting schemas to their initial state, scroll to the Restore default highlighting schemas section and press Restore Defaults. This action affects only predefined schemas, it does not alter custom schemas. Modifying a syntax highlighting schema Click the name of the desired syntax highlighting schema in the Schemas List. This will display schema editor. The editor has several tabs to configure different aspects of syntax highlighting. All the tabs will be described below. On the General tab you can specify general set of scheme parameters.
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. On the Keyword Patterns tab you can specify a list of patterns to denote reserved identifiers and keywords used by the selected computer language.
To edit an existing pattern, click its name in the list. To create a new pattern, click New Pattern. Any of these actions will display a "Configure lexeme pattern data" form:
Once specified the pattern data, click Save. 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. Some computer languages may include fragments of code on another computer language. Typical examples are client-side and server-side scripts. Based on HTML, they include fragments of embedded code on JavaScript, PHP, ASP.Net, Ruby and other languages. Collaborator may apply syntax highlighting to embedded code as well. To do this, you need to define a list of patterns that will match the fragments of embedded code in the Embedded Code Patterns tab and select which syntax highlighting schema must be applied to these fragments in the Embedded code schema drop-down list. On the Miscellaneous Patterns tab you can specify a list of any other syntactical elements to be highlighted. |
|
© 2003-2025 SmartBear Software. All rights reserved. |