- Console and HTML highlighting output
- Supported Languages:
- PHP
- XML
- HTML 4/5
- Javascript
- C++
- C (beta)
- CSS
- INI files
- Line numbering
- Bundled Themes:
- Skittles Dark: Based on Vim Theme
- Wombat: Based on Vim Theme
- Native: Based on Vim Theme
- Github theme
* PHP 5.2.x or greater * Linux only until PHP 5.3 1. `chmod a+x install.sh` 2. `./install.sh` (sudo if you want to install for all users) man lzhighlight **Setting the default theme**: To set the default theme just symlink your preferred theme to a folder named `syntax/` in the base of the repo:
ln -s themes/wombat/ syntax
Override default: You can use the -e
option to override the default
highlight -i somefile.php -e skittles_dark
T_STRING 1;32
T_ELSEIF #FF00FF
The tokens in syntax.syn must match the tokens produced by <syntax>.php
. The
.syn files can link together by using the #LINK directive ie.,
T_STRING 1;32
T_ELSEIF 31
#LINK html.syn
The color can also be another token which links multiple tokens together:
T_STRING bgreen // use human readable color
T_ENCAPS_STRING T_STRING // link T_ENCAPS_STRING to T_STRING
You can also apply bold/italics to a token using %
:
COMMENT #5D8D8F%i // italic
OP #8AC6F2%b // bold
Background colors are supported but only applied to HTML output:
ERROR #960050%bi #1E0010 // bold, italic and custom bgcolor
Inside the tokenizers you can write methods to handle tokens directly if there is extra processing that needs to take place (making URLs links, etc) To do this, simply put the name of the function as the color:
HTML_STRING HtmlLexer::handleString
Also, you can specify whether or not it should happen only on HTML or console output. When you do this you must specify a fallback color to use.
HTML_STRING HtmlLexer::handleString|STRING HTMLONLY
The function must always come first followed by a pipe and a color, which like above, can be another token name.
The .php file at minimum must contain the camelized class Lexer ie., PhpLexer. This class's tokenize method returns 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 tokenizers/php.php
and syntax/php.syn
for more examples.
- themes/
- wombat/
- php.syn
- default.syn
- ...
- skittles_dark/
- php.syn
- default.syn
- ...
- wombat/