Stateless Syntax Highlighter Part 2

 

The highlighter has been completely overhauled to be extensible using external tokenizers and color files.

Here is the new README from the file: PlainCommand line syntax highlighter ------------------------------- Getting Started: Requirements: Requires PHP 5.2.x or greater Installing: 1. Extract to desired directory 2. Make 'highlight' executable 3. Edit RESC_DIR constant in 'highlight' to point to the directory 4. (optional) symlink highlight file in /usr/bin/ Usage: See command (highlight -h) Extending: To add a syntax to the highlighter you need to create two files: <syntax>.syn and <syntax>.lib. <syntax>.syn will be a newline separated file containing the tokens and associated color (see man console_codes) Example: T_STRING 1;32 T_ELSEIF 31 The tokens in <syntax>.syn must match the tokens produced by <syntax>.lib. The <syntax>.lib file at minimum must contain the function tokenize_<syntax> ie., tokenize_php. This function will return an array of tokenizations of the code passed to the function as a string. The array should follow the format of: array( 0 => array( 'token' => 'T_STRING', 'string' => "'this is some string in the code'" ), 1 => array( 'token' => 'T_ELSEIF', 'string' => 'elseif' ) ) See the bundled php.lib and php.syn for more examples. Each token may have a specialized handler for the color, see T_VARIABLE in php.syn and handlevar() in php.lib as an example.