typedoc 0.26.0-beta.2 → 0.26.0-beta.3

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.
Files changed (66) hide show
  1. package/README.md +0 -2
  2. package/dist/lib/application.js +5 -0
  3. package/dist/lib/cli.js +1 -0
  4. package/dist/lib/converter/comments/discovery.js +0 -1
  5. package/dist/lib/converter/comments/index.d.ts +1 -1
  6. package/dist/lib/converter/comments/index.js +2 -2
  7. package/dist/lib/converter/comments/textParser.d.ts +0 -3
  8. package/dist/lib/converter/comments/textParser.js +39 -3
  9. package/dist/lib/converter/context.d.ts +2 -2
  10. package/dist/lib/converter/context.js +2 -4
  11. package/dist/lib/converter/converter.d.ts +1 -0
  12. package/dist/lib/converter/converter.js +58 -9
  13. package/dist/lib/converter/factories/index-signature.js +1 -1
  14. package/dist/lib/converter/symbols.js +22 -0
  15. package/dist/lib/converter/types.js +20 -1
  16. package/dist/lib/converter/utils/base-path.js +11 -6
  17. package/dist/lib/converter/utils/repository.js +2 -2
  18. package/dist/lib/internationalization/internationalization.js +0 -1
  19. package/dist/lib/internationalization/translatable.d.ts +6 -0
  20. package/dist/lib/internationalization/translatable.js +6 -0
  21. package/dist/lib/models/comments/comment.d.ts +28 -3
  22. package/dist/lib/models/comments/comment.js +6 -0
  23. package/dist/lib/models/reflections/document.d.ts +6 -1
  24. package/dist/lib/models/reflections/document.js +12 -2
  25. package/dist/lib/models/reflections/kind.d.ts +2 -0
  26. package/dist/lib/models/reflections/kind.js +3 -1
  27. package/dist/lib/models/reflections/project.js +1 -0
  28. package/dist/lib/models/reflections/signature.js +7 -2
  29. package/dist/lib/models/types.d.ts +9 -1
  30. package/dist/lib/models/types.js +5 -18
  31. package/dist/lib/output/components.d.ts +2 -0
  32. package/dist/lib/output/components.js +139 -66
  33. package/dist/lib/output/models/UrlMapping.d.ts +4 -0
  34. package/dist/lib/output/renderer.d.ts +16 -0
  35. package/dist/lib/output/themes/MarkedPlugin.js +8 -2
  36. package/dist/lib/output/themes/default/DefaultTheme.js +4 -1
  37. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -3
  38. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +3 -2
  39. package/dist/lib/output/themes/default/layouts/default.js +10 -10
  40. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  41. package/dist/lib/output/themes/default/partials/comment.js +16 -11
  42. package/dist/lib/output/themes/default/partials/footer.js +2 -2
  43. package/dist/lib/output/themes/default/partials/index.js +1 -1
  44. package/dist/lib/output/themes/default/partials/member.declaration.js +30 -4
  45. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +2 -1
  46. package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -2
  47. package/dist/lib/output/themes/default/partials/members.group.js +17 -10
  48. package/dist/lib/output/themes/default/partials/members.js +7 -3
  49. package/dist/lib/output/themes/default/partials/navigation.js +2 -2
  50. package/dist/lib/output/themes/default/partials/reflectionPreview.js +3 -2
  51. package/dist/lib/output/themes/default/partials/type.js +26 -2
  52. package/dist/lib/serialization/schema.d.ts +23 -11
  53. package/dist/lib/serialization/serializer.d.ts +1 -1
  54. package/dist/lib/utils/component.js +0 -3
  55. package/dist/lib/utils/events.js +0 -1
  56. package/dist/lib/utils/html-entities.json +2324 -2231
  57. package/dist/lib/utils/html.d.ts +59 -1
  58. package/dist/lib/utils/html.js +577 -19
  59. package/dist/lib/utils/options/declaration.d.ts +1 -0
  60. package/dist/lib/utils/options/help.js +0 -1
  61. package/dist/lib/utils/options/options.js +0 -1
  62. package/dist/lib/utils/options/sources/typedoc.js +5 -0
  63. package/dist/lib/utils/sort.js +4 -13
  64. package/package.json +4 -6
  65. package/static/main.js +4 -4
  66. package/static/style.css +5 -2
@@ -1,2 +1,60 @@
1
- export declare function getTextContent(text: string): string;
2
1
  export declare function escapeHtml(html: string): string;
2
+ export declare const enum ParserState {
3
+ BeforeAttributeName = 0,
4
+ AfterAttributeName = 1,
5
+ BeforeAttributeValue = 2,
6
+ END = 3
7
+ }
8
+ /**
9
+ * Parser for HTML attributes, each call to {@link step} will
10
+ * pause the parser at key points used to extract relative links from markdown
11
+ *
12
+ * The parser will pause at the points marked with `^`:
13
+ *
14
+ * ```text
15
+ * attr="value" attr='value' attr=value attr attr2 />
16
+ * ^ ^ ^ ^ ^ ^ ^ ^^
17
+ * BeforeValue | | | | | ||
18
+ * BeforeName | | | | ||
19
+ * BeforeValue | | | ||
20
+ * BeforeName | | ||
21
+ * BeforeValue| ||
22
+ * BeforeName ||
23
+ * AfterName
24
+ * AfterName
25
+ * END
26
+ * ```
27
+ */
28
+ export declare class HtmlAttributeParser {
29
+ readonly text: string;
30
+ pos: number;
31
+ state: ParserState;
32
+ currentAttributeName: string;
33
+ currentAttributeValueStart: number;
34
+ currentAttributeValueEnd: number;
35
+ currentAttributeValue: string;
36
+ private temporaryBuffer;
37
+ private characterReferenceCode;
38
+ constructor(text: string, pos?: number);
39
+ step(): void;
40
+ private peek;
41
+ private consume;
42
+ beforeAttributeName(): void;
43
+ attributeName(): void;
44
+ afterAttributeName(): void;
45
+ beforeAttributeValue(): void;
46
+ attributeValueDoubleQuoted(): void;
47
+ attributeValueSingleQuoted(): void;
48
+ attributeValueUnquoted(): void;
49
+ afterAttributeValueQuoted(): void;
50
+ characterReference(): void;
51
+ namedCharacterReference(): void;
52
+ ambiguousAmpersand(): void;
53
+ numericCharacterReference(): void;
54
+ hexadecimalCharacterReferenceStart(): void;
55
+ decimalCharacterReferenceStart(): void;
56
+ hexadecimalCharacterReference(): void;
57
+ decimalCharacterReference(): void;
58
+ numericCharacterReferenceEndState(): void;
59
+ private flushTemporaryBuffer;
60
+ }
@@ -3,29 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTextContent = getTextContent;
6
+ exports.HtmlAttributeParser = exports.ParserState = void 0;
7
7
  exports.escapeHtml = escapeHtml;
8
8
  // There is a fixed list of named character references which will not be expanded in the future.
9
9
  // This json file is based on https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
10
- // with some modifications to reduce the file size of the original JSON since we just need.
10
+ // with some modifications to reduce the file size of the original JSON.
11
+ const general_1 = require("./general");
11
12
  const html_entities_json_1 = __importDefault(require("./html-entities.json"));
12
- // Three cases:
13
- // { - numeric escape
14
- //  - hex escape
15
- // & - named escape
16
- function unescapeEntities(html) {
17
- return html.replace(/&(#(?:\d+);?|(?:#[xX][0-9A-Fa-f]+);?|(?:\w+);?)/g, (_, n) => {
18
- if (n[0] === "#") {
19
- return String.fromCharCode(n[1] === "x" || n[1] === "X"
20
- ? parseInt(n.substring(2), 16)
21
- : parseInt(n.substring(1), 10));
22
- }
23
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
24
- return html_entities_json_1.default[n] || "";
25
- });
26
- }
27
- function getTextContent(text) {
28
- return unescapeEntities(text.replace(/<.*?(?:>|$)/g, ""));
13
+ const htmlEntitiesTrie = {};
14
+ for (const [name, data] of Object.entries(html_entities_json_1.default)) {
15
+ let current = htmlEntitiesTrie;
16
+ for (let i = 0; i < name.length; ++i) {
17
+ current.children ||= {};
18
+ current = current.children[name.charCodeAt(i)] ||= {};
19
+ }
20
+ current.data = data;
29
21
  }
30
22
  const htmlEscapes = {
31
23
  "&": "&amp;",
@@ -37,3 +29,569 @@ const htmlEscapes = {
37
29
  function escapeHtml(html) {
38
30
  return html.replace(/[&<>'"]/g, (c) => htmlEscapes[c]);
39
31
  }
32
+ /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
33
+ var Chars;
34
+ (function (Chars) {
35
+ Chars[Chars["EOF"] = -1] = "EOF";
36
+ Chars[Chars["NULL"] = 0] = "NULL";
37
+ Chars[Chars["TAB"] = 9] = "TAB";
38
+ Chars[Chars["LF"] = 10] = "LF";
39
+ Chars[Chars["FF"] = 12] = "FF";
40
+ Chars[Chars["SPACE"] = 32] = "SPACE";
41
+ Chars[Chars["NUMBER_SIGN"] = 35] = "NUMBER_SIGN";
42
+ Chars[Chars["SOLIDUS"] = 47] = "SOLIDUS";
43
+ Chars[Chars["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
44
+ Chars[Chars["AMPERSAND"] = 38] = "AMPERSAND";
45
+ Chars[Chars["APOTROPHE"] = 39] = "APOTROPHE";
46
+ Chars[Chars["SEMICOLON"] = 59] = "SEMICOLON";
47
+ Chars[Chars["ZERO"] = 48] = "ZERO";
48
+ Chars[Chars["NINE"] = 57] = "NINE";
49
+ Chars[Chars["LESS_THAN"] = 60] = "LESS_THAN";
50
+ Chars[Chars["EQUALS"] = 61] = "EQUALS";
51
+ Chars[Chars["GREATER_THAN"] = 62] = "GREATER_THAN";
52
+ Chars[Chars["UPPERCASE_A"] = 65] = "UPPERCASE_A";
53
+ Chars[Chars["UPPERCASE_F"] = 70] = "UPPERCASE_F";
54
+ Chars[Chars["UPPERCASE_X"] = 88] = "UPPERCASE_X";
55
+ Chars[Chars["UPPERCASE_Z"] = 90] = "UPPERCASE_Z";
56
+ Chars[Chars["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
57
+ Chars[Chars["LOWERCASE_A"] = 97] = "LOWERCASE_A";
58
+ Chars[Chars["LOWERCASE_F"] = 102] = "LOWERCASE_F";
59
+ Chars[Chars["LOWERCASE_X"] = 120] = "LOWERCASE_X";
60
+ Chars[Chars["LOWERCASE_Z"] = 122] = "LOWERCASE_Z";
61
+ })(Chars || (Chars = {}));
62
+ function isalpha(ch) {
63
+ return Chars.LOWERCASE_A <= (ch | 0x20) && (ch | 0x20) <= Chars.LOWERCASE_Z;
64
+ }
65
+ function isdigit(ch) {
66
+ return Chars.ZERO <= ch && ch <= Chars.NINE;
67
+ }
68
+ function isalnum(ch) {
69
+ return isalpha(ch) || isdigit(ch);
70
+ }
71
+ function isxdigit(ch) {
72
+ return (isdigit(ch) ||
73
+ (Chars.LOWERCASE_A <= (ch | 0x20) && (ch | 0x20) <= Chars.LOWERCASE_F));
74
+ }
75
+ var ParserState;
76
+ (function (ParserState) {
77
+ ParserState[ParserState["BeforeAttributeName"] = 0] = "BeforeAttributeName";
78
+ ParserState[ParserState["AfterAttributeName"] = 1] = "AfterAttributeName";
79
+ ParserState[ParserState["BeforeAttributeValue"] = 2] = "BeforeAttributeValue";
80
+ ParserState[ParserState["END"] = 3] = "END";
81
+ })(ParserState || (exports.ParserState = ParserState = {}));
82
+ /**
83
+ * Parser for HTML attributes, each call to {@link step} will
84
+ * pause the parser at key points used to extract relative links from markdown
85
+ *
86
+ * The parser will pause at the points marked with `^`:
87
+ *
88
+ * ```text
89
+ * attr="value" attr='value' attr=value attr attr2 />
90
+ * ^ ^ ^ ^ ^ ^ ^ ^^
91
+ * BeforeValue | | | | | ||
92
+ * BeforeName | | | | ||
93
+ * BeforeValue | | | ||
94
+ * BeforeName | | ||
95
+ * BeforeValue| ||
96
+ * BeforeName ||
97
+ * AfterName
98
+ * AfterName
99
+ * END
100
+ * ```
101
+ */
102
+ class HtmlAttributeParser {
103
+ constructor(text, pos = 0) {
104
+ this.text = text;
105
+ this.pos = pos;
106
+ this.state = ParserState.BeforeAttributeName;
107
+ this.currentAttributeName = "";
108
+ this.currentAttributeValueStart = -1;
109
+ this.currentAttributeValueEnd = -1;
110
+ this.currentAttributeValue = "";
111
+ this.temporaryBuffer = [];
112
+ this.characterReferenceCode = 0;
113
+ }
114
+ step() {
115
+ switch (this.state) {
116
+ case ParserState.BeforeAttributeName:
117
+ this.beforeAttributeName();
118
+ return;
119
+ case ParserState.AfterAttributeName:
120
+ this.afterAttributeName();
121
+ return;
122
+ case ParserState.BeforeAttributeValue:
123
+ this.beforeAttributeValue();
124
+ return;
125
+ case ParserState.END:
126
+ return; // Do nothing
127
+ }
128
+ /* c8 ignore next */
129
+ (0, general_1.assertNever)(this.state);
130
+ }
131
+ peek() {
132
+ const ch = this.text.charCodeAt(this.pos);
133
+ return isNaN(ch) ? Chars.EOF : ch;
134
+ }
135
+ consume() {
136
+ const ch = this.peek();
137
+ ++this.pos;
138
+ return ch;
139
+ }
140
+ // https://html.spec.whatwg.org/multipage/parsing.html#before-attribute-name-state
141
+ beforeAttributeName() {
142
+ this.currentAttributeName = "";
143
+ this.currentAttributeValue = "";
144
+ loop: for (;;) {
145
+ switch (this.consume()) {
146
+ case Chars.TAB:
147
+ case Chars.LF:
148
+ case Chars.FF:
149
+ case Chars.SPACE:
150
+ break;
151
+ case Chars.SOLIDUS:
152
+ case Chars.GREATER_THAN:
153
+ case Chars.EOF:
154
+ --this.pos;
155
+ this.afterAttributeName();
156
+ break loop;
157
+ case Chars.EQUALS:
158
+ // Unexpected equals sign before attribute name parse error.
159
+ // fall through
160
+ default:
161
+ --this.pos;
162
+ this.attributeName();
163
+ break loop;
164
+ }
165
+ }
166
+ }
167
+ // https://html.spec.whatwg.org/multipage/parsing.html#attribute-name-state
168
+ attributeName() {
169
+ const startPos = this.pos;
170
+ loop: for (;;) {
171
+ const ch = this.consume();
172
+ switch (ch) {
173
+ case Chars.TAB:
174
+ case Chars.LF:
175
+ case Chars.FF:
176
+ case Chars.SPACE:
177
+ case Chars.SOLIDUS:
178
+ case Chars.GREATER_THAN:
179
+ case Chars.EOF:
180
+ --this.pos;
181
+ this.state = ParserState.AfterAttributeName;
182
+ break loop;
183
+ case Chars.EQUALS:
184
+ this.state = ParserState.BeforeAttributeValue;
185
+ break loop;
186
+ case Chars.QUOTATION_MARK:
187
+ case Chars.APOTROPHE:
188
+ case Chars.LESS_THAN:
189
+ // This is an unexpected-character-in-attribute-name parse error. Treat it as per the "anything else" entry below.
190
+ // fall through
191
+ default:
192
+ // Do nothing, we collect the attribute name after the loop
193
+ break;
194
+ }
195
+ }
196
+ if (this.state === ParserState.BeforeAttributeValue) {
197
+ this.currentAttributeName = this.text
198
+ .substring(startPos, this.pos - 1)
199
+ .toLowerCase();
200
+ }
201
+ else {
202
+ this.currentAttributeName = this.text
203
+ .substring(startPos, this.pos)
204
+ .toLowerCase();
205
+ }
206
+ }
207
+ // https://html.spec.whatwg.org/multipage/parsing.html#after-attribute-name-state
208
+ afterAttributeName() {
209
+ loop: for (;;) {
210
+ switch (this.consume()) {
211
+ case Chars.TAB:
212
+ case Chars.LF:
213
+ case Chars.FF:
214
+ case Chars.SPACE:
215
+ break; // Ignore the character
216
+ case Chars.SOLIDUS:
217
+ this.state = ParserState.END; // self-closing start tag state
218
+ break loop;
219
+ case Chars.EQUALS:
220
+ this.state = ParserState.BeforeAttributeValue;
221
+ break loop;
222
+ case Chars.GREATER_THAN:
223
+ this.state = ParserState.END; // data state
224
+ break loop;
225
+ case Chars.EOF:
226
+ this.state = ParserState.END; // eof-in-tag parse error
227
+ break loop;
228
+ default:
229
+ --this.pos;
230
+ this.attributeName();
231
+ break loop;
232
+ }
233
+ }
234
+ }
235
+ // https://html.spec.whatwg.org/multipage/parsing.html#before-attribute-value-state
236
+ beforeAttributeValue() {
237
+ loop: for (;;) {
238
+ switch (this.consume()) {
239
+ case Chars.TAB:
240
+ case Chars.LF:
241
+ case Chars.FF:
242
+ case Chars.SPACE:
243
+ break; // Ignore the character
244
+ case Chars.QUOTATION_MARK:
245
+ this.attributeValueDoubleQuoted();
246
+ break loop;
247
+ case Chars.APOTROPHE:
248
+ this.attributeValueSingleQuoted();
249
+ break loop;
250
+ case Chars.GREATER_THAN:
251
+ this.state = ParserState.END; // missing-attribute-value parse error
252
+ break loop;
253
+ default:
254
+ --this.pos;
255
+ this.attributeValueUnquoted();
256
+ break loop;
257
+ }
258
+ }
259
+ }
260
+ // https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state
261
+ attributeValueDoubleQuoted() {
262
+ this.currentAttributeValueStart = this.pos;
263
+ loop: for (;;) {
264
+ switch (this.consume()) {
265
+ case Chars.QUOTATION_MARK:
266
+ this.currentAttributeValueEnd = this.pos - 1;
267
+ this.afterAttributeValueQuoted();
268
+ break loop;
269
+ case Chars.AMPERSAND:
270
+ this.characterReference();
271
+ break;
272
+ case Chars.NULL:
273
+ this.currentAttributeValue += String.fromCharCode(0xfffd);
274
+ break;
275
+ case Chars.EOF:
276
+ this.currentAttributeValueEnd = this.pos;
277
+ this.state = ParserState.END; // eof-in-tag parse error
278
+ break loop;
279
+ default:
280
+ this.currentAttributeValue += this.text[this.pos - 1];
281
+ break;
282
+ }
283
+ }
284
+ }
285
+ // https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(single-quoted)-state
286
+ attributeValueSingleQuoted() {
287
+ this.currentAttributeValueStart = this.pos;
288
+ loop: for (;;) {
289
+ switch (this.consume()) {
290
+ case Chars.APOTROPHE:
291
+ this.currentAttributeValueEnd = this.pos - 1;
292
+ this.afterAttributeValueQuoted();
293
+ break loop;
294
+ case Chars.AMPERSAND:
295
+ this.characterReference();
296
+ break;
297
+ case Chars.NULL:
298
+ this.currentAttributeValue += String.fromCharCode(0xfffd);
299
+ break;
300
+ case Chars.EOF:
301
+ this.currentAttributeValueEnd = this.pos;
302
+ this.state = ParserState.END; // eof-in-tag parse error
303
+ break loop;
304
+ default:
305
+ this.currentAttributeValue += this.text[this.pos - 1];
306
+ break;
307
+ }
308
+ }
309
+ }
310
+ // https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(unquoted)-state
311
+ attributeValueUnquoted() {
312
+ this.currentAttributeValueStart = this.pos;
313
+ loop: for (;;) {
314
+ switch (this.consume()) {
315
+ case Chars.TAB:
316
+ case Chars.LF:
317
+ case Chars.FF:
318
+ case Chars.SPACE:
319
+ this.currentAttributeValueEnd = this.pos - 1;
320
+ this.state = ParserState.BeforeAttributeName;
321
+ break loop;
322
+ case Chars.AMPERSAND:
323
+ this.characterReference();
324
+ break;
325
+ case Chars.GREATER_THAN:
326
+ this.currentAttributeValueEnd = this.pos;
327
+ this.state = ParserState.END;
328
+ break loop;
329
+ case Chars.NULL:
330
+ this.currentAttributeValue += String.fromCharCode(0xfffd);
331
+ break;
332
+ case Chars.EOF:
333
+ this.currentAttributeValueEnd = this.pos;
334
+ this.state = ParserState.END; // eof-in-tag parse error
335
+ break loop;
336
+ case Chars.QUOTATION_MARK:
337
+ case Chars.APOTROPHE:
338
+ case Chars.LESS_THAN:
339
+ case Chars.EQUALS:
340
+ case Chars.GRAVE_ACCENT:
341
+ // This is an unexpected-character-in-unquoted-attribute-value parse error. Treat it as per the "anything else" entry below.
342
+ // fall through
343
+ default:
344
+ this.currentAttributeValue += this.text[this.pos - 1];
345
+ break;
346
+ }
347
+ }
348
+ }
349
+ // https://html.spec.whatwg.org/multipage/parsing.html#after-attribute-value-(quoted)-state
350
+ afterAttributeValueQuoted() {
351
+ switch (this.consume()) {
352
+ case Chars.TAB:
353
+ case Chars.LF:
354
+ case Chars.FF:
355
+ case Chars.SPACE:
356
+ this.state = ParserState.BeforeAttributeName;
357
+ break;
358
+ case Chars.SOLIDUS:
359
+ case Chars.GREATER_THAN:
360
+ case Chars.EOF:
361
+ this.state = ParserState.END;
362
+ break;
363
+ default:
364
+ // This is a missing-whitespace-between-attributes parse error. Reconsume in the before attribute name state.
365
+ --this.pos;
366
+ this.state = ParserState.BeforeAttributeName;
367
+ break;
368
+ }
369
+ }
370
+ // https://html.spec.whatwg.org/multipage/parsing.html#character-reference-state
371
+ characterReference() {
372
+ this.temporaryBuffer = [Chars.AMPERSAND];
373
+ const next = this.consume();
374
+ if (isalnum(next)) {
375
+ --this.pos;
376
+ this.namedCharacterReference();
377
+ }
378
+ else if (next == Chars.NUMBER_SIGN) {
379
+ this.temporaryBuffer.push(next);
380
+ this.numericCharacterReference();
381
+ }
382
+ else {
383
+ --this.pos;
384
+ this.flushTemporaryBuffer();
385
+ }
386
+ }
387
+ // https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
388
+ // Intentionally only handling part of an attribute
389
+ namedCharacterReference() {
390
+ // Consume the maximum number of characters possible, where the consumed
391
+ // characters are one of the identifiers in the first column of the named
392
+ // character references table. Append each character to the temporary buffer
393
+ // when it's consumed.
394
+ let currentTrie = htmlEntitiesTrie;
395
+ for (;;) {
396
+ const ch = this.consume();
397
+ this.temporaryBuffer.push(ch);
398
+ if (currentTrie.children && ch in currentTrie.children) {
399
+ currentTrie = currentTrie.children[ch];
400
+ }
401
+ else {
402
+ --this.pos;
403
+ this.temporaryBuffer.pop();
404
+ const lastChar = this.temporaryBuffer[this.temporaryBuffer.length - 1];
405
+ // If there is a match
406
+ if (currentTrie.data) {
407
+ // If the character reference was consumed as part of an attribute,
408
+ // and the last character matched is not a U+003B SEMICOLON character (;),
409
+ // and the next input character is either a U+003D EQUALS SIGN character (=)
410
+ // or an ASCII alphanumeric, then, for historical reasons, flush code points
411
+ // consumed as a character reference and switch to the return state.
412
+ if (lastChar != Chars.SEMICOLON &&
413
+ (this.peek() == Chars.EQUALS || isalpha(this.peek()))) {
414
+ this.flushTemporaryBuffer();
415
+ return;
416
+ }
417
+ else {
418
+ // missing-semicolon-after-character-reference parse error
419
+ this.temporaryBuffer = currentTrie.data.p;
420
+ this.flushTemporaryBuffer();
421
+ return;
422
+ }
423
+ }
424
+ else {
425
+ this.flushTemporaryBuffer();
426
+ this.ambiguousAmpersand();
427
+ return;
428
+ }
429
+ }
430
+ }
431
+ }
432
+ // https://html.spec.whatwg.org/multipage/parsing.html#ambiguous-ampersand-state
433
+ ambiguousAmpersand() {
434
+ const ch = this.consume();
435
+ if (isalnum(ch)) {
436
+ this.currentAttributeValue += String.fromCharCode(ch);
437
+ }
438
+ else {
439
+ --this.pos;
440
+ return;
441
+ }
442
+ }
443
+ // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-state
444
+ numericCharacterReference() {
445
+ this.characterReferenceCode = 0;
446
+ const ch = this.consume();
447
+ switch (ch) {
448
+ case Chars.LOWERCASE_X:
449
+ case Chars.UPPERCASE_X:
450
+ this.temporaryBuffer.push(ch);
451
+ this.hexadecimalCharacterReferenceStart();
452
+ break;
453
+ default:
454
+ --this.pos;
455
+ this.decimalCharacterReferenceStart();
456
+ break;
457
+ }
458
+ }
459
+ // https://html.spec.whatwg.org/multipage/parsing.html#hexadecimal-character-reference-start-state
460
+ hexadecimalCharacterReferenceStart() {
461
+ const ch = this.consume();
462
+ if (isxdigit(ch)) {
463
+ --this.pos;
464
+ this.hexadecimalCharacterReference();
465
+ }
466
+ else {
467
+ --this.pos;
468
+ this.flushTemporaryBuffer();
469
+ }
470
+ }
471
+ // https://html.spec.whatwg.org/multipage/parsing.html#decimal-character-reference-start-state
472
+ decimalCharacterReferenceStart() {
473
+ const ch = this.consume();
474
+ if (isdigit(ch)) {
475
+ --this.pos;
476
+ this.decimalCharacterReference();
477
+ }
478
+ else {
479
+ --this.pos;
480
+ this.flushTemporaryBuffer();
481
+ }
482
+ }
483
+ // https://html.spec.whatwg.org/multipage/parsing.html#hexadecimal-character-reference-state
484
+ hexadecimalCharacterReference() {
485
+ for (;;) {
486
+ const ch = this.consume();
487
+ if (isdigit(ch)) {
488
+ this.characterReferenceCode *= 16;
489
+ this.characterReferenceCode += ch - 0x30;
490
+ }
491
+ else if (Chars.UPPERCASE_A <= ch && ch <= Chars.UPPERCASE_F) {
492
+ this.characterReferenceCode *= 16;
493
+ this.characterReferenceCode += ch - 0x37;
494
+ }
495
+ else if (Chars.LOWERCASE_A <= ch && ch <= Chars.LOWERCASE_F) {
496
+ this.characterReferenceCode *= 16;
497
+ this.characterReferenceCode += ch - 0x57;
498
+ }
499
+ else if (ch === Chars.SEMICOLON) {
500
+ this.numericCharacterReferenceEndState();
501
+ return;
502
+ }
503
+ else {
504
+ --this.pos;
505
+ this.numericCharacterReferenceEndState();
506
+ return;
507
+ }
508
+ }
509
+ }
510
+ // https://html.spec.whatwg.org/multipage/parsing.html#decimal-character-reference-state
511
+ decimalCharacterReference() {
512
+ for (;;) {
513
+ const ch = this.consume();
514
+ if (isdigit(ch)) {
515
+ this.characterReferenceCode *= 10;
516
+ this.characterReferenceCode += ch - 0x30;
517
+ }
518
+ else if (ch === Chars.SEMICOLON) {
519
+ this.numericCharacterReferenceEndState();
520
+ return;
521
+ }
522
+ else {
523
+ --this.pos;
524
+ this.numericCharacterReferenceEndState();
525
+ return;
526
+ }
527
+ }
528
+ }
529
+ // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
530
+ numericCharacterReferenceEndState() {
531
+ if (this.characterReferenceCode == 0) {
532
+ // null-character-reference parse error
533
+ this.characterReferenceCode = 0xfffd;
534
+ }
535
+ if (this.characterReferenceCode > 0x10ffff) {
536
+ // character-reference-outside-unicode-range parse error
537
+ this.characterReferenceCode = 0xfffd;
538
+ }
539
+ if (isSurrogate(this.characterReferenceCode)) {
540
+ // surrogate-character-reference parse error
541
+ this.characterReferenceCode = 0xfffd;
542
+ }
543
+ // If the number is a noncharacter, then this is a noncharacter-character-reference parse error.
544
+ // ... and do nothing, so don't bother checking.
545
+ // Handle replacements
546
+ this.characterReferenceCode =
547
+ characterReferenceCodePointReplacements.get(this.characterReferenceCode) ?? this.characterReferenceCode;
548
+ this.temporaryBuffer = [this.characterReferenceCode];
549
+ this.flushTemporaryBuffer();
550
+ }
551
+ flushTemporaryBuffer() {
552
+ this.currentAttributeValue += String.fromCodePoint(...this.temporaryBuffer);
553
+ this.temporaryBuffer = [];
554
+ }
555
+ }
556
+ exports.HtmlAttributeParser = HtmlAttributeParser;
557
+ // https://infra.spec.whatwg.org/#leading-surrogate
558
+ function isLeadingSurrogate(ch) {
559
+ return 0xd800 <= ch && ch <= 0xdbff;
560
+ }
561
+ // https://infra.spec.whatwg.org/#trailing-surrogate
562
+ function isTrailingSurrogate(ch) {
563
+ return 0xdc00 <= ch && ch <= 0xdfff;
564
+ }
565
+ // https://infra.spec.whatwg.org/#surrogate
566
+ function isSurrogate(ch) {
567
+ return isLeadingSurrogate(ch) || isTrailingSurrogate(ch);
568
+ }
569
+ const characterReferenceCodePointReplacements = new Map([
570
+ [0x80, 0x20ac], // EURO SIGN (€)
571
+ [0x82, 0x201a], // SINGLE LOW-9 QUOTATION MARK (‚)
572
+ [0x83, 0x0192], // LATIN SMALL LETTER F WITH HOOK (ƒ)
573
+ [0x84, 0x201e], // DOUBLE LOW-9 QUOTATION MARK („)
574
+ [0x85, 0x2026], // HORIZONTAL ELLIPSIS (…)
575
+ [0x86, 0x2020], // DAGGER (†)
576
+ [0x87, 0x2021], // DOUBLE DAGGER (‡)
577
+ [0x88, 0x02c6], // MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
578
+ [0x89, 0x2030], // PER MILLE SIGN (‰)
579
+ [0x8a, 0x0160], // LATIN CAPITAL LETTER S WITH CARON (Š)
580
+ [0x8b, 0x2039], // SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
581
+ [0x8c, 0x0152], // LATIN CAPITAL LIGATURE OE (Œ)
582
+ [0x8e, 0x017d], // LATIN CAPITAL LETTER Z WITH CARON (Ž)
583
+ [0x91, 0x2018], // LEFT SINGLE QUOTATION MARK (‘)
584
+ [0x92, 0x2019], // RIGHT SINGLE QUOTATION MARK (’)
585
+ [0x93, 0x201c], // LEFT DOUBLE QUOTATION MARK (“)
586
+ [0x94, 0x201d], // RIGHT DOUBLE QUOTATION MARK (”)
587
+ [0x95, 0x2022], // BULLET (•)
588
+ [0x96, 0x2013], // EN DASH (–)
589
+ [0x97, 0x2014], // EM DASH (—)
590
+ [0x98, 0x02dc], // SMALL TILDE (˜)
591
+ [0x99, 0x2122], // TRADE MARK SIGN (™)
592
+ [0x9a, 0x0161], // LATIN SMALL LETTER S WITH CARON (š)
593
+ [0x9b, 0x203a], // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
594
+ [0x9c, 0x0153], // LATIN SMALL LIGATURE OE (œ)
595
+ [0x9e, 0x017e], // LATIN SMALL LETTER Z WITH CARON (ž)
596
+ [0x9f, 0x0178], // LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
597
+ ]);
@@ -124,6 +124,7 @@ export interface TypeDocOptionMap {
124
124
  cname: string;
125
125
  githubPages: boolean;
126
126
  hostedBaseUrl: string;
127
+ useHostedBaseUrlForAbsoluteLinks: boolean;
127
128
  cacheBust: boolean;
128
129
  gaID: string;
129
130
  hideGenerator: boolean;
@@ -20,7 +20,6 @@ function getParameterHelp(options, i18n) {
20
20
  const helps = [];
21
21
  let margin = 0;
22
22
  for (const parameter of parameters) {
23
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
24
23
  if (!parameter.help || parameter.configFileOnly) {
25
24
  continue;
26
25
  }