htmlToMarkdown

Textarea
stable

Converts a pre-sanitised HTML string (as produced by OrigamTextareaField in rich mode) to a Markdown string. Only the subset of tags emitted by the rich toolbar is translated; everything else is unwrapped and its text content kept.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

input
required
string
A pre-sanitised HTML string. Null, empty string, and non-string values are returned as an empty string. If DOMParser is unavailable (SSR), the input is returned as-is.

API

Return value

The value returned by this util.

The Markdown representation of the HTML content. Returns an empty string when input is null or empty.

Usage

Examples

Ready-to-paste usage snippets.

Convert bold and italic HTML

typescript