Wenmode#

Build a Markdown dialect with explicit rules, AST output, safe defaults, and pluggable renderers.

Wenmode is for Python applications where Markdown is part of the product model: documentation systems, user-generated content, static-site pipelines, AI/AST workflows, custom dialects, and format converters.

Quick start#

Install Wenmode from PyPI:

pip install wenmode

Render Markdown with the default CommonMark-style rules and safer HTML defaults:

from wenmode import Wenmode

html = Wenmode().render('# Hello\n')

assert html == '<h1>Hello</h1>\n'

Why Wenmode?#

From Mistune’s author

Wenmode comes from the same author as Mistune, redesigned for applications that need to own the full Markdown pipeline.

Introduction
Explicit rule composition

Choose CommonMark-style Markdown, GitHub-flavored Markdown, streaming output, or the exact rule list your product needs.

Presets
AST-first workflows

Parse to mdast-compatible nodes before indexing, transforming, storing, validating, or rendering content.

Node model
Safer HTML defaults

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

Security

Parsing, rule selection, transforms, directive handling, and rendering are separate pieces. Start with the default renderer, then opt into presets, plugins, or AST workflows only when your application needs them.

Markdown pipeline#

Wenmode keeps the Markdown pipeline explicit:

Markdown source
  -> Parser + explicit rules
  -> mdast-compatible nodes
  -> transforms, validation, storage, or indexing
  -> HTML, Markdown, reStructuredText, AsciiDoc, or custom output

That split lets one application parse once, generate heading IDs, collect a table of contents, store AST JSON for search, and render HTML from the same tree.

Project status#

Tested Markdown coverage

Wenmode runs CommonMark and GitHub-flavored Markdown fixture suites in its test suite, with documented compatibility boundaries.

Compliance
Modern Python support

The package supports Python 3.10 and newer, including current CPython releases and PyPy versions covered by the project metadata.

Compatibility

Start here#

Goal

Start here

Decide whether Wenmode fits your application

Introduction

Parse Markdown and render HTML

Usage

Choose CommonMark, GFM, streaming, or custom rules

Presets

Add directives or non-standard syntax

Directives and Plugins

Render user-authored Markdown safely

Security

Parse and filter AI-generated Markdown

AI Markdown

Build AST transforms, TOCs, or custom renderers

Recipes

Integrate Wenmode into an application pipeline

Integrations

Compare Python Markdown parsers

Comparison

Migrate from another Markdown parser

Migration guides

Check compatibility and project status

Compatibility