UNPKG

986 BJavaScriptView Raw
1'use strict';
2
3var cheerio = require('./lib/cheerio');
4var makeJuiceClient = require('./lib/inline');
5
6/**
7 * Note that makeJuiceClient will take a base object (in this case a function) and enhance it
8 * with a lot of useful properties and functions.
9 *
10 * This client adopts cheerio as a DOM parser and adds an "inlineContent" function that let
11 * users to specify the CSS to be inlined instead of extracting it from the html.
12 *
13 * The weird "makeJuiceClient" behaviour is there in order to keep backward API compatibility.
14 */
15var juiceClient = makeJuiceClient(function(html,options) {
16 return cheerio(html, { xmlMode: options && options.xmlMode}, juiceDocument, [options]);
17});
18
19var juiceDocument = function(html, options) {
20 return juiceClient.juiceDocument(html, options);
21}
22
23juiceClient.inlineContent = function(html, css, options) {
24 return cheerio(html, { xmlMode: options && options.xmlMode}, juiceClient.inlineDocument, [css, options]);
25};
26
27module.exports = juiceClient;