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:
Example:
>>> from python_comrak import markdown_to_html
>>> markdown_to_html("\tfoo\tbaz\t\tbim\n")
"<pre><code>foo\tbaz\t\tbim\n</code></pre>\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")
"<pre><code>foo\tbaz\t\tbim\n</code></pre>\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
.
Benchmarks
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('README.md', 'r') as f:
... contents = f.read()
>>> 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file python_comrak-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_comrak-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848fed070658c1a089eab279f839e7c9bab1324ad365705d601682b90de01b69 |
|
MD5 | 1ab0cabf858ebbcb5446fdd93752a353 |
|
BLAKE2b-256 | 5b1e107a21d6a072c6c77ff93b115ea62e7c7a0003069b4a8a808fb27169d29c |
File details
Details for the file python_comrak-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_comrak-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f40a1e7c8bbdbd6b791a28ae60da0a543abedc0668e2c0d9fd1d130f2a90da9a |
|
MD5 | eadb1804472dadc44bd4f1f6f9071cbb |
|
BLAKE2b-256 | 793cae43652dfe1b54264e94b8d86ecdd9e0d186e16c9b97c49e145f384707a4 |
File details
Details for the file python_comrak-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_comrak-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b25870c47328f1376e75f9a5349ac0aa09c01ff8e4db1929e2bc040abad3a2b6 |
|
MD5 | 4d942334b4767a7f5e4a77d0a1c761a9 |
|
BLAKE2b-256 | ed46fecd7ef64be5289d2d9790e48937374e0d75b2d962bc21468152e771f45b |
File details
Details for the file python_comrak-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_comrak-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c26577ff3bb35d4e349df83eb1b771851e836f130fdc3c4cc08b278afcb89551 |
|
MD5 | 17a4f464fb4952dcab808f0296c6703b |
|
BLAKE2b-256 | d12687ab41a485b17559b05b15faf59ebff72a13677903019830b2d0a6ada4e9 |
File details
Details for the file python_comrak-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_comrak-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4d37ecfffe9372a271ef748be1c5c3a489ee38033fa83710ffc837133c22475 |
|
MD5 | a6c634409ea6891fc60466c46ed4da76 |
|
BLAKE2b-256 | 0fb2558cc0198d8cfe655f395fc7ff65aaad202d035b596b910a99c739aac9f3 |