JavaScript Editor Javascript validator     Web page editor 


Provides functionality to perform syntax highlighting for different file formats.


With Text_Highlighter it is possible to create syntax highlighted versions of different file formats.

Currently, the following formats are supported:

There are different options for getting the results of the highlighting, through the use of renderers. The list of renderers is as follows.


The class Text_Highlighter contains all necessary functionality to perform the syntax highlighting except for the actual highlighting rules for the different formats. These rules are defined in subclasses of Text_Highlighter, but one must not directly instantiate these subclasses. Instead the object-oriented factory pattern is used to create a highlighter object depending on the format:

In order to produce syntax highlighting for other formats, one must replace the argument value SQL of Text_Highlighter::factory with one of ABAP, CPP, CSS, DIFF, DTD, HTML, JAVA, JAVASCRIPT, MYSQL, PERL, PHP, PYTHON, RUBY, SQL, or XML.

Output Customization

The default behaviour of Text_Highlighter is to generate a syntax highlighted HTML version of the input.

It is possible to instead generate output that is suitable for being displayed on color-capable terminals such as xterm or through less(1) by telling Text_Highlighter to use another renderer:

Also it is possible to further customize the output of both the HTML- and the console-renderer by passing an associative array of options to the constructor:

The following options are applicable:

JavaScript Editor Javascript validator     Web page editor