Skip to main content

Markdown HTML converters for Python made in Rust

Project description

Markdown HTML converters for Python made in Rust

Exposes two Rust crates which parse markdown to Python using PyO3.

Using Comrak

The first crate exposed is comrak from which we inherited the name:


  >>> from python_comrak import markdown_to_html
  >>> markdown_to_html("\tfoo\tbaz\t\tbim\n")

markdown_to_html activates the extensions:

Using pulldown-cmark

The second crate is pulldown-cmark. Example:

  >>> from python_comrak import commonmark_to_html
  >>> commonmark_to_html("\tfoo\tbaz\t\tbim\n")

commonmark_to_html activates the extensions:

Notice that pulldown-cmark doesn't implement 100% of CommonMark yet. Also it doesn't have the same set of extensions we use with comrak.


This implementation is quite simple and doesn't allow much of the underlying crates. The extensions and options are fixed. The following is just a micro-benchmark parsing the text of this README file:

>>> with open('', 'r') as f:
...     contents =

>>> from python_comrak import markdown_to_html, commonmark_to_html

>>> %timeit markdown_to_html(contents)
54.4 µs ± 1.24 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

>>> %timeit commonmark_to_html(contents)
12.5 µs ± 97.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-comrak, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size python_comrak-0.3.2-cp38-cp38-manylinux2010_x86_64.whl (1.5 MB) File type Wheel Python version cp38 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page