BenBE's humble thoughts Thoughts the world doesn't need yet …

09.01.2009

Highlighting Perl in all its oddity

Filed under: GeSHi — Schlagwörter: , — BenBE @ 00:02:34

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /var/www/virtual/benny-baumann.de/blog/htdocs/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /var/www/virtual/benny-baumann.de/blog/htdocs/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Following up on a discussion on the GeSHi-devel mailing list I got some interesting testcases for testing Perl in all its oddity.

So lets get things startet: Open up the testcase, and see: The CSS is not fully precise on some stuff (some classes in GeSHi can be used for different things like .co5 for perl is used for predefined variables). So I did a quick editing of the CSS stylesheet with the Web Developer Toolbar to mark everything that was of specific classes (as expected) in a different color than white to see if it actually is highlighted (which most stuff was).

Adding the missing stuff into the language file I got an updated version for Perl that can be found as revision 1975 in the GeSHi SVN repository for testing. Things I didn’t include there are file descriptors as they should already be highlighted (even if <> and <test> are marked as different things.

But in one thing the testcase wasn’t right: Heredocs As well as Regular expressions are supported by GeSHi, see:

$test = <<HEREIAM;
Some text to show this is a heredoc part
HEREIAM;
$match =~ /te[sx]t/g;
$replace =~ s/x/s/i;

Just to be complete on this. Oh, and the

< <

bug is a problem with my WordPress. The demo page does the Heredoc correctly, for those that don’t believe me 😉

Now I’m only lacking this little testcase as a file for inclusion into the Code Repository of GeSHi and I can declare this „done“ …

Update: Revision 1977 contains some important updates on the rev1975\r1974 version of this file: I missed some things due to some issue I had with encoding $ inside of regexps (I missed the escapes PHP needed inside the string). I also added the few remaining cases that the previous version didn’t yet.

What will not be highlighted correctly are bacreferences to numbers (and I thought C was odd …) and nested Heredocs (i.e. Heredocs with two or more starters on one line).

But given the current state this should somewhat resemble most of what even most insane Perl programmers need when puking their code …

Flattr this!

Powered by WordPress