SyntaxHighlighter 3.0.83

Fork Me On GitHub
whats new?
SyntaxHighlighter is an open source Java Script client side code syntax highlighter.
donate download installation autoloader configuration @syntaxhighlight

API

SyntaxHighlighter.Highlighter.prototype.getKeywords(keywords)

keywords
String Takes 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.

NameTypeDescription
allFunctionStatic function which process all elements on the page and performs syntax highlighting.
HighlighterClassThe base class for a brush.
regexLibObjectCommonly 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:

NameTypeDescription
getKeywordsFunctionConverts space separated keywords into usable regular expression to match these keywords.
forHtmlScriptFunctionSets up the brush for html-script functionality.