Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94145 invoked by uid 1010); 11 Nov 2004 03:36:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94120 invoked by uid 1007); 11 Nov 2004 03:36:45 -0000 Message-ID: <20041111033645.94072.qmail@pb1.pair.com> To: internals@lists.php.net Date: Thu, 11 Nov 2004 14:36:48 +1100 Lines: 28 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-Posted-By: 144.132.79.80 Subject: zend_highlight routine From: aidan@php.net ("Aidan Lister") 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