import { cleanAttributes, cleanHeaders, cleanHOnes, cleanImages, cleanTags, removeEmpty, rewriteTopLevel, markToKeep, stripJunkTags, makeLinksAbsolute, } from 'utils/dom'; // Clean our article content, returning a new, cleaned node. export default function extractCleanNode( article, { $, cleanConditionally = true, title = '', url = '', defaultCleaner = true } ) { // Rewrite the tag name to div if it's a top level node like body or // html to avoid later complications with multiple body tags. rewriteTopLevel(article, $); // Drop small images and spacer images // Only do this is defaultCleaner is set to true; // this can sometimes be too aggressive. if (defaultCleaner) cleanImages(article, $); // Make links absolute makeLinksAbsolute(article, $, url); // Mark elements to keep that would normally be removed. // E.g., stripJunkTags will remove iframes, so we're going to mark // YouTube/Vimeo videos as elements we want to keep. markToKeep(article, $, url); // Drop certain tags like