A porting of PrismJS to C# or .NET.
All supported language grammars are here.
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);
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.