Markdig 0.39.1
Prefix Reserveddotnet add package Markdig --version 0.39.1
NuGet\Install-Package Markdig -Version 0.39.1
<PackageReference Include="Markdig" Version="0.39.1" />
paket add Markdig --version 0.39.1
#r "nuget: Markdig, 0.39.1"
// Install Markdig as a Cake Addin #addin nuget:?package=Markdig&version=0.39.1 // Install Markdig as a Cake Tool #tool nuget:?package=Markdig&version=0.39.1
Markdig
<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
- Very fast parser and html renderer (no-regexp), very lightweight in terms of GC pressure. See benchmarks
- Abstract Syntax Tree with precise source code location for syntax tree, useful when building a Markdown editor.
- Checkout Markdown Editor v2 for Visual Studio 2022 powered by Markdig!
- Converter to HTML
- Passing more than 600+ tests from the latest CommonMark specs (0.30)
- Includes all the core elements of CommonMark:
- including GFM fenced code blocks.
- Extensible architecture
- Even the core Markdown/CommonMark parsing is pluggable, so it allows to disable builtin Markdown/Commonmark parsing (e.g Disable HTML parsing) or change behaviour (e.g change matching
#
of a headers with@
)
- Even the core Markdown/CommonMark parsing is pluggable, so it allows to disable builtin Markdown/Commonmark parsing (e.g Disable HTML parsing) or change behaviour (e.g change matching
- Roundtrip support: Parses trivia (whitespace, newlines and other characters) to support lossless parse ⭢ render roundtrip. This enables changing markdown documents without introducing undesired trivia changes.
- Built-in with 20+ extensions, including:
- 2 kind of tables:
- Pipe tables (inspired from GitHub tables and PanDoc - Pipe Tables)
- Grid tables (inspired from Pandoc - Grid Tables)
- Extra emphasis (inspired from Pandoc - Emphasis and Markdown-it)
- strike through
~~
, - Subscript
~
- Superscript
^
- Inserted
++
- Marked
==
- strike through
- Special attributes or attached HTML attributes (inspired from PHP Markdown Extra - Special Attributes)
- Definition lists (inspired from PHP Markdown Extra - Definitions Lists)
- Footnotes (inspired from PHP Markdown Extra - Footnotes)
- Auto-identifiers for headings (similar to Pandoc - Auto Identifiers)
- Auto-links generates links if a text starts with
http://
orhttps://
orftp://
ormailto:
orwww.xxx.yyy
- Task Lists inspired from Github Task lists.
- Extra bullet lists, supporting alpha bullet
a.
b.
and roman bullet (i
,ii
...etc.) - Media support for media url (youtube, vimeo, mp4...etc.) (inspired from this CommonMark discussion)
- Abbreviations (inspired from PHP Markdown Extra - Abbreviations)
- Citation text by enclosing
""...""
(inspired by this CommonMark discussion ) - Custom containers similar to fenced code block
:::
for generating a proper<div>...</div>
instead (inspired by this CommonMark discussion ) - Figures (inspired from this CommonMark discussion)
- Footers (inspired from this CommonMark discussion)
- Mathematics/Latex extension by enclosing
$$
for block and$
for inline math (inspired from this CommonMark discussion) - Soft lines as hard lines
- Emoji support (inspired from Markdown-it)
- SmartyPants (inspired from Daring Fireball - SmartyPants)
- Bootstrap class (to output bootstrap class)
- Diagrams extension whenever a fenced code block contains a special keyword, it will be converted to a div block with the content as-is (currently, supports
mermaid
andnomnoml
diagrams) - YAML Front Matter to parse without evaluating the front matter and to discard it from the HTML output (typically used for previewing without the front matter in MarkdownEditor)
- JIRA links to automatically generate links for JIRA project references (Thanks to @clarkd: https://github.com/clarkd/MarkdigJiraLinker)
- 2 kind of tables:
- Starting with Markdig version
0.20.0+
, Markdig is compatible only withNETStandard 2.0
,NETStandard 2.1
,NETCoreApp 2.1
andNETCoreApp 3.1
.
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
- WPF/XAML Markdown Renderer:
markdig.wpf
- WPF/XAML Markdown Renderer:
Neo.Markdig.Xaml
- Syntax highlighting:
Markdig.SyntaxHighlighting
- Syntax highlighting using ColorCode-Universal:
Markdown.ColorCode
- Syntax highlighting using Prism.js:
WebStoating.Markdig.Prism
- Embedded C# scripting:
Markdig.Extensions.ScriptCs
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:
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);
You can have a look at the MarkdownExtensions that describes all actionable extensions (by modifying the MarkdownPipeline)
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. For detailed contributing guidelines, please see contributing.md.
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
The latest benchmark was collected on April 23 2022, against the following implementations:
- Markdig (version: 0.30.2): itself
- cmark (version: 0.30.2): Reference C implementation of CommonMark, no support for extensions
- CommonMark.NET(master) (version: 0.15.1): CommonMark implementation for .NET, no support for extensions, port of cmark, deprecated.
- MarkdownSharp (version: 2.0.5): Open source C# implementation of Markdown processor, as featured previously on Stack Overflow, regexp based.
// * Summary *
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
AMD Ryzen 9 5950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK=6.0.202
[Host] : .NET 6.0.4 (6.0.422.16404), X64 RyuJIT
DefaultJob : .NET 6.0.4 (6.0.422.16404), X64 RyuJIT
| Method | Mean | Error | StdDev |
|------------------ |-----------:|----------:|----------:|
| markdig | 1.979 ms | 0.0221 ms | 0.0185 ms |
| cmark | 2.571 ms | 0.0081 ms | 0.0076 ms |
| CommonMark.NET | 2.016 ms | 0.0169 ms | 0.0158 ms |
| MarkdownSharp | 221.455 ms | 1.4442 ms | 1.3509 ms |
- Markdig is roughly x100 times faster than MarkdownSharp
- 20% faster than the reference cmark C implementation
Sponsors
Supports this project with a monthly donation and help me continue improving it. [Become a sponsor]
<img src="https://github.com/lilith.png?size=200" width="64px;" style="border-radius: 50%" alt="lilith"/> Lilith River, author of Imageflow Server, an easy on-demand image editing, optimization, and delivery server
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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Memory (>= 4.5.5)
-
.NETStandard 2.0
- System.Memory (>= 4.5.5)
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (341)
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 |
|
Octostache
Variable substitution syntax used in Octopus Deploy. |
|
FenixAlliance.ACL.Dependencies
Application Component for the Alliance Business Suite. |
|
Piranha
Core package for Piranha CMS for .NET Core |
GitHub repositories (148)
Showing the top 5 popular GitHub repositories that depend on Markdig:
Repository | Stars |
---|---|
DevToys-app/DevToys
A Swiss Army knife for developers.
|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
dotnet/maui
.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
JosefNemec/Playnite
Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
|
Version | Downloads | Last updated |
---|---|---|
0.39.1 | 6,897 | 12/19/2024 |
0.39.0 | 5,576 | 12/17/2024 |
0.38.0 | 265,440 | 10/25/2024 |
0.37.0 | 1,751,984 | 4/9/2024 |
0.36.2 | 315,161 | 3/14/2024 |
0.36.1 | 332 | 3/14/2024 |
0.36.0 | 18,669 | 3/14/2024 |
0.35.0 | 312,535 | 2/17/2024 |
0.34.0 | 699,142 | 12/14/2023 |
0.33.0 | 1,842,858 | 8/30/2023 |
0.32.0 | 298,340 | 8/4/2023 |
0.31.0 | 1,730,802 | 2/27/2023 |
0.30.4 | 1,901,738 | 9/27/2022 |
0.30.3 | 651,864 | 8/12/2022 |
0.30.2 | 1,309,728 | 4/23/2022 |
0.30.1 | 6,203 | 4/22/2022 |
0.30.0 | 53,539 | 4/21/2022 |
0.29.0 | 2,843 | 4/20/2022 |
0.28.1 | 211,166 | 3/27/2022 |
0.28.0 | 199,451 | 3/11/2022 |
0.27.0 | 517,199 | 1/23/2022 |
0.26.0 | 1,957,460 | 8/27/2021 |
0.25.0 | 801,802 | 6/10/2021 |
0.24.0 | 2,194,397 | 3/20/2021 |
0.23.0 | 1,694,238 | 1/16/2021 |
0.22.1 | 551,668 | 12/2/2020 |
0.22.0 | 2,368,585 | 10/5/2020 |
0.21.1 | 617,927 | 8/17/2020 |
0.21.0 | 9,132 | 8/17/2020 |
0.20.0 | 1,045,813 | 4/18/2020 |
0.18.3 | 394,349 | 3/8/2020 |
0.18.2 | 1,983 | 3/8/2020 |
0.18.1 | 513,675 | 1/21/2020 |
0.18.0 | 683,551 | 10/24/2019 |
0.17.1 | 717,681 | 7/4/2019 |
0.17.0 | 439,745 | 5/11/2019 |
0.16.0 | 551,464 | 2/25/2019 |
0.15.7 | 149,158 | 1/11/2019 |
0.15.6 | 22,126 | 12/28/2018 |
0.15.5 | 66,897 | 12/11/2018 |
0.15.4 | 692,162 | 10/7/2018 |
0.15.3 | 19,478 | 9/26/2018 |
0.15.2 | 238,293 | 8/21/2018 |
0.15.1 | 90,362 | 7/10/2018 |
0.15.0 | 621,676 | 4/4/2018 |
0.14.9 | 325,092 | 1/15/2018 |
0.14.8 | 177,932 | 12/5/2017 |
0.14.7 | 34,808 | 11/25/2017 |
0.14.6 | 67,113 | 11/21/2017 |
0.14.5 | 10,317 | 11/18/2017 |
0.14.4 | 3,951 | 11/18/2017 |
0.14.3 | 37,908 | 11/1/2017 |
0.14.2 | 4,006 | 11/1/2017 |
0.14.1 | 8,378 | 10/27/2017 |
0.14.0 | 3,949 | 10/27/2017 |
0.13.4 | 42,406 | 10/17/2017 |
0.13.3 | 77,551 | 8/30/2017 |
0.13.2 | 14,772 | 8/29/2017 |
0.13.1 | 143,894 | 8/21/2017 |
0.13.0 | 10,008 | 8/3/2017 |
0.12.4 | 29,349 | 7/31/2017 |
0.12.3 | 45,229 | 6/26/2017 |
0.12.2 | 8,546 | 6/18/2017 |
0.12.1 | 85,566 | 5/29/2017 |
0.12.0 | 4,055 | 5/28/2017 |
0.11.0 | 48,133 | 5/8/2017 |
0.10.7 | 26,955 | 4/1/2017 |
0.10.6 | 122,901 | 2/24/2017 |
0.10.5 | 61,078 | 2/14/2017 |
0.10.4 | 523,997 | 12/12/2016 |
0.10.3 | 53,118 | 11/29/2016 |
0.10.2 | 3,912 | 11/26/2016 |
0.10.1 | 6,035 | 11/19/2016 |
0.10.0 | 14,814 | 10/16/2016 |
0.9.1 | 4,846 | 10/11/2016 |
0.9.0 | 4,753 | 10/11/2016 |
0.8.5 | 7,407 | 9/23/2016 |
0.8.4 | 4,068 | 9/22/2016 |
0.8.3 | 4,444 | 9/22/2016 |
0.8.2 | 4,444 | 9/22/2016 |
0.8.1 | 4,358 | 9/21/2016 |
0.8.0 | 4,359 | 9/19/2016 |
0.7.5 | 4,285 | 9/18/2016 |
0.7.4 | 24,514 | 7/30/2016 |
0.7.3 | 5,543 | 7/23/2016 |
0.7.2 | 8,129 | 7/20/2016 |
0.7.1 | 6,679 | 6/30/2016 |
0.7.0 | 4,336 | 6/27/2016 |
0.6.2 | 4,111 | 6/25/2016 |
0.6.1 | 4,101 | 6/24/2016 |
0.6.0 | 4,031 | 6/24/2016 |
0.5.12 | 4,030 | 6/23/2016 |
0.5.11 | 4,013 | 6/23/2016 |
0.5.10 | 4,066 | 6/22/2016 |
0.5.9 | 33,105 | 6/21/2016 |
0.5.8 | 4,139 | 6/21/2016 |
0.5.7 | 4,130 | 6/20/2016 |
0.5.6 | 4,066 | 6/20/2016 |
0.5.5 | 4,100 | 6/20/2016 |
0.5.4 | 4,002 | 6/19/2016 |
0.5.3 | 4,066 | 6/19/2016 |
0.5.2 | 4,087 | 6/17/2016 |
0.5.1 | 4,237 | 6/15/2016 |
0.5.0 | 4,092 | 6/15/2016 |
0.4.0 | 4,242 | 6/13/2016 |
0.3.4 | 4,041 | 6/10/2016 |
0.3.3 | 4,100 | 6/10/2016 |
0.3.2 | 3,999 | 6/9/2016 |
0.3.1 | 4,043 | 6/9/2016 |
0.3.0 | 4,000 | 6/8/2016 |
0.2.1 | 4,075 | 6/6/2016 |
0.2.0 | 4,053 | 5/30/2016 |
0.1.1 | 4,056 | 5/30/2016 |
0.1.0 | 8,877 | 5/25/2016 |