Tanguv0.35.0
Text & i18n4 exports
Raw Markdown

/html

HTML entity escaping, attribute sanitization, and tag stripping for safe user-generated content.

(use /html)

Functions & symbols#

escape#

function
(escape text) -> String

Escapes HTML special characters (`&`, `<`, `>`, `"`, `'`) for safe attribute and element rendering.

ParameterTypeOptionalDescription
textStringrequiredPlain string to HTML-escape
Returns:Any
(html/escape "<b>hi</b>")

escape-text#

function
(escape-text html) -> String

Escapes `&`, `<`, and `>` characters in text nodes without escaping quotes.

ParameterTypeOptionalDescription
htmlStringrequiredString containing HTML markup
Returns:Any
(html/escape-text "a < b")

sanitize#

function
(sanitize html) -> String

Sanitizes untrusted HTML using an allowlist-based cleaner, stripping scripts, event handlers, and unsafe URLs.

ParameterTypeOptionalDescription
htmlStringrequiredUntrusted HTML fragment
Returns:Any
(html/sanitize user-bio-html)

strip-tags#

function
(strip-tags html) -> String

Strips all HTML tags and returns plain concatenated text.

ParameterTypeOptionalDescription
htmlStringrequiredHTML markup string
Returns:Any
(html/strip-tags "<p>Hello <b>world</b></p>") ; -> "Hello world"