I’ve recently been updating the syntax highlighting on this blog. The main reason was Kusto Query Language (KQL). Queries from Microsoft Fabric Eventhouse or Azure Data Explorer (ADX) should still be easy to follow when they end up in a WordPress post. I also wanted proper support for TypeScript, JSON and Power Query (M). Until now, I’d been selecting JavaScript for TypeScript snippets.
The pipes, operators and function calls are part of how I explain a query. I wanted those to be readable without going through old posts and fixing code blocks by hand. The other languages mattered too, but KQL was the reason to stop treating SQL highlighting as good enough.
I’ve used SyntaxHighlighter Evolved as the starting point and replaced its rendering engine with Prism.js. My version now lives in a standalone GitHub repository. It keeps the existing blocks, shortcodes and settings. I’ve also used GitHub Copilot to help with the implementation and tests, although there were still a few rounds of checking the output in WordPress and fixing what didn’t look right.
Adding another language turned out to be the easy part.
Why not SQL?
SQL highlighting is a reasonable temporary workaround for a KQL snippet. It recognizes strings and numbers, and at least gives the query some color. But it doesn’t know much about KQL pipelines or operators such as summarize and project-away.
Let’s take a simple query against the StormEvents sample table from the KQL operator tutorial:
StormEvents
| where State == "TEXAS"
| summarize Events = count() by EventType
| top 10 by Events descI want where, summarize and top to look like operators, rather than random words between pipes. When explaining an Eventhouse query, it helps if readers can see where filtering ends and aggregation begins. Functions and strings should be recognizable too. Nothing fancy here.
The plugin only handles the publishing side. It doesn’t connect WordPress to Eventhouse or run a query on a reader’s behalf.
Replacing the engine
The original plugin uses SyntaxHighlighter 2 or 3, with separate JavaScript files called brushes for the different languages. Its PHP class also handles shortcodes, settings, widgets, Classic editor encoding and Gutenberg blocks. Replacing the JavaScript isn’t the whole upgrade.
I’ve kept that WordPress integration and replaced the frontend engine. Prism 1.30.0 already includes a Kusto grammar, including pipeline operators, common duration literals, datetime values and multiline strings. Credit for that work belongs to the Prism contributors – I haven’t written a KQL parser.
Registering the language
Both kql and kusto point to Prism’s kusto component. These are the relevant entries in languages.json, alongside the other supported languages:
{
"aliases": {
"typescript": "typescript",
"ts": "typescript",
"tsx": "tsx",
"json": "json",
"kusto": "kusto",
"kql": "kusto"
}
}The build produces local grammar files and a manifest describing their dependencies. PHP resolves the alias, registers the required assets and passes the same language information to the editor. An unknown language falls back to escaped plain text, rather than trying to download an arbitrary component.
Keeping old posts
I’ve kept the Gutenberg block name, syntaxhighlighter/code, and its original save function. The saved pre markup stays compatible, while PHP handles the new frontend output. No database migration or content resave is needed.
Classic content is less straightforward. Some older snippets contain raw text; others contain encoded text, identified by the existing encoding metadata. Decoding everything would change intentional entities. Escaping everything again would leave readers looking at < instead of <.
I’ve kept those paths separate. There is also a regression test for shortcode examples inside Gutenberg code blocks: should remain an example, not become another shortcode while WordPress saves the post....
I wanted new colors, not a content-repair project.
From a KQL queryset to WordPress
In the block editor, choose Kusto Query Language (KQL) from the searchable language selector. The source remains a plain code textarea, with an optional highlighted preview. Paste the query text from your Eventhouse KQL queryset, then use the preview to check how the example will read in the post. TypeScript, TSX, JSON and Power Query (M) are available there too, if the explanation also needs client code, a sample event payload or a data-preparation step.
For shortcodes, here’s a complete example:
[code language="kql" firstline="10" highlight="11-12"]
StormEvents
| where State == "TEXAS"
| summarize Events = count() by EventType
[/code]StormEvents
| where State == "TEXAS"
| summarize Events = count() by EventType and ... use the same grammar. Existing ..., and language-specific tags still work.
I’ve switched the light appearance to Prism’s Coy theme, by Tim Shedor, with a dark adaptation and CSS scoped to the plugin. Copying, line numbers, highlighted ranges and native collapse are kept separate from the grammar. The copied text comes from the original source, not the decorated display. Readers can copy a query back into their own KQL queryset without picking up line numbers or HTML markup. They’ll still need access to the relevant database and tables, of course.
If you’re replacing the original plugin, check the compatibility notes, back up first and try it on staging. Deactivate SyntaxHighlighter Evolved before activating this version; they share identifiers and shouldn’t run together. This version requires WordPress 6.8.12+ and PHP 8.2+. Old theme CSS and custom brush scripts may need changes, so content compatibility doesn’t mean an identical appearance.
Checking the rough edges
I’ve improved Prism.js’ existing KQL support, refining how it recognizes query keywords, operators and strings.
The overlay also distinguishes management commands such as .show tables from ordinary dotted names.
The updated grammar also handles doubled quotes in verbatim strings and uppercase function names. Prism already handled triple-backtick strings and hyphenated pipeline operators; those aren’t additions I’ve made.
The tests cover those distinctions, longer examples and a timed adversarial-string case. They don’t prove complete KQL coverage. For the actual language rules, including string literals, the Kusto documentation is still the reference.
Loading only what’s needed
By default, the plugin loads only the languages a post uses and their dependencies, all from locally bundled files. Very large snippets fall back to plain text to keep the page responsive.
What’s next
The useful part of this update is fairly small: I can publish an Eventhouse or ADX query without disguising it as SQL or repairing old posts. Readers get recognizable KQL operators, function calls and strings, and can copy the original query back into a KQL queryset. Most of the work was keeping that source intact through WordPress, the editor and the copy button.
The source code and development notes are on GitHub. I’ve kept the KQL overlay separate from the WordPress integration so grammar fixes don’t require changing saved queries. If you find an Eventhouse or ADX query that gets the wrong colors, a small, sanitized example would help.