Comparing version 0.1.0 to 0.1.1
@@ -57,5 +57,6 @@ | ||
juice.juiceFile = juiceFile; | ||
juice.inlineDocument = inlineDocument; | ||
juice.inlineContent = inlineContent; | ||
function inlineCssInDocument(document, css) { | ||
function inlineDocument(document, css) { | ||
var rules = utils.parseCSS(css) | ||
@@ -129,3 +130,3 @@ , editedElements = [] | ||
css += "\n" + options.extraCss; | ||
inlineCssWithCb(document, css, callback); | ||
inlineDocumentWithCb(document, css, callback); | ||
}); | ||
@@ -177,5 +178,5 @@ } | ||
function legacyJuice(html, css) { | ||
function inlineContent(html, css) { | ||
var document = utils.jsdom(html); | ||
inlineCssInDocument(document, css); | ||
inlineDocument(document, css); | ||
var inner = document.innerHTML; | ||
@@ -197,3 +198,4 @@ // free the associated memory | ||
function juice (arg1, arg2, arg3) { | ||
if (typeof arg2 === 'string') return legacyJuice(arg1, arg2); | ||
// legacy behavior | ||
if (typeof arg2 === 'string') return inlineContent(arg1, arg2); | ||
var options = arg3 ? arg2 : {}; | ||
@@ -204,5 +206,5 @@ var callback = arg3 ? arg3 : arg2; | ||
function inlineCssWithCb(document, css, callback) { | ||
function inlineDocumentWithCb(document, css, callback) { | ||
try { | ||
inlineCssInDocument(document, css); | ||
inlineDocument(document, css); | ||
callback(); | ||
@@ -209,0 +211,0 @@ } catch (err) { |
{ | ||
"name": "juice", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Inlines css into html source", | ||
@@ -26,2 +26,5 @@ "scripts": { | ||
], | ||
"engines": { | ||
"node": ">=0.6.0 <0.9.0" | ||
}, | ||
"dependencies": { | ||
@@ -28,0 +31,0 @@ "cssom": "~0.2.5", |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/LearnBoost/juice.png?branch=master)](https://travis-ci.org/LearnBoost/juice) | ||
![](http://david-dm.org/LearnBoost/juice.png) | ||
# Juice ![](http://i.imgur.com/jN8Ht.gif) | ||
@@ -77,3 +79,3 @@ | ||
Defaults to `true`. | ||
- `applyLinkTags` - whether to resolve `<link rel="stylesheet"` tags | ||
- `applyLinkTags` - whether to resolve `<link rel="stylesheet">` tags | ||
and inline the resulting styles. Defaults to `true`. | ||
@@ -108,2 +110,13 @@ - `removeStyleTags` - whether to remove the original `<style></style>` | ||
### juice.inlineContent(html, css) | ||
This takes html and css and returns new html with the provided css inlined. | ||
It does not look at `<style>` or `<link rel="stylesheet">` elements at all. | ||
### juice.inlineDocument(document, css) | ||
Given a jsdom instance and css, this modifies the jsdom instance so that the | ||
provided css is inlined. It does not look at `<style>` or | ||
`<link rel="stylesheet">` elements at all. | ||
### juice.ignoredPseudos | ||
@@ -110,0 +123,0 @@ |
21322
11
476
156