Home

Awesome

Markdig.Prism

An extension that adds syntax highlighting to a Markdig pipeline through Prism.js JavaScript library.

Usage

  1. Add WebStoating.Markdig.Prism to your project.
dotnet add package WebStoating.Markdig.Prism --version 1.0.0
  1. Create Markdig pipeline
private static readonly MarkdownPipeline MarkdownPipeline = new MarkdownPipelineBuilder()
    .UseAdvancedExtensions()
    .UsePrism()
    .Build();
  1. 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>
  1. Convert Markdown to HTML
var html = Markdown.ToHtml(markdown, MarkdownPipeline);