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