After php7.3/7.4, Crayon Syntax Highlighter plug-in reports an error: Compilation failed: invalid range in character class at offset 4.
More classified articles:
Website Construction | Python | Linux | Big Data | Database | Git | Nodejs | Golang | Computer Skills | Computer Technology
Error description
After installing Crayon Syntax Highlighter, an error is reported in the WordPress background
Compilation failed: invalid range in character class at offset 4
Reason for error
This is a problem after the installation of the syntax highlighting plugin Crayon Syntax Highlighter after php7.3. Locate this line in the crayon_langs.class.php file in the plugin directory.
return preg_replace('/[^\w-+#]/msi', '', $id);
The rewritten code is as follows:
// Override
function clean_id($id) {
$id = CrayonUtil::space_to_hyphen( strtolower(trim($id)) );
// PARSED_ERRORS
//return preg_replace('/[^\w-+#]/msi', '', $id);
// So
return preg_replace('/[^\w\-+#]/msi', '', $id);
}
Reference from:
https://crunchify.com/fix-for-crayon-syntax-highlighter-wordpress-plugin-and-php-7-3-fatal-error/
Original link: Solve the installation problem of Crayon Syntax Highlighter