Markdig



  1. Markdig Nuget
  2. Use Markdown With ASP.NET Core - CODE Mag
  3. Markdig Table

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!

Markdig

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! Markdig Extension – Bad Header Handler First off, if you haven’t seen Markdig yet, you’re missing out! It has to be the most extensible Markdown processor I’ve ever seen, and it is still incredibly fast. It’s slim enough to confidently use on small.NET Clients like Xamarin, and supports custom output as. Rendering HTML with MarkDig To convert the Markdown into HTML, I used the superb MarkDig library. This not only makes it super easy to convert basic Markdown to HTML, but supports several useful extensions. Rossibel Rojas Huama (@rossibel.markdig) en TikTok 144 me gusta. 📊 ℕ𝕖𝕘𝕠𝕔𝕚𝕠𝕤 𝕆𝕟𝕝𝕚𝕟𝕖 💎 𝔾𝕒𝕟𝕒.

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.29)
  • 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 @)
  • 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
    • 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:// or https:// or ftp:// or mailto: or www.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)
    • 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 and nomnoml 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)
  • Starting with Markdig version 0.20.0+, Markdig is compatible only with NETStandard 2.0, NETStandard 2.1, NETCoreApp 2.1 and NETCoreApp 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

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

See

Markdig Nuget

Markdig

Use Markdown With ASP.NET Core - CODE Mag

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:

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

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 Core RTM

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
See all results for this question

.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

JavaScript/V8 implementations:

  • Strike.V8 (version: 1.5.0) marked.js running in Google V8 (not .NET based)

Markdig Table

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:

Performance for x64:

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