Markdig.Signed
0.30.1
Prefix Reserved
See the version list below for details.
dotnet add package Markdig.Signed --version 0.30.1
NuGet\Install-Package Markdig.Signed -Version 0.30.1
<PackageReference Include="Markdig.Signed" Version="0.30.1" />
paket add Markdig.Signed --version 0.30.1
#r "nuget: Markdig.Signed, 0.30.1"
// Install Markdig.Signed as a Cake Addin #addin nuget:?package=Markdig.Signed&version=0.30.1 // Install Markdig.Signed as a Cake Tool #tool nuget:?package=Markdig.Signed&version=0.30.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 MarkdownEditor for Visual Studio 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)
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:
- Markdig (version: 0.5.x): itself
- CommonMark.NET(master) (version: 0.11.0): CommonMark implementation for .NET, no support for extensions, port of cmark
- CommonMark.NET(pipe_tables): An evolution of CommonMark.NET, supports extensions, not released yet
- MarkdownDeep (version: 1.5.0): another .NET implementation
- MarkdownSharp (version: 1.13.0): Open source C# implementation of Markdown processor, as featured on Stack Overflow, regexp based.
- Marked.NET (version: 1.0.5) port of original marked.js project
- Microsoft.DocAsCode.MarkdownLite (version: 2.0.1) used by the docfx project
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:
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!
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 is compatible. 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 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. 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. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.5.2
- System.Memory (>= 4.5.4)
-
.NETStandard 2.0
- System.Memory (>= 4.5.4)
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (58)
Showing the top 5 NuGet packages that depend on Markdig.Signed:
Package | Downloads |
---|---|
Microsoft.PowerShell.Commands.Utility
Runtime for hosting PowerShell |
|
Microsoft.PowerShell.MarkdownRender
MarkdownRenderer for PowerShell |
|
Microsoft.Quantum.Compiler
The Q# compiler. |
|
Soneta.Types
Składnik programu Soneta. Program obsługi firmy: kadry-płace, księgowość, handel, magazyn, CRM, BI ... |
|
Microsoft.Quantum.CSharpGeneration
C# code generation for executing Q# programs on a quantum simulator. |
GitHub repositories (22)
Showing the top 5 popular GitHub repositories that depend on Markdig.Signed:
Repository | Stars |
---|---|
microsoft/PowerToys
Windows system utilities to maximize productivity
|
|
PowerShell/PowerShell
PowerShell for every system!
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
JustArchiNET/ArchiSteamFarm
C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
|
|
microsoft/fluentui-blazor
Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
|
Version | Downloads | Last updated |
---|---|---|
0.38.0 | 4,097 | 10/25/2024 |
0.37.0 | 170,707 | 4/9/2024 |
0.36.2 | 24,867 | 3/14/2024 |
0.36.1 | 218 | 3/14/2024 |
0.36.0 | 570 | 3/14/2024 |
0.35.0 | 20,675 | 2/17/2024 |
0.34.0 | 57,392 | 12/14/2023 |
0.33.0 | 1,319,351 | 8/30/2023 |
0.32.0 | 28,901 | 8/4/2023 |
0.31.0 | 1,378,458 | 2/27/2023 |
0.30.4 | 1,085,185 | 9/27/2022 |
0.30.3 | 40,731 | 8/12/2022 |
0.30.2 | 121,817 | 4/23/2022 |
0.30.1 | 1,551 | 4/22/2022 |
0.30.0 | 2,055 | 4/21/2022 |
0.29.0 | 2,699 | 4/20/2022 |
0.28.1 | 15,241 | 3/27/2022 |
0.28.0 | 5,999 | 3/11/2022 |
0.27.0 | 38,322 | 1/23/2022 |
0.26.0 | 279,303 | 8/27/2021 |
0.25.0 | 29,959 | 6/10/2021 |
0.24.0 | 31,755 | 3/20/2021 |
0.23.0 | 66,270 | 1/16/2021 |
0.22.1 | 382,295 | 12/2/2020 |
0.22.0 | 1,961,977 | 10/5/2020 |
0.21.1 | 1,508,553 | 8/17/2020 |
0.20.0 | 698,012 | 4/18/2020 |
0.18.3 | 1,024,827 | 3/8/2020 |
0.18.2 | 723 | 3/8/2020 |
0.18.1 | 205,192 | 1/21/2020 |
0.18.0 | 165,390 | 10/24/2019 |
0.17.1 | 978,099 | 7/4/2019 |
0.17.0 | 337,385 | 5/11/2019 |
0.16.0 | 170,739 | 2/25/2019 |
0.15.7 | 136,713 | 1/11/2019 |
0.15.6 | 226,804 | 12/28/2018 |
0.15.5 | 3,434 | 12/11/2018 |
0.15.4 | 242,062 | 10/7/2018 |
0.15.3 | 3,353 | 9/26/2018 |
0.15.2 | 150,002 | 8/21/2018 |
0.15.1 | 500,955 | 7/10/2018 |
0.15.0 | 2,798 | 4/4/2018 |
0.14.9 | 14,117 | 1/15/2018 |
0.14.8 | 4,718 | 12/5/2017 |
0.14.7 | 1,124 | 11/25/2017 |
0.14.6 | 1,318 | 11/21/2017 |
0.14.5 | 1,342 | 11/18/2017 |
0.14.4 | 1,293 | 11/18/2017 |
0.14.3 | 2,454 | 11/1/2017 |
0.14.2 | 1,303 | 11/1/2017 |
0.14.1 | 1,317 | 10/27/2017 |
0.14.0 | 1,295 | 10/27/2017 |
0.13.4 | 1,347 | 10/17/2017 |
0.13.3 | 23,958 | 8/30/2017 |
0.13.2 | 1,119 | 8/29/2017 |
0.13.1 | 1,122 | 8/21/2017 |
0.13.0 | 13,491 | 8/3/2017 |
0.12.4 | 2,450 | 8/3/2017 |