Skip to main content

render_markdown

Function render_markdown 

Source
pub fn render_markdown(input: &str) -> Markup
Expand description

Render untrusted CommonMark and GitHub-flavored Markdown into safe Markup.

Enables tables, strikethrough, and task lists. Heading attributes are explicitly disabled to prevent Alpine/HTMX attribute injection (x-init, x-data, hx-*). Drops raw HTML blocks and inline HTML tags so untrusted authors cannot inject <script> or event handlers. Rewrites unsafe link or image URLs (disallowed schemes such as javascript:, vbscript:, data:, protocol-relative // or /\, or URLs with ASCII control characters) to "#", and adds rel="noopener noreferrer ugc" to every rendered <a> link.