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

refactor(options): Revamp option handling #2916

Merged
merged 4 commits into from Dec 24, 2022
Merged

refactor(options): Revamp option handling #2916

merged 4 commits into from Dec 24, 2022

Conversation

fb55
Copy link
Member

@fb55 fb55 commented Dec 24, 2022

Fixes #2744. I'm not quite happy yet, but am out of ideas of how to improve the situation without breakages in JS code.

htmlparser2 options have been moved out of the root options for Cheerio, making it more obvious which options will take effect. This only affects the TypeScript type.

Users that want to use htmlparser2 should use the xml option:

const $ = cheerio.load('<html>', { xml: {
  withStartIndices: true
}})

Just as before, users are still able to force htmlparser2 using a combination of xml and xmlMode:

const $ = cheerio.load('<html>', { xml: {
  // Force `htmlparser2`, but parse document as HTML.
  xmlMode: false
}})

htmlparser2 options have been moved out of the root options for Cheerio, making it more obvious which options will take effect. This currently only affects the TypeScript type.

Users that want to use htmlparser2 should use the `xml` option:

```js
const $ = cheerio.load('<html>', { xml: {
  withStartIndices: true
}})
```
@fb55 fb55 enabled auto-merge (squash) December 24, 2022 12:26
@fb55 fb55 merged commit 16c3149 into main Dec 24, 2022
@fb55 fb55 deleted the options-revamp branch December 24, 2022 12:29
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

Successfully merging this pull request may close these issues.

Impact of options is hard to understand
1 participant