entities 7.0.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decode-codepoint.d.ts +8 -0
- package/dist/decode-codepoint.d.ts.map +1 -0
- package/dist/decode-codepoint.js +46 -0
- package/dist/decode-codepoint.js.map +1 -0
- package/dist/{commonjs/decode.d.ts → decode.d.ts} +9 -20
- package/dist/decode.d.ts.map +1 -0
- package/dist/{esm/decode.js → decode.js} +38 -48
- package/dist/decode.js.map +1 -0
- package/dist/{commonjs/encode.d.ts → encode.d.ts} +2 -0
- package/dist/encode.d.ts.map +1 -0
- package/dist/{esm/encode.js → encode.js} +6 -4
- package/dist/encode.js.map +1 -0
- package/dist/{esm/escape.d.ts → escape.d.ts} +6 -4
- package/dist/escape.d.ts.map +1 -0
- package/dist/{esm/escape.js → escape.js} +15 -17
- package/dist/escape.js.map +1 -0
- package/dist/generated/decode-data-html.d.ts +3 -0
- package/dist/generated/decode-data-html.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/decode-data-html.js +1 -0
- package/dist/generated/decode-data-html.js.map +1 -0
- package/dist/generated/decode-data-xml.d.ts +3 -0
- package/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/decode-data-xml.js +1 -0
- package/dist/generated/decode-data-xml.js.map +1 -0
- package/dist/generated/encode-html.d.ts +5 -0
- package/dist/generated/encode-html.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/encode-html.js +2 -1
- package/dist/generated/encode-html.js.map +1 -0
- package/dist/{commonjs/index.d.ts → index.d.ts} +9 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +7 -23
- package/dist/index.js.map +1 -0
- package/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/dist/internal/bin-trie-flags.js.map +1 -0
- package/dist/internal/decode-shared.d.ts +7 -0
- package/dist/internal/decode-shared.d.ts.map +1 -0
- package/dist/internal/decode-shared.js +17 -0
- package/dist/internal/decode-shared.js.map +1 -0
- package/dist/{commonjs/internal → internal}/encode-shared.d.ts +1 -0
- package/dist/internal/encode-shared.d.ts.map +1 -0
- package/dist/{esm/internal → internal}/encode-shared.js +4 -2
- package/dist/internal/encode-shared.js.map +1 -0
- package/package.json +25 -62
- package/readme.md +4 -16
- package/src/decode-codepoint.ts +1 -32
- package/src/decode.ts +12 -26
- package/src/encode.ts +2 -0
- package/src/escape.ts +11 -12
- package/src/generated/decode-data-html.ts +1 -0
- package/src/generated/decode-data-xml.ts +1 -0
- package/src/generated/encode-html.ts +2 -1
- package/src/index.ts +8 -33
- package/src/internal/decode-shared.ts +3 -15
- package/src/internal/encode-shared.ts +4 -2
- package/decode.d.ts +0 -3
- package/decode.js +0 -3
- package/dist/commonjs/decode-codepoint.d.ts +0 -19
- package/dist/commonjs/decode-codepoint.d.ts.map +0 -1
- package/dist/commonjs/decode-codepoint.js +0 -77
- package/dist/commonjs/decode-codepoint.js.map +0 -1
- package/dist/commonjs/decode.d.ts.map +0 -1
- package/dist/commonjs/decode.js +0 -568
- package/dist/commonjs/decode.js.map +0 -1
- package/dist/commonjs/encode.d.ts.map +0 -1
- package/dist/commonjs/encode.js +0 -92
- package/dist/commonjs/encode.js.map +0 -1
- package/dist/commonjs/escape.d.ts +0 -46
- package/dist/commonjs/escape.d.ts.map +0 -1
- package/dist/commonjs/escape.js +0 -138
- package/dist/commonjs/escape.js.map +0 -1
- package/dist/commonjs/generated/decode-data-html.d.ts +0 -2
- package/dist/commonjs/generated/decode-data-html.d.ts.map +0 -1
- package/dist/commonjs/generated/decode-data-html.js +0 -7
- package/dist/commonjs/generated/decode-data-html.js.map +0 -1
- package/dist/commonjs/generated/decode-data-xml.d.ts +0 -2
- package/dist/commonjs/generated/decode-data-xml.d.ts.map +0 -1
- package/dist/commonjs/generated/decode-data-xml.js +0 -7
- package/dist/commonjs/generated/decode-data-xml.js.map +0 -1
- package/dist/commonjs/generated/encode-html.d.ts +0 -3
- package/dist/commonjs/generated/encode-html.d.ts.map +0 -1
- package/dist/commonjs/generated/encode-html.js +0 -14
- package/dist/commonjs/generated/encode-html.js.map +0 -1
- package/dist/commonjs/index.d.ts.map +0 -1
- package/dist/commonjs/index.js +0 -131
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/internal/bin-trie-flags.d.ts.map +0 -1
- package/dist/commonjs/internal/bin-trie-flags.js +0 -21
- package/dist/commonjs/internal/bin-trie-flags.js.map +0 -1
- package/dist/commonjs/internal/decode-shared.d.ts +0 -2
- package/dist/commonjs/internal/decode-shared.d.ts.map +0 -1
- package/dist/commonjs/internal/decode-shared.js +0 -31
- package/dist/commonjs/internal/decode-shared.js.map +0 -1
- package/dist/commonjs/internal/encode-shared.d.ts.map +0 -1
- package/dist/commonjs/internal/encode-shared.js +0 -94
- package/dist/commonjs/internal/encode-shared.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/decode-codepoint.d.ts +0 -19
- package/dist/esm/decode-codepoint.d.ts.map +0 -1
- package/dist/esm/decode-codepoint.js +0 -72
- package/dist/esm/decode-codepoint.js.map +0 -1
- package/dist/esm/decode.d.ts +0 -205
- package/dist/esm/decode.d.ts.map +0 -1
- package/dist/esm/decode.js.map +0 -1
- package/dist/esm/encode.d.ts +0 -22
- package/dist/esm/encode.d.ts.map +0 -1
- package/dist/esm/encode.js.map +0 -1
- package/dist/esm/escape.d.ts.map +0 -1
- package/dist/esm/escape.js.map +0 -1
- package/dist/esm/generated/decode-data-html.d.ts +0 -2
- package/dist/esm/generated/decode-data-html.d.ts.map +0 -1
- package/dist/esm/generated/decode-data-html.js.map +0 -1
- package/dist/esm/generated/decode-data-xml.d.ts +0 -2
- package/dist/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/dist/esm/generated/decode-data-xml.js.map +0 -1
- package/dist/esm/generated/encode-html.d.ts +0 -3
- package/dist/esm/generated/encode-html.d.ts.map +0 -1
- package/dist/esm/generated/encode-html.js.map +0 -1
- package/dist/esm/index.d.ts +0 -96
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internal/bin-trie-flags.d.ts +0 -17
- package/dist/esm/internal/bin-trie-flags.d.ts.map +0 -1
- package/dist/esm/internal/bin-trie-flags.js.map +0 -1
- package/dist/esm/internal/decode-shared.d.ts +0 -2
- package/dist/esm/internal/decode-shared.d.ts.map +0 -1
- package/dist/esm/internal/decode-shared.js +0 -28
- package/dist/esm/internal/decode-shared.js.map +0 -1
- package/dist/esm/internal/encode-shared.d.ts +0 -32
- package/dist/esm/internal/encode-shared.d.ts.map +0 -1
- package/dist/esm/internal/encode-shared.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/escape.d.ts +0 -3
- package/escape.js +0 -3
- package/src/generated/.eslintrc.json +0 -10
- /package/dist/{commonjs/internal → internal}/bin-trie-flags.d.ts +0 -0
- /package/dist/{esm/internal → internal}/bin-trie-flags.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace the given code point with a replacement character if it is a
|
|
3
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
4
|
+
* point unchanged.
|
|
5
|
+
* @param codePoint Unicode code point to convert.
|
|
6
|
+
*/
|
|
7
|
+
export declare function replaceCodePoint(codePoint: number): number;
|
|
8
|
+
//# sourceMappingURL=decode-codepoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.d.ts","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS1D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
|
|
2
|
+
const decodeMap = new Map([
|
|
3
|
+
[0, 65_533],
|
|
4
|
+
// C1 Unicode control character reference replacements
|
|
5
|
+
[128, 8364],
|
|
6
|
+
[130, 8218],
|
|
7
|
+
[131, 402],
|
|
8
|
+
[132, 8222],
|
|
9
|
+
[133, 8230],
|
|
10
|
+
[134, 8224],
|
|
11
|
+
[135, 8225],
|
|
12
|
+
[136, 710],
|
|
13
|
+
[137, 8240],
|
|
14
|
+
[138, 352],
|
|
15
|
+
[139, 8249],
|
|
16
|
+
[140, 338],
|
|
17
|
+
[142, 381],
|
|
18
|
+
[145, 8216],
|
|
19
|
+
[146, 8217],
|
|
20
|
+
[147, 8220],
|
|
21
|
+
[148, 8221],
|
|
22
|
+
[149, 8226],
|
|
23
|
+
[150, 8211],
|
|
24
|
+
[151, 8212],
|
|
25
|
+
[152, 732],
|
|
26
|
+
[153, 8482],
|
|
27
|
+
[154, 353],
|
|
28
|
+
[155, 8250],
|
|
29
|
+
[156, 339],
|
|
30
|
+
[158, 382],
|
|
31
|
+
[159, 376],
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Replace the given code point with a replacement character if it is a
|
|
35
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
36
|
+
* point unchanged.
|
|
37
|
+
* @param codePoint Unicode code point to convert.
|
|
38
|
+
*/
|
|
39
|
+
export function replaceCodePoint(codePoint) {
|
|
40
|
+
if ((codePoint >= 0xd8_00 && codePoint <= 0xdf_ff) ||
|
|
41
|
+
codePoint > 0x10_ff_ff) {
|
|
42
|
+
return 0xff_fd;
|
|
43
|
+
}
|
|
44
|
+
return decodeMap.get(codePoint) ?? codePoint;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=decode-codepoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.js","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAErH,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,sDAAsD;I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|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoding mode for named entities.
|
|
3
|
+
*/
|
|
1
4
|
export declare enum DecodingMode {
|
|
2
5
|
/** Entities in text nodes that can end with any character. */
|
|
3
6
|
Legacy = 0,
|
|
@@ -25,7 +28,6 @@ export declare class EntityDecoder {
|
|
|
25
28
|
*
|
|
26
29
|
* For multi-byte named entities, this will be called multiple times,
|
|
27
30
|
* with the second codepoint, and the same `consumed` value.
|
|
28
|
-
*
|
|
29
31
|
* @param codepoint The decoded codepoint.
|
|
30
32
|
* @param consumed The number of bytes consumed by the decoder.
|
|
31
33
|
*/
|
|
@@ -40,7 +42,6 @@ export declare class EntityDecoder {
|
|
|
40
42
|
*
|
|
41
43
|
* For multi-byte named entities, this will be called multiple times,
|
|
42
44
|
* with the second codepoint, and the same `consumed` value.
|
|
43
|
-
*
|
|
44
45
|
* @param codepoint The decoded codepoint.
|
|
45
46
|
* @param consumed The number of bytes consumed by the decoder.
|
|
46
47
|
*/
|
|
@@ -66,7 +67,10 @@ export declare class EntityDecoder {
|
|
|
66
67
|
private decodeMode;
|
|
67
68
|
/** The number of characters that have been consumed in the current run. */
|
|
68
69
|
private runConsumed;
|
|
69
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Resets the instance to make it reusable.
|
|
72
|
+
* @param decodeMode Entity decoding mode to use.
|
|
73
|
+
*/
|
|
70
74
|
startEntity(decodeMode: DecodingMode): void;
|
|
71
75
|
/**
|
|
72
76
|
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
@@ -74,7 +78,6 @@ export declare class EntityDecoder {
|
|
|
74
78
|
*
|
|
75
79
|
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
76
80
|
* entity is incomplete, and resume when the next string is written.
|
|
77
|
-
*
|
|
78
81
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
79
82
|
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
80
83
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -84,7 +87,6 @@ export declare class EntityDecoder {
|
|
|
84
87
|
* Switches between the numeric decimal and hexadecimal states.
|
|
85
88
|
*
|
|
86
89
|
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
87
|
-
*
|
|
88
90
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
89
91
|
* @param offset The current offset.
|
|
90
92
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -94,7 +96,6 @@ export declare class EntityDecoder {
|
|
|
94
96
|
* Parses a hexadecimal numeric entity.
|
|
95
97
|
*
|
|
96
98
|
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
97
|
-
*
|
|
98
99
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
99
100
|
* @param offset The current offset.
|
|
100
101
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -104,7 +105,6 @@ export declare class EntityDecoder {
|
|
|
104
105
|
* Parses a decimal numeric entity.
|
|
105
106
|
*
|
|
106
107
|
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
107
|
-
*
|
|
108
108
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
109
109
|
* @param offset The current offset.
|
|
110
110
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -115,7 +115,6 @@ export declare class EntityDecoder {
|
|
|
115
115
|
*
|
|
116
116
|
* Implements the logic from the `Hexademical character reference start
|
|
117
117
|
* state` and `Numeric character reference end state` in the HTML spec.
|
|
118
|
-
*
|
|
119
118
|
* @param lastCp The last code point of the entity. Used to see if the
|
|
120
119
|
* entity was terminated with a semicolon.
|
|
121
120
|
* @param expectedLength The minimum number of characters that should be
|
|
@@ -128,7 +127,6 @@ export declare class EntityDecoder {
|
|
|
128
127
|
* Parses a named entity.
|
|
129
128
|
*
|
|
130
129
|
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
131
|
-
*
|
|
132
130
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
133
131
|
* @param offset The current offset.
|
|
134
132
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -136,17 +134,14 @@ export declare class EntityDecoder {
|
|
|
136
134
|
private stateNamedEntity;
|
|
137
135
|
/**
|
|
138
136
|
* Emit a named entity that was not terminated with a semicolon.
|
|
139
|
-
*
|
|
140
137
|
* @returns The number of characters consumed.
|
|
141
138
|
*/
|
|
142
139
|
private emitNotTerminatedNamedEntity;
|
|
143
140
|
/**
|
|
144
141
|
* Emit a named entity.
|
|
145
|
-
*
|
|
146
142
|
* @param result The index of the entity in the decode tree.
|
|
147
143
|
* @param valueLength The number of bytes in the entity.
|
|
148
144
|
* @param consumed The number of characters consumed.
|
|
149
|
-
*
|
|
150
145
|
* @returns The number of characters consumed.
|
|
151
146
|
*/
|
|
152
147
|
private emitNamedEntityData;
|
|
@@ -154,7 +149,6 @@ export declare class EntityDecoder {
|
|
|
154
149
|
* Signal to the parser that the end of the input was reached.
|
|
155
150
|
*
|
|
156
151
|
* Remaining data will be emitted and relevant errors will be produced.
|
|
157
|
-
*
|
|
158
152
|
* @returns The number of characters consumed.
|
|
159
153
|
*/
|
|
160
154
|
end(): number;
|
|
@@ -162,17 +156,15 @@ export declare class EntityDecoder {
|
|
|
162
156
|
/**
|
|
163
157
|
* Determines the branch of the current node that is taken given the current
|
|
164
158
|
* character. This function is used to traverse the trie.
|
|
165
|
-
*
|
|
166
159
|
* @param decodeTree The trie.
|
|
167
160
|
* @param current The current node.
|
|
168
|
-
* @param
|
|
161
|
+
* @param nodeIndex Index immediately after the current node header.
|
|
169
162
|
* @param char The current character.
|
|
170
163
|
* @returns The index of the next node, or -1 if no branch is taken.
|
|
171
164
|
*/
|
|
172
165
|
export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIndex: number, char: number): number;
|
|
173
166
|
/**
|
|
174
167
|
* Decodes an HTML string.
|
|
175
|
-
*
|
|
176
168
|
* @param htmlString The string to decode.
|
|
177
169
|
* @param mode The decoding mode.
|
|
178
170
|
* @returns The decoded string.
|
|
@@ -180,26 +172,23 @@ export declare function determineBranch(decodeTree: Uint16Array, current: number
|
|
|
180
172
|
export declare function decodeHTML(htmlString: string, mode?: DecodingMode): string;
|
|
181
173
|
/**
|
|
182
174
|
* Decodes an HTML string in an attribute.
|
|
183
|
-
*
|
|
184
175
|
* @param htmlAttribute The string to decode.
|
|
185
176
|
* @returns The decoded string.
|
|
186
177
|
*/
|
|
187
178
|
export declare function decodeHTMLAttribute(htmlAttribute: string): string;
|
|
188
179
|
/**
|
|
189
180
|
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
190
|
-
*
|
|
191
181
|
* @param htmlString The string to decode.
|
|
192
182
|
* @returns The decoded string.
|
|
193
183
|
*/
|
|
194
184
|
export declare function decodeHTMLStrict(htmlString: string): string;
|
|
195
185
|
/**
|
|
196
186
|
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
197
|
-
*
|
|
198
187
|
* @param xmlString The string to decode.
|
|
199
188
|
* @returns The decoded string.
|
|
200
189
|
*/
|
|
201
190
|
export declare function decodeXML(xmlString: string): string;
|
|
202
|
-
export {
|
|
191
|
+
export { replaceCodePoint } from "./decode-codepoint.js";
|
|
203
192
|
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
204
193
|
export { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
205
194
|
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AA6DA;;GAEG;AACH,oBAAY,YAAY;IACpB,8DAA8D;IAC9D,MAAM,IAAI;IACV,uDAAuD;IACvD,MAAM,IAAI;IACV,oEAAoE;IACpE,SAAS,IAAI;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,uCAAuC,IAAI,IAAI,CAAC;IAChD,0CAA0C,CACtC,kBAAkB,E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C,4BAA4B;IAYpC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;;;;OAKG;IACH,GAAG,IAAI,MAAM;CA6BhB;AAmDD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC3B,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACb,MAAM,CA4CR;AAKD;;;;;GAKG;AACH,wBAAgB,UAAU,CACtB,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,YAAkC,GACzC,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { replaceCodePoint } from "./decode-codepoint.js";
|
|
2
2
|
import { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
3
3
|
import { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
4
4
|
import { BinTrieFlags } from "./internal/bin-trie-flags.js";
|
|
@@ -18,7 +18,7 @@ var CharCodes;
|
|
|
18
18
|
CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
|
|
19
19
|
})(CharCodes || (CharCodes = {}));
|
|
20
20
|
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
21
|
-
const TO_LOWER_BIT =
|
|
21
|
+
const TO_LOWER_BIT = 0b10_0000;
|
|
22
22
|
function isNumber(code) {
|
|
23
23
|
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|
24
24
|
}
|
|
@@ -36,6 +36,7 @@ function isAsciiAlphaNumeric(code) {
|
|
|
36
36
|
*
|
|
37
37
|
* Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
38
38
|
* See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
39
|
+
* @param code Code point to decode.
|
|
39
40
|
*/
|
|
40
41
|
function isEntityInAttributeInvalidEnd(code) {
|
|
41
42
|
return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
|
|
@@ -48,6 +49,9 @@ var EntityDecoderState;
|
|
|
48
49
|
EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
|
|
49
50
|
EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
|
|
50
51
|
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
52
|
+
/**
|
|
53
|
+
* Decoding mode for named entities.
|
|
54
|
+
*/
|
|
51
55
|
export var DecodingMode;
|
|
52
56
|
(function (DecodingMode) {
|
|
53
57
|
/** Entities in text nodes that can end with any character. */
|
|
@@ -61,6 +65,9 @@ export var DecodingMode;
|
|
|
61
65
|
* Token decoder with support of writing partial entities.
|
|
62
66
|
*/
|
|
63
67
|
export class EntityDecoder {
|
|
68
|
+
decodeTree;
|
|
69
|
+
emitCodePoint;
|
|
70
|
+
errors;
|
|
64
71
|
constructor(
|
|
65
72
|
/** The tree used to decode entities. */
|
|
66
73
|
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive
|
|
@@ -70,7 +77,6 @@ export class EntityDecoder {
|
|
|
70
77
|
*
|
|
71
78
|
* For multi-byte named entities, this will be called multiple times,
|
|
72
79
|
* with the second codepoint, and the same `consumed` value.
|
|
73
|
-
*
|
|
74
80
|
* @param codepoint The decoded codepoint.
|
|
75
81
|
* @param consumed The number of bytes consumed by the decoder.
|
|
76
82
|
*/
|
|
@@ -80,27 +86,30 @@ export class EntityDecoder {
|
|
|
80
86
|
this.decodeTree = decodeTree;
|
|
81
87
|
this.emitCodePoint = emitCodePoint;
|
|
82
88
|
this.errors = errors;
|
|
83
|
-
/** The current state of the decoder. */
|
|
84
|
-
this.state = EntityDecoderState.EntityStart;
|
|
85
|
-
/** Characters that were consumed while parsing an entity. */
|
|
86
|
-
this.consumed = 1;
|
|
87
|
-
/**
|
|
88
|
-
* The result of the entity.
|
|
89
|
-
*
|
|
90
|
-
* Either the result index of a numeric entity, or the codepoint of a
|
|
91
|
-
* numeric entity.
|
|
92
|
-
*/
|
|
93
|
-
this.result = 0;
|
|
94
|
-
/** The current index in the decode tree. */
|
|
95
|
-
this.treeIndex = 0;
|
|
96
|
-
/** The number of characters that were consumed in excess. */
|
|
97
|
-
this.excess = 1;
|
|
98
|
-
/** The mode in which the decoder is operating. */
|
|
99
|
-
this.decodeMode = DecodingMode.Strict;
|
|
100
|
-
/** The number of characters that have been consumed in the current run. */
|
|
101
|
-
this.runConsumed = 0;
|
|
102
89
|
}
|
|
103
|
-
/**
|
|
90
|
+
/** The current state of the decoder. */
|
|
91
|
+
state = EntityDecoderState.EntityStart;
|
|
92
|
+
/** Characters that were consumed while parsing an entity. */
|
|
93
|
+
consumed = 1;
|
|
94
|
+
/**
|
|
95
|
+
* The result of the entity.
|
|
96
|
+
*
|
|
97
|
+
* Either the result index of a numeric entity, or the codepoint of a
|
|
98
|
+
* numeric entity.
|
|
99
|
+
*/
|
|
100
|
+
result = 0;
|
|
101
|
+
/** The current index in the decode tree. */
|
|
102
|
+
treeIndex = 0;
|
|
103
|
+
/** The number of characters that were consumed in excess. */
|
|
104
|
+
excess = 1;
|
|
105
|
+
/** The mode in which the decoder is operating. */
|
|
106
|
+
decodeMode = DecodingMode.Strict;
|
|
107
|
+
/** The number of characters that have been consumed in the current run. */
|
|
108
|
+
runConsumed = 0;
|
|
109
|
+
/**
|
|
110
|
+
* Resets the instance to make it reusable.
|
|
111
|
+
* @param decodeMode Entity decoding mode to use.
|
|
112
|
+
*/
|
|
104
113
|
startEntity(decodeMode) {
|
|
105
114
|
this.decodeMode = decodeMode;
|
|
106
115
|
this.state = EntityDecoderState.EntityStart;
|
|
@@ -116,7 +125,6 @@ export class EntityDecoder {
|
|
|
116
125
|
*
|
|
117
126
|
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
118
127
|
* entity is incomplete, and resume when the next string is written.
|
|
119
|
-
*
|
|
120
128
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
121
129
|
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
122
130
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -150,7 +158,6 @@ export class EntityDecoder {
|
|
|
150
158
|
* Switches between the numeric decimal and hexadecimal states.
|
|
151
159
|
*
|
|
152
160
|
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
153
|
-
*
|
|
154
161
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
155
162
|
* @param offset The current offset.
|
|
156
163
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -171,7 +178,6 @@ export class EntityDecoder {
|
|
|
171
178
|
* Parses a hexadecimal numeric entity.
|
|
172
179
|
*
|
|
173
180
|
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
174
|
-
*
|
|
175
181
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
176
182
|
* @param offset The current offset.
|
|
177
183
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -198,7 +204,6 @@ export class EntityDecoder {
|
|
|
198
204
|
* Parses a decimal numeric entity.
|
|
199
205
|
*
|
|
200
206
|
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
201
|
-
*
|
|
202
207
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
203
208
|
* @param offset The current offset.
|
|
204
209
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -222,7 +227,6 @@ export class EntityDecoder {
|
|
|
222
227
|
*
|
|
223
228
|
* Implements the logic from the `Hexademical character reference start
|
|
224
229
|
* state` and `Numeric character reference end state` in the HTML spec.
|
|
225
|
-
*
|
|
226
230
|
* @param lastCp The last code point of the entity. Used to see if the
|
|
227
231
|
* entity was terminated with a semicolon.
|
|
228
232
|
* @param expectedLength The minimum number of characters that should be
|
|
@@ -231,10 +235,9 @@ export class EntityDecoder {
|
|
|
231
235
|
* @returns The number of characters that were consumed.
|
|
232
236
|
*/
|
|
233
237
|
emitNumericEntity(lastCp, expectedLength) {
|
|
234
|
-
var _a;
|
|
235
238
|
// Ensure we consumed at least one digit.
|
|
236
239
|
if (this.consumed <= expectedLength) {
|
|
237
|
-
|
|
240
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
238
241
|
return 0;
|
|
239
242
|
}
|
|
240
243
|
// Figure out if this is a legit end of the entity
|
|
@@ -257,7 +260,6 @@ export class EntityDecoder {
|
|
|
257
260
|
* Parses a named entity.
|
|
258
261
|
*
|
|
259
262
|
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
260
|
-
*
|
|
261
263
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
262
264
|
* @param offset The current offset.
|
|
263
265
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -359,24 +361,20 @@ export class EntityDecoder {
|
|
|
359
361
|
}
|
|
360
362
|
/**
|
|
361
363
|
* Emit a named entity that was not terminated with a semicolon.
|
|
362
|
-
*
|
|
363
364
|
* @returns The number of characters consumed.
|
|
364
365
|
*/
|
|
365
366
|
emitNotTerminatedNamedEntity() {
|
|
366
|
-
var _a;
|
|
367
367
|
const { result, decodeTree } = this;
|
|
368
368
|
const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
369
369
|
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
370
|
-
|
|
370
|
+
this.errors?.missingSemicolonAfterCharacterReference();
|
|
371
371
|
return this.consumed;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* Emit a named entity.
|
|
375
|
-
*
|
|
376
375
|
* @param result The index of the entity in the decode tree.
|
|
377
376
|
* @param valueLength The number of bytes in the entity.
|
|
378
377
|
* @param consumed The number of characters consumed.
|
|
379
|
-
*
|
|
380
378
|
* @returns The number of characters consumed.
|
|
381
379
|
*/
|
|
382
380
|
emitNamedEntityData(result, valueLength, consumed) {
|
|
@@ -395,11 +393,9 @@ export class EntityDecoder {
|
|
|
395
393
|
* Signal to the parser that the end of the input was reached.
|
|
396
394
|
*
|
|
397
395
|
* Remaining data will be emitted and relevant errors will be produced.
|
|
398
|
-
*
|
|
399
396
|
* @returns The number of characters consumed.
|
|
400
397
|
*/
|
|
401
398
|
end() {
|
|
402
|
-
var _a;
|
|
403
399
|
switch (this.state) {
|
|
404
400
|
case EntityDecoderState.NamedEntity: {
|
|
405
401
|
// Emit a named entity if we have one.
|
|
@@ -417,7 +413,7 @@ export class EntityDecoder {
|
|
|
417
413
|
return this.emitNumericEntity(0, 3);
|
|
418
414
|
}
|
|
419
415
|
case EntityDecoderState.NumericStart: {
|
|
420
|
-
|
|
416
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
421
417
|
return 0;
|
|
422
418
|
}
|
|
423
419
|
case EntityDecoderState.EntityStart: {
|
|
@@ -429,13 +425,12 @@ export class EntityDecoder {
|
|
|
429
425
|
}
|
|
430
426
|
/**
|
|
431
427
|
* Creates a function that decodes entities in a string.
|
|
432
|
-
*
|
|
433
428
|
* @param decodeTree The decode tree.
|
|
434
429
|
* @returns A function that decodes entities in a string.
|
|
435
430
|
*/
|
|
436
431
|
function getDecoder(decodeTree) {
|
|
437
432
|
let returnValue = "";
|
|
438
|
-
const decoder = new EntityDecoder(decodeTree, (data) => (returnValue += fromCodePoint(data)));
|
|
433
|
+
const decoder = new EntityDecoder(decodeTree, (data) => (returnValue += String.fromCodePoint(data)));
|
|
439
434
|
return function decodeWithTrie(input, decodeMode) {
|
|
440
435
|
let lastIndex = 0;
|
|
441
436
|
let offset = 0;
|
|
@@ -462,10 +457,9 @@ function getDecoder(decodeTree) {
|
|
|
462
457
|
/**
|
|
463
458
|
* Determines the branch of the current node that is taken given the current
|
|
464
459
|
* character. This function is used to traverse the trie.
|
|
465
|
-
*
|
|
466
460
|
* @param decodeTree The trie.
|
|
467
461
|
* @param current The current node.
|
|
468
|
-
* @param
|
|
462
|
+
* @param nodeIndex Index immediately after the current node header.
|
|
469
463
|
* @param char The current character.
|
|
470
464
|
* @returns The index of the next node, or -1 if no branch is taken.
|
|
471
465
|
*/
|
|
@@ -512,7 +506,6 @@ const htmlDecoder = /* #__PURE__ */ getDecoder(htmlDecodeTree);
|
|
|
512
506
|
const xmlDecoder = /* #__PURE__ */ getDecoder(xmlDecodeTree);
|
|
513
507
|
/**
|
|
514
508
|
* Decodes an HTML string.
|
|
515
|
-
*
|
|
516
509
|
* @param htmlString The string to decode.
|
|
517
510
|
* @param mode The decoding mode.
|
|
518
511
|
* @returns The decoded string.
|
|
@@ -522,7 +515,6 @@ export function decodeHTML(htmlString, mode = DecodingMode.Legacy) {
|
|
|
522
515
|
}
|
|
523
516
|
/**
|
|
524
517
|
* Decodes an HTML string in an attribute.
|
|
525
|
-
*
|
|
526
518
|
* @param htmlAttribute The string to decode.
|
|
527
519
|
* @returns The decoded string.
|
|
528
520
|
*/
|
|
@@ -531,7 +523,6 @@ export function decodeHTMLAttribute(htmlAttribute) {
|
|
|
531
523
|
}
|
|
532
524
|
/**
|
|
533
525
|
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
534
|
-
*
|
|
535
526
|
* @param htmlString The string to decode.
|
|
536
527
|
* @returns The decoded string.
|
|
537
528
|
*/
|
|
@@ -540,14 +531,13 @@ export function decodeHTMLStrict(htmlString) {
|
|
|
540
531
|
}
|
|
541
532
|
/**
|
|
542
533
|
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
543
|
-
*
|
|
544
534
|
* @param xmlString The string to decode.
|
|
545
535
|
* @returns The decoded string.
|
|
546
536
|
*/
|
|
547
537
|
export function decodeXML(xmlString) {
|
|
548
538
|
return xmlDecoder(xmlString, DecodingMode.Strict);
|
|
549
539
|
}
|
|
550
|
-
export {
|
|
540
|
+
export { replaceCodePoint } from "./decode-codepoint.js";
|
|
551
541
|
// Re-export for use by eg. htmlparser2
|
|
552
542
|
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
553
543
|
export { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,IAAW,SAaV;AAbD,WAAW,SAAS;IAChB,wCAAQ,CAAA;IACR,0CAAS,CAAA;IACT,8CAAW,CAAA;IACX,0CAAS,CAAA;IACT,0CAAS,CAAA;IACT,gDAAY,CAAA;IACZ,iDAAa,CAAA;IACb,iDAAa,CAAA;IACb,iDAAa,CAAA;IACb,gDAAY,CAAA;IACZ,gDAAY,CAAA;IACZ,gDAAY,CAAA;AAChB,CAAC,EAbU,SAAS,KAAT,SAAS,QAanB;AAED,sFAAsF;AACtF,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,SAAS,QAAQ,CAAC,IAAY;IAC1B,OAAO,IAAI,IAAI,SAAS,CAAC,IAAI,IAAI,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IACxC,OAAO,CACH,CAAC,IAAI,IAAI,SAAS,CAAC,OAAO,IAAI,IAAI,IAAI,SAAS,CAAC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AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IAC/C,OAAO,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACvC,OAAO,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
10
10
|
* (eg. `ü`) will be used.
|
|
11
|
+
* @param input Input string to encode or decode.
|
|
11
12
|
*/
|
|
12
13
|
export declare function encodeHTML(input: string): string;
|
|
13
14
|
/**
|
|
@@ -17,6 +18,7 @@ export declare function encodeHTML(input: string): string;
|
|
|
17
18
|
*
|
|
18
19
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
19
20
|
* (eg. `ü`) will be used.
|
|
21
|
+
* @param input Input string to encode or decode.
|
|
20
22
|
*/
|
|
21
23
|
export declare function encodeNonAsciiHTML(input: string): string;
|
|
22
24
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AACD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -4,10 +4,10 @@ import { htmlTrie } from "./generated/encode-html.js";
|
|
|
4
4
|
* We store the characters to consider as a compact bitset for fast lookups.
|
|
5
5
|
*/
|
|
6
6
|
const HTML_BITSET = /* #__PURE__ */ new Uint32Array([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
0x16_00, // Bits for 09,0A,0C
|
|
8
|
+
0xfc_00_ff_fe, // 32..63 -> 21-2D (minus space), 2E,2F,3A-3F
|
|
9
|
+
0xf8_00_00_01, // 64..95 -> 40, 5B-5F
|
|
10
|
+
0x38_00_00_01, // 96..127-> 60, 7B-7D
|
|
11
11
|
]);
|
|
12
12
|
const XML_BITSET = /* #__PURE__ */ new Uint32Array([0, XML_BITSET_VALUE, 0, 0]);
|
|
13
13
|
/**
|
|
@@ -20,6 +20,7 @@ const XML_BITSET = /* #__PURE__ */ new Uint32Array([0, XML_BITSET_VALUE, 0, 0]);
|
|
|
20
20
|
*
|
|
21
21
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
22
22
|
* (eg. `ü`) will be used.
|
|
23
|
+
* @param input Input string to encode or decode.
|
|
23
24
|
*/
|
|
24
25
|
export function encodeHTML(input) {
|
|
25
26
|
return encodeHTMLTrieRe(HTML_BITSET, input);
|
|
@@ -31,6 +32,7 @@ export function encodeHTML(input) {
|
|
|
31
32
|
*
|
|
32
33
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
33
34
|
* (eg. `ü`) will be used.
|
|
35
|
+
* @param input Input string to encode or decode.
|
|
34
36
|
*/
|
|
35
37
|
export function encodeNonAsciiHTML(input) {
|
|
36
38
|
return encodeHTMLTrieRe(XML_BITSET, input);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,GAAG,eAAe,CAAC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KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a code point at a given index.
|
|
3
|
+
* @param input Input string to encode or decode.
|
|
4
|
+
* @param index Current read position in the input string.
|
|
5
|
+
*/
|
|
1
6
|
export declare const getCodePoint: (c: string, index: number) => number;
|
|
2
7
|
/**
|
|
3
8
|
* Bitset for ASCII characters that need to be escaped in XML.
|
|
@@ -9,6 +14,7 @@ export declare const XML_BITSET_VALUE = 1342177476;
|
|
|
9
14
|
*
|
|
10
15
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
11
16
|
* (eg. `ü`) will be used.
|
|
17
|
+
* @param input Input string to encode or decode.
|
|
12
18
|
*/
|
|
13
19
|
export declare function encodeXML(input: string): string;
|
|
14
20
|
/**
|
|
@@ -17,7 +23,6 @@ export declare function encodeXML(input: string): string;
|
|
|
17
23
|
*
|
|
18
24
|
* Have a look at `escapeUTF8` if you want a more concise output at the expense
|
|
19
25
|
* of reduced transportability.
|
|
20
|
-
*
|
|
21
26
|
* @param data String to escape.
|
|
22
27
|
*/
|
|
23
28
|
export declare const escape: typeof encodeXML;
|
|
@@ -25,21 +30,18 @@ export declare const escape: typeof encodeXML;
|
|
|
25
30
|
* Encodes all characters not valid in XML documents using XML entities.
|
|
26
31
|
*
|
|
27
32
|
* Note that the output will be character-set dependent.
|
|
28
|
-
*
|
|
29
33
|
* @param data String to escape.
|
|
30
34
|
*/
|
|
31
35
|
export declare const escapeUTF8: (data: string) => string;
|
|
32
36
|
/**
|
|
33
37
|
* Encodes all characters that have to be escaped in HTML attributes,
|
|
34
38
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
35
|
-
*
|
|
36
39
|
* @param data String to escape.
|
|
37
40
|
*/
|
|
38
41
|
export declare const escapeAttribute: (data: string) => string;
|
|
39
42
|
/**
|
|
40
43
|
* Encodes all characters that have to be escaped in HTML text,
|
|
41
44
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
42
|
-
*
|
|
43
45
|
* @param data String to escape.
|
|
44
46
|
*/
|
|
45
47
|
export declare const escapeText: (data: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../src/escape.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAUlB,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,gBAAgB,aAAgB,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoC/C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,SAAqB,CAAC;AAmClD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAG1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAQ3C,CAAC;AAEN;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAQ1C,CAAC"}
|