https://github.com/markdown-it-rust/markdown-it
markdown-it js library rewritten in rust
https://github.com/markdown-it-rust/markdown-it
Last synced: 6 months ago
JSON representation
markdown-it js library rewritten in rust
- Host: GitHub
- URL: https://github.com/markdown-it-rust/markdown-it
- Owner: markdown-it-rust
- License: other
- Created: 2022-05-21T14:12:44.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-07T17:51:21.000Z (over 1 year ago)
- Last Synced: 2025-03-30T13:08:58.706Z (6 months ago)
- Language: Rust
- Size: 793 KB
- Stars: 90
- Watchers: 5
- Forks: 11
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# markdown-it
[
](https://markdown-it-rust.github.io/markdown-it/)
[](https://github.com/markdown-it-rust/markdown-it)
[](https://docs.rs/markdown-it)
[](https://crates.io/crates/markdown-it)
[](https://app.codecov.io/gh/markdown-it-rust/markdown-it)
Rust port of popular [markdown-it.js](https://github.com/markdown-it/markdown-it) library.
TL;DR:
- if you want to get result *fast*, use [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark)
- if you want to render GFM exactly like github, use [comrak](https://github.com/kivikakk/comrak)
- if you want to define your own syntax (like `@mentions`, `:emoji:`, custom html classes), use this libraryYou can check a [demo](https://markdown-it-rust.github.io/markdown-it/) 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
```rust
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 "Hello world!
"
```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](https://github.com/mundimark/awesome-markdown-alternatives) plain text format with this without too much effort. I might eventually write these as proof-of-concept.*