Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fixtures.forEach(fname => {
const html = fs.readFileSync(`./fixtures/${fname}`);
const htmlStr = html.toString();
console.log('---');
const scopeifyId = `scopeify-html ${fname}`;
const doc = jsdom(html);
console.time(scopeifyId);
scopeifyHtml().sync(doc);
console.timeEnd(scopeifyId);
const juiceId = `juice ${fname}`;
const $ = cheerio.load(htmlStr);
console.time(juiceId);
juice.juiceDocument($);
console.timeEnd(juiceId);
console.log('---');
});
function cssCallback($, options, callback) {
try {
if (options.removeLinks) {
removeLinks($);
}
$('body').html($(options.selector) || '');
$('head').append(`<style>${options.extraCss}</style>`);
const cacheKey = `${options.data}#${options.selector}#css${options.inlineCss}#innerText${options.innerText}`;
nodeCache.set(cacheKey, juice.juiceDocument($, {
extraCss: options.extraCss || ''
})('body').html());
callback(nodeCache.get(cacheKey));
} catch (e) {
callback();
}
}
function inline ($, options = {}) {
const { juice: juiceOptions = {} } = options
juice.juiceDocument($, {
...juiceOptions
})
inlineMargins($)
preferMaxWidth($, '[class$="__ie"]')
fixWidthsFor($, 'img, .block__table__ie, .column')
removeProcessingIds($)
return $
}