Filter and sanitize HTML input
npm install filthy-cleandocument.implementation.createHTMLDocument() allows us to manipulate a DOM element without running any scripts or preloading any resource.js
const filthy = require('filthy-clean');
const cleanHtml = filthy(userProvidedHtmlString, options);
`$3
- options.allowedNodes - An array of nodes to keep (eg: ['div', 'br', 'strong'])
- options.allowedAttrs - An array of attributes to keep (eg: ['alt', 'href', 'src'])$3
- options.allowedNodes - ['div, 'p', 'a', 'br', 'i', 'em', 'strong', 'b', 'img']
- options.allowedAttrs` - ['href', 'title', 'alt', 'src', 'width', 'height']