Shared markdown rendering for comment content.
Comments are authored as markdown in the Leaf composer (which renders with
MDEx); rendering with the same engine and render options on display keeps
the two consistent. Output passes through core's HtmlSanitizer for XSS
protection. Used by both the public comments component and the admin
moderation page so bold/italics/lists/etc. show formatted instead of raw.
Summary
Functions
Renders a comment's markdown content to sanitized HTML inside a pk-comment-md
block. The .pk-comment-md class (styled by comment_markdown_styles/1)
restores list/block spacing without depending on the @tailwindcss/typography
(prose) plugin being present in the host — render comment_markdown_styles
once on any page that uses this.
One-off <style> block with the .pk-comment-md rules. Render it ONCE per
page that uses comment_markdown/1 (Tailwind's preflight zeroes list/block
margins; this restores them without the typography plugin). Bold/italic render
via <strong>/<em> already.
Renders markdown to sanitized HTML (or escaped text on a parse error). Blank
input returns an empty string. Uses the same MDEx options as the Leaf composer
(hardbreaks, unsafe) so display matches what was typed.
Functions
Renders a comment's markdown content to sanitized HTML inside a pk-comment-md
block. The .pk-comment-md class (styled by comment_markdown_styles/1)
restores list/block spacing without depending on the @tailwindcss/typography
(prose) plugin being present in the host — render comment_markdown_styles
once on any page that uses this.
Named comment_markdown (not markdown) to avoid clashing with core's
PhoenixKitWeb.Components.Core.Markdown.markdown/1, which is imported wherever
use PhoenixKitWeb is in play.
Attributes
content(:string) (required) - The markdown content to render.class(:string) - Additional CSS classes. Defaults to"".compact(:boolean) - Use smaller (text-sm) text for previews. Defaults tofalse.sanitize(:boolean) - Enable HTML sanitization. Defaults totrue.
One-off <style> block with the .pk-comment-md rules. Render it ONCE per
page that uses comment_markdown/1 (Tailwind's preflight zeroes list/block
margins; this restores them without the typography plugin). Bold/italic render
via <strong>/<em> already.
Renders markdown to sanitized HTML (or escaped text on a parse error). Blank
input returns an empty string. Uses the same MDEx options as the Leaf composer
(hardbreaks, unsafe) so display matches what was typed.