Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.02 KB

README.md

File metadata and controls

43 lines (31 loc) · 1.02 KB

PrismSharp

A porting of PrismJS to C# or .NET.

All supported language grammars are here.

Getting Started

Tokenize Code

Install PrismSharp.Core package:

dotnet add package PrismSharp.Core --prerelease

Then,

using PrismSharp.Core;

var text = @"<p>Hello world!</p>";
var grammar = LanguageGrammars.Html; // or defined yourself
var tokens = Prism.Tokenize(text, grammar);

Highlight Code

Install PrismSharp.Highlighting.HTML package:

dotnet add package PrismSharp.Highlighting.HTML --prerelease

Then,

using PrismSharp.Core;
using PrismSharp.Highlighting.HTML;

var text = @"<p>Hello world!</p>";
var grammar = LanguageGrammars.Html; // or defined yourself
var highlighter = new HtmlHighlighter();
var html = highlighter.Highlight(text, grammar, "html");

The css styles can customize yourself, or download from PrismJS.