Awesome
Markdig.Prism
An extension that adds syntax highlighting to a Markdig pipeline through Prism.js JavaScript library.
Usage
- Add
WebStoating.Markdig.Prism
to your project.
dotnet add package WebStoating.Markdig.Prism --version 1.0.0
- Create Markdig pipeline
private static readonly MarkdownPipeline MarkdownPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UsePrism()
.Build();
- Download Prism and add it to your Razor page or layout template.
<!DOCTYPE html>
<html>
<head>
...
<link href="themes/prism.css" rel="stylesheet" />
</head>
<body>
...
<script src="prism.js"></script>
</body>
</html>
- Convert Markdown to HTML
var html = Markdown.ToHtml(markdown, MarkdownPipeline);