Skip to content
Open core software, built in Singapore Established 2018  /  Five utilities
Jering
Talk to us

Quick Start

Web.SyntaxHighlighters.Prism Jering documentation Open source NuGet package
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

Package Manager
dotnet add package Jering.Web.SyntaxHighlighters.Prism

Create the service

C#
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.

C#
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.

C#
var html = await StaticPrismService.HighlightAsync(code, "csharp");

Next

Read Exception Handling before you feed aliases from user input into the service.

Reference shelf