A fast, extensible Markdown parser in pure Python.
Project description
markcraft
Your next Markdown parser in Python: pure Python, CommonMark-oriented, and easy to extend.
Why You Will Like It
- Pure Python, no C extension burden: simpler deployment across environments.
- CommonMark-oriented behavior: predictable parsing with stable token precedence.
- Extensible architecture: add custom block/span tokens and custom renderers.
- More than HTML output: ships with HTML, LaTeX, AST, and Markdown renderers.
- Built for maintainability: parser and renderer responsibilities stay cleanly separated.
Installation
Install from PyPI:
pip install markcraft
Local development setup (uv + Python 3.13):
git clone https://github.com/niu2x/markcraft.git
cd markcraft
uv sync
30-Second Quick Start
1) Render to HTML by default
import markcraft
with open("example.md", "r", encoding="utf-8") as fin:
html = markcraft.render(fin)
2) Use a specific renderer (for example, LaTeX)
import markcraft
from markcraft.renderers import LaTeXRenderer
with open("example.md", "r", encoding="utf-8") as fin:
latex = markcraft.render(fin, LaTeXRenderer)
3) Parse explicitly when you need a Document tree
import markcraft
from markcraft.renderers import MarkdownRenderer
doc = markcraft.parse("a\n\n[b]: /uri\n")
with MarkdownRenderer() as renderer:
renderer_specific_doc = markcraft.parse("a\n\n[b]: /uri\n", renderer)
markdown = renderer.render(renderer_specific_doc)
Why call markcraft.parse(...) twice here?
doc = markcraft.parse(...)uses the default parser path and returns a genericDocumenttree.markcraft.parse(..., renderer)parses with renderer context, so renderer-specific token rules are included when needed.- Use the first form for renderer-agnostic analysis; use the second form when your renderer adds or depends on extra syntax.
Outputs and Extensions
Core renderers
markcraft.renderers.HtmlRenderermarkcraft.renderers.LaTeXRenderermarkcraft.renderers.AstRenderermarkcraft.renderers.MarkdownRenderer
Extension renderers
Import directly from extension modules:
markcraft.extensions.mathjax.MathJaxRenderermarkcraft.extensions.pygments_renderer.PygmentsRenderermarkcraft.extensions.toc_renderer.TocRenderermarkcraft.extensions.github_wiki.GithubWikiRenderermarkcraft.extensions.jira_renderer.JiraRenderermarkcraft.extensions.xwiki20_renderer.XWiki20Renderermarkcraft.extensions.scheme.SchemeRenderer
Or import from the aggregated namespace:
markcraft.renderers.extensions.GithubWikiRenderermarkcraft.renderers.extensions.JiraRenderermarkcraft.renderers.extensions.MathJaxRenderermarkcraft.renderers.extensions.PygmentsRenderermarkcraft.renderers.extensions.SchemeRenderermarkcraft.renderers.extensions.TocRenderermarkcraft.renderers.extensions.XWiki20Renderer
For Contributors
Use uv and Python 3.13 for local development.
uv sync
uv run pytest
For benchmarks:
uv sync --group benchmark
uv run python tests/benchmark.py
More implementation details: DEVELOPMENT.md and BENCHMARKING.md.
Contributing
Issues, discussions, and pull requests are welcome.
- For larger changes, open an issue first with context and a minimal reproduction.
- Keep code contributions focused and add tests under
tests/.
Versioning and License
- Licensed under MIT. See
LICENSE.
Project Links
- Repository: https://github.com/niu2x/markcraft
- Issues: https://github.com/niu2x/markcraft/issues
- Actions: https://github.com/niu2x/markcraft/actions
- PyPI: https://pypi.org/project/markcraft/
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 markcraft-1.0.2.tar.gz.
File metadata
- Download URL: markcraft-1.0.2.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
532cd3081faf0b58a6dd8e1ff411cb3a3bdd5049462d042b45eb7541ce5bb22c
|
|
| MD5 |
fa024683d3a5caf2bb64e7ceeb9ba54e
|
|
| BLAKE2b-256 |
8f990f1c2c8438a1c0f8272be6937d6776424ae8893fd0ea41772c7e058e26f5
|
Provenance
The following attestation bundles were made for markcraft-1.0.2.tar.gz:
Publisher:
publish-pypi.yml on niu2x/markcraft
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markcraft-1.0.2.tar.gz -
Subject digest:
532cd3081faf0b58a6dd8e1ff411cb3a3bdd5049462d042b45eb7541ce5bb22c - Sigstore transparency entry: 1341856447
- Sigstore integration time:
-
Permalink:
niu2x/markcraft@8ff663b5b9ac536937600e3205fa659c6e9440ad -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/niu2x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8ff663b5b9ac536937600e3205fa659c6e9440ad -
Trigger Event:
push
-
Statement type:
File details
Details for the file markcraft-1.0.2-py3-none-any.whl.
File metadata
- Download URL: markcraft-1.0.2-py3-none-any.whl
- Upload date:
- Size: 56.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cfa3324f941e988e3595ed04207ff0f3095dd07ed48e0b64c10a01e88495467
|
|
| MD5 |
eab7df7ff4932501321f7f61bee0cf7d
|
|
| BLAKE2b-256 |
0b7d0de55a3448fa847c29c70d43f0bc215b207162f6d1e9fac2ccd8438985ea
|
Provenance
The following attestation bundles were made for markcraft-1.0.2-py3-none-any.whl:
Publisher:
publish-pypi.yml on niu2x/markcraft
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markcraft-1.0.2-py3-none-any.whl -
Subject digest:
2cfa3324f941e988e3595ed04207ff0f3095dd07ed48e0b64c10a01e88495467 - Sigstore transparency entry: 1341856453
- Sigstore integration time:
-
Permalink:
niu2x/markcraft@8ff663b5b9ac536937600e3205fa659c6e9440ad -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/niu2x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8ff663b5b9ac536937600e3205fa659c6e9440ad -
Trigger Event:
push
-
Statement type: