Making SyntaxHighlighter plugin display “>” symbol correctly.

My SyntaxHighlighter plugin started to display “>” as “ = & g t ;” after I updated my WordPress to a version where blocks were added. To fix the plugin I added the following line to wp-content/plugins/syntaxhighlighter/syntaxhighlighter.php:

$code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );

// Undo escaping done by WordPress
$code = htmlspecialchars_decode( $code );

return $this->shortcode_callback( $attributes, $code, 'code' );

In version 3.5.1 the author added a code that replaces ‘<‘, but it is not enough, because there is ‘&’ and ‘>’ in C++ code.

                $code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );

                // Undo escaping done by WordPress
                $code = str_replace( '& lt;', '<', $code );

                return $this->shortcode_callback( $attributes, $code, 'code' );

(I added a space after ‘&’ in the code above to prevent it from being replaced)

So I still use my own fix.

2 Responses to Making SyntaxHighlighter plugin display “>” symbol correctly.

  1. Craig says:

    Submitted a pull request so hopefully this gets fixed in an updated version of the plugin soon:
    https://github.com/Viper007Bond/syntaxhighlighter/pull/109

Leave a Reply

Your email address will not be published. Required fields are marked *