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

Advanced

Web.SyntaxHighlighters.HighlightJS Jering documentation Open source NuGet package
Documentation menu

These notes cover service lifetime, language handling and the class prefix used by highlight.js output.

Service lifetime

IHighlightJSService is a singleton and its members are thread safe. Resolve one instance and share it. Each new instance starts a Node.js process, which is wasted work in a web application.

Language aliases

Use a valid highlight.js language alias and validate user supplied values with IsValidLanguageAliasAsync. The language sources in the highlight.js repository are the reference for valid aliases.

Class prefix

HighlightAsync accepts a class prefix. The default is hljs. Change it only when your stylesheet expects a different prefix; mixing prefixes in one page produces unstyled output.

Disposal

Call Dispose() during shutdown when you want a deterministic stop. After disposal, calls throw ObjectDisposedException. The process also stops when its parent process dies.

Related topics

Reference shelf