Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cheerio encodes HTML entities with decodeEntities: false #2974

Closed
dstapp opened this issue Jan 24, 2023 · 1 comment
Closed

Cheerio encodes HTML entities with decodeEntities: false #2974

dstapp opened this issue Jan 24, 2023 · 1 comment

Comments

@dstapp
Copy link

dstapp commented Jan 24, 2023

When using the latest-tagged version of cheerio on npm (1.0.0-rc12), decodeEntities apparently does not do what it was doing before.

Example:

const cheerio = require('cheerio');
const outHtml = cheerio.load('foo > bar', { decodeEntities: false });
console.log(outHtml.html());

With > 0.22.0 (1.0.0-rc*):

foo > bar

While with 0.22.0:

foo > bar

In general, I'm not super sure about the name of this option because in 0.22.0, decodeEntities actually prevents encoding the characters to HTML entities in the first place while no "encodeEntities" option exists. Since we're relying on this behavior, I had to downgrade to 0.22.0 for now.

Other dependents of cheerio also have this problem now, e.g. https://github.com/jonkemp/inline-css in version 4.0.0 is using the rc-* version of cheerio, which causes the same problem there. As described in #1261 tagging an rc as latest is probably the problem here.

@fb55
Copy link
Member

fb55 commented Jan 24, 2023

This is intentional: The default parser has changed in 1.0, and the new parser doesn't support these options. See this (not yet published) guide that explains how to restore htmlparser2 as the parser: https://github.com/cheeriojs/cheerio/blob/335e65d0cd93dc4f866019719575b22449068bd9/website/docs/advanced/configuring-cheerio.md

@fb55 fb55 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants