Expand description
Middleware for content negotiation returning Markdown to agents and clients.
When an incoming request accepts text/markdown or text/x-markdown, the
middleware checks if the response is an HTML document:
- If the response was created from Markdown (indicated by the
crate::OriginalMarkdownextension), the original Markdown is reused directly to avoid unnecessary HTML roundtripping. - If the response was rendered as standard HTML, it is converted to Markdown
via [
ctb_formats_html::markdown::html2md]. - Non-HTML responses (e.g. JSON, CSS, images, streaming downloads) are left unmodified without buffering.
Functionsยง
- markdown_
negotiation_ middleware - Middleware that negotiates Markdown representations for HTML endpoints.
- prefers_
markdown - Returns whether the request headers indicate preference for Markdown content over HTML.