toPlainText
●shopify-html · /index·function
Converts a Shopify-origin HTML string to plain text, inserting newlines at block-element boundaries to preserve paragraph structure.
Signature
function toPlainText(html: string): string;Parameters
| Name | Type | Description |
|---|---|---|
html | string |
Returns
Newline-separated plain-text content, or an empty string when the input is blank or un-parseable.
Example
const text = toPlainText('<p>Hello <strong>world</strong></p><p>Another paragraph.</p>');
// "Hello world\nAnother paragraph."Related
ToReactNodesOptions toReactNodes