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

@nordcom/commerce-shopify-html
function toPlainText(html: string): string;

Parameters

NameTypeDescription
htmlstring

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."

ToReactNodesOptions toReactNodes

Metadata@nordcom/commerce-shopify-html@0.0.0Open in GitHub ↗

On this page