SyntaxHighlighter.Highlighter.prototype.getKeywords(keywords)
keywordsStringTakes a space separated list of keywords and returns regular expression string to match those keywords.
Example
SyntaxHighlighter.brushes.JScript = function()
{
var keywords = 'break case catch continue ' +
'default delete do else false ' +
'for function if in instanceof ' +
'new null return super switch ' +
'this throw true try typeof var while with'
;
this.regexList = [
...
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
...
];
...
};
SyntaxHighlighter API
SyntaxHighlighter is the top level object and contains a number of functionality and predefined variables.
| Name | Type | Description |
|---|---|---|
all | Function | Static function which process all elements on the page and performs syntax highlighting. |
Highlighter | Class | The base class for a brush. |
regexLib | Object | Commonly used regular expressions. |
SyntaxHighlighter.Highlighter
This is the main class that performs all the highlighting work and it’s the base class for developing custom brushes. Each brush extends this class and adds its own custom lexicon and rules. Here are the properties and methods of interest:
| Name | Type | Description |
|---|---|---|
getKeywords | Function | Converts space separated keywords into usable regular expression to match these keywords. |
forHtmlScript | Function | Sets up the brush for html-script functionality. |