Wenmode¶
Build exactly the Markdown dialect your Python application needs. Wenmode gives you fast CommonMark-style parsing, explicit rule composition, mdast-compatible AST output, safe HTML defaults, streaming, and pluggable renderers.
Wenmode is designed for applications that need more control than a single Markdown-to-HTML helper can provide: documentation systems, user-generated content, static-site pipelines, AI/AST workflows, custom Markdown dialects, and format converters.
Why Wenmode?¶
Start with CommonMark-style Markdown, switch to GitHub-flavored Markdown, use streaming output, or pass the exact rule list your product needs.
Parse to mdast-compatible nodes for indexing, transforms, storage, analysis, or conversion before choosing an output format.
Render HTML, normalized Markdown, reStructuredText, or your own output by registering handlers for the node types you care about.
Escape raw HTML and sanitize unsafe URLs by default, then opt into trusted HTML only when your application has a separate sanitization layer.
Emit HTML chunks as Markdown is parsed when latency matters, using a preset that avoids document-wide deferred resolution.
Keep runtime dependencies at zero and enable only the syntax rules you need, so larger dialects do not become the default cost for every parse.
Wenmode separates parsing, rendering, syntax rules, and directive rendering so you can start with a CommonMark-style parser and then opt in to only the Markdown features you need.
Install Wenmode from PyPI:
pip install wenmode
uv add wenmode
from wenmode import Wenmode
wenmode = Wenmode()
text = '''
# Hello
This is **wenmode**.
'''
expected = '''
<h1>Hello</h1>
<p>This is <strong>wenmode</strong>.</p>
'''
html = wenmode.render(text)
assert html == expected.lstrip()
Choose your path¶
Goal |
Start here |
|---|---|
Parse Markdown and render HTML |
|
Choose CommonMark, GFM, streaming, or a custom dialect |
|
Render user-authored Markdown safely |
|
Add a table of contents, heading IDs, or a custom renderer |
|
Build application pipelines around Wenmode |
|
Troubleshoot escaping, directives, streaming, or custom renderers |
|
Migrate from another Markdown parser |
|
Review benchmark methodology and results |
|
Build new syntax rules |
|
Check compatibility, compliance, changelog, and project status |
Compatibility, Compliance, and Changelog |