This commit is contained in:
2026-07-10 20:17:43 +03:00
parent 2f0bfba1cf
commit 07db914ca0
15 changed files with 382 additions and 315 deletions
+20
View File
@@ -0,0 +1,20 @@
export function htmlToText(html: string): string {
if (!html) return "";
let text = html.replace(/<script[^>]*>.*?<\/script>/gis, "");
text = text.replace(/<style[^>]*>.*?<\/style>/gis, "");
text = text.replace(/<br\s*\/?>/gi, "\n");
text = text.replace(/<p[^>]*>/gi, "\n");
text = text.replace(/<\/p>/gi, "");
text = text.replace(/<div[^>]*>/gi, "\n");
text = text.replace(/<\/div>/gi, "");
text = text.replace(/<[^>]+>/g, "");
text = text.replace(/&nbsp;/g, " ");
text = text.replace(/&amp;/g, "&");
text = text.replace(/&lt;/g, "<");
text = text.replace(/&gt;/g, ">");
text = text.replace(/&quot;/g, "\"");
text = text.replace(/&#39;/g, "'");
text = text.replace(/\n\s*\n/g, "\n\n");
text = text.replace(/[ \t]+/g, " ");
return text.trim();
}