/**
* Convert HTML string to plain text, handling common tags and entities.
*/
export function parseHtmlToText(html: string): string {
if (!html || typeof html !== "string") return "";
return html
.replace(/
/gi, "\n")
.replace(/<[^>]*>/g, "")
.replace(/ /g, " ")
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/\n\s*\n\s*\n/g, "\n\n")
.trim();
}