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?

Composable syntax

Start with CommonMark-style Markdown, switch to GitHub-flavored Markdown, use streaming output, or pass the exact rule list your product needs.

Presets
AST-first workflows

Parse to mdast-compatible nodes for indexing, transforms, storage, analysis, or conversion before choosing an output format.

Node model
Pluggable output

Render HTML, normalized Markdown, reStructuredText, or your own output by registering handlers for the node types you care about.

Recipes
Safe HTML defaults

Escape raw HTML and sanitize unsafe URLs by default, then opt into trusted HTML only when your application has a separate sanitization layer.

Security
Streaming support

Emit HTML chunks as Markdown is parsed when latency matters, using a preset that avoids document-wide deferred resolution.

Usage
Fast and lightweight

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.

Compatibility

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

Usage

Choose CommonMark, GFM, streaming, or a custom dialect

Presets

Render user-authored Markdown safely

Security

Add a table of contents, heading IDs, or a custom renderer

Recipes

Build application pipelines around Wenmode

Integrations

Troubleshoot escaping, directives, streaming, or custom renderers

Troubleshooting

Migrate from another Markdown parser

Migration guides

Review benchmark methodology and results

Benchmarks

Build new syntax rules

Custom rules

Check compatibility, compliance, changelog, and project status

Compatibility, Compliance, and Changelog