18 lines
478 B
TypeScript
18 lines
478 B
TypeScript
export function htmlToPlainText(html: string): string {
|
|
return html
|
|
.replace(/<br\s*\/?\s*>/gi, ' ')
|
|
.replace(/<[^>]+>/g, '')
|
|
.replace(/ | /gi, ' ')
|
|
.replace(/</gi, '<')
|
|
.replace(/>/gi, '>')
|
|
.replace(/&/gi, '&')
|
|
.replace(/"/gi, '"')
|
|
.replace(/'|'/gi, "'")
|
|
.replace(/\s+/g, ' ')
|
|
.trim();
|
|
}
|
|
|
|
export function defaultFinancialSummary(html: string): string {
|
|
return htmlToPlainText(html).slice(0, 120);
|
|
}
|