GeSHi is a Generic Syntax Highlighter for PHP. The user inputs the source to be highlighted and a language to highlight it in, and GeSHi returns the source code, highlighted and formatted for the web.
It includes features for increasing the speed of highlighting, changing how the source is displayed and decreasing the amount of HTML source outputted for speed over slower connections.
GeSHi features also include:
* The ability to check for keywords in source code in either a case sensitive or non-case sensitive manner (for example, Java will only accept classes with TheCorrectCapitalisation, while in PHP it doesn't matter)
* The ability to auto-caps/auto-noncaps keywords in the source (particularly for SQL and older BASIC dialects)
* The ability to change the style of almost any aspect of the source on the fly, or even choose whether some parts of the source (for example, strings) are highlighted at all. The use of CSS means that the source can take on many aspects - rather than those provided by deprecated HTML elements such as <font>, <b> etc.
* The ability to use CSS classes to massively reduce the amount of outputted code.
* XHTML compliant output.
* Simple adding and removing languages.
* Function to URL conversion so functions can be linked to API documentation
* Line numbering, context highlighting and much, much more!
GeSHi requires PHP 4.1.0 or better. It requires no extra PHP extensions.
Prize: One copy of the PHP Anthology book set
|Syntax highlighting maybe an useful for sites that need to present source code, as it makes source code more readable and easier to understand.
PHP comes with built-in functions that can highlight the syntax of PHP code. This is useful if you just need to present source code in PHP.
This class provides a more generic solution t highlight the syntax of source code of many languages.
Furthermore, if you need to highlight the syntax of source code of a language that is not supported, you can create a new language configuration script and extend the utility of this class to suite your needs.