return new Promise((resolve) => { inlineCss(campaign.body, { url: './' }) .then((inlinedBody) => { resolve(omitEmpty({ userId: campaign.userId, userPlan: this.userPlan, appendFooter: this.appendFooter, currentUserState: this.currentState, campaign: { id: campaign.id, subject: campaign.subject, name: campaign.name, body: inlinedBody, senderId: campaign.senderId, precompiled: false, listIds: campaign.listIds, attachments: campaign.attachments, metadata: campaignMetadata, scheduledAt: campaign.scheduledAt }, user: { id: this.userId, phoneNumber: this.userPhone, notifications: this.userNotifications } })); }); });
return through.obj(function (file, enc, cb) { var _opt = JSON.parse(JSON.stringify(opt || {})); // 'url' option is required // set it automatically if not provided if (!_opt.url) { _opt.url = 'file://' + file.path; } if (file.isNull()) { cb(null, file); return; } if (file.isStream()) { this.emit('error', new gutil.PluginError('gulp-inline-css', 'Streaming not supported')); return cb(); } inlineCss(file.contents, _opt) .then(function (html) { file.contents = new Buffer(String(html)); this.push(file); return cb(); }.bind(this)) .catch(function (err) { if (err) { this.emit('error', new gutil.PluginError('gulp-inline-css', err)); } }.bind(this)); });
fs.readFile(cssPath, { encoding: 'utf-8' }, function (err, css) { if (err) return callback(err); var mail = jade.compile(template,{ filename: filePath, globals: vars }); t.lang(lang); var locales = merge({ t: t, markdown: markdown, title: t('templates.' + name + '.subject',{config: opts.config}), config: opts.config },makeLocals(vars)); log('locales : %o',locales); var content = mail(locales); inlineCss(content, { extraCss: css, url: filePath }).then(function(html) { callback(null, html) }); })
async processStyles($, mathStyles) { // Get highlight theme from configuration const conf = await this.getConfig() const highlightTheme = conf.highlight || DEFAULT_HIGHLIGHT_THEME // Process html styles const styles = await Promise.all([ mathStyles, fileUtils.readFile(path.join(MARKDOWN_THEME_PATH, 'github.css')), fileUtils.readFile(path.join(HIGHLIGHT_THEME_PATH, `${highlightTheme}.css`)) ]) const styleHtml = `<style>${styles.join('')}</style>` + `<div class="markdown-body">${$.html()}</div>` debug('styleHtml: %s', styleHtml) $.root().html(styleHtml) // Change html classes to inline styles const inlineStyleHtml = await inlineCss($.html(), { url: '/', removeStyleTags: true, removeHtmlSelectors: true }) $.root().html(inlineStyleHtml) $('en-todo').removeAttr('style') }
function inlineHtml (next) { var config = { url: authority }; inlineCss(model.html, config) .then(function inlined (html) { next(null, html); }) .catch(function failed (err) { next(err); }); }
var inlineStyleMw = function(req, res, next) { inlineCss(req.body.svgData, { url: '/' }) .then(function(newSvgData) { req.body.svgData = newSvgData; next(); }) .catch(() => { next(); }); };
readFilePathWithFallbackToDefaultLanguage(type, language, function compileHandlebarsFile(err, file) { if (err) { return callback(err); } InlineCSS(file, { url: 'file://' + path.resolve(filePath) + '/' }) .then(function (inlinedContent) { templateFunction = Handlebars.compile(inlinedContent); if (isProd) { mails[key] = templateFunction; } callback(null, templateFunction); }) });
return new Promise((resolve) => { inlineCss(campaign.body, {url: './'}) .then(inlinedBody => { resolve({ userId: campaign.userId, userPlan: this.userPlan, sentCampaignsInMonth: this.sentCampaignsInMonth, campaign: { id: campaign.id, subject: campaign.subject, body: inlinedBody, senderId: campaign.senderId, precompiled: false, listIds: campaign.listIds } }); }); });
function formatContent (contentHtml, done) { var compilerOpts = { markdown: false, absolutize: true, removeEmoji: true }; var inliningOpts = { extraCss: css, url: authority }; var contents = '<div class="f-core md-markdown">' + contentHtml + '</div>'; var fixed = markupService.compile(contents, compilerOpts); inlineCss(fixed, inliningOpts).then(inlinedCss, done); function inlinedCss (inlined) { var $ = cheerio.load(inlined); var html = $.html(); done(null, html); } }