DeltaHtml (DeltaHtml v0.5.0)

Copy Markdown View Source

Convert Quill (Slab) Delta document format to HTML.

Use to_html/2 to render rich text for web pages and emails. See the README for usage, feature support, and alternatives.

Summary

Functions

Convert Quill Delta to HTML.

Functions

to_html(delta, opts \\ [])

Convert Quill Delta to HTML.

Options

  • :preserve_whitespace - When true, wraps the output in a div with white-space: pre-wrap to preserve whitespace. Defaults to false.
  • :quill_css - When true, emits Quill-style classes (for example ql-align-*, ql-direction-rtl, ql-indent-*) instead of inline block styles. Defaults to false.
  • :link_sanitization - Link sanitization policy:
    • :quill (default) - Allows http, https, mailto, tel, and sms. Non-whitelisted or malformed links fallback to about:blank.
    • :strict - Allows only http, https, and mailto. Non-whitelisted or malformed links are removed.

Examples

iex> to_html([%{"insert" => "word\n"}])
"<p>word</p>"

iex> to_html([%{"insert" => "word\n"}], preserve_whitespace: true)
"<div style=\"white-space: pre-wrap;\"><p>word</p></div>"