refactor: drop skill file, rework client
This commit was merged in pull request #3.
This commit is contained in:
@@ -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(/ /g, " ");
|
||||
text = text.replace(/&/g, "&");
|
||||
text = text.replace(/</g, "<");
|
||||
text = text.replace(/>/g, ">");
|
||||
text = text.replace(/"/g, "\"");
|
||||
text = text.replace(/'/g, "'");
|
||||
text = text.replace(/\n\s*\n/g, "\n\n");
|
||||
text = text.replace(/[ \t]+/g, " ");
|
||||
return text.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user