Skip to content

Commit

Permalink
Merge pull request #497 from CarsonF/master
Browse files Browse the repository at this point in the history
Bump dependencies & node versions
  • Loading branch information
jrit authored Aug 22, 2024
2 parents 8caaf8f + 72f03c7 commit 0a0b026
Show file tree
Hide file tree
Showing 10 changed files with 1,744 additions and 2,704 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:

strategy:
matrix:
node-version: [10, 12, 14]
node-version: [18, 20, 22]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
3 changes: 2 additions & 1 deletion lib/cheerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var cheerio = require('cheerio');
var utils = require('./utils');

var cheerioLoad = function(html, options, encodeEntities) {
options = Object.assign({decodeEntities: false, _useHtmlParser2:true}, options);
const { xmlMode, ...rest } = options;
options = Object.assign({ xml: { decodeEntities: false, xmlMode } }, rest);
html = encodeEntities(html);
return cheerio.load(html, options);
};
Expand Down
9 changes: 5 additions & 4 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ var cli = {};
module.exports = cli;

cli.getProgram = function() {
program.name = pkg.name;

program.version(pkg.version)
program
.name(pkg.name)
.description(pkg.description)
.version(pkg.version)
.usage('[options] input.html output.html');

Object.keys(cli.options).forEach(function(key) {
Expand Down Expand Up @@ -124,7 +125,7 @@ cli.argsToOptions = function(program) {
var result = { webResources: {} };
Object.keys(cli.options).forEach(function(key) {
var option = cli.options[key];
var value = program[option.pMap];
var value = program.getOptionValue(option.pMap);
if (value !== undefined) {
if (option.coercion) {
value = option.coercion(value);
Expand Down
17 changes: 5 additions & 12 deletions lib/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ function inlineDocument($, css, options) {
props.sort(function(a, b) {
return a.compareFunc(b);
});

var string = props
.filter(function(prop) {

// don't add css variables if we're resolving their values
if (options.resolveCSSVariables && (prop.prop.indexOf('--') === 0) ) {
return false;
}

// Content becomes the innerHTML of pseudo elements, not used as a
// style property
return (prop.prop !== 'content');
Expand Down Expand Up @@ -469,10 +469,7 @@ function getStylesData($, options) {
var styleDataList, styleData, styleElement;
stylesList.each(function() {
styleElement = this;
// the API for Cheerio using parse5 (default) and htmlparser2 are slightly different
// detect this by checking if .childNodes exist (as opposed to .children)
var usingParse5 = !!styleElement.childNodes;
styleDataList = usingParse5 ? styleElement.childNodes : styleElement.children;
styleDataList = styleElement.childNodes;
if (styleDataList.length !== 1) {
if (options.removeStyleTags) {
$(styleElement).remove();
Expand All @@ -484,19 +481,15 @@ function getStylesData($, options) {
results.push(styleData);
}
if (options.removeStyleTags && $(styleElement).attr('data-embed') === undefined) {
var text = usingParse5 ? styleElement.childNodes[0].nodeValue : styleElement.children[0].data;
var text = styleElement.childNodes[0].nodeValue;
var preservedText = utils.getPreservedText(text, {
mediaQueries: options.preserveMediaQueries,
fontFaces: options.preserveFontFaces,
keyFrames: options.preserveKeyFrames,
pseudos: options.preservePseudos
}, juiceClient.ignoredPseudos);
if (preservedText) {
if (usingParse5) {
styleElement.childNodes[0].nodeValue = preservedText;
} else {
styleElement.children[0].data = preservedText;
}
styleElement.childNodes[0].nodeValue = preservedText;
} else {
$(styleElement).remove();
}
Expand Down
Loading

0 comments on commit 0a0b026

Please sign in to comment.