Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/monosans/pyromark
Blazingly fast Markdown parser for Python written in Rust.
https://github.com/monosans/pyromark
converter html
Last synced: 20 days ago
JSON representation
Blazingly fast Markdown parser for Python written in Rust.
- Host: GitHub
- URL: https://github.com/monosans/pyromark
- Owner: monosans
- License: mit
- Created: 2023-05-07T12:54:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-23T00:36:23.000Z (6 months ago)
- Last Synced: 2024-05-23T01:36:57.782Z (6 months ago)
- Topics: converter, html
- Language: Python
- Homepage: https://pyromark.readthedocs.io
- Size: 368 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pyromark
[![CI](https://github.com/monosans/pyromark/actions/workflows/ci.yml/badge.svg)](https://github.com/monosans/pyromark/actions/workflows/ci.yml)
[![Downloads](https://static.pepy.tech/badge/pyromark)](https://pepy.tech/project/pyromark)pyromark (stands for Python Rust Optimized Markdown) is a blazingly fast CommonMark-compliant Markdown parser for Python.
Uses [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark) Rust crate under the hood.
## Installation
```bash
python -m pip install -U pyromark
```## Documentation
### Basic examples
See documentation for more comprehensive examples.
#### Convert Markdown to HTML
```python
import pyromarkhtml = pyromark.markdown("# Hello world")
assert html == "Hello world
\n"
```#### Iterating over Markdown elements
```python
import pyromarkfor event in pyromark.events("# Hello world"):
# All event types are fully type annotated
# so you will get static type checking
# and Tab completions in your IDE!
match event:
case ("Start", ("Heading", {"level": heading_level})):
print(f"Heading with {heading_level} level started")
case ("Text", text):
print(f"Got {text!r} text")
case ("End", ("Heading", heading_level)):
print(f"Heading with {heading_level} level ended")
case other_event:
print(f"Got {other_event!r}")
```## Documentation
## Performance
128x faster than [Markdown](https://pypi.org/project/Markdown/),
105x faster than [markdown-it-py](https://pypi.org/project/markdown-it-py/),
79x faster than [mistune](https://pypi.org/project/mistune/),
8x faster than [markdown-it-pyrs](https://pypi.org/project/markdown-it-pyrs/).If you use threading, the difference with other libraries will be even more enormous, since pyromark releases the [GIL](https://docs.python.org/3/glossary.html#term-global-interpreter-lock).
See [benchmark](https://pyromark.readthedocs.io/en/latest/performance/).
## License
[MIT](https://github.com/monosans/pyromark/blob/main/LICENSE)