mirror of
https://github.com/KevinMidboe/inline-html.git
synced 2025-12-08 20:29:06 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d9eeaa926 | ||
|
|
840dba9901 | ||
|
|
f827188cf2 | ||
|
|
8261b58971 |
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user