1 | import Tokenizer from "./Tokenizer";
|
2 | export interface ParserOptions {
|
3 | |
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | xmlMode?: boolean;
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 | decodeEntities?: boolean;
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 | lowerCaseTags?: boolean;
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | lowerCaseAttributeNames?: boolean;
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | recognizeCDATA?: boolean;
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | recognizeSelfClosing?: boolean;
|
44 | |
45 |
|
46 |
|
47 | Tokenizer?: typeof Tokenizer;
|
48 | }
|
49 | export interface Handler {
|
50 | onparserinit(parser: Parser): void;
|
51 | |
52 |
|
53 |
|
54 | onreset(): void;
|
55 | |
56 |
|
57 |
|
58 | onend(): void;
|
59 | onerror(error: Error): void;
|
60 | onclosetag(name: string, isImplied: boolean): void;
|
61 | onopentagname(name: string): void;
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | onattribute(name: string, value: string, quote?: string | undefined | null): void;
|
69 | onopentag(name: string, attribs: {
|
70 | [s: string]: string;
|
71 | }, isImplied: boolean): void;
|
72 | ontext(data: string): void;
|
73 | oncomment(data: string): void;
|
74 | oncdatastart(): void;
|
75 | oncdataend(): void;
|
76 | oncommentend(): void;
|
77 | onprocessinginstruction(name: string, data: string): void;
|
78 | }
|
79 | export declare class Parser {
|
80 | private readonly options;
|
81 |
|
82 | startIndex: number;
|
83 |
|
84 | endIndex: number;
|
85 | |
86 |
|
87 |
|
88 |
|
89 | private openTagStart;
|
90 | private tagname;
|
91 | private attribname;
|
92 | private attribvalue;
|
93 | private attribs;
|
94 | private stack;
|
95 | private readonly foreignContext;
|
96 | private readonly cbs;
|
97 | private readonly lowerCaseTagNames;
|
98 | private readonly lowerCaseAttributeNames;
|
99 | private readonly tokenizer;
|
100 | constructor(cbs?: Partial<Handler> | null, options?: ParserOptions);
|
101 | /** @internal */
|
102 | ontext(data: string): void;
|
103 | protected isVoidElement(name: string): boolean;
|
104 | /** @internal */
|
105 | onopentagname(name: string): void;
|
106 | private emitOpenTag;
|
107 | private endOpenTag;
|
108 | /** @internal */
|
109 | onopentagend(): void;
|
110 | /** @internal */
|
111 | onclosetag(name: string): void;
|
112 | /** @internal */
|
113 | onselfclosingtag(): void;
|
114 | private closeCurrentTag;
|
115 | /** @internal */
|
116 | onattribname(name: string): void;
|
117 | /** @internal */
|
118 | onattribdata(value: string): void;
|
119 | /** @internal */
|
120 | onattribend(quote: string | undefined | null): void;
|
121 | private getInstructionName;
|
122 | /** @internal */
|
123 | ondeclaration(value: string): void;
|
124 | /** @internal */
|
125 | onprocessinginstruction(value: string): void;
|
126 | /** @internal */
|
127 | oncomment(value: string): void;
|
128 | /** @internal */
|
129 | oncdata(value: string): void;
|
130 | /** @internal */
|
131 | onerror(err: Error): void;
|
132 | /** @internal */
|
133 | onend(): void;
|
134 | /**
|
135 | * Resets the parser to a blank state, ready to parse a new HTML document
|
136 | */
|
137 | reset(): void;
|
138 | /**
|
139 | * Resets the parser, then parses a complete document and
|
140 | * pushes it to the handler.
|
141 | *
|
142 | * @param data Document to parse.
|
143 | */
|
144 | parseComplete(data: string): void;
|
145 | /**
|
146 | * Parses a chunk of data and calls the corresponding callbacks.
|
147 | *
|
148 | * @param chunk Chunk to parse.
|
149 | */
|
150 | write(chunk: string): void;
|
151 | /**
|
152 | * Parses the end of the buffer and clears the stack, calls onend.
|
153 | *
|
154 | * @param chunk Optional final chunk to parse.
|
155 | */
|
156 | end(chunk?: string): void;
|
157 | /**
|
158 | * Pauses parsing. The parser won't emit events until `resume` is called.
|
159 | */
|
160 | pause(): void;
|
161 | /**
|
162 | * Resumes parsing after `pause` was called.
|
163 | */
|
164 | resume(): void;
|
165 | /**
|
166 | * Alias of `write`, for backwards compatibility.
|
167 | *
|
168 | * @param chunk Chunk to parse.
|
169 | * @deprecated
|
170 | */
|
171 | parseChunk(chunk: string): void;
|
172 | /**
|
173 | * Alias of `end`, for backwards compatibility.
|
174 | *
|
175 | * @param chunk Optional final chunk to parse.
|
176 | * @deprecated
|
177 | */
|
178 | done(chunk?: string): void;
|
179 | }
|
180 | //# sourceMappingURL=Parser.d.ts.map |
\ | No newline at end of file |