mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* - added draft type for html-parser * fixed dom reference in package; corrected options interface; rewrote tests * reverted prev commit * corrected options interface; introduced dom lib into global space; corrected tests params * reverted prev commit * - added some tests. * added @type/html-parses * corrected formatting * corrected formatting * corrected errors after namespace correction * removed namespace declaration * corrected export declarations * fixed comments * corrected formatting * rewrote args so that they will be self-explanatory * corrected formatting
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
// Type definitions for html-parser 0.11
|
|
// Project: https://www.npmjs.com/package/html-parser
|
|
// Definitions by: Vladimir Grenaderov https://github.com/VladimirGrenaderov,
|
|
// Max Boguslavskiy <https://github.com/maxbogus>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.4
|
|
|
|
export type Callback = (arg: any) => any;
|
|
export type Token = '>' | '/>' | '?>';
|
|
|
|
export interface CallbacksOption {
|
|
attribute?(name: string, value: any): void;
|
|
openElement?(tagName: string): void;
|
|
closeOpenedElement?(tagName: string, token: Token, isUnary: boolean): void;
|
|
closeElement?(name: string): void;
|
|
comment?(content: string): void;
|
|
docType?(content: string): void;
|
|
cdata?(content: string): void;
|
|
xmlProlog?(): void;
|
|
text?(value: string): void;
|
|
}
|
|
|
|
export interface RegExpOptions {
|
|
name?: RegExp;
|
|
attribute?: RegExp;
|
|
}
|
|
|
|
export interface RemovalCallback {
|
|
attributes: Callback | string[];
|
|
elements: Callback | string[];
|
|
comments: Callback | boolean;
|
|
docTypes: Callback | boolean;
|
|
}
|
|
|
|
export function parse(htmlString: string, callbacks?: CallbacksOption, regex?: RegExpOptions): void;
|
|
|
|
export function parseFile(fileName: string, encoding: string | undefined, callbacks: CallbacksOption, callback: Callback): void;
|
|
|
|
export function sanitize(htmlString: string, removalCallbacks?: RemovalCallback): string;
|