Files
lehuo/apps/admin-web/src/financial-document.ts
T

18 lines
478 B
TypeScript

export function htmlToPlainText(html: string): string {
return html
.replace(/<br\s*\/?\s*>/gi, ' ')
.replace(/<[^>]+>/g, '')
.replace(/&nbsp;|&#160;/gi, ' ')
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&amp;/gi, '&')
.replace(/&quot;/gi, '"')
.replace(/&#39;|&apos;/gi, "'")
.replace(/\s+/g, ' ')
.trim();
}
export function defaultFinancialSummary(html: string): string {
return htmlToPlainText(html).slice(0, 120);
}