Module

markdown.renderer

Core markdown renderer wrapping patitas.

Provides a stateful renderer that can be used directly or registered as a template filter. The interface is designed so that incremental parsing can be added behind it later without changing downstream code.

Classes

MarkdownRenderer 2
Render Markdown source to HTML via patitas. Wraps ``patitas.Markdown`` with a stable interface tha…

Render Markdown source to HTML via patitas.

Wrapspatitas.Markdownwith a stable interface that chirp controls. Phase 1 does a full parse+render on every call. Incremental parsing can be layered in later behindrender().

Methods

render 1 Markup
Render Markdown source to an HTML string. Returns sanitized ``Markup`` so kida…
def render(self, source: str) -> Markup

Render Markdown source to an HTML string.

Returns sanitizedMarkupso kida's auto-escaping preserves Markdown-generated HTML when the renderer is used as a template filter. Passsanitize=Falseonly for trusted content.

Parameters
Name Type Description
source

Raw Markdown text.

Returns
Markup Rendered HTML wrapped in ``Markup``.
Internal Methods 1
__init__ 3
def __init__(self, *, plugins: list[str] | None = None, highlight: bool = True, sanitize: bool = True) -> None
Parameters
Name Type Description
plugins Default:None
highlight Default:True
sanitize Default:True
_MarkdownHTMLSanitizer 8

Methods

html 0 str
property
def html(self) -> str
Returns
str
handle_starttag 2
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None
Parameters
Name Type Description
tag
attrs
handle_startendtag 2
def handle_startendtag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None
Parameters
Name Type Description
tag
attrs
handle_endtag 1
def handle_endtag(self, tag: str) -> None
Parameters
Name Type Description
tag
handle_data 1
def handle_data(self, data: str) -> None
Parameters
Name Type Description
data
handle_entityref 1
def handle_entityref(self, name: str) -> None
Parameters
Name Type Description
name
handle_charref 1
def handle_charref(self, name: str) -> None
Parameters
Name Type Description
name
Internal Methods 1
__init__ 0
def __init__(self) -> None

Functions

_get_markdown 2 Markdown
Create a patitas Markdown instance, raising a clear error if missing.
def _get_markdown(*, plugins: list[str] | None, highlight: bool) -> Markdown
Parameters
Name Type Description
plugins list[str] | None
highlight bool
Returns
Markdown