scrivito
Version:
Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.
24 lines (21 loc) • 589 B
text/typescript
import { htmlToText } from 'html-to-text';
export function htmlToTextForNode(html: string): string {
return htmlToText(html, htmlToTextOptions);
}
/** @see nodeToText for tags we consider inline */
const htmlToTextOptions = {
tags: {
'': { format: 'block' },
a: { format: 'inline' },
h1: { format: 'block' },
h2: { format: 'block' },
h3: { format: 'block' },
h4: { format: 'block' },
h5: { format: 'block' },
h6: { format: 'block' },
img: { format: 'skip' },
table: { format: 'block' },
ul: { format: 'block' },
},
wordwrap: false,
};