Wrapper around MDEx for rendering Markdown to HTML.
Provides a consistent interface with {:ok, html} / {:error, reason}
tuples and a bang variant that raises on error.
Supports optional syntax highlighting theme selection via the theme parameter.
Code blocks are highlighted for both light and dark color schemes at once
using Lumis' :html_multi_themes formatter, so the colors automatically
follow the reader's color-scheme via the CSS light-dark() function.
Examples
iex> {:ok, html} = Sayfa.Markdown.render("# Hello")
iex> html =~ "Hello"
true
iex> Sayfa.Markdown.render!("**bold**")
"<p><strong>bold</strong></p>"
Summary
Types
Functions
Renders a Markdown string to HTML.
Headings include anchor IDs for linking (e.g., <h1 id="hello">...</h1>).
The optional theme selects the syntax highlighting themes. It accepts either
a single theme name (applied to both schemes) or a [light: ..., dark: ...]
pair (default: [light: "catppuccin_latte", dark: "catppuccin_mocha"]).
Examples
iex> {:ok, html} = Sayfa.Markdown.render("# Hello")
iex> html =~ ~s(id="hello")
true
iex> Sayfa.Markdown.render("plain text")
{:ok, "<p>plain text</p>"}
Renders a Markdown string to HTML, raising on error.
Examples
iex> html = Sayfa.Markdown.render!("# Hello")
iex> html =~ ~s(id="hello")
true