Markdig 0.30.2 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved

.NET 6.0 .NET Core 3.1 .NET Standard 2.0 .NET Framework 4.5.2
Install-Package Markdig -Version 0.30.2
dotnet add package Markdig --version 0.30.2
<PackageReference Include="Markdig" Version="0.30.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Markdig --version 0.30.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Markdig, 0.30.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Markdig as a Cake Addin
#addin nuget:?package=Markdig&version=0.30.2

// Install Markdig as a Cake Tool
#tool nuget:?package=Markdig&version=0.30.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Markdig Build Status Coverage Status NuGet Donate

<img align="right" width="160px" height="160px" src="img/markdig.png">

Markdig is a fast, powerful, CommonMark compliant, extensible Markdown processor for .NET.

NOTE: The repository is under construction. There will be a dedicated website and proper documentation at some point!

You can try Markdig online and compare it to other implementations on babelmark3

Features

If you are looking for support for an old .NET Framework 3.5 or 4.0, you can download Markdig 0.18.3.

Third Party Extensions

Documentation

The repository is under construction. There will be a dedicated website and proper documentation at some point!

While there is not yet a dedicated documentation, you can find from the specs documentation how to use these extensions.

In the meantime, you can have a "behind the scene" article about Markdig in my blog post "Implementing a Markdown Engine for .NET"

Download

Markdig is available as a NuGet package: NuGet

Also Markdig.Signed NuGet package provides signed assemblies.

Usage

The main entry point for the API is the Markdig.Markdown class:

By default, without any options, Markdig is using the plain CommonMark parser:

var result = Markdown.ToHtml("This is a text with some *emphasis*");
Console.WriteLine(result);   // prints: <p>This is a text with some <em>emphasis</em></p>

In order to activate most of all advanced extensions (except Emoji, SoftLine as HardLine, Bootstrap, YAML Front Matter, JiraLinks and SmartyPants)

// Configure the pipeline with all advanced extensions active
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
var result = Markdown.ToHtml("This is a text with some *emphasis*", pipeline);

Try it online!

You can have a look at the MarkdownExtensions that describes all actionable extensions (by modifying the MarkdownPipeline)

Build

In order to build Markdig, you need to install .NET 6.0

License

This software is released under the BSD-Clause 2 license.

Benchmarking

This is an early preview of the benchmarking against various implementations:

C implementations:

  • cmark (version: 0.25.0): Reference C implementation of CommonMark, no support for extensions
  • Moonshine (version: : popular C Markdown processor

.NET implementations:

Analysis of the results:

  • Markdig is roughly x100 times faster than MarkdownSharp, 30x times faster than docfx
  • Among the best in CPU, Extremely competitive and often faster than other implementations (not feature wise equivalent)
  • 15% to 30% less allocations and GC pressure

Because Marked.NET, MarkdownSharp and DocAsCode.MarkdownLite are way too slow, they are not included in the following charts:

BenchMark CPU Time

BenchMark Memory

Performance for x86:

BenchmarkDotNet-Dev=v0.9.7.0+
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4770 CPU 3.40GHz, ProcessorCount=8
Frequency=3319351 ticks, Resolution=301.2637 ns, Timer=TSC
HostCLR=MS.NET 4.0.30319.42000, Arch=32-bit RELEASE
JitModules=clrjit-v4.6.1080.0

Type=Program  Mode=SingleRun  LaunchCount=2
WarmupCount=2  TargetCount=10

                     Method |      Median |    StdDev |Scaled |  Gen 0 | Gen 1|    Gen 2|Bytes Allocated/Op |
--------------------------- |------------ |---------- |------ | ------ |------|---------|------------------ |
                    Markdig |   5.5316 ms | 0.0372 ms |  0.71 |   56.00| 21.00|    49.00|      1,285,917.31 |
     CommonMark.NET(master) |   4.7035 ms | 0.0422 ms |  0.60 |  113.00|  7.00|    49.00|      1,502,404.60 |
CommonMark.NET(pipe_tables) |   5.6164 ms | 0.0298 ms |  0.72 |  111.00| 56.00|    49.00|      1,863,128.13 |
               MarkdownDeep |   7.8193 ms | 0.0334 ms |  1.00 |  120.00| 56.00|    49.00|      1,884,854.85 |
                      cmark |   4.2698 ms | 0.1526 ms |  0.55 |       -|     -|        -|                NA |
                  Moonshine |   6.0929 ms | 0.1053 ms |  1.28 |       -|     -|        -|                NA |
                 Marked.NET | 207.3169 ms | 5.2628 ms | 26.51 |    0.00|  0.00|     0.00|    303,125,228.65 |
              MarkdownSharp | 675.0185 ms | 2.8447 ms | 86.32 |   40.00| 27.00|    41.00|      2,413,394.17 |
Microsoft DocfxMarkdownLite | 166.3357 ms | 0.4529 ms | 21.27 |4,452.00|948.00|11,167.00|    180,218,359.60 |

Performance for x64:

BenchmarkDotNet-Dev=v0.9.6.0+
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, ProcessorCount=8
Frequency=3319351 ticks, Resolution=301.2637 ns, Timer=TSC
HostCLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT]
JitModules=clrjit-v4.6.1080.0

Type=Program  Mode=SingleRun  LaunchCount=2
WarmupCount=2  TargetCount=10

               Method |    Median |    StdDev |  Gen 0 |  Gen 1 | Gen 2 | Bytes Allocated/Op |
--------------------- |---------- |---------- |------- |------- |------ |------------------- |
          TestMarkdig | 5.5276 ms | 0.0402 ms | 109.00 |  96.00 | 84.00 |       1,537,027.66 |
    TestCommonMarkNet | 4.4661 ms | 0.1190 ms | 157.00 |  96.00 | 84.00 |       1,747,432.06 |
 TestCommonMarkNetNew | 5.3151 ms | 0.0815 ms | 229.00 | 168.00 | 84.00 |       2,323,922.97 |
     TestMarkdownDeep | 7.4076 ms | 0.0617 ms | 318.00 | 186.00 | 84.00 |       2,576,728.69 |

Donate

If you are using this library and find it useful for your project, please consider a donation for it!

Donate

Credits

Thanks to the fantastic work done by John Mac Farlane for the CommonMark specs and all the people involved in making Markdown a better standard!

This project would not have been possible without this huge foundation.

Thanks also to the project BenchmarkDotNet that makes benchmarking so easy to setup!

Some decoding part (e.g HTML EntityHelper.cs) have been re-used from CommonMark.NET

Thanks to the work done by @clarkd on the JIRA Link extension (https://github.com/clarkd/MarkdigJiraLinker), now included with this project!

Author

Alexandre MUTEL aka xoofx

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5.2

  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (190)

Showing the top 5 NuGet packages that depend on Markdig:

Package Downloads
ppy.osu.Framework

A 2D application/game framework written with rhythm games in mind.

Westwind.AspNetCore.Markdown

This library provides Markdown support for ASP.NET Core applications: * Markdown TagHelper - embed static markdown text from files, urls or bind model data * Markdown Page Handler Middleware to render Markdown files in your site * Markdown Parsing Support via Markdown.Parse() and Markdown.ParseHtmlString() * Markdown Parsing from Files via Markdown.ParseFromFile() and .ParseFromFileAsync() * Markdown Parsing from URL via Markdown.ParseFromUrl() and .ParseFromUrlAsync() * Supports basic HTML Sanitation * TagHelper supports White Space Normalization * Customization of Markdown Processing Options For similar features in System.Web based classic ASP.NET apps see `Westwind.Web.Markdown`.

Octostache

Variable substitution syntax used in Octopus Deploy.

Indice.AspNetCore

Indice.AspNetCore Class Library

OO.Presentation.Component.Tools

Razor Tools Components technology server types and implementations for EasyDataCore infrastructure

GitHub repositories (61)

Showing the top 5 popular GitHub repositories that depend on Markdig:

Repository Stars
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
veler/DevToys
A Swiss Army knife for developers.
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0, 6.0 and 7.0 projects you can use. Readme contains explanations on all projects.
OrchardCMS/OrchardCore
Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
Version Downloads Last updated
0.30.2 24,270 4/23/2022
0.30.1 1,700 4/22/2022
0.30.0 11,193 4/21/2022
0.29.0 780 4/20/2022
0.28.1 41,245 3/27/2022
0.28.0 40,090 3/11/2022
0.27.0 139,351 1/23/2022
0.26.0 564,748 8/27/2021
0.25.0 375,226 6/10/2021
0.24.0 535,599 3/20/2021
0.23.0 560,275 1/16/2021
0.22.1 302,965 12/2/2020
0.22.0 630,771 10/5/2020
0.21.1 340,769 8/17/2020
0.21.0 2,472 8/17/2020
0.20.0 519,186 4/18/2020
0.18.3 237,548 3/8/2020
0.18.2 550 3/8/2020
0.18.1 310,466 1/21/2020
0.18.0 403,211 10/24/2019
0.17.1 464,533 7/4/2019
0.17.0 385,162 5/11/2019
0.16.0 340,786 2/25/2019
0.15.7 98,155 1/11/2019
0.15.6 19,384 12/28/2018
0.15.5 57,533 12/11/2018
0.15.4 340,807 10/7/2018
0.15.3 13,972 9/26/2018
0.15.2 178,393 8/21/2018
0.15.1 65,435 7/10/2018
0.15.0 298,164 4/4/2018
0.14.9 268,524 1/15/2018
0.14.8 145,454 12/5/2017
0.14.7 24,211 11/25/2017
0.14.6 31,742 11/21/2017
0.14.5 6,067 11/18/2017
0.14.4 2,613 11/18/2017
0.14.3 31,716 11/1/2017
0.14.2 2,605 11/1/2017
0.14.1 5,164 10/27/2017
0.14.0 2,612 10/27/2017
0.13.4 21,194 10/17/2017
0.13.3 55,507 8/30/2017
0.13.2 11,548 8/29/2017
0.13.1 136,472 8/21/2017
0.13.0 7,660 8/3/2017
0.12.4 17,915 7/31/2017
0.12.3 31,444 6/26/2017
0.12.2 5,307 6/18/2017
0.12.1 53,733 5/29/2017
0.12.0 2,669 5/28/2017
0.11.0 15,908 5/8/2017
0.10.7 24,414 4/1/2017
0.10.6 85,019 2/24/2017
0.10.5 48,915 2/14/2017
0.10.4 189,133 12/12/2016
0.10.3 30,333 11/29/2016
0.10.2 2,560 11/26/2016
0.10.1 4,256 11/19/2016
0.10.0 9,894 10/16/2016
0.9.1 3,481 10/11/2016
0.9.0 3,420 10/11/2016
0.8.5 4,935 9/23/2016
0.8.4 2,719 9/22/2016
0.8.3 3,101 9/22/2016
0.8.2 3,034 9/22/2016
0.8.1 3,027 9/21/2016
0.8.0 3,022 9/19/2016
0.7.5 2,869 9/18/2016
0.7.4 9,872 7/30/2016
0.7.3 3,927 7/23/2016
0.7.2 5,799 7/20/2016
0.7.1 4,868 6/30/2016
0.7.0 2,956 6/27/2016
0.6.2 2,745 6/25/2016
0.6.1 2,785 6/24/2016
0.6.0 2,714 6/24/2016
0.5.12 2,704 6/23/2016
0.5.11 2,709 6/23/2016
0.5.10 2,705 6/22/2016
0.5.9 31,592 6/21/2016
0.5.8 2,773 6/21/2016
0.5.7 2,771 6/20/2016
0.5.6 2,723 6/20/2016
0.5.5 2,725 6/20/2016
0.5.4 2,709 6/19/2016
0.5.3 2,726 6/19/2016
0.5.2 2,736 6/17/2016
0.5.1 2,903 6/15/2016
0.5.0 2,717 6/15/2016
0.4.0 2,943 6/13/2016
0.3.4 2,711 6/10/2016
0.3.3 2,790 6/10/2016
0.3.2 2,715 6/9/2016
0.3.1 2,700 6/9/2016
0.3.0 2,696 6/8/2016
0.2.1 2,708 6/6/2016
0.2.0 2,778 5/30/2016
0.1.1 2,709 5/30/2016
0.1.0 3,684 5/25/2016