PhoenixKitWeb.Components.Core.Markdown (phoenix_kit v1.7.71)

Copy Markdown View Source

Renders markdown content safely with consistent styling.

This component parses markdown to HTML using Earmark, sanitizes the output for XSS prevention, and renders with appropriate styling.

Usage

# Full markdown rendering with styling
<.markdown content={@description} />

# Compact mode for previews/inline
<.markdown content={@description} compact />

# With custom class
<.markdown content={@description} class="text-sm" />

# Without sanitization (trusted admin content)
<.markdown content={@description} sanitize={false} />

Features

  • GFM (GitHub Flavored Markdown) support
  • Smart typography (smartypants)
  • Code block syntax highlighting classes
  • XSS sanitization (enabled by default)
  • Compact mode for previews
  • Graceful error handling

Summary

Functions

Renders markdown content with styling and optional XSS protection.

Functions

markdown(assigns)

Renders markdown content with styling and optional XSS protection.

Attributes

  • content - The markdown string to render (required)
  • class - Additional CSS classes (optional)
  • compact - Use compact styling for previews (default: false)
  • sanitize - Enable HTML sanitization (default: true)

Attributes

  • content (:string) (required) - The markdown content to render.
  • class (:string) - Additional CSS classes. Defaults to "".
  • compact (:boolean) - Use compact styling for previews. Defaults to false.
  • sanitize (:boolean) - Enable HTML sanitization. Defaults to true.