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

Impact of options is hard to understand #2744

Closed
tbaustin opened this issue Sep 7, 2022 · 2 comments · Fixed by #2916
Closed

Impact of options is hard to understand #2744

tbaustin opened this issue Sep 7, 2022 · 2 comments · Fixed by #2916

Comments

@tbaustin
Copy link

tbaustin commented Sep 7, 2022

I am passing

const $ = cheerio.load("<div> > Hello world </div>", { decodeEntities: false }, false) // tried true and false for decodeEntities

return $.html()

We want it to return <div> > Hello world </div>, but it's returning <div> &gt; Hello world </div> instead.

@tbaustin tbaustin changed the title DecodeEntities not keep '>' symbol in the html. DecodeEntities not keeping '>' symbol in the html. Sep 7, 2022
@Properko
Copy link

Not the maintainer, but decodeEntities controls the opposite - if &gt; in the input should become > in the output.
I think you want xmlMode: true instead.

@fb55
Copy link
Member

fb55 commented Sep 13, 2022

That's almost the answer: The reason why decodeEntities doesn't work is that it is an option for htmlparser2, which isn't the default parser. Have a look at https://github.com/cheeriojs/cheerio#using-htmlparser2 for more details. The easiest way around this is probably by using the slim export.

Leaving this open to track the deeper issue.

@fb55 fb55 changed the title DecodeEntities not keeping '>' symbol in the html. Impact of options is hard to understand Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants