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
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { parse, parseFile, sanitize, RegExpOptions, CallbacksOption, Token } from 'html-parser';
|
|
|
|
// test data
|
|
const attributes = (arg: string) => arg;
|
|
const elements = (arg: string) => arg;
|
|
const comments = (arg: boolean) => arg;
|
|
const docTypes = (arg: boolean) => arg;
|
|
const attribute = (name: string, value: string) => {};
|
|
const openElement = (tagName: string) => {};
|
|
const closeOpenedElement = (tagName: string, token: Token, isUnary: boolean) => {};
|
|
const closeElement = (name: string) => {};
|
|
const comment = (content: string) => {};
|
|
const docType = (content: string) => {};
|
|
const cdata = (content: string) => {};
|
|
const xmlProlog = () => {};
|
|
const text = (value: string) => {};
|
|
const emptyRegExpOptions: RegExpOptions = {};
|
|
const filledRegExpOptions: RegExpOptions = {attribute: new RegExp(''), name: new RegExp('')};
|
|
const emptyCallbackOptions: CallbacksOption = {};
|
|
const filled: CallbacksOption = {
|
|
attribute,
|
|
openElement,
|
|
closeOpenedElement,
|
|
closeElement,
|
|
comment,
|
|
docType,
|
|
cdata,
|
|
xmlProlog,
|
|
text
|
|
};
|
|
|
|
// parse tests:
|
|
parse('');
|
|
parse('', emptyCallbackOptions, emptyRegExpOptions);
|
|
parse('', filled, filledRegExpOptions);
|
|
|
|
// parseFile tests:
|
|
parseFile('', '', emptyCallbackOptions, attributes);
|
|
parseFile('', '', filled, attributes);
|
|
|
|
// sanitize tests:
|
|
sanitize('');
|
|
sanitize('', {attributes: [ 'hello' ], elements: [ 'hi' ], comments: true, docTypes: false});
|
|
sanitize('', {attributes, elements, comments, docTypes });
|