Module markdown_negotiation

Module markdown_negotiation 

Source
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::OriginalMarkdown extension), 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.