#markdown #commonmark

bin+lib markdown-it

Rust port of popular markdown-it.js library

5 releases (3 breaking)

0.4.0 Oct 3, 2022
0.3.0 Sep 10, 2022
0.2.0 Aug 12, 2022
0.1.1 Jul 21, 2022
0.1.0 Jul 21, 2022

#521 in Text processing

Download history 2/week @ 2022-12-02 8/week @ 2022-12-09 12/week @ 2022-12-16 9/week @ 2022-12-23 2/week @ 2022-12-30 3/week @ 2023-01-06 2/week @ 2023-01-13 8/week @ 2023-01-20 14/week @ 2023-01-27 10/week @ 2023-02-03 28/week @ 2023-02-10 63/week @ 2023-02-17 23/week @ 2023-02-24 11/week @ 2023-03-03 14/week @ 2023-03-10 19/week @ 2023-03-17

105 downloads per month
Used in crabix-desktop

MIT license

235KB
5K SLoC

markdown-it

web demo github docs.rs crates.io coverage

Rust port of popular markdown-it.js library.

TL;DR:

  • if you want to get result fast, use pulldown-cmark
  • if you want to render GFM exactly like github, use comrak
  • if you want to define your own syntax (like @mentions, :emoji:, custom html classes), use this library

You can check a demo in your browser (it's Rust compiled into WASM).

Features

  • 100% CommonMark compatibility
  • AST
  • Source maps (full support, not just on block tags like cmark)
  • Ability to write your own syntax of arbitrary complexity
    • to prove this point, CommonMark syntax itself is written as a plugin

Usage

let parser = &mut markdown_it::MarkdownIt::new();
markdown_it::plugins::cmark::add(parser);
markdown_it::plugins::extra::add(parser);

let ast  = parser.parse("Hello **world**!");
let html = ast.render();

print!("{html}");
// prints "<p>Hello <strong>world</strong>!</p>"

For a guide on how to extend it, see examples folder.

Notes

This is an attempt at making a language-agnostic parser. You can probably parse AsciiDoc, reStructuredText or any other plain text format with this without too much effort. I might eventually write these as proof-of-concept.

Dependencies

~7.5MB
~177K SLoC