1import Tokenizer from "./Tokenizer";
2export interface ParserOptions {
3    /**
4     * Indicates whether special tags (<script>, <style>, and <title>) should get special treatment
5     * and if "empty" tags (eg. <br>) can have children.  If `false`, the content of special tags
6     * will be text only. For feeds and other XML content (documents that don't consist of HTML),
7     * set this to `true`. Default: `false`.
8     */
9    xmlMode?: boolean;
10    /**
11     * Decode entities within the document. Defaults to `true`.
12     */
13    decodeEntities?: boolean;
14    /**
15     * If set to true, all tags will be lowercased. If xmlMode is disabled, this defaults to `true`.
16     */
17    lowerCaseTags?: boolean;
18    /**
19     * If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed, so it defaults to `false`.
20     */
21    lowerCaseAttributeNames?: boolean;
22    /**
23     * If set to true, CDATA sections will be recognized as text even if the xmlMode option is not enabled.
24     * NOTE: If xmlMode is set to `true` then CDATA sections will always be recognized as text.
25     */
26    recognizeCDATA?: boolean;
27    /**
28     * If set to `true`, self-closing tags will trigger the onclosetag event even if xmlMode is not set to `true`.
29     * NOTE: If xmlMode is set to `true` then self-closing tags will always be recognized.
30     */
31    recognizeSelfClosing?: boolean;
32    /**
33     * Allows the default tokenizer to be overwritten.
34     */
35    Tokenizer?: typeof Tokenizer;
36}
37export interface Handler {
38    onparserinit(parser: Parser): void;
39    /**
40     * Resets the handler back to starting state
41     */
42    onreset(): void;
43    /**
44     * Signals the handler that parsing is done
45     */
46    onend(): void;
47    onerror(error: Error): void;
48    onclosetag(name: string): void;
49    onopentagname(name: string): void;
50    /**
51     *
52     * @param name Name of the attribute
53     * @param value Value of the attribute.
54     * @param quote Quotes used around the attribute. `null` if the attribute has no quotes around the value, `undefined` if the attribute has no value.
55     */
56    onattribute(name: string, value: string, quote?: string | undefined | null): void;
57    onopentag(name: string, attribs: {
58        [s: string]: string;
59    }): void;
60    ontext(data: string): void;
61    oncomment(data: string): void;
62    oncdatastart(): void;
63    oncdataend(): void;
64    oncommentend(): void;
65    onprocessinginstruction(name: string, data: string): void;
66}
67export declare class Parser {
68    /** The start index of the last event. */
69    startIndex: number;
70    /** The end index of the last event. */
71    endIndex: number | null;
72    private tagname;
73    private attribname;
74    private attribvalue;
75    private attribs;
76    private stack;
77    private readonly foreignContext;
78    private readonly cbs;
79    private readonly options;
80    private readonly lowerCaseTagNames;
81    private readonly lowerCaseAttributeNames;
82    private readonly tokenizer;
83    constructor(cbs: Partial<Handler> | null, options?: ParserOptions);
84    private updatePosition;
85    ontext(data: string): void;
86    onopentagname(name: string): void;
87    onopentagend(): void;
88    onclosetag(name: string): void;
89    onselfclosingtag(): void;
90    private closeCurrentTag;
91    onattribname(name: string): void;
92    onattribdata(value: string): void;
93    onattribend(quote: string | undefined | null): void;
94    private getInstructionName;
95    ondeclaration(value: string): void;
96    onprocessinginstruction(value: string): void;
97    oncomment(value: string): void;
98    oncdata(value: string): void;
99    onerror(err: Error): void;
100    onend(): void;
101    /**
102     * Resets the parser to a blank state, ready to parse a new HTML document
103     */
104    reset(): void;
105    /**
106     * Parses a complete document and pushes it to the handler.
107     *
108     * @param data Document to parse.
109     */
110    parseComplete(data: string): void;
111    /**
112     * Parses a chunk of data and calls the corresponding callbacks.
113     *
114     * @param chunk Chunk to parse.
115     */
116    write(chunk: string): void;
117    /**
118     * Parses the end of the buffer and clears the stack, calls onend.
119     *
120     * @param chunk Optional final chunk to parse.
121     */
122    end(chunk?: string): void;
123    /**
124     * Pauses parsing. The parser won't emit events until `resume` is called.
125     */
126    pause(): void;
127    /**
128     * Resumes parsing after `pause` was called.
129     */
130    resume(): void;
131    /**
132     * Alias of `write`, for backwards compatibility.
133     *
134     * @param chunk Chunk to parse.
135     * @deprecated
136     */
137    parseChunk(chunk: string): void;
138    /**
139     * Alias of `end`, for backwards compatibility.
140     *
141     * @param chunk Optional final chunk to parse.
142     * @deprecated
143     */
144    done(chunk?: string): void;
145}
146//# sourceMappingURL=Parser.d.ts.map