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 files = [];
var $ = cheerio.load(html, {decodeEntities: false});
// style elements
var styles = $('style');
styles.each(function (index, element) {
var css = $(element).html();
result = inlineUrl(css, filename);
var result = inlineUrl(css, filename);
files.push(result.files);
$(element).html(result.css);
});
// style attributes
var attributes = $('body *').filter('[style]');
var attributes = $('*').filter('[style]');
attributes.each(function (index, element) {
var css = $(element).attr('style');
css = wrap(css);
result = inlineUrl(css, filename);
var result = inlineUrl(css, filename);
files.push(result.files);
css = string(result.css).collapseWhitespace().toString();
css = unwrap(css);

View File

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