blog

Fixing Geshi on line 2132

I recently noticed that some of my blog posts, most notably my Templates in YARPP 3 article, was producing a PHP error:

Warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 3 in /…/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2132

This seemed to be coming from the version 1.0.8.4 version of Geshi I had installed. A quick google search for “geshi line 2132” gives you over a thousand errors, so this seems to be common issue. Geshi is a fabulous and popular syntax highlighter and is the core component of the WP-Syntax plugin for WordPress.

I did some digging around and realized that the issue was with the compilation of this monstrosity of a regular expression, used (as far as I can tell) to identify PHP code snippets, for example the <?php … ?> keywords:

/(?<start><\\?(?>php\b)?)(?:
(?>[^\"'?\\/<]+)|
\\?(?!>)|
(?>'(?>[^'\\\\]|\\\\'|\\\\\\\|\\\\)*')|
(?>\"(?>[^\"\\\\]|\\\\\"|\\\\\\\\|\\\\)*\")|
(?>\\/\\*(?>[^\\*]|(?!\\*\\/)\\*)*\\*\\/)|
\\/\\/(?>.*?$)|
\\/(?=[^*\\/])|
<(?!<<)|
<<<(?<phpdoc>\w+)\s.*?\s\k<phpdoc>
)*(?<end>\\?>|\Z)/sm

Not knowing exactly where to start in diagnosing this crazy expression, I simply disabled those “script delimiters” in the geshi/php.php file. The sections I commented out are lines 1080-1101. Now the script delimiters like &lt;?php don’t get highlighted nicely, but I feel that’s a small price to pay for eliminating these errors. Another solution for the WP-Syntax users seems to be to downgrade to 0.9.4. Hopefully in the near future an update to Geshi will come out which fixes this issue once and for all.

Related posts:

  1. Yet Another Related Posts Plugin
  2. Modifiying WordPress plugin activation behavior
  3. Keep up with Yet Another Related Posts Plugin with RSS!
  4. Yet Another Related Posts Plugin 2.0
  5. Using Templates with YARPP 3

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , , , , , ,

If you enjoyed this post, make sure you subscribe to my RSS feed (optionally with tweets from my Twitter)!

6 Responses to “Fixing Geshi on line 2132”

  1. Fixing Geshi on line 2132 Says:

    […] See the original post:  Fixing Geshi on line 2132 […]

  2. Posts about plugins as of June 13, 2009 | All About WordPress Says:

    […] 3&#116s perfect for beginner Fixing Geshi on line 2132&#32– mitcho.com &#48&#54&#4713/2009 I recently noticed […]

  3. あり » Blog Archive » WP-Syntaxプラグインのバグ Says:

    […] Fixing Geshi on line 2132 Version 0.9.4にダウングレード(現在使用しているのは0.9.6)するしかないらしい。 […]

  4. Mike Wojcik Says:

    I just wanted to stop by and say THANKYOU! THANKYOU! THANKYOU! for posting this. I searched high and dry for a fix and you came to my rescue. I will be sure to give you a link back from my site.

  5. Nabeel Says:

    Fixed in latest release…looks like

  6. Marcelo Says:

    Hello, to fix this problem, i put an @ in 2132 line on geshi.php

    The @, especifies that the function wich use it, does not show any warning, so, this line begin such as: @preg_match….

    PS: I don´t comment any line of the php.php file


© 2006-2010 mitcho (Michael 芳貴 Erlewine).
Proudly powered by WordPress.
Entries (RSS) and Comments (RSS).
The views expressed on these pages are mine alone and do not
reflect those of my employers and clients, past and present.