Skip to content

Commit 0a0b026

Browse files
authored
Merge pull request #497 from CarsonF/master
Bump dependencies & node versions
2 parents 8caaf8f + 72f03c7 commit 0a0b026

File tree

10 files changed

+1744
-2704
lines changed

10 files changed

+1744
-2704
lines changed

.github/workflows/nodejs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [10, 12, 14]
17+
node-version: [18, 20, 22]
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/setup-node@v1
22+
uses: actions/setup-node@v4
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
- run: npm install

lib/cheerio.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var cheerio = require('cheerio');
77
var utils = require('./utils');
88

99
var cheerioLoad = function(html, options, encodeEntities) {
10-
options = Object.assign({decodeEntities: false, _useHtmlParser2:true}, options);
10+
const { xmlMode, ...rest } = options;
11+
options = Object.assign({ xml: { decodeEntities: false, xmlMode } }, rest);
1112
html = encodeEntities(html);
1213
return cheerio.load(html, options);
1314
};

lib/cli.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ var cli = {};
88
module.exports = cli;
99

1010
cli.getProgram = function() {
11-
program.name = pkg.name;
12-
13-
program.version(pkg.version)
11+
program
12+
.name(pkg.name)
13+
.description(pkg.description)
14+
.version(pkg.version)
1415
.usage('[options] input.html output.html');
1516

1617
Object.keys(cli.options).forEach(function(key) {
@@ -124,7 +125,7 @@ cli.argsToOptions = function(program) {
124125
var result = { webResources: {} };
125126
Object.keys(cli.options).forEach(function(key) {
126127
var option = cli.options[key];
127-
var value = program[option.pMap];
128+
var value = program.getOptionValue(option.pMap);
128129
if (value !== undefined) {
129130
if (option.coercion) {
130131
value = option.coercion(value);

lib/inline.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ function inlineDocument($, css, options) {
251251
props.sort(function(a, b) {
252252
return a.compareFunc(b);
253253
});
254-
254+
255255
var string = props
256256
.filter(function(prop) {
257257

258258
// don't add css variables if we're resolving their values
259259
if (options.resolveCSSVariables && (prop.prop.indexOf('--') === 0) ) {
260260
return false;
261261
}
262-
262+
263263
// Content becomes the innerHTML of pseudo elements, not used as a
264264
// style property
265265
return (prop.prop !== 'content');
@@ -469,10 +469,7 @@ function getStylesData($, options) {
469469
var styleDataList, styleData, styleElement;
470470
stylesList.each(function() {
471471
styleElement = this;
472-
// the API for Cheerio using parse5 (default) and htmlparser2 are slightly different
473-
// detect this by checking if .childNodes exist (as opposed to .children)
474-
var usingParse5 = !!styleElement.childNodes;
475-
styleDataList = usingParse5 ? styleElement.childNodes : styleElement.children;
472+
styleDataList = styleElement.childNodes;
476473
if (styleDataList.length !== 1) {
477474
if (options.removeStyleTags) {
478475
$(styleElement).remove();
@@ -484,19 +481,15 @@ function getStylesData($, options) {
484481
results.push(styleData);
485482
}
486483
if (options.removeStyleTags && $(styleElement).attr('data-embed') === undefined) {
487-
var text = usingParse5 ? styleElement.childNodes[0].nodeValue : styleElement.children[0].data;
484+
var text = styleElement.childNodes[0].nodeValue;
488485
var preservedText = utils.getPreservedText(text, {
489486
mediaQueries: options.preserveMediaQueries,
490487
fontFaces: options.preserveFontFaces,
491488
keyFrames: options.preserveKeyFrames,
492489
pseudos: options.preservePseudos
493490
}, juiceClient.ignoredPseudos);
494491
if (preservedText) {
495-
if (usingParse5) {
496-
styleElement.childNodes[0].nodeValue = preservedText;
497-
} else {
498-
styleElement.children[0].data = preservedText;
499-
}
492+
styleElement.childNodes[0].nodeValue = preservedText;
500493
} else {
501494
$(styleElement).remove();
502495
}

0 commit comments

Comments
 (0)