Syntax Highlighter, WordPress & CSS
// April 26th, 2009 // No Comments » // Tools, wordpress
I recently changed my Syntax Highlighter (which was cool, but old and abandon-ware) for the SyntaxHighlighter Evolved. Which I must say I love. Old versions were really bad. They were not that flexible. But version 2.0 is VERY flexible, and looks great. So I did the change in Neonlabs and Structum.
I stumbled with several problems. The first, and the one that bothered me more, was that in the Structum page, the code seemed to be broken into weird lines.

This was obviously a CSS problem since I didn’t have that problem in Neonlabs. So I used several tools to see which was the offending style. I mostly looked for the ‘pre’ tag on CSS but was not successful. After looking through the whole CSS style for my theme, I found the offending line of code:
#primary code {
display:block;
...
}
Yep, it was a simple display attribute. I just commented that line and everything just worked.

After that I tried editing the code to make it look better for the Structum page and I noticed that when it loaded it had a nasty Warning:
Warning: htmlspecialchars_decode() expects parameter 1 to be string, NULL given in /…/wp-includes/compat.php on line 105
And when I looked at the code blocks in my posts, there was nothing. They were empty.
I did a little research to see what was the problem, and it seems it is a WordPress bug. Simple variable naming bug in compat.php:
function htmlspecialchars_decode( $str, $quote_style = ENT_COMPAT )
{
if ( !is_scalar( $string ) ) {
trigger_error( 'htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype( $string ) . ' given', E_USER_WARNING );
return;
}
...
}
Can you see the problem ? The problem resides in the $string variable. It doesn’t exist, so its value is null. Changing the variable parameter for is_scalar and gettype from $string to $str fixed the problem.
This is how it should look:
function htmlspecialchars_decode( $str, $quote_style = ENT_COMPAT )
{
if ( !is_scalar( $str ) ) {
trigger_error( 'htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype( $str ) . ' given', E_USER_WARNING );
return;
}
...
}
After that, everything is working seamlessly again :D. hope this helps :D.
