blog

Posts Tagged ‘bug’

Fixing Geshi on line 2132

Saturday, June 13th, 2009

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.

dvipng color trouble

Friday, December 28th, 2007

I still have yet to find a fix to the dvipng discoloration mystery I ran into back at The Academic Approach, even with the latest MacTeX version, so I’m going to repost the problem here.

In May 2007, I wrote the following to the OS X TeX listhost:1

Hi all,

I’ve recently run into what I believe is a rare bug in dvipng: here’s the setup. (To play along, you can get my test files: http://mitcho.com/discolor.zip .) I am using MacTeX… in fact, it’s today’s release.

The LaTeX source file (discolored.tex) loads just two packages: color and graphicx. The body does two things: an \includegraphics with a local PNG file (with the bb option to specify the BoundingBox explicitly) and a \textcolor command introducing some green text, using the green defined there.

pdflatex produces the expected result: the figure and the green text.

Original color

But when you run the following commands…

latex discolored.tex

dvipng -D 200 discolored.dvi

you get a PNG (discolored1.png) which shows the text in a brownish color… the green is gone!!

Discolored version

There are two quick ways to fix this that I’ve found: one is to not include the image… if you comment the \includegraphics command out, the color comes out fine. The second is to not specify a -D (output resolution) parameter in the dvipng… this also gives you the expected output. However, in my current project, neither of these are available options…

I am frankly not very familiar with the inner workings of dvipng… does anyone have any thoughts? Can this bug be reproduced?

Any hints or suggestions are welcome!

Ditto.

discolor.zip
496 kb - zip

  1. Inline cropped images added to this web version, just to spice things up. 


© 2006–2011 mitcho (Michael 芳貴 Erlewine).
Proudly powered by WordPress on Media Temple.
The views expressed on these pages are mine alone and do not
reflect those of my employers and clients, past and present.