4 Commits

Author SHA1 Message Date
Alexandre Gigliotti
4d9eeaa926 0.1.1 2015-07-30 09:13:44 -07:00
Alexandre Gigliotti
840dba9901 Fixed bug where style attributes of elements outside a body element would not be inlined. 2015-07-30 09:13:39 -07:00
Alexandre Gigliotti
f827188cf2 0.1.0 2015-07-29 15:54:14 -07:00
Alexandre Gigliotti
8261b58971 Updated dependencies. 2015-07-29 15:54:05 -07:00
2 changed files with 5 additions and 6 deletions

View File

@@ -14,22 +14,21 @@ var unwrap = function (value) {
var inline = function (html, filename) { var inline = function (html, filename) {
var files = []; var files = [];
var $ = cheerio.load(html, {decodeEntities: false}); var $ = cheerio.load(html, {decodeEntities: false});
// style elements // style elements
var styles = $('style'); var styles = $('style');
styles.each(function (index, element) { styles.each(function (index, element) {
var css = $(element).html(); var css = $(element).html();
result = inlineUrl(css, filename); var result = inlineUrl(css, filename);
files.push(result.files); files.push(result.files);
$(element).html(result.css); $(element).html(result.css);
}); });
// style attributes // style attributes
var attributes = $('body *').filter('[style]'); var attributes = $('*').filter('[style]');
attributes.each(function (index, element) { attributes.each(function (index, element) {
var css = $(element).attr('style'); var css = $(element).attr('style');
css = wrap(css); css = wrap(css);
result = inlineUrl(css, filename); var result = inlineUrl(css, filename);
files.push(result.files); files.push(result.files);
css = string(result.css).collapseWhitespace().toString(); css = string(result.css).collapseWhitespace().toString();
css = unwrap(css); css = unwrap(css);

View File

@@ -1,6 +1,6 @@
{ {
"name": "inline-html", "name": "inline-html",
"version": "0.0.1", "version": "0.1.1",
"description": "Inline an html file.", "description": "Inline an html file.",
"repository": "panosoft/inline-html", "repository": "panosoft/inline-html",
"main": "lib/index.js", "main": "lib/index.js",
@@ -13,7 +13,7 @@
"cheerio": "^0.19.0", "cheerio": "^0.19.0",
"co": "^4.6.0", "co": "^4.6.0",
"datauri": "^0.7.1", "datauri": "^0.7.1",
"is-local-path": "0.0.1", "is-local-path": "^0.1.0",
"less": "^2.5.1", "less": "^2.5.1",
"lodash": "^3.10.0", "lodash": "^3.10.0",
"mz": "^2.0.0", "mz": "^2.0.0",