1
1
import type { DomHandlerOptions } from 'domhandler' ;
2
2
import type { ParserOptions } from 'htmlparser2' ;
3
+ import type { Options as SelectOptions } from 'cheerio-select' ;
3
4
4
5
/** Options accepted by htmlparser2, the default parser for XML. */
5
6
export interface HTMLParser2Options extends DomHandlerOptions , ParserOptions { }
@@ -11,14 +12,6 @@ export interface Parse5Options {
11
12
sourceCodeLocationInfo ?: boolean ;
12
13
}
13
14
14
- /** Internal options for Cheerio. */
15
- export interface InternalOptions extends HTMLParser2Options , Parse5Options {
16
- _useHtmlParser2 ?: boolean ;
17
-
18
- /** The base URI for the document. Used for the `href` and `src` props. */
19
- baseURI ?: string | URL ; // eslint-disable-line node/no-unsupported-features/node-builtins
20
- }
21
-
22
15
/**
23
16
* Options accepted by Cheerio.
24
17
*
@@ -31,6 +24,50 @@ export interface CheerioOptions extends HTMLParser2Options, Parse5Options {
31
24
32
25
/** The base URI for the document. Used for the `href` and `src` props. */
33
26
baseURI ?: string | URL ; // eslint-disable-line node/no-unsupported-features/node-builtins
27
+
28
+ /**
29
+ * Is the document in quirks mode?
30
+ *
31
+ * This will lead to `.className` and `#id` being case-insensitive.
32
+ *
33
+ * @default false
34
+ */
35
+ quirksMode ?: SelectOptions [ 'quirksMode' ] ;
36
+ /**
37
+ * Extension point for pseudo-classes.
38
+ *
39
+ * Maps from names to either strings of functions.
40
+ *
41
+ * - A string value is a selector that the element must match to be selected.
42
+ * - A function is called with the element as its first argument, and optional
43
+ * parameters second. If it returns true, the element is selected.
44
+ *
45
+ * @example
46
+ *
47
+ * ```js
48
+ * const $ = cheerio.load(
49
+ * '<div class="foo"></div><div data-bar="boo"></div>',
50
+ * {
51
+ * pseudos: {
52
+ * // `:foo` is an alias for `div.foo`
53
+ * foo: 'div.foo',
54
+ * // `:bar(val)` is equivalent to `[data-bar=val s]`
55
+ * bar: (el, val) => el.attribs['data-bar'] === val,
56
+ * },
57
+ * }
58
+ * );
59
+ *
60
+ * $(':foo').length; // 1
61
+ * $('div:bar(boo)').length; // 1
62
+ * $('div:bar(baz)').length; // 0
63
+ * ```
64
+ */
65
+ pseudos ?: SelectOptions [ 'pseudos' ] ;
66
+ }
67
+
68
+ /** Internal options for Cheerio. */
69
+ export interface InternalOptions extends Omit < CheerioOptions , 'xml' > {
70
+ _useHtmlParser2 ?: boolean ;
34
71
}
35
72
36
73
const defaultOpts : CheerioOptions = {
0 commit comments