I'm rewriting the highlight_file/string methods in userland code (using the
tokenizer) because I've found the native functions painful.
It is difficult to insert line numbering properly, and have accurate
function referencing - most pastebins now use PEAR's Text_Highlight to
highlight the code with a bunch of intensive preg_matches. Hopefully this
can be updated one day (though according to the bug reports it caused
segfaults with the current implementation), but until then I thought this
may be useful.
I'm almost finished:
http://aidan.dotgeek.org/lib/?file=PHP_Highlight.php
My problem is the token2color method, I'm not sure which tokens are classed
as keywords. At the moment I've just guessed as many as I could think of,
it's a bit ugly - presuming there is an easier way to do it.
I've had a look through zend_highlight.c and found that anything with
token.type = 0 is highlighted as a keyword, however I'm unable to track down
where token.type is set.
Is anyone able to provide some insight?
King Regards,
Aidan Lister