Menu

1 / 2

Syntax Highlighting in Blazor with No JavaScript. The Story Behind Prismizor

DEV Community: blazor·jsakamoto·2 days ago
#djtDUlGJ
#devtoblazor#devto#dev#prism#blazor
Long article (1957 words) — no AI summary yet.
Reading 0:00
15s threshold

Have you ever seen this in a Blazor WebAssembly app? You open a page that is prerendered on the server, and the code samples on it are just plain text at first. A few moments later, after Blazor starts, the colors appear.

I really hated that moment. 😣

In this article, I'd like to tell you the story of how that small annoyance made me port Prism.js to C#, with the help of an AI coding agent. The result is "Prismizor" , a syntax highlighting component for Blazor.

Before I start

Please note that there is no original idea of mine in Prismizor. The grammars, the way it tokenizes code, the HTML it makes, and the themes all come from Prism.js . I only moved them into C#.

😖 The flash of plain code

I had been using Prism.js in my Blazor apps for a long time. Prism.js is a great library.

But it works in a certain order. First, the browser shows the code block as plain text. Then, Prism.js runs and adds colors to it.

In many web apps, that gap is too short to notice.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.