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

Texts within consecutive li tags get concatenated when using $.text() #2841

Closed
gaganprajapati opened this issue Nov 3, 2022 · 1 comment
Closed

Comments

@gaganprajapati
Copy link

Texts within consecutive li tags get concatenated without any space between which converts the last word in the li tag and the first word of the next li tag into a single word.
For example:
<ul><li>It has an easy-to-use interface.</li><li>Flipboard is customizable by topic interest, making it great for niche blog promotion.</li></ul>
Using $.text() for this html I get the following result:
It has an easy-to-use interfaceFlipboard is customizable by topic interest, making it great for niche blog promotion.

You can see how 'interface'(last word of first li tag) and 'Flipboard'(first word of the next li tag) is converted to a single text 'interfaceFlipboard'

@fb55
Copy link
Member

fb55 commented Nov 4, 2022

Unfortunately there isn't much we can do here; the browser's innerText implementation is based entirely on CSS properties, which Cheerio doesn't have access to, as we don't render the document. Instead, Cheerio follows the spec for nodes that aren't rendered — this is technically correct, but not ideal.

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

No branches or pull requests

2 participants