I use the Crayon syntax highlighting plugin in order to display code on this blog. Recently I upgrade my server to PHP 7.3, which broke a fair few things, including this plugin.

Unfortunately, it looks like this plugin is no longer being maintained – the latest stable release was three years ago, and the latest commit on their GitHub was over a year ago.

Never fear, open source is here!

If you’re using the stable version, open up crayon_langs.class.php and change crayon_langs.class.php:340 from this:

preg_replace('/[^\w-+#]/msi', '', $id);

To this:

preg_replace('/[^\w\-+#]/msi', '', $id);

Notice the escaping before the - character.

Should work now.

One thought on “Fixing Crayon Syntax Highlighting plugin

Leave a Reply