Add your description here
Project description
puku-markdown
A CommonMark‑compliant Markdown parser for block elements, written in pure Python with an explicit stack – no recursion, no hidden state, and a strong focus on readability and maintainability. Requires Python 3.12 or higher.
Motivation
While markdown-it-py is a solid parser, its codebase has several pain points that this project addresses:
- Recursive descent → explicit stack –
puku-markdownuses an explicit stack, eliminating recursion limits and improving portability (e.g., to C). For example,markdown-it-pyrelies on recursion and a mutablestate.tightflag that becomes inconsistent across nested lists;puku-markdownstores per‑level state on an explicit stack instead. - No obscure quirks – Removes confusing state flags like
sCount = -1for continuation. - Readability first – Clean variable names, thorough comments, and a well‑structured codebase.
- Designed for long‑term maintenance – Every internal detail is documented and intentional.
This library was born from a deep refactoring attempt of
markdown-it-py. Instead of fighting the original code, we built a fresh, cleaner implementation.
Features
- ✅ CommonMark block elements – headings, code blocks, lists, blockquotes, HTML blocks, thematic breaks, and more.
- ✅ Explicit stack – no recursion, easy to reason about and port.
- ✅ Pure Python – no external runtime dependencies.
- ✅ Tested against
markdown-it-py– we reuse their extensive test suite for compliance.
Current status: Block elements are fully supported. Inline elements (emphasis, links, images, etc.) are planned.
Installation
pip install puku-markdown
Or with uv (recommended):
uv add puku-markdown
Quick Usage
from puku_markdown import parse
document = parse("""
# Heading
- List item 1
- List item 2
> A blockquote.
""")
print(document)
Development
Clone the repository and set up the environment:
git clone https://github.com/curlinkw/puku-markdown.git
cd puku-markdown
uv sync --group test
Run tests:
uv run pytest
Contributing
Issues and pull requests are welcome. Please ensure that changes pass the CommonMark test suite and maintain 100% compatibility for the supported block elements.
License
MIT License. See LICENSE for details.
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file puku_markdown-0.1.2.tar.gz.
File metadata
- Download URL: puku_markdown-0.1.2.tar.gz
- Upload date:
- Size: 140.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c4dc12856ebafb9f921e443a4c73d8d86fbc2104ee64115947a814cdb00024c
|
|
| MD5 |
3c1b68d2295a87173f6260c3a227b2ed
|
|
| BLAKE2b-256 |
f8dd6d81d51d697ffee793943b48548fc75da61f767525455292d5977cdeab94
|
File details
Details for the file puku_markdown-0.1.2-py3-none-any.whl.
File metadata
- Download URL: puku_markdown-0.1.2-py3-none-any.whl
- Upload date:
- Size: 84.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb246b9c62893b36226eea887e21096c24335b64a0529c60c9a461a6b82b437
|
|
| MD5 |
129d5077957f7ebe7eed3f7a425500ce
|
|
| BLAKE2b-256 |
591a1f60ff49cdce98f0b5b0e614532fb501a209dcd2e34a5bee880423a1a868
|