Patitas

Modern Markdown parser for Python 3.14t

Markdown, Parsed Right

Fast. Safe. Modern. Standards-based.

Patitas is a pure-Python Markdown parser designed for Python 3.14t+. It uses a state-machine lexer—no regex backtracking, no ReDoS vulnerabilities, O(n) guaranteed parsing.

from patitas import Markdown

md = Markdown()
html = md("# Hello **World**")
# Output: <h1>Hello <strong>World</strong></h1>

What's good about it

State-Machine Lexer

No regex catastrophic backtracking. O(n) guaranteed parsing with predictable performance on any input.

Free-Threading Ready

Built for Python 3.14t (PEP 703). Parse documents concurrently without the GIL.

CommonMark Compliant

Passes all 652 CommonMark 0.31.2 specification tests. Standards-first design.

Zero Dependencies

Pure Python with no runtime dependencies. Optional extras for directives and syntax highlighting.


Performance

  • 652 CommonMark examples — ~26ms single-threaded
  • Incremental parsing — For a 1-char edit in a ~100KB doc,parse_incrementalis ~200x faster than full re-parse (~160µs vs ~32ms)
  • Parallel scaling — ~2.5x speedup with 4 threads under Python 3.14t free-threading

Patitas prioritizes safety over raw speed: O(n) guaranteed parsing, typed AST, and full thread-safety.


Typed AST

Every node is a frozen dataclass with full type information:

from patitas import parse

doc = parse("# Hello **World**")
heading = doc[0]

# Type-safe access
print(heading.level)      # 1
print(heading.children)   # [Text, Strong]

# IDE autocompletion works
heading.level  # int
heading.children[1].children  # Sequence[Inline]

The Bengal Ecosystem

A structured reactive stack — every layer written in pure Python for 3.14t free-threading.

ᓚᘏᗢ Bengal Static site generator Docs
∿∿ Purr Content runtime
⌁⌁ Chirp Web framework Docs
=^..^= Pounce ASGI server Docs
)彡 Kida Template engine Docs
ฅᨐฅ Patitas Markdown parser ← You are here Docs
⌾⌾⌾ Rosettes Syntax highlighter Docs

Python-native. Free-threading ready. No npm required.