lettersanitizer
DOM-based HTML email sanitizer for in-browser email rendering.
Used in react-letter and vue-letter.
Installation
lettersanitizer is available on npm, you can install it with either npm or yarn:
npm install lettersanitizer
yarn install lettersanitizer
Example usage
export function sanitize(
html: string,
text?: string,
options?: SanitizerOptions
) {
let contents = html ?? '';
if (contents?.length === 0 && text) {
contents = sanitizeText(text)
.split('\n')
.map(line => '<p>' + line + '</p>')
.join('\n');
}
return sanitizeHtml(contents, options ?? {});
}