aboutsummaryrefslogtreecommitdiff
path: root/node_modules/htmlparser2/lib/Parser.d.ts
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-02-09 17:58:07 +0100
committerMinteck <contact@minteck.org>2022-02-09 17:58:07 +0100
commit22a25ded9f7d9c9a96cce8d1bc12475ca0434201 (patch)
tree0e33d0650fe58f41c00bbc4b8047956905766823 /node_modules/htmlparser2/lib/Parser.d.ts
parent8f54d903fb3470823a5e4d6ff4655de009836245 (diff)
downloadyoutoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.tar.gz
youtoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.tar.bz2
youtoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.zip
Major update
Diffstat (limited to 'node_modules/htmlparser2/lib/Parser.d.ts')
-rw-r--r--node_modules/htmlparser2/lib/Parser.d.ts159
1 files changed, 159 insertions, 0 deletions
diff --git a/node_modules/htmlparser2/lib/Parser.d.ts b/node_modules/htmlparser2/lib/Parser.d.ts
new file mode 100644
index 0000000..e5a7c49
--- /dev/null
+++ b/node_modules/htmlparser2/lib/Parser.d.ts
@@ -0,0 +1,159 @@
+import Tokenizer from "./Tokenizer";
+export interface ParserOptions {
+ /**
+ * Indicates whether special tags (`<script>`, `<style>`, and `<title>`) should get special treatment
+ * and if "empty" tags (eg. `<br>`) can have children. If `false`, the content of special tags
+ * will be text only. For feeds and other XML content (documents that don't consist of HTML),
+ * set this to `true`.
+ *
+ * @default false
+ */
+ xmlMode?: boolean;
+ /**
+ * Decode entities within the document.
+ *
+ * @default true
+ */
+ decodeEntities?: boolean;
+ /**
+ * If set to true, all tags will be lowercased.
+ *
+ * @default !xmlMode
+ */
+ lowerCaseTags?: boolean;
+ /**
+ * If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed.
+ *
+ * @default !xmlMode
+ */
+ lowerCaseAttributeNames?: boolean;
+ /**
+ * If set to true, CDATA sections will be recognized as text even if the xmlMode option is not enabled.
+ * NOTE: If xmlMode is set to `true` then CDATA sections will always be recognized as text.
+ *
+ * @default xmlMode
+ */
+ recognizeCDATA?: boolean;
+ /**
+ * If set to `true`, self-closing tags will trigger the onclosetag event even if xmlMode is not set to `true`.
+ * NOTE: If xmlMode is set to `true` then self-closing tags will always be recognized.
+ *
+ * @default xmlMode
+ */
+ recognizeSelfClosing?: boolean;
+ /**
+ * Allows the default tokenizer to be overwritten.
+ */
+ Tokenizer?: typeof Tokenizer;
+}
+export interface Handler {
+ onparserinit(parser: Parser): void;
+ /**
+ * Resets the handler back to starting state
+ */
+ onreset(): void;
+ /**
+ * Signals the handler that parsing is done
+ */
+ onend(): void;
+ onerror(error: Error): void;
+ onclosetag(name: string): void;
+ onopentagname(name: string): void;
+ /**
+ *
+ * @param name Name of the attribute
+ * @param value Value of the attribute.
+ * @param quote Quotes used around the attribute. `null` if the attribute has no quotes around the value, `undefined` if the attribute has no value.
+ */
+ onattribute(name: string, value: string, quote?: string | undefined | null): void;
+ onopentag(name: string, attribs: {
+ [s: string]: string;
+ }): void;
+ ontext(data: string): void;
+ oncomment(data: string): void;
+ oncdatastart(): void;
+ oncdataend(): void;
+ oncommentend(): void;
+ onprocessinginstruction(name: string, data: string): void;
+}
+export declare class Parser {
+ /** The start index of the last event. */
+ startIndex: number;
+ /** The end index of the last event. */
+ endIndex: number | null;
+ private tagname;
+ private attribname;
+ private attribvalue;
+ private attribs;
+ private stack;
+ private readonly foreignContext;
+ private readonly cbs;
+ private readonly options;
+ private readonly lowerCaseTagNames;
+ private readonly lowerCaseAttributeNames;
+ private readonly tokenizer;
+ constructor(cbs: Partial<Handler> | null, options?: ParserOptions);
+ private updatePosition;
+ ontext(data: string): void;
+ onopentagname(name: string): void;
+ onopentagend(): void;
+ onclosetag(name: string): void;
+ onselfclosingtag(): void;
+ private closeCurrentTag;
+ onattribname(name: string): void;
+ onattribdata(value: string): void;
+ onattribend(quote: string | undefined | null): void;
+ private getInstructionName;
+ ondeclaration(value: string): void;
+ onprocessinginstruction(value: string): void;
+ oncomment(value: string): void;
+ oncdata(value: string): void;
+ onerror(err: Error): void;
+ onend(): void;
+ /**
+ * Resets the parser to a blank state, ready to parse a new HTML document
+ */
+ reset(): void;
+ /**
+ * Resets the parser, then parses a complete document and
+ * pushes it to the handler.
+ *
+ * @param data Document to parse.
+ */
+ parseComplete(data: string): void;
+ /**
+ * Parses a chunk of data and calls the corresponding callbacks.
+ *
+ * @param chunk Chunk to parse.
+ */
+ write(chunk: string): void;
+ /**
+ * Parses the end of the buffer and clears the stack, calls onend.
+ *
+ * @param chunk Optional final chunk to parse.
+ */
+ end(chunk?: string): void;
+ /**
+ * Pauses parsing. The parser won't emit events until `resume` is called.
+ */
+ pause(): void;
+ /**
+ * Resumes parsing after `pause` was called.
+ */
+ resume(): void;
+ /**
+ * Alias of `write`, for backwards compatibility.
+ *
+ * @param chunk Chunk to parse.
+ * @deprecated
+ */
+ parseChunk(chunk: string): void;
+ /**
+ * Alias of `end`, for backwards compatibility.
+ *
+ * @param chunk Optional final chunk to parse.
+ * @deprecated
+ */
+ done(chunk?: string): void;
+}
+//# sourceMappingURL=Parser.d.ts.map \ No newline at end of file