A Python interface for markdown-it.rs, using Rust for blazingly fast Markdown parsing ⚡️
Low maintenance activity. Last release over 2 years ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
Consider insteadmarkdown-it-pyPythie’s Index: 65614.7M downloads/moCompare →
pip install markdown-it-pyrsmarkdown-it-pyrs
Currently in Beta, feedback welcome!
A Python interface for markdown-it.rs (and plugins), using Rust for blazingly fast Markdown parsing ⚡️
The goal of this project is to provide a fast, safe, extensible, and easy-to-use Markdown parser for Python. It is complimentary to markdown-it-py, which is a pure Python implementation of markdown-it, and here we aim to follow as close as possible the API for that package.
If you care primarily about speed, this is the library for you. For example, benchmarking the two libraries when parsing the CommonMark Spec file, markdown-it-pyrs is 20x faster than markdown-it-py.
| Name (time, ms) | Min | Max | Mean | Rounds |
|---|---|---|---|---|
| markdown-it-pyrs | 5.217 | 7.969 | 5.968 | 85 |
| markdown-it-py | 122.696 | 143.246 | 131.431 | 7 |
The drawback is that the library vendors compiled Rust code, and so:
- Parser plugins cannot currently be written in Python and added dynamically to the parser.
- It can be more difficult to integrate into environments like pyiodide and py-script (but maybe not for long: https://discuss.python.org/t/support-wasm-wheels-on-pypi/21924/3).
Usage
First install the package:
pip install markdown-it-pyrs
Then use it like you would markdown-it-py:
from markdown_it_pyrs import MarkdownIt
md = MarkdownIt("commonmark").enable("table")
md.render("# Hello, world!")
# '<h1>Hello, world!</h1>\n'