pyromark - Blazingly Fast Markdown Parser
pyromark (stands for Python Rust Optimized Markdown) is a blazingly fast CommonMark-compliant Markdown parser for Python. It leverages the `pulldown-cmark` Rust crate under the hood for high performance, often outperforming other Python Markdown libraries significantly. The library is actively maintained and releases new versions periodically. It's designed for speed, including releasing the GIL for better threading performance.
Common errors
-
ERROR: Could not find a version that satisfies the requirement pyromark
cause This usually indicates an attempt to install on an unsupported Python version (e.g., Python 3.9 or older) or an issue with network connectivity preventing access to PyPI.fixVerify your Python version with `python --version`. If it's older than 3.10, upgrade to Python 3.10 or newer. Also, check your internet connection and PyPI accessibility. -
ImportError: cannot import name 'markdown' from 'pyromark'
cause Users might attempt to import `markdown` as a top-level function directly from the `pyromark` package, assuming a different API structure.fixThe main parsing function is a method on the imported `pyromark` module itself. Use `import pyromark` and then call `pyromark.markdown(your_text)`.
Warnings
- gotcha Be aware of naming collision: 'PyroMark' (with a capital 'P') is also a trademark for biotechnology instruments and reagents from QIAGEN. Ensure you are installing and using `pyromark` (lowercase 'p') for Markdown parsing, not the QIAGEN products.
- gotcha pyromark requires Python 3.10 or newer. Installing on older Python versions will fail.
- gotcha While pyromark is written in Rust and releases the GIL, this benefit is primarily for CPU-bound tasks in a multi-threaded Python application. For single-threaded applications or I/O-bound tasks, the performance gains from GIL release might not be as pronounced.
Install
-
pip install -U pyromark
Imports
- markdown
import pyromark html = pyromark.markdown('**Hello**, *world*!')
Quickstart
import pyromark
markdown_text = """
# My Title
This is some **bold** and *italic* text.
- Item 1
- Item 2
```python
print('Hello, Pyromark!')
```
"""
html_output = pyromark.markdown(markdown_text)
print(html_output)