Quick Start
Documentation menu
Install the package, create a Prism service and highlight a code block in a few lines of C#.
Before you start
Prism runs in Node.js. Install Node.js and confirm that its executable directory is on the PATH. The package has been tested with Node.js 10.5.2 through 12.13.0.
Install
dotnet add package Jering.Web.SyntaxHighlighters.Prism
Create the service
var services = new ServiceCollection();
services.AddPrism();
var provider = services.BuildServiceProvider();
var prism = provider.GetRequiredService<IPrismService>();
Highlight code
Pass the source and a valid Prism language alias. The result is markup that you can write into a page.
var code = "public string ExampleFunction(string arg) { return arg; }";
var html = await prism.HighlightAsync(code, "csharp");
Use the static API
If the application does not use a container, StaticPrismService exposes the same operations without managing a service collection.
var html = await StaticPrismService.HighlightAsync(code, "csharp");
Next
Read Exception Handling before you feed aliases from user input into the service.