Using Blazor and Code Highlight
12/07/2019
Code highlight or syntax highlight is a feature that displays text as source code. It is using different fonts and colors, that matches with the syntactical meaning of the code constructs. For examples keywords such as public
or if
are colored blue, while method names such as Main()
can be colored to green. Highlighting code on an HTML website is a relatively easy task if one is using an existing syntax highlighter.
Integrating an existing code highlighter with Blazor is a one step more complex though. In this post, I am going integrate a Blazor site with Prism, which is a lightweight extensible code highlighter.
Getting started
The first step with prism is to choose a theme, additional languages and plugins. Prism will generate a CSS file and a Javascript file, which can be downlaoded from their website. Both files then should be added to the wwwroot
folder of the Blazor project.