PhoenixKit.Newsletters.Content (PhoenixKitNewsletters v0.1.3)

Copy Markdown View Source

Content rendering utilities for newsletters.

Converts markdown to HTML and HTML to plain text for email delivery.

Summary

Functions

Renders markdown to HTML. Returns the HTML string on both success and partial-error (Earmark may produce HTML even with warnings/errors).

Renders markdown to HTML, returning an ok/error tuple.

Converts HTML to plain text for the text/plain part of emails.

Functions

render_markdown(markdown)

@spec render_markdown(String.t()) :: String.t()

Renders markdown to HTML. Returns the HTML string on both success and partial-error (Earmark may produce HTML even with warnings/errors).

render_markdown_strict(markdown)

@spec render_markdown_strict(String.t()) :: {:ok, String.t()} | {:error, list()}

Renders markdown to HTML, returning an ok/error tuple.

Returns {:ok, html} on success or {:error, errors} when Earmark cannot produce valid output.

strip_html(html)

@spec strip_html(String.t()) :: String.t()

Converts HTML to plain text for the text/plain part of emails.

Converts <br> tags to newlines, </p> to double newlines, and strips all remaining HTML tags.