The HTML string to strip
The string with HTML tags removed
stripHTML("<p>Hello <b>world</b></p>") // Returns "Hello world"
export function stripHTML(html: string): string {
if (typeof document === 'undefined') {
return html;
}
const tempDiv = document.createElement('DIV');
tempDiv.innerHTML = html;
return tempDiv.textContent || '';
}
Strips HTML tags from a string.