1 | /** The level of entities to support. */
|
2 | export declare enum EntityLevel {
|
3 | /** Support only XML entities. */
|
4 | XML = 0,
|
5 | /** Support HTML entities, which are a superset of XML entities. */
|
6 | HTML = 1
|
7 | }
|
8 | /** Determines whether some entities are allowed to be written without a trailing `;`. */
|
9 | export declare enum DecodingMode {
|
10 | /** Support legacy HTML entities. */
|
11 | Legacy = 0,
|
12 | /** Do not support legacy HTML entities. */
|
13 | Strict = 1
|
14 | }
|
15 | export declare enum EncodingMode {
|
16 | /**
|
17 | * The output is UTF-8 encoded. Only characters that need escaping within
|
18 | * HTML will be escaped.
|
19 | */
|
20 | UTF8 = 0,
|
21 | /**
|
22 | * The output consists only of ASCII characters. Characters that need
|
23 | * escaping within HTML, and characters that aren't ASCII characters will
|
24 | * be escaped.
|
25 | */
|
26 | ASCII = 1,
|
27 | /**
|
28 | * Encode all characters that have an equivalent entity, as well as all
|
29 | * characters that are not ASCII characters.
|
30 | */
|
31 | Extensive = 2
|
32 | }
|
33 | interface DecodingOptions {
|
34 | /**
|
35 | * The level of entities to support.
|
36 | * @default EntityLevel.XML
|
37 | */
|
38 | level?: EntityLevel;
|
39 | /**
|
40 | * Decoding mode. If `Legacy`, will support legacy entities not terminated
|
41 | * with a semicolon (`;`).
|
42 | *
|
43 | * Always `Strict` for XML. For HTML, set this to `true` if you are parsing
|
44 | * an attribute value.
|
45 | *
|
46 | * The deprecated `decodeStrict` function defaults this to `Strict`.
|
47 | *
|
48 | * @default DecodingMode.Legacy
|
49 | */
|
50 | mode?: DecodingMode;
|
51 | }
|
52 | /**
|
53 | * Decodes a string with entities.
|
54 | *
|
55 | * @param data String to decode.
|
56 | * @param options Decoding options.
|
57 | */
|
58 | export declare function decode(data: string, options?: DecodingOptions | EntityLevel): string;
|
59 | /**
|
60 | * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
61 | *
|
62 | * @param data String to decode.
|
63 | * @param options Decoding options.
|
64 | * @deprecated Use `decode` with the `mode` set to `Strict`.
|
65 | */
|
66 | export declare function decodeStrict(data: string, options?: DecodingOptions | EntityLevel): string;
|
67 | /**
|
68 | * Options for `encode`.
|
69 | */
|
70 | export interface EncodingOptions {
|
71 | /**
|
72 | * The level of entities to support.
|
73 | * @default EntityLevel.XML
|
74 | */
|
75 | level?: EntityLevel;
|
76 | /**
|
77 | * Output format.
|
78 | * @default EncodingMode.Extensive
|
79 | */
|
80 | mode?: EncodingMode;
|
81 | }
|
82 | /**
|
83 | * Encodes a string with entities.
|
84 | *
|
85 | * @param data String to encode.
|
86 | * @param options Encoding options.
|
87 | */
|
88 | export declare function encode(data: string, options?: EncodingOptions | EntityLevel): string;
|
89 | export { encodeXML, encodeHTML, encodeNonAsciiHTML, escape, escapeUTF8, encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, } from "./encode";
|
90 | export { decodeXML, decodeHTML, decodeHTMLStrict, decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML as decodeXMLStrict, } from "./decode";
|
91 | //# sourceMappingURL=index.d.ts.map |
\ | No newline at end of file |