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

text should only return human readable text #198

Open
ucarbehlul opened this issue Mar 21, 2022 · 1 comment
Open

text should only return human readable text #198

ucarbehlul opened this issue Mar 21, 2022 · 1 comment

Comments

@ucarbehlul
Copy link

I notice that HTMLElement.text returns text content of script and style tags too. Expected behavior of it is to not include those, as innerText should return only human readable content.

On the other hand textContent can return all text content, even if not human readable.

@xileftenurb
Copy link

I had the same issue,
If your use case make that you never need the content of script and style tag, the parser have the options to ignore those tag from the start ->

HTMLParser.parse(text, {
  comment: false,
  blockTextElements: {
    noscript: false,
    script: false,
    style: false,
    pre: false,
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants