It took 4 years this time instead of 7, so I guess I’m improving. 😉 The release of v5.1 came out in May 2022 & in that I said the next release would drop GeSHi for a different syntax highlighting library. Well, this is that release & it took its own sweet time getting here. Life, work & everything in between kept pushing it down the list, but its done now.
This release also comes with a milestone. iG:Syntax Hiliter was first released on 6th August 2004, which makes it 22 years old this month. 🥳 To the best of my knowledge that makes it the oldest WordPress plugin still in use & still maintained – if you don’t count “Hello Dolly”, the demo plugin that was the first WP plugin ever. 22 years is a long time for any piece of software & I did not imagine back in 2004 that this little plugin would outlast pretty much everything from that era.
iG:Syntax Hiliter v6.0.0 is now available for download.
What has changed?!
Pretty much everything under the hood. This is the biggest release in the plugin’s history & the first one since 2004 that does not ship GeSHi.
See ya GeSHi, Hello there Prism! GeSHi served this plugin well for two decades but it has not seen any updates in quite a while & keeping it running on newer PHP versions was becoming a chore. I had to patch the library for last release to make it work with PHP 7.x. Now we are in PHP 8.x & while the patched version was holding its ground, I had decided with v5.1 release itself that it was last version with GeSHi.
Syntax highlighting is now done by Prism.js in the browser instead of on server. Prism’s assets load only on pages that actually have a code box & only the language files those snippets need. Nothing loads on pages which don’t have code boxes. The plugin bundles support for ~300 languages that Prism.js supports, up from the 37 languages last version shipped with.
Minimum requirements have gone up. You need WordPress 6.9 or above running on PHP 8.4 or above. On anything lower, the plugin refuses to load – no fatal error, just a notice in wp-admin telling you what it needs. 🙂
Block editor support, finally. 🎉 There’s now an iG:Syntax Hiliter block for code & iG:Syntax Hiliter Gist block for embedding GitHub Gists. Code in the block is stored as plain text in block attributes, so neither the editor nor the content filters can touch it – paste your code as is & it stays exactly as you typed it.
There’s one behaviour here you should know about before updating. If you open an old post containing this plugin’s shortcodes in the block editor, those snippets are converted to blocks automatically & the conversion is written to the post when you save it. This is deliberate. WordPress hands a classic post to the block editor as one big TinyMCE block & TinyMCE mangles code – it reads <?php echo "<div>x</div>"; ?> as HTML, renders the <div> & throws away the PHP. Converting the snippets to blocks before TinyMCE gets at them is the only way to keep your code safe. Posts you never open in the block editor are never touched & the classic editor’s Code view converts nothing.
A way back out. Blocks have one downside shortcodes never had – if this plugin is deactivated, its blocks will no longer be registered with WordPress. WP does not render an unregistered block & your code silently vanishes from the post. A shortcode at least stays visible as text. So the settings page now has a Before you deactivate section with a tool that converts all of this plugin’s blocks back to shortcodes across your entire site. Run it before you deactivate or delete the plugin & your snippets stay on screen.
Themes & fonts. The old Use plugin CSS for styling? option has become a Theme dropdown with 43 themes – Prism’s own 8 plus 35 from the prism-themes collection, so One Dark, Nord, Dracula, VS Code Dark+, Gruvbox & friends are all in there. Whichever you pick, exactly one stylesheet loads on a page with code. There’s also a new Font setting with 15 monospaced fonts, grouped by whether they draw code ligatures or not. Fonts are served from Bunny Fonts – a GDPR compliant service with no cookies & no logs. By default this setting is set to None – the plugin does not make any external call to download any font – its your decision to make. A live preview sits beside the settings & repaints as you change things, so you can see a theme or font or any other setting update before committing to it.
Bracket matching. Two new options using Prism’s match-braces plugin. One outlines a bracket & its partner when a reader hovers over it (on by default, since a page at rest looks unchanged). The other colours brackets by nesting depth (off by default).
Bug fixes worth calling out:
- Language only tags like
[php]&[css]were not rendering in v5.1. They work again. - The
langattribute has been documented as shorthand forlanguagesince v4.1 but hasn’t worked for quite a while. It does now. [github gist="URL"]embeds were broken in v5 becausewptexturizecurled the quotes around the URL before the plugin could read it. This has been fixed now.
Breaking changes
A major version bump earns its number, so read this bit if you’ve been running the plugin for a while.
Support for adding languages by dropping GeSHi language files into a geshi/ directory – in the plugin or in your theme – is gone, since GeSHi itself is gone. If you were using drop in tags like [email] for a custom language, those tags are no longer recognised & will show up as plain text in your posts. The good news is that with ~300 bundled languages, whatever you were adding is very likely supported now – just use it via [sourcecode language="..."] or better yet use it with the plugin’s block in the block editor.
A few old tags now highlight as a different language because Prism has no equivalent component. asp is highlighted as ASP.NET (GeSHi’s asp was classic ASP), perl6 as Perl (Perl 6 has been Raku since 2019) & c_mac as plain C. Your code itself is untouched in every case, only the colouring differs.
The plaintext, toolbar & strict_mode attributes in your shortcodes are now ignored – they were GeSHi era ideas with no Prism equivalent. Old posts using them won’t break, but don’t use them in new ones.
Existing shortcodes otherwise work exactly as they always have & your settings are migrated on update. As I’d promised back in 2022, the transition should be seamless for the most part.
A detailed changelog is available here.
And here are the download links:
- WordPress Plugins Repo: https://wordpress.org/plugins/igsyntax-hiliter/
- Github: https://github.com/coolamit/ig-syntax-hiliter/
Notice any issues? A feature request? Open an issue on Github repo: https://github.com/coolamit/ig-syntax-hiliter/issues
As always, pull requests are welcome at Github. 🙂