1 | 'use strict';
|
2 |
|
3 | var Promise = require('bluebird'),
|
4 | inlineContent = require('./lib/inlineContent');
|
5 |
|
6 | function extend(obj, src) {
|
7 | var key,
|
8 | own = {}.hasOwnProperty;
|
9 |
|
10 | for (key in src) {
|
11 | if (own.call(src, key)) {
|
12 | obj[key] = src[key];
|
13 | }
|
14 | }
|
15 | return obj;
|
16 | }
|
17 |
|
18 | module.exports = function (html, options) {
|
19 | return new Promise(function (resolve, reject) {
|
20 | var opt = extend({
|
21 | extraCss: '',
|
22 | applyStyleTags: true,
|
23 | removeStyleTags: true,
|
24 | applyLinkTags: true,
|
25 | removeLinkTags: true,
|
26 | preserveMediaQueries: false,
|
27 | removeHtmlSelectors: false,
|
28 | applyWidthAttributes: false,
|
29 | applyTableAttributes: false
|
30 | }, options);
|
31 |
|
32 | inlineContent(html, opt)
|
33 | .then(function (data) {
|
34 | resolve(data);
|
35 | })
|
36 | .catch(function (err) {
|
37 | reject(err);
|
38 | });
|
39 | });
|
40 | };
|