Skip to main content

Add your description here

Project description

puku-markdown

PyPI version Python >=3.12 Test Status

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 stackpuku-markdown uses an explicit stack, eliminating recursion limits and improving portability (e.g., to C). For example, markdown-it-py relies on recursion and a mutable state.tight flag that becomes inconsistent across nested lists; puku-markdown stores per‑level state on an explicit stack instead.
  • No obscure quirks – Removes confusing state flags like sCount = -1 for 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


Download files

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

Source Distribution

puku_markdown-0.1.2.tar.gz (140.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

puku_markdown-0.1.2-py3-none-any.whl (84.8 kB view details)

Uploaded Python 3

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

Hashes for puku_markdown-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6c4dc12856ebafb9f921e443a4c73d8d86fbc2104ee64115947a814cdb00024c
MD5 3c1b68d2295a87173f6260c3a227b2ed
BLAKE2b-256 f8dd6d81d51d697ffee793943b48548fc75da61f767525455292d5977cdeab94

See more details on using hashes here.

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

Hashes for puku_markdown-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cb246b9c62893b36226eea887e21096c24335b64a0529c60c9a461a6b82b437
MD5 129d5077957f7ebe7eed3f7a425500ce
BLAKE2b-256 591a1f60ff49cdce98f0b5b0e614532fb501a209dcd2e34a5bee880423a1a868

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page