DefinitelyTyped/types/sanitize-html/index.d.ts
Johan Davidsson 3c9fd4a692 [@types/htmlparser2] Update typings for Htmlparser2 (and related modules) to match updates (#33921)
* Added new types for domelementtype

* Modify existing types for htmlparser2

* Updating PULL_REQUEST_TEMPLATE.md

* Revert changes to .github/PULL_REQUEST_TEMPLATE.md

* Fixed missing optional

* Adding DomUtils

* Update dependencies

* Removed requirement for TypeScript 2.1 and updated test

* Updated test to include DomUtils and DomHandlerOptions.

* Updated domhandler tests

* Remove incorrect constructor in Parser

* Remove incorrect constructor in WritableStream

* Change way of importing in tests

* Adding deprecated fallback to Options

* Add deprecated Options as a fallback to sanitize-html

* Add ParserOptions

* Use the deprecated Options
2019-03-25 09:39:20 -07:00

68 lines
2.1 KiB
TypeScript

// Type definitions for sanitize-html 1.18.2
// Project: https://github.com/punkave/sanitize-html
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Afshin Darian <https://github.com/afshin>
// BehindTheMath <https://github.com/BehindTheMath>
// Rinze de Laat <https://github.com/biermeester>
// Will Gibson <https://github.com/WillGibson>
// A penguin <https://github.com/sirMerr>
// Johan Davidsson <https://github.com/johandavidson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import {Options} from "htmlparser2";
export = sanitize;
declare function sanitize(dirty: string, options?: sanitize.IOptions): string;
declare namespace sanitize {
type Attributes = { [attr: string]: string };
type Tag = { tagName: string; attribs: Attributes; text?: string; };
type Transformer = (tagName: string, attribs: Attributes) => Tag;
interface IDefaults {
allowedAttributes: { [index: string]: string[] };
allowedSchemes: string[];
allowedSchemesByTag: { [index: string]: string[] };
allowedTags: string[];
selfClosing: string[];
}
interface IFrame {
tag: string;
attribs: { [index: string]: string };
text: string;
tagPosition: number;
}
interface IOptions {
allowedAttributes?: { [index: string]: string[] } | boolean;
allowedStyles?: { [index: string]: { [index: string]: RegExp[] } };
allowedClasses?: { [index: string]: string[] } | boolean;
allowedIframeHostnames?: string[];
allowedSchemes?: string[] | boolean;
allowedSchemesByTag?: { [index: string]: string[] } | boolean;
allowedSchemesAppliedToAttributes?: string[];
allowProtocolRelative?: boolean;
allowedTags?: string[] | boolean;
exclusiveFilter?: (frame: IFrame) => boolean;
nonTextTags?: string[];
selfClosing?: string[];
transformTags?: { [tagName: string]: string | Transformer };
parser?: Options;
}
var defaults: IDefaults;
function simpleTransform(tagName: string, attribs: Attributes, merge?: boolean): Transformer;
}