@tamagui/code-to-html 1.1.8 → 1.1.9

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.
@@ -20,6 +20,10 @@ var __copyProps = (to, from, except, desc) => {
20
20
  return to;
21
21
  };
22
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
27
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
28
  mod
25
29
  ));
@@ -101,11 +105,17 @@ var require_unicode = __commonJS({
101
105
  };
102
106
  exports.CODE_POINT_SEQUENCES = {
103
107
  DASH_DASH_STRING: [45, 45],
108
+ //--
104
109
  DOCTYPE_STRING: [68, 79, 67, 84, 89, 80, 69],
110
+ //DOCTYPE
105
111
  CDATA_START_STRING: [91, 67, 68, 65, 84, 65, 91],
112
+ //[CDATA[
106
113
  SCRIPT_STRING: [115, 99, 114, 105, 112, 116],
114
+ //script
107
115
  PUBLIC_STRING: [80, 85, 66, 76, 73, 67],
116
+ //PUBLIC
108
117
  SYSTEM_STRING: [83, 89, 83, 84, 69, 77]
118
+ //SYSTEM
109
119
  };
110
120
  exports.isSurrogate = function(cp) {
111
121
  return cp >= 55296 && cp <= 57343;
@@ -508,6 +518,7 @@ var require_tokenizer = __commonJS({
508
518
  this.currentToken = null;
509
519
  this.currentAttr = null;
510
520
  }
521
+ //Errors
511
522
  _err() {
512
523
  }
513
524
  _errOnNextCodePoint(err) {
@@ -515,6 +526,7 @@ var require_tokenizer = __commonJS({
515
526
  this._err(err);
516
527
  this._unconsume();
517
528
  }
529
+ //API
518
530
  getNextToken() {
519
531
  while (!this.tokenQueue.length && this.active) {
520
532
  this.consumedAfterSnapshot = 0;
@@ -533,6 +545,7 @@ var require_tokenizer = __commonJS({
533
545
  this.active = true;
534
546
  this.preprocessor.insertHtmlAtCurrentPos(chunk);
535
547
  }
548
+ //Hibernation
536
549
  _ensureHibernation() {
537
550
  if (this.preprocessor.endOfChunkHit) {
538
551
  for (; this.consumedAfterSnapshot > 0; this.consumedAfterSnapshot--) {
@@ -544,6 +557,7 @@ var require_tokenizer = __commonJS({
544
557
  }
545
558
  return false;
546
559
  }
560
+ //Consumption
547
561
  _consume() {
548
562
  this.consumedAfterSnapshot++;
549
563
  return this.preprocessor.advance();
@@ -585,6 +599,7 @@ var require_tokenizer = __commonJS({
585
599
  }
586
600
  return isMatch;
587
601
  }
602
+ //Temp buffer
588
603
  _isTempBufferEqualToScriptString() {
589
604
  if (this.tempBuff.length !== $$.SCRIPT_STRING.length) {
590
605
  return false;
@@ -596,6 +611,7 @@ var require_tokenizer = __commonJS({
596
611
  }
597
612
  return true;
598
613
  }
614
+ //Token creation
599
615
  _createStartTagToken() {
600
616
  this.currentToken = {
601
617
  type: Tokenizer.START_TAG_TOKEN,
@@ -637,6 +653,7 @@ var require_tokenizer = __commonJS({
637
653
  _createEOFToken() {
638
654
  this.currentToken = { type: Tokenizer.EOF_TOKEN };
639
655
  }
656
+ //Tag attributes
640
657
  _createAttr(attrNameFirstCh) {
641
658
  this.currentAttr = {
642
659
  name: attrNameFirstCh,
@@ -654,6 +671,7 @@ var require_tokenizer = __commonJS({
654
671
  _leaveAttrValue(toState) {
655
672
  this.state = toState;
656
673
  }
674
+ //Token emission
657
675
  _emitCurrentToken() {
658
676
  this._emitCurrentCharacterToken();
659
677
  const ct = this.currentToken;
@@ -680,6 +698,15 @@ var require_tokenizer = __commonJS({
680
698
  this._createEOFToken();
681
699
  this._emitCurrentToken();
682
700
  }
701
+ //Characters emission
702
+ //OPTIMIZATION: specification uses only one type of character tokens (one token per character).
703
+ //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
704
+ //If we have a sequence of characters that belong to the same group, parser can process it
705
+ //as a single solid character token.
706
+ //So, there are 3 types of character tokens in parse5:
707
+ //1)NULL_CHARACTER_TOKEN - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
708
+ //2)WHITESPACE_CHARACTER_TOKEN - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
709
+ //3)CHARACTER_TOKEN - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
683
710
  _appendCharToCurrentCharacterToken(type, ch) {
684
711
  if (this.currentCharacterToken && this.currentCharacterToken.type !== type) {
685
712
  this._emitCurrentCharacterToken();
@@ -704,9 +731,12 @@ var require_tokenizer = __commonJS({
704
731
  this._emitCodePoint(codePoints[i]);
705
732
  }
706
733
  }
734
+ //NOTE: used then we emit character explicitly. This is always a non-whitespace and a non-null character.
735
+ //So we can avoid additional checks here.
707
736
  _emitChars(ch) {
708
737
  this._appendCharToCurrentCharacterToken(Tokenizer.CHARACTER_TOKEN, ch);
709
738
  }
739
+ // Character reference helpers
710
740
  _matchNamedCharacterReference(startCp) {
711
741
  let result = null;
712
742
  let excess = 1;
@@ -759,6 +789,9 @@ var require_tokenizer = __commonJS({
759
789
  }
760
790
  this.tempBuff = [];
761
791
  }
792
+ // State machine
793
+ // Data state
794
+ //------------------------------------------------------------------
762
795
  [DATA_STATE](cp) {
763
796
  this.preprocessor.dropParsedChunk();
764
797
  if (cp === $.LESS_THAN_SIGN) {
@@ -775,6 +808,8 @@ var require_tokenizer = __commonJS({
775
808
  this._emitCodePoint(cp);
776
809
  }
777
810
  }
811
+ // RCDATA state
812
+ //------------------------------------------------------------------
778
813
  [RCDATA_STATE](cp) {
779
814
  this.preprocessor.dropParsedChunk();
780
815
  if (cp === $.AMPERSAND) {
@@ -791,6 +826,8 @@ var require_tokenizer = __commonJS({
791
826
  this._emitCodePoint(cp);
792
827
  }
793
828
  }
829
+ // RAWTEXT state
830
+ //------------------------------------------------------------------
794
831
  [RAWTEXT_STATE](cp) {
795
832
  this.preprocessor.dropParsedChunk();
796
833
  if (cp === $.LESS_THAN_SIGN) {
@@ -804,6 +841,8 @@ var require_tokenizer = __commonJS({
804
841
  this._emitCodePoint(cp);
805
842
  }
806
843
  }
844
+ // Script data state
845
+ //------------------------------------------------------------------
807
846
  [SCRIPT_DATA_STATE](cp) {
808
847
  this.preprocessor.dropParsedChunk();
809
848
  if (cp === $.LESS_THAN_SIGN) {
@@ -817,6 +856,8 @@ var require_tokenizer = __commonJS({
817
856
  this._emitCodePoint(cp);
818
857
  }
819
858
  }
859
+ // PLAINTEXT state
860
+ //------------------------------------------------------------------
820
861
  [PLAINTEXT_STATE](cp) {
821
862
  this.preprocessor.dropParsedChunk();
822
863
  if (cp === $.NULL) {
@@ -828,6 +869,8 @@ var require_tokenizer = __commonJS({
828
869
  this._emitCodePoint(cp);
829
870
  }
830
871
  }
872
+ // Tag open state
873
+ //------------------------------------------------------------------
831
874
  [TAG_OPEN_STATE](cp) {
832
875
  if (cp === $.EXCLAMATION_MARK) {
833
876
  this.state = MARKUP_DECLARATION_OPEN_STATE;
@@ -850,6 +893,8 @@ var require_tokenizer = __commonJS({
850
893
  this._reconsumeInState(DATA_STATE);
851
894
  }
852
895
  }
896
+ // End tag open state
897
+ //------------------------------------------------------------------
853
898
  [END_TAG_OPEN_STATE](cp) {
854
899
  if (isAsciiLetter(cp)) {
855
900
  this._createEndTagToken();
@@ -867,6 +912,8 @@ var require_tokenizer = __commonJS({
867
912
  this._reconsumeInState(BOGUS_COMMENT_STATE);
868
913
  }
869
914
  }
915
+ // Tag name state
916
+ //------------------------------------------------------------------
870
917
  [TAG_NAME_STATE](cp) {
871
918
  if (isWhitespace(cp)) {
872
919
  this.state = BEFORE_ATTRIBUTE_NAME_STATE;
@@ -887,6 +934,8 @@ var require_tokenizer = __commonJS({
887
934
  this.currentToken.tagName += toChar(cp);
888
935
  }
889
936
  }
937
+ // RCDATA less-than sign state
938
+ //------------------------------------------------------------------
890
939
  [RCDATA_LESS_THAN_SIGN_STATE](cp) {
891
940
  if (cp === $.SOLIDUS) {
892
941
  this.tempBuff = [];
@@ -896,6 +945,8 @@ var require_tokenizer = __commonJS({
896
945
  this._reconsumeInState(RCDATA_STATE);
897
946
  }
898
947
  }
948
+ // RCDATA end tag open state
949
+ //------------------------------------------------------------------
899
950
  [RCDATA_END_TAG_OPEN_STATE](cp) {
900
951
  if (isAsciiLetter(cp)) {
901
952
  this._createEndTagToken();
@@ -905,6 +956,8 @@ var require_tokenizer = __commonJS({
905
956
  this._reconsumeInState(RCDATA_STATE);
906
957
  }
907
958
  }
959
+ // RCDATA end tag name state
960
+ //------------------------------------------------------------------
908
961
  [RCDATA_END_TAG_NAME_STATE](cp) {
909
962
  if (isAsciiUpper(cp)) {
910
963
  this.currentToken.tagName += toAsciiLowerChar(cp);
@@ -933,6 +986,8 @@ var require_tokenizer = __commonJS({
933
986
  this._reconsumeInState(RCDATA_STATE);
934
987
  }
935
988
  }
989
+ // RAWTEXT less-than sign state
990
+ //------------------------------------------------------------------
936
991
  [RAWTEXT_LESS_THAN_SIGN_STATE](cp) {
937
992
  if (cp === $.SOLIDUS) {
938
993
  this.tempBuff = [];
@@ -942,6 +997,8 @@ var require_tokenizer = __commonJS({
942
997
  this._reconsumeInState(RAWTEXT_STATE);
943
998
  }
944
999
  }
1000
+ // RAWTEXT end tag open state
1001
+ //------------------------------------------------------------------
945
1002
  [RAWTEXT_END_TAG_OPEN_STATE](cp) {
946
1003
  if (isAsciiLetter(cp)) {
947
1004
  this._createEndTagToken();
@@ -951,6 +1008,8 @@ var require_tokenizer = __commonJS({
951
1008
  this._reconsumeInState(RAWTEXT_STATE);
952
1009
  }
953
1010
  }
1011
+ // RAWTEXT end tag name state
1012
+ //------------------------------------------------------------------
954
1013
  [RAWTEXT_END_TAG_NAME_STATE](cp) {
955
1014
  if (isAsciiUpper(cp)) {
956
1015
  this.currentToken.tagName += toAsciiLowerChar(cp);
@@ -979,6 +1038,8 @@ var require_tokenizer = __commonJS({
979
1038
  this._reconsumeInState(RAWTEXT_STATE);
980
1039
  }
981
1040
  }
1041
+ // Script data less-than sign state
1042
+ //------------------------------------------------------------------
982
1043
  [SCRIPT_DATA_LESS_THAN_SIGN_STATE](cp) {
983
1044
  if (cp === $.SOLIDUS) {
984
1045
  this.tempBuff = [];
@@ -991,6 +1052,8 @@ var require_tokenizer = __commonJS({
991
1052
  this._reconsumeInState(SCRIPT_DATA_STATE);
992
1053
  }
993
1054
  }
1055
+ // Script data end tag open state
1056
+ //------------------------------------------------------------------
994
1057
  [SCRIPT_DATA_END_TAG_OPEN_STATE](cp) {
995
1058
  if (isAsciiLetter(cp)) {
996
1059
  this._createEndTagToken();
@@ -1000,6 +1063,8 @@ var require_tokenizer = __commonJS({
1000
1063
  this._reconsumeInState(SCRIPT_DATA_STATE);
1001
1064
  }
1002
1065
  }
1066
+ // Script data end tag name state
1067
+ //------------------------------------------------------------------
1003
1068
  [SCRIPT_DATA_END_TAG_NAME_STATE](cp) {
1004
1069
  if (isAsciiUpper(cp)) {
1005
1070
  this.currentToken.tagName += toAsciiLowerChar(cp);
@@ -1026,6 +1091,8 @@ var require_tokenizer = __commonJS({
1026
1091
  this._reconsumeInState(SCRIPT_DATA_STATE);
1027
1092
  }
1028
1093
  }
1094
+ // Script data escape start state
1095
+ //------------------------------------------------------------------
1029
1096
  [SCRIPT_DATA_ESCAPE_START_STATE](cp) {
1030
1097
  if (cp === $.HYPHEN_MINUS) {
1031
1098
  this.state = SCRIPT_DATA_ESCAPE_START_DASH_STATE;
@@ -1034,6 +1101,8 @@ var require_tokenizer = __commonJS({
1034
1101
  this._reconsumeInState(SCRIPT_DATA_STATE);
1035
1102
  }
1036
1103
  }
1104
+ // Script data escape start dash state
1105
+ //------------------------------------------------------------------
1037
1106
  [SCRIPT_DATA_ESCAPE_START_DASH_STATE](cp) {
1038
1107
  if (cp === $.HYPHEN_MINUS) {
1039
1108
  this.state = SCRIPT_DATA_ESCAPED_DASH_DASH_STATE;
@@ -1042,6 +1111,8 @@ var require_tokenizer = __commonJS({
1042
1111
  this._reconsumeInState(SCRIPT_DATA_STATE);
1043
1112
  }
1044
1113
  }
1114
+ // Script data escaped state
1115
+ //------------------------------------------------------------------
1045
1116
  [SCRIPT_DATA_ESCAPED_STATE](cp) {
1046
1117
  if (cp === $.HYPHEN_MINUS) {
1047
1118
  this.state = SCRIPT_DATA_ESCAPED_DASH_STATE;
@@ -1058,6 +1129,8 @@ var require_tokenizer = __commonJS({
1058
1129
  this._emitCodePoint(cp);
1059
1130
  }
1060
1131
  }
1132
+ // Script data escaped dash state
1133
+ //------------------------------------------------------------------
1061
1134
  [SCRIPT_DATA_ESCAPED_DASH_STATE](cp) {
1062
1135
  if (cp === $.HYPHEN_MINUS) {
1063
1136
  this.state = SCRIPT_DATA_ESCAPED_DASH_DASH_STATE;
@@ -1076,6 +1149,8 @@ var require_tokenizer = __commonJS({
1076
1149
  this._emitCodePoint(cp);
1077
1150
  }
1078
1151
  }
1152
+ // Script data escaped dash dash state
1153
+ //------------------------------------------------------------------
1079
1154
  [SCRIPT_DATA_ESCAPED_DASH_DASH_STATE](cp) {
1080
1155
  if (cp === $.HYPHEN_MINUS) {
1081
1156
  this._emitChars("-");
@@ -1096,6 +1171,8 @@ var require_tokenizer = __commonJS({
1096
1171
  this._emitCodePoint(cp);
1097
1172
  }
1098
1173
  }
1174
+ // Script data escaped less-than sign state
1175
+ //------------------------------------------------------------------
1099
1176
  [SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE](cp) {
1100
1177
  if (cp === $.SOLIDUS) {
1101
1178
  this.tempBuff = [];
@@ -1109,6 +1186,8 @@ var require_tokenizer = __commonJS({
1109
1186
  this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
1110
1187
  }
1111
1188
  }
1189
+ // Script data escaped end tag open state
1190
+ //------------------------------------------------------------------
1112
1191
  [SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE](cp) {
1113
1192
  if (isAsciiLetter(cp)) {
1114
1193
  this._createEndTagToken();
@@ -1118,6 +1197,8 @@ var require_tokenizer = __commonJS({
1118
1197
  this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
1119
1198
  }
1120
1199
  }
1200
+ // Script data escaped end tag name state
1201
+ //------------------------------------------------------------------
1121
1202
  [SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE](cp) {
1122
1203
  if (isAsciiUpper(cp)) {
1123
1204
  this.currentToken.tagName += toAsciiLowerChar(cp);
@@ -1146,6 +1227,8 @@ var require_tokenizer = __commonJS({
1146
1227
  this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
1147
1228
  }
1148
1229
  }
1230
+ // Script data double escape start state
1231
+ //------------------------------------------------------------------
1149
1232
  [SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE](cp) {
1150
1233
  if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) {
1151
1234
  this.state = this._isTempBufferEqualToScriptString() ? SCRIPT_DATA_DOUBLE_ESCAPED_STATE : SCRIPT_DATA_ESCAPED_STATE;
@@ -1160,6 +1243,8 @@ var require_tokenizer = __commonJS({
1160
1243
  this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
1161
1244
  }
1162
1245
  }
1246
+ // Script data double escaped state
1247
+ //------------------------------------------------------------------
1163
1248
  [SCRIPT_DATA_DOUBLE_ESCAPED_STATE](cp) {
1164
1249
  if (cp === $.HYPHEN_MINUS) {
1165
1250
  this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE;
@@ -1177,6 +1262,8 @@ var require_tokenizer = __commonJS({
1177
1262
  this._emitCodePoint(cp);
1178
1263
  }
1179
1264
  }
1265
+ // Script data double escaped dash state
1266
+ //------------------------------------------------------------------
1180
1267
  [SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE](cp) {
1181
1268
  if (cp === $.HYPHEN_MINUS) {
1182
1269
  this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE;
@@ -1196,6 +1283,8 @@ var require_tokenizer = __commonJS({
1196
1283
  this._emitCodePoint(cp);
1197
1284
  }
1198
1285
  }
1286
+ // Script data double escaped dash dash state
1287
+ //------------------------------------------------------------------
1199
1288
  [SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE](cp) {
1200
1289
  if (cp === $.HYPHEN_MINUS) {
1201
1290
  this._emitChars("-");
@@ -1217,6 +1306,8 @@ var require_tokenizer = __commonJS({
1217
1306
  this._emitCodePoint(cp);
1218
1307
  }
1219
1308
  }
1309
+ // Script data double escaped less-than sign state
1310
+ //------------------------------------------------------------------
1220
1311
  [SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE](cp) {
1221
1312
  if (cp === $.SOLIDUS) {
1222
1313
  this.tempBuff = [];
@@ -1226,6 +1317,8 @@ var require_tokenizer = __commonJS({
1226
1317
  this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE);
1227
1318
  }
1228
1319
  }
1320
+ // Script data double escape end state
1321
+ //------------------------------------------------------------------
1229
1322
  [SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE](cp) {
1230
1323
  if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) {
1231
1324
  this.state = this._isTempBufferEqualToScriptString() ? SCRIPT_DATA_ESCAPED_STATE : SCRIPT_DATA_DOUBLE_ESCAPED_STATE;
@@ -1240,6 +1333,8 @@ var require_tokenizer = __commonJS({
1240
1333
  this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE);
1241
1334
  }
1242
1335
  }
1336
+ // Before attribute name state
1337
+ //------------------------------------------------------------------
1243
1338
  [BEFORE_ATTRIBUTE_NAME_STATE](cp) {
1244
1339
  if (isWhitespace(cp)) {
1245
1340
  return;
@@ -1255,6 +1350,8 @@ var require_tokenizer = __commonJS({
1255
1350
  this._reconsumeInState(ATTRIBUTE_NAME_STATE);
1256
1351
  }
1257
1352
  }
1353
+ // Attribute name state
1354
+ //------------------------------------------------------------------
1258
1355
  [ATTRIBUTE_NAME_STATE](cp) {
1259
1356
  if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN || cp === $.EOF) {
1260
1357
  this._leaveAttrName(AFTER_ATTRIBUTE_NAME_STATE);
@@ -1273,6 +1370,8 @@ var require_tokenizer = __commonJS({
1273
1370
  this.currentAttr.name += toChar(cp);
1274
1371
  }
1275
1372
  }
1373
+ // After attribute name state
1374
+ //------------------------------------------------------------------
1276
1375
  [AFTER_ATTRIBUTE_NAME_STATE](cp) {
1277
1376
  if (isWhitespace(cp)) {
1278
1377
  return;
@@ -1292,6 +1391,8 @@ var require_tokenizer = __commonJS({
1292
1391
  this._reconsumeInState(ATTRIBUTE_NAME_STATE);
1293
1392
  }
1294
1393
  }
1394
+ // Before attribute value state
1395
+ //------------------------------------------------------------------
1295
1396
  [BEFORE_ATTRIBUTE_VALUE_STATE](cp) {
1296
1397
  if (isWhitespace(cp)) {
1297
1398
  return;
@@ -1308,6 +1409,8 @@ var require_tokenizer = __commonJS({
1308
1409
  this._reconsumeInState(ATTRIBUTE_VALUE_UNQUOTED_STATE);
1309
1410
  }
1310
1411
  }
1412
+ // Attribute value (double-quoted) state
1413
+ //------------------------------------------------------------------
1311
1414
  [ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE](cp) {
1312
1415
  if (cp === $.QUOTATION_MARK) {
1313
1416
  this.state = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE;
@@ -1324,6 +1427,8 @@ var require_tokenizer = __commonJS({
1324
1427
  this.currentAttr.value += toChar(cp);
1325
1428
  }
1326
1429
  }
1430
+ // Attribute value (single-quoted) state
1431
+ //------------------------------------------------------------------
1327
1432
  [ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE](cp) {
1328
1433
  if (cp === $.APOSTROPHE) {
1329
1434
  this.state = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE;
@@ -1340,6 +1445,8 @@ var require_tokenizer = __commonJS({
1340
1445
  this.currentAttr.value += toChar(cp);
1341
1446
  }
1342
1447
  }
1448
+ // Attribute value (unquoted) state
1449
+ //------------------------------------------------------------------
1343
1450
  [ATTRIBUTE_VALUE_UNQUOTED_STATE](cp) {
1344
1451
  if (isWhitespace(cp)) {
1345
1452
  this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE);
@@ -1362,6 +1469,8 @@ var require_tokenizer = __commonJS({
1362
1469
  this.currentAttr.value += toChar(cp);
1363
1470
  }
1364
1471
  }
1472
+ // After attribute value (quoted) state
1473
+ //------------------------------------------------------------------
1365
1474
  [AFTER_ATTRIBUTE_VALUE_QUOTED_STATE](cp) {
1366
1475
  if (isWhitespace(cp)) {
1367
1476
  this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE);
@@ -1378,6 +1487,8 @@ var require_tokenizer = __commonJS({
1378
1487
  this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE);
1379
1488
  }
1380
1489
  }
1490
+ // Self-closing start tag state
1491
+ //------------------------------------------------------------------
1381
1492
  [SELF_CLOSING_START_TAG_STATE](cp) {
1382
1493
  if (cp === $.GREATER_THAN_SIGN) {
1383
1494
  this.currentToken.selfClosing = true;
@@ -1391,6 +1502,8 @@ var require_tokenizer = __commonJS({
1391
1502
  this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE);
1392
1503
  }
1393
1504
  }
1505
+ // Bogus comment state
1506
+ //------------------------------------------------------------------
1394
1507
  [BOGUS_COMMENT_STATE](cp) {
1395
1508
  if (cp === $.GREATER_THAN_SIGN) {
1396
1509
  this.state = DATA_STATE;
@@ -1405,6 +1518,8 @@ var require_tokenizer = __commonJS({
1405
1518
  this.currentToken.data += toChar(cp);
1406
1519
  }
1407
1520
  }
1521
+ // Markup declaration open state
1522
+ //------------------------------------------------------------------
1408
1523
  [MARKUP_DECLARATION_OPEN_STATE](cp) {
1409
1524
  if (this._consumeSequenceIfMatch($$.DASH_DASH_STRING, cp, true)) {
1410
1525
  this._createCommentToken();
@@ -1426,6 +1541,8 @@ var require_tokenizer = __commonJS({
1426
1541
  this._reconsumeInState(BOGUS_COMMENT_STATE);
1427
1542
  }
1428
1543
  }
1544
+ // Comment start state
1545
+ //------------------------------------------------------------------
1429
1546
  [COMMENT_START_STATE](cp) {
1430
1547
  if (cp === $.HYPHEN_MINUS) {
1431
1548
  this.state = COMMENT_START_DASH_STATE;
@@ -1437,6 +1554,8 @@ var require_tokenizer = __commonJS({
1437
1554
  this._reconsumeInState(COMMENT_STATE);
1438
1555
  }
1439
1556
  }
1557
+ // Comment start dash state
1558
+ //------------------------------------------------------------------
1440
1559
  [COMMENT_START_DASH_STATE](cp) {
1441
1560
  if (cp === $.HYPHEN_MINUS) {
1442
1561
  this.state = COMMENT_END_STATE;
@@ -1453,6 +1572,8 @@ var require_tokenizer = __commonJS({
1453
1572
  this._reconsumeInState(COMMENT_STATE);
1454
1573
  }
1455
1574
  }
1575
+ // Comment state
1576
+ //------------------------------------------------------------------
1456
1577
  [COMMENT_STATE](cp) {
1457
1578
  if (cp === $.HYPHEN_MINUS) {
1458
1579
  this.state = COMMENT_END_DASH_STATE;
@@ -1470,6 +1591,8 @@ var require_tokenizer = __commonJS({
1470
1591
  this.currentToken.data += toChar(cp);
1471
1592
  }
1472
1593
  }
1594
+ // Comment less-than sign state
1595
+ //------------------------------------------------------------------
1473
1596
  [COMMENT_LESS_THAN_SIGN_STATE](cp) {
1474
1597
  if (cp === $.EXCLAMATION_MARK) {
1475
1598
  this.currentToken.data += "!";
@@ -1480,6 +1603,8 @@ var require_tokenizer = __commonJS({
1480
1603
  this._reconsumeInState(COMMENT_STATE);
1481
1604
  }
1482
1605
  }
1606
+ // Comment less-than sign bang state
1607
+ //------------------------------------------------------------------
1483
1608
  [COMMENT_LESS_THAN_SIGN_BANG_STATE](cp) {
1484
1609
  if (cp === $.HYPHEN_MINUS) {
1485
1610
  this.state = COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE;
@@ -1487,6 +1612,8 @@ var require_tokenizer = __commonJS({
1487
1612
  this._reconsumeInState(COMMENT_STATE);
1488
1613
  }
1489
1614
  }
1615
+ // Comment less-than sign bang dash state
1616
+ //------------------------------------------------------------------
1490
1617
  [COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE](cp) {
1491
1618
  if (cp === $.HYPHEN_MINUS) {
1492
1619
  this.state = COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE;
@@ -1494,12 +1621,16 @@ var require_tokenizer = __commonJS({
1494
1621
  this._reconsumeInState(COMMENT_END_DASH_STATE);
1495
1622
  }
1496
1623
  }
1624
+ // Comment less-than sign bang dash dash state
1625
+ //------------------------------------------------------------------
1497
1626
  [COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE](cp) {
1498
1627
  if (cp !== $.GREATER_THAN_SIGN && cp !== $.EOF) {
1499
1628
  this._err(ERR.nestedComment);
1500
1629
  }
1501
1630
  this._reconsumeInState(COMMENT_END_STATE);
1502
1631
  }
1632
+ // Comment end dash state
1633
+ //------------------------------------------------------------------
1503
1634
  [COMMENT_END_DASH_STATE](cp) {
1504
1635
  if (cp === $.HYPHEN_MINUS) {
1505
1636
  this.state = COMMENT_END_STATE;
@@ -1512,6 +1643,8 @@ var require_tokenizer = __commonJS({
1512
1643
  this._reconsumeInState(COMMENT_STATE);
1513
1644
  }
1514
1645
  }
1646
+ // Comment end state
1647
+ //------------------------------------------------------------------
1515
1648
  [COMMENT_END_STATE](cp) {
1516
1649
  if (cp === $.GREATER_THAN_SIGN) {
1517
1650
  this.state = DATA_STATE;
@@ -1529,6 +1662,8 @@ var require_tokenizer = __commonJS({
1529
1662
  this._reconsumeInState(COMMENT_STATE);
1530
1663
  }
1531
1664
  }
1665
+ // Comment end bang state
1666
+ //------------------------------------------------------------------
1532
1667
  [COMMENT_END_BANG_STATE](cp) {
1533
1668
  if (cp === $.HYPHEN_MINUS) {
1534
1669
  this.currentToken.data += "--!";
@@ -1546,6 +1681,8 @@ var require_tokenizer = __commonJS({
1546
1681
  this._reconsumeInState(COMMENT_STATE);
1547
1682
  }
1548
1683
  }
1684
+ // DOCTYPE state
1685
+ //------------------------------------------------------------------
1549
1686
  [DOCTYPE_STATE](cp) {
1550
1687
  if (isWhitespace(cp)) {
1551
1688
  this.state = BEFORE_DOCTYPE_NAME_STATE;
@@ -1562,6 +1699,8 @@ var require_tokenizer = __commonJS({
1562
1699
  this._reconsumeInState(BEFORE_DOCTYPE_NAME_STATE);
1563
1700
  }
1564
1701
  }
1702
+ // Before DOCTYPE name state
1703
+ //------------------------------------------------------------------
1565
1704
  [BEFORE_DOCTYPE_NAME_STATE](cp) {
1566
1705
  if (isWhitespace(cp)) {
1567
1706
  return;
@@ -1590,6 +1729,8 @@ var require_tokenizer = __commonJS({
1590
1729
  this.state = DOCTYPE_NAME_STATE;
1591
1730
  }
1592
1731
  }
1732
+ // DOCTYPE name state
1733
+ //------------------------------------------------------------------
1593
1734
  [DOCTYPE_NAME_STATE](cp) {
1594
1735
  if (isWhitespace(cp)) {
1595
1736
  this.state = AFTER_DOCTYPE_NAME_STATE;
@@ -1610,6 +1751,8 @@ var require_tokenizer = __commonJS({
1610
1751
  this.currentToken.name += toChar(cp);
1611
1752
  }
1612
1753
  }
1754
+ // After DOCTYPE name state
1755
+ //------------------------------------------------------------------
1613
1756
  [AFTER_DOCTYPE_NAME_STATE](cp) {
1614
1757
  if (isWhitespace(cp)) {
1615
1758
  return;
@@ -1632,6 +1775,8 @@ var require_tokenizer = __commonJS({
1632
1775
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1633
1776
  }
1634
1777
  }
1778
+ // After DOCTYPE public keyword state
1779
+ //------------------------------------------------------------------
1635
1780
  [AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE](cp) {
1636
1781
  if (isWhitespace(cp)) {
1637
1782
  this.state = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
@@ -1659,6 +1804,8 @@ var require_tokenizer = __commonJS({
1659
1804
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1660
1805
  }
1661
1806
  }
1807
+ // Before DOCTYPE public identifier state
1808
+ //------------------------------------------------------------------
1662
1809
  [BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE](cp) {
1663
1810
  if (isWhitespace(cp)) {
1664
1811
  return;
@@ -1685,6 +1832,8 @@ var require_tokenizer = __commonJS({
1685
1832
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1686
1833
  }
1687
1834
  }
1835
+ // DOCTYPE public identifier (double-quoted) state
1836
+ //------------------------------------------------------------------
1688
1837
  [DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE](cp) {
1689
1838
  if (cp === $.QUOTATION_MARK) {
1690
1839
  this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
@@ -1705,6 +1854,8 @@ var require_tokenizer = __commonJS({
1705
1854
  this.currentToken.publicId += toChar(cp);
1706
1855
  }
1707
1856
  }
1857
+ // DOCTYPE public identifier (single-quoted) state
1858
+ //------------------------------------------------------------------
1708
1859
  [DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE](cp) {
1709
1860
  if (cp === $.APOSTROPHE) {
1710
1861
  this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
@@ -1725,6 +1876,8 @@ var require_tokenizer = __commonJS({
1725
1876
  this.currentToken.publicId += toChar(cp);
1726
1877
  }
1727
1878
  }
1879
+ // After DOCTYPE public identifier state
1880
+ //------------------------------------------------------------------
1728
1881
  [AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE](cp) {
1729
1882
  if (isWhitespace(cp)) {
1730
1883
  this.state = BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE;
@@ -1750,6 +1903,8 @@ var require_tokenizer = __commonJS({
1750
1903
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1751
1904
  }
1752
1905
  }
1906
+ // Between DOCTYPE public and system identifiers state
1907
+ //------------------------------------------------------------------
1753
1908
  [BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE](cp) {
1754
1909
  if (isWhitespace(cp)) {
1755
1910
  return;
@@ -1774,6 +1929,8 @@ var require_tokenizer = __commonJS({
1774
1929
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1775
1930
  }
1776
1931
  }
1932
+ // After DOCTYPE system keyword state
1933
+ //------------------------------------------------------------------
1777
1934
  [AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE](cp) {
1778
1935
  if (isWhitespace(cp)) {
1779
1936
  this.state = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
@@ -1801,6 +1958,8 @@ var require_tokenizer = __commonJS({
1801
1958
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1802
1959
  }
1803
1960
  }
1961
+ // Before DOCTYPE system identifier state
1962
+ //------------------------------------------------------------------
1804
1963
  [BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE](cp) {
1805
1964
  if (isWhitespace(cp)) {
1806
1965
  return;
@@ -1827,6 +1986,8 @@ var require_tokenizer = __commonJS({
1827
1986
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1828
1987
  }
1829
1988
  }
1989
+ // DOCTYPE system identifier (double-quoted) state
1990
+ //------------------------------------------------------------------
1830
1991
  [DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE](cp) {
1831
1992
  if (cp === $.QUOTATION_MARK) {
1832
1993
  this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
@@ -1847,6 +2008,8 @@ var require_tokenizer = __commonJS({
1847
2008
  this.currentToken.systemId += toChar(cp);
1848
2009
  }
1849
2010
  }
2011
+ // DOCTYPE system identifier (single-quoted) state
2012
+ //------------------------------------------------------------------
1850
2013
  [DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE](cp) {
1851
2014
  if (cp === $.APOSTROPHE) {
1852
2015
  this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
@@ -1867,6 +2030,8 @@ var require_tokenizer = __commonJS({
1867
2030
  this.currentToken.systemId += toChar(cp);
1868
2031
  }
1869
2032
  }
2033
+ // After DOCTYPE system identifier state
2034
+ //------------------------------------------------------------------
1870
2035
  [AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE](cp) {
1871
2036
  if (isWhitespace(cp)) {
1872
2037
  return;
@@ -1884,6 +2049,8 @@ var require_tokenizer = __commonJS({
1884
2049
  this._reconsumeInState(BOGUS_DOCTYPE_STATE);
1885
2050
  }
1886
2051
  }
2052
+ // Bogus DOCTYPE state
2053
+ //------------------------------------------------------------------
1887
2054
  [BOGUS_DOCTYPE_STATE](cp) {
1888
2055
  if (cp === $.GREATER_THAN_SIGN) {
1889
2056
  this._emitCurrentToken();
@@ -1895,6 +2062,8 @@ var require_tokenizer = __commonJS({
1895
2062
  this._emitEOFToken();
1896
2063
  }
1897
2064
  }
2065
+ // CDATA section state
2066
+ //------------------------------------------------------------------
1898
2067
  [CDATA_SECTION_STATE](cp) {
1899
2068
  if (cp === $.RIGHT_SQUARE_BRACKET) {
1900
2069
  this.state = CDATA_SECTION_BRACKET_STATE;
@@ -1905,6 +2074,8 @@ var require_tokenizer = __commonJS({
1905
2074
  this._emitCodePoint(cp);
1906
2075
  }
1907
2076
  }
2077
+ // CDATA section bracket state
2078
+ //------------------------------------------------------------------
1908
2079
  [CDATA_SECTION_BRACKET_STATE](cp) {
1909
2080
  if (cp === $.RIGHT_SQUARE_BRACKET) {
1910
2081
  this.state = CDATA_SECTION_END_STATE;
@@ -1913,6 +2084,8 @@ var require_tokenizer = __commonJS({
1913
2084
  this._reconsumeInState(CDATA_SECTION_STATE);
1914
2085
  }
1915
2086
  }
2087
+ // CDATA section end state
2088
+ //------------------------------------------------------------------
1916
2089
  [CDATA_SECTION_END_STATE](cp) {
1917
2090
  if (cp === $.GREATER_THAN_SIGN) {
1918
2091
  this.state = DATA_STATE;
@@ -1923,6 +2096,8 @@ var require_tokenizer = __commonJS({
1923
2096
  this._reconsumeInState(CDATA_SECTION_STATE);
1924
2097
  }
1925
2098
  }
2099
+ // Character reference state
2100
+ //------------------------------------------------------------------
1926
2101
  [CHARACTER_REFERENCE_STATE](cp) {
1927
2102
  this.tempBuff = [$.AMPERSAND];
1928
2103
  if (cp === $.NUMBER_SIGN) {
@@ -1935,6 +2110,8 @@ var require_tokenizer = __commonJS({
1935
2110
  this._reconsumeInState(this.returnState);
1936
2111
  }
1937
2112
  }
2113
+ // Named character reference state
2114
+ //------------------------------------------------------------------
1938
2115
  [NAMED_CHARACTER_REFERENCE_STATE](cp) {
1939
2116
  const matchResult = this._matchNamedCharacterReference(cp);
1940
2117
  if (this._ensureHibernation()) {
@@ -1954,6 +2131,8 @@ var require_tokenizer = __commonJS({
1954
2131
  this.state = AMBIGUOUS_AMPERSAND_STATE;
1955
2132
  }
1956
2133
  }
2134
+ // Ambiguos ampersand state
2135
+ //------------------------------------------------------------------
1957
2136
  [AMBIGUOUS_AMPERSAND_STATE](cp) {
1958
2137
  if (isAsciiAlphaNumeric(cp)) {
1959
2138
  if (this._isCharacterReferenceInAttribute()) {
@@ -1968,6 +2147,8 @@ var require_tokenizer = __commonJS({
1968
2147
  this._reconsumeInState(this.returnState);
1969
2148
  }
1970
2149
  }
2150
+ // Numeric character reference state
2151
+ //------------------------------------------------------------------
1971
2152
  [NUMERIC_CHARACTER_REFERENCE_STATE](cp) {
1972
2153
  this.charRefCode = 0;
1973
2154
  if (cp === $.LATIN_SMALL_X || cp === $.LATIN_CAPITAL_X) {
@@ -1977,6 +2158,8 @@ var require_tokenizer = __commonJS({
1977
2158
  this._reconsumeInState(DECIMAL_CHARACTER_REFERENCE_START_STATE);
1978
2159
  }
1979
2160
  }
2161
+ // Hexademical character reference start state
2162
+ //------------------------------------------------------------------
1980
2163
  [HEXADEMICAL_CHARACTER_REFERENCE_START_STATE](cp) {
1981
2164
  if (isAsciiHexDigit(cp)) {
1982
2165
  this._reconsumeInState(HEXADEMICAL_CHARACTER_REFERENCE_STATE);
@@ -1986,6 +2169,8 @@ var require_tokenizer = __commonJS({
1986
2169
  this._reconsumeInState(this.returnState);
1987
2170
  }
1988
2171
  }
2172
+ // Decimal character reference start state
2173
+ //------------------------------------------------------------------
1989
2174
  [DECIMAL_CHARACTER_REFERENCE_START_STATE](cp) {
1990
2175
  if (isAsciiDigit(cp)) {
1991
2176
  this._reconsumeInState(DECIMAL_CHARACTER_REFERENCE_STATE);
@@ -1995,6 +2180,8 @@ var require_tokenizer = __commonJS({
1995
2180
  this._reconsumeInState(this.returnState);
1996
2181
  }
1997
2182
  }
2183
+ // Hexademical character reference state
2184
+ //------------------------------------------------------------------
1998
2185
  [HEXADEMICAL_CHARACTER_REFERENCE_STATE](cp) {
1999
2186
  if (isAsciiUpperHexDigit(cp)) {
2000
2187
  this.charRefCode = this.charRefCode * 16 + cp - 55;
@@ -2009,6 +2196,8 @@ var require_tokenizer = __commonJS({
2009
2196
  this._reconsumeInState(NUMERIC_CHARACTER_REFERENCE_END_STATE);
2010
2197
  }
2011
2198
  }
2199
+ // Decimal character reference state
2200
+ //------------------------------------------------------------------
2012
2201
  [DECIMAL_CHARACTER_REFERENCE_STATE](cp) {
2013
2202
  if (isAsciiDigit(cp)) {
2014
2203
  this.charRefCode = this.charRefCode * 10 + cp - 48;
@@ -2019,6 +2208,8 @@ var require_tokenizer = __commonJS({
2019
2208
  this._reconsumeInState(NUMERIC_CHARACTER_REFERENCE_END_STATE);
2020
2209
  }
2021
2210
  }
2211
+ // Numeric character reference end state
2212
+ //------------------------------------------------------------------
2022
2213
  [NUMERIC_CHARACTER_REFERENCE_END_STATE]() {
2023
2214
  if (this.charRefCode === $.NULL) {
2024
2215
  this._err(ERR.nullCharacterReference);
@@ -2412,6 +2603,7 @@ var require_open_element_stack = __commonJS({
2412
2603
  this.tmplCount = 0;
2413
2604
  this.treeAdapter = treeAdapter;
2414
2605
  }
2606
+ //Index of element
2415
2607
  _indexOf(element4) {
2416
2608
  let idx = -1;
2417
2609
  for (let i = this.stackTop; i >= 0; i--) {
@@ -2422,6 +2614,7 @@ var require_open_element_stack = __commonJS({
2422
2614
  }
2423
2615
  return idx;
2424
2616
  }
2617
+ //Update current element
2425
2618
  _isInTemplate() {
2426
2619
  return this.currentTagName === $.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
2427
2620
  }
@@ -2430,6 +2623,7 @@ var require_open_element_stack = __commonJS({
2430
2623
  this.currentTagName = this.current && this.treeAdapter.getTagName(this.current);
2431
2624
  this.currentTmplContent = this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : null;
2432
2625
  }
2626
+ //Mutations
2433
2627
  push(element4) {
2434
2628
  this.items[++this.stackTop] = element4;
2435
2629
  this._updateCurrentElement();
@@ -2526,6 +2720,7 @@ var require_open_element_stack = __commonJS({
2526
2720
  }
2527
2721
  }
2528
2722
  }
2723
+ //Search
2529
2724
  tryPeekProperlyNestedBodyElement() {
2530
2725
  const element4 = this.items[1];
2531
2726
  return element4 && this.treeAdapter.getTagName(element4) === $.BODY ? element4 : null;
@@ -2540,6 +2735,7 @@ var require_open_element_stack = __commonJS({
2540
2735
  isRootHtmlElementCurrent() {
2541
2736
  return this.stackTop === 0 && this.currentTagName === $.HTML;
2542
2737
  }
2738
+ //Element in scope
2543
2739
  hasInScope(tagName) {
2544
2740
  for (let i = this.stackTop; i >= 0; i--) {
2545
2741
  const tn = this.treeAdapter.getTagName(this.items[i]);
@@ -2640,6 +2836,7 @@ var require_open_element_stack = __commonJS({
2640
2836
  }
2641
2837
  return true;
2642
2838
  }
2839
+ //Implied end tags
2643
2840
  generateImpliedEndTags() {
2644
2841
  while (isImpliedEndTagRequired(this.currentTagName)) {
2645
2842
  this.pop();
@@ -2672,6 +2869,9 @@ var require_formatting_element_list = __commonJS({
2672
2869
  this.treeAdapter = treeAdapter;
2673
2870
  this.bookmark = null;
2674
2871
  }
2872
+ //Noah Ark's condition
2873
+ //OPTIMIZATION: at first we try to find possible candidates for exclusion using
2874
+ //lightweight heuristics without thorough attributes check.
2675
2875
  _getNoahArkConditionCandidates(newElement) {
2676
2876
  const candidates = [];
2677
2877
  if (this.length >= NOAH_ARK_CAPACITY) {
@@ -2722,6 +2922,7 @@ var require_formatting_element_list = __commonJS({
2722
2922
  }
2723
2923
  }
2724
2924
  }
2925
+ //Mutations
2725
2926
  insertMarker() {
2726
2927
  this.entries.push({ type: FormattingElementList.MARKER_ENTRY });
2727
2928
  this.length++;
@@ -2767,6 +2968,7 @@ var require_formatting_element_list = __commonJS({
2767
2968
  }
2768
2969
  }
2769
2970
  }
2971
+ //Search
2770
2972
  getElementEntryInScopeWithTagName(tagName) {
2771
2973
  for (let i = this.length - 1; i >= 0; i--) {
2772
2974
  const entry = this.entries[i];
@@ -3104,6 +3306,7 @@ var require_parser_mixin = __commonJS({
3104
3306
  mxn._setEndLocation(this.openElements.items[i], mxn.currentToken);
3105
3307
  }
3106
3308
  },
3309
+ //Token processing
3107
3310
  _processTokenInForeignContent(token) {
3108
3311
  mxn.currentToken = token;
3109
3312
  orig._processTokenInForeignContent.call(this, token);
@@ -3122,6 +3325,7 @@ var require_parser_mixin = __commonJS({
3122
3325
  }
3123
3326
  }
3124
3327
  },
3328
+ //Doctype
3125
3329
  _setDocumentType(token) {
3126
3330
  orig._setDocumentType.call(this, token);
3127
3331
  const documentChildren = this.treeAdapter.getChildNodes(this.document);
@@ -3134,6 +3338,7 @@ var require_parser_mixin = __commonJS({
3134
3338
  }
3135
3339
  }
3136
3340
  },
3341
+ //Elements
3137
3342
  _attachElementToTree(element4) {
3138
3343
  mxn._setStartLocation(element4);
3139
3344
  mxn.lastStartTagToken = null;
@@ -3157,12 +3362,14 @@ var require_parser_mixin = __commonJS({
3157
3362
  orig._insertFakeRootElement.call(this);
3158
3363
  this.treeAdapter.setNodeSourceCodeLocation(this.openElements.current, null);
3159
3364
  },
3365
+ //Comments
3160
3366
  _appendCommentNode(token, parent) {
3161
3367
  orig._appendCommentNode.call(this, token, parent);
3162
3368
  const children = this.treeAdapter.getChildNodes(parent);
3163
3369
  const commentNode = children[children.length - 1];
3164
3370
  this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
3165
3371
  },
3372
+ //Text
3166
3373
  _findFosterParentingLocation() {
3167
3374
  mxn.lastFosterParentingLocation = orig._findFosterParentingLocation.call(this);
3168
3375
  return mxn.lastFosterParentingLocation;
@@ -4199,6 +4406,7 @@ var require_parser = __commonJS({
4199
4406
  Mixin.install(this, ErrorReportingParserMixin, { onParseError: this.options.onParseError });
4200
4407
  }
4201
4408
  }
4409
+ // API
4202
4410
  parse(html5) {
4203
4411
  const document = this.treeAdapter.createDocument();
4204
4412
  this._bootstrap(document, null);
@@ -4226,6 +4434,7 @@ var require_parser = __commonJS({
4226
4434
  this._adoptNodes(rootElement, fragment);
4227
4435
  return fragment;
4228
4436
  }
4437
+ //Bootstrap parser
4229
4438
  _bootstrap(document, fragmentContext) {
4230
4439
  this.tokenizer = new Tokenizer(this.options);
4231
4440
  this.stopped = false;
@@ -4246,8 +4455,10 @@ var require_parser = __commonJS({
4246
4455
  this.skipNextNewLine = false;
4247
4456
  this.fosterParentingEnabled = false;
4248
4457
  }
4458
+ //Errors
4249
4459
  _err() {
4250
4460
  }
4461
+ //Parsing loop
4251
4462
  _runParsingLoop(scriptHandler) {
4252
4463
  while (!this.stopped) {
4253
4464
  this._setupTokenizerCDATAMode();
@@ -4282,6 +4493,7 @@ var require_parser = __commonJS({
4282
4493
  writeCallback();
4283
4494
  }
4284
4495
  }
4496
+ //Text parsing
4285
4497
  _setupTokenizerCDATAMode() {
4286
4498
  const current = this._getAdjustedCurrentElement();
4287
4499
  this.tokenizer.allowCDATA = current && current !== this.document && this.treeAdapter.getNamespaceURI(current) !== NS.HTML && !this._isIntegrationPoint(current);
@@ -4297,6 +4509,7 @@ var require_parser = __commonJS({
4297
4509
  this.originalInsertionMode = IN_BODY_MODE;
4298
4510
  this.tokenizer.state = Tokenizer.MODE.PLAINTEXT;
4299
4511
  }
4512
+ //Fragment parsing
4300
4513
  _getAdjustedCurrentElement() {
4301
4514
  return this.openElements.stackTop === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.current;
4302
4515
  }
@@ -4324,6 +4537,7 @@ var require_parser = __commonJS({
4324
4537
  }
4325
4538
  }
4326
4539
  }
4540
+ //Tree mutation
4327
4541
  _setDocumentType(token) {
4328
4542
  const name = token.name || "";
4329
4543
  const publicId = token.publicId || "";
@@ -4382,6 +4596,7 @@ var require_parser = __commonJS({
4382
4596
  this.treeAdapter.appendChild(recipient, child);
4383
4597
  }
4384
4598
  }
4599
+ //Token processing
4385
4600
  _shouldProcessTokenInForeignContent(token) {
4386
4601
  const current = this._getAdjustedCurrentElement();
4387
4602
  if (!current || current === this.document) {
@@ -4435,12 +4650,14 @@ var require_parser = __commonJS({
4435
4650
  this._err(ERR.nonVoidHtmlElementStartTagWithTrailingSolidus);
4436
4651
  }
4437
4652
  }
4653
+ //Integration points
4438
4654
  _isIntegrationPoint(element4, foreignNS) {
4439
4655
  const tn = this.treeAdapter.getTagName(element4);
4440
4656
  const ns = this.treeAdapter.getNamespaceURI(element4);
4441
4657
  const attrs = this.treeAdapter.getAttrList(element4);
4442
4658
  return foreignContent.isIntegrationPoint(tn, ns, attrs, foreignNS);
4443
4659
  }
4660
+ //Active formatting elements reconstruction
4444
4661
  _reconstructActiveFormattingElements() {
4445
4662
  const listLength = this.activeFormattingElements.length;
4446
4663
  if (listLength) {
@@ -4461,6 +4678,7 @@ var require_parser = __commonJS({
4461
4678
  }
4462
4679
  }
4463
4680
  }
4681
+ //Close elements
4464
4682
  _closeTableCell() {
4465
4683
  this.openElements.generateImpliedEndTags();
4466
4684
  this.openElements.popUntilTableCellPopped();
@@ -4471,6 +4689,7 @@ var require_parser = __commonJS({
4471
4689
  this.openElements.generateImpliedEndTagsWithExclusion($.P);
4472
4690
  this.openElements.popUntilTagNamePopped($.P);
4473
4691
  }
4692
+ //Insertion modes
4474
4693
  _resetInsertionMode() {
4475
4694
  for (let i = this.openElements.stackTop, last = false; i >= 0; i--) {
4476
4695
  let element4 = this.openElements.items[i];
@@ -4531,6 +4750,7 @@ var require_parser = __commonJS({
4531
4750
  this.tmplInsertionModeStackTop--;
4532
4751
  this.currentTmplInsertionMode = this.tmplInsertionModeStack[this.tmplInsertionModeStackTop];
4533
4752
  }
4753
+ //Foster parenting
4534
4754
  _isElementCausesFosterParenting(element4) {
4535
4755
  const tn = this.treeAdapter.getTagName(element4);
4536
4756
  return tn === $.TABLE || tn === $.TBODY || tn === $.TFOOT || tn === $.THEAD || tn === $.TR;
@@ -4581,6 +4801,7 @@ var require_parser = __commonJS({
4581
4801
  this.treeAdapter.insertText(location2.parent, chars);
4582
4802
  }
4583
4803
  }
4804
+ //Special elements
4584
4805
  _isSpecialElement(element4) {
4585
4806
  const tn = this.treeAdapter.getTagName(element4);
4586
4807
  const ns = this.treeAdapter.getNamespaceURI(element4);
@@ -6229,6 +6450,12 @@ var require_is_buffer2 = __commonJS({
6229
6450
 
6230
6451
  // ../../node_modules/property-information/lib/util/schema.js
6231
6452
  var Schema = class {
6453
+ /**
6454
+ * @constructor
6455
+ * @param {Properties} property
6456
+ * @param {Normal} normal
6457
+ * @param {string} [space]
6458
+ */
6232
6459
  constructor(property, normal, space) {
6233
6460
  this.property = property;
6234
6461
  this.normal = normal;
@@ -6260,6 +6487,11 @@ function normalize(value) {
6260
6487
 
6261
6488
  // ../../node_modules/property-information/lib/util/info.js
6262
6489
  var Info = class {
6490
+ /**
6491
+ * @constructor
6492
+ * @param {string} property
6493
+ * @param {string} attribute
6494
+ */
6263
6495
  constructor(property, attribute) {
6264
6496
  this.property = property;
6265
6497
  this.attribute = attribute;
@@ -6302,6 +6534,13 @@ function increment() {
6302
6534
  // ../../node_modules/property-information/lib/util/defined-info.js
6303
6535
  var checks = Object.keys(types_exports);
6304
6536
  var DefinedInfo = class extends Info {
6537
+ /**
6538
+ * @constructor
6539
+ * @param {string} property
6540
+ * @param {string} attribute
6541
+ * @param {number|null} [mask]
6542
+ * @param {string} [space]
6543
+ */
6305
6544
  constructor(property, attribute, mask, space) {
6306
6545
  let index2 = -1;
6307
6546
  super(property, attribute);
@@ -6461,6 +6700,7 @@ var html = create({
6461
6700
  transform: caseInsensitiveTransform,
6462
6701
  mustUseProperty: ["checked", "multiple", "muted", "selected"],
6463
6702
  properties: {
6703
+ // Standard Properties.
6464
6704
  abbr: null,
6465
6705
  accept: commaSeparated,
6466
6706
  acceptCharset: spaceSeparated,
@@ -6679,59 +6919,115 @@ var html = create({
6679
6919
  value: booleanish,
6680
6920
  width: number,
6681
6921
  wrap: null,
6922
+ // Legacy.
6923
+ // See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis
6682
6924
  align: null,
6925
+ // Several. Use CSS `text-align` instead,
6683
6926
  aLink: null,
6927
+ // `<body>`. Use CSS `a:active {color}` instead
6684
6928
  archive: spaceSeparated,
6929
+ // `<object>`. List of URIs to archives
6685
6930
  axis: null,
6931
+ // `<td>` and `<th>`. Use `scope` on `<th>`
6686
6932
  background: null,
6933
+ // `<body>`. Use CSS `background-image` instead
6687
6934
  bgColor: null,
6935
+ // `<body>` and table elements. Use CSS `background-color` instead
6688
6936
  border: number,
6937
+ // `<table>`. Use CSS `border-width` instead,
6689
6938
  borderColor: null,
6939
+ // `<table>`. Use CSS `border-color` instead,
6690
6940
  bottomMargin: number,
6941
+ // `<body>`
6691
6942
  cellPadding: null,
6943
+ // `<table>`
6692
6944
  cellSpacing: null,
6945
+ // `<table>`
6693
6946
  char: null,
6947
+ // Several table elements. When `align=char`, sets the character to align on
6694
6948
  charOff: null,
6949
+ // Several table elements. When `char`, offsets the alignment
6695
6950
  classId: null,
6951
+ // `<object>`
6696
6952
  clear: null,
6953
+ // `<br>`. Use CSS `clear` instead
6697
6954
  code: null,
6955
+ // `<object>`
6698
6956
  codeBase: null,
6957
+ // `<object>`
6699
6958
  codeType: null,
6959
+ // `<object>`
6700
6960
  color: null,
6961
+ // `<font>` and `<hr>`. Use CSS instead
6701
6962
  compact: boolean,
6963
+ // Lists. Use CSS to reduce space between items instead
6702
6964
  declare: boolean,
6965
+ // `<object>`
6703
6966
  event: null,
6967
+ // `<script>`
6704
6968
  face: null,
6969
+ // `<font>`. Use CSS instead
6705
6970
  frame: null,
6971
+ // `<table>`
6706
6972
  frameBorder: null,
6973
+ // `<iframe>`. Use CSS `border` instead
6707
6974
  hSpace: number,
6975
+ // `<img>` and `<object>`
6708
6976
  leftMargin: number,
6977
+ // `<body>`
6709
6978
  link: null,
6979
+ // `<body>`. Use CSS `a:link {color: *}` instead
6710
6980
  longDesc: null,
6981
+ // `<frame>`, `<iframe>`, and `<img>`. Use an `<a>`
6711
6982
  lowSrc: null,
6983
+ // `<img>`. Use a `<picture>`
6712
6984
  marginHeight: number,
6985
+ // `<body>`
6713
6986
  marginWidth: number,
6987
+ // `<body>`
6714
6988
  noResize: boolean,
6989
+ // `<frame>`
6715
6990
  noHref: boolean,
6991
+ // `<area>`. Use no href instead of an explicit `nohref`
6716
6992
  noShade: boolean,
6993
+ // `<hr>`. Use background-color and height instead of borders
6717
6994
  noWrap: boolean,
6995
+ // `<td>` and `<th>`
6718
6996
  object: null,
6997
+ // `<applet>`
6719
6998
  profile: null,
6999
+ // `<head>`
6720
7000
  prompt: null,
7001
+ // `<isindex>`
6721
7002
  rev: null,
7003
+ // `<link>`
6722
7004
  rightMargin: number,
7005
+ // `<body>`
6723
7006
  rules: null,
7007
+ // `<table>`
6724
7008
  scheme: null,
7009
+ // `<meta>`
6725
7010
  scrolling: booleanish,
7011
+ // `<frame>`. Use overflow in the child context
6726
7012
  standby: null,
7013
+ // `<object>`
6727
7014
  summary: null,
7015
+ // `<table>`
6728
7016
  text: null,
7017
+ // `<body>`. Use CSS `color` instead
6729
7018
  topMargin: number,
7019
+ // `<body>`
6730
7020
  valueType: null,
7021
+ // `<param>`
6731
7022
  version: null,
7023
+ // `<html>`. Use a doctype.
6732
7024
  vAlign: null,
7025
+ // Several. Use CSS `vertical-align` instead
6733
7026
  vLink: null,
7027
+ // `<body>`. Use CSS `a:visited {color}` instead
6734
7028
  vSpace: number,
7029
+ // `<img>` and `<object>`
7030
+ // Non-standard Properties.
6735
7031
  allowTransparency: null,
6736
7032
  autoCorrect: null,
6737
7033
  autoSave: null,
@@ -6918,6 +7214,7 @@ var svg = create({
6918
7214
  wordSpacing: "word-spacing",
6919
7215
  writingMode: "writing-mode",
6920
7216
  xHeight: "x-height",
7217
+ // These were camelcased in Tiny. Now lowercased in SVG 2
6921
7218
  playbackOrder: "playbackorder",
6922
7219
  timelineBegin: "timelinebegin"
6923
7220
  },
@@ -7038,8 +7335,11 @@ var svg = create({
7038
7335
  kernelMatrix: commaOrSpaceSeparated,
7039
7336
  kernelUnitLength: null,
7040
7337
  keyPoints: null,
7338
+ // SEMI_COLON_SEPARATED
7041
7339
  keySplines: null,
7340
+ // SEMI_COLON_SEPARATED
7042
7341
  keyTimes: null,
7342
+ // SEMI_COLON_SEPARATED
7043
7343
  kerning: null,
7044
7344
  lang: null,
7045
7345
  lengthAdjust: null,
@@ -7369,37 +7669,82 @@ var htmlVoidElements = [
7369
7669
  ];
7370
7670
 
7371
7671
  // ../../node_modules/hast-util-is-element/index.js
7372
- var isElement = function(node, test, index2, parent, context) {
7373
- const check = convertElement(test);
7374
- if (index2 !== void 0 && index2 !== null && (typeof index2 !== "number" || index2 < 0 || index2 === Number.POSITIVE_INFINITY)) {
7375
- throw new Error("Expected positive finite index for child node");
7376
- }
7377
- if (parent !== void 0 && parent !== null && (!parent.type || !parent.children)) {
7378
- throw new Error("Expected parent node");
7379
- }
7380
- if (!node || !node.type || typeof node.type !== "string") {
7381
- return false;
7382
- }
7383
- if ((parent === void 0 || parent === null) !== (index2 === void 0 || index2 === null)) {
7384
- throw new Error("Expected both parent and index");
7385
- }
7386
- return check.call(context, node, index2, parent);
7387
- };
7388
- var convertElement = function(test) {
7389
- if (test === void 0 || test === null) {
7390
- return element;
7391
- }
7392
- if (typeof test === "string") {
7393
- return tagNameFactory(test);
7394
- }
7395
- if (typeof test === "object") {
7396
- return anyFactory(test);
7397
- }
7398
- if (typeof test === "function") {
7399
- return castFactory(test);
7400
- }
7401
- throw new Error("Expected function, string, or array as test");
7402
- };
7672
+ var isElement = (
7673
+ /**
7674
+ * Check if a node is an element and passes a test.
7675
+ * When a `parent` node is known the `index` of node should also be given.
7676
+ *
7677
+ * @type {(
7678
+ * (() => false) &
7679
+ * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
7680
+ * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
7681
+ * )}
7682
+ */
7683
+ /**
7684
+ * Check if a node passes a test.
7685
+ * When a `parent` node is known the `index` of node should also be given.
7686
+ *
7687
+ * @param {unknown} [node] Node to check
7688
+ * @param {Test} [test] When nullish, checks if `node` is a `Node`.
7689
+ * When `string`, works like passing `function (node) {return node.type === test}`.
7690
+ * When `function` checks if function passed the node is true.
7691
+ * When `array`, checks any one of the subtests pass.
7692
+ * @param {number} [index] Position of `node` in `parent`
7693
+ * @param {Parent} [parent] Parent of `node`
7694
+ * @param {unknown} [context] Context object to invoke `test` with
7695
+ * @returns {boolean} Whether test passed and `node` is an `Element` (object with `type` set to `element` and `tagName` set to a non-empty string).
7696
+ */
7697
+ // eslint-disable-next-line max-params
7698
+ function(node, test, index2, parent, context) {
7699
+ const check = convertElement(test);
7700
+ if (index2 !== void 0 && index2 !== null && (typeof index2 !== "number" || index2 < 0 || index2 === Number.POSITIVE_INFINITY)) {
7701
+ throw new Error("Expected positive finite index for child node");
7702
+ }
7703
+ if (parent !== void 0 && parent !== null && (!parent.type || !parent.children)) {
7704
+ throw new Error("Expected parent node");
7705
+ }
7706
+ if (!node || !node.type || typeof node.type !== "string") {
7707
+ return false;
7708
+ }
7709
+ if ((parent === void 0 || parent === null) !== (index2 === void 0 || index2 === null)) {
7710
+ throw new Error("Expected both parent and index");
7711
+ }
7712
+ return check.call(context, node, index2, parent);
7713
+ }
7714
+ );
7715
+ var convertElement = (
7716
+ /**
7717
+ * @type {(
7718
+ * (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
7719
+ * ((test?: Test) => AssertAnything)
7720
+ * )}
7721
+ */
7722
+ /**
7723
+ * Generate an assertion from a check.
7724
+ * @param {Test} [test]
7725
+ * When nullish, checks if `node` is a `Node`.
7726
+ * When `string`, works like passing `function (node) {return node.type === test}`.
7727
+ * When `function` checks if function passed the node is true.
7728
+ * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
7729
+ * When `array`, checks any one of the subtests pass.
7730
+ * @returns {AssertAnything}
7731
+ */
7732
+ function(test) {
7733
+ if (test === void 0 || test === null) {
7734
+ return element;
7735
+ }
7736
+ if (typeof test === "string") {
7737
+ return tagNameFactory(test);
7738
+ }
7739
+ if (typeof test === "object") {
7740
+ return anyFactory(test);
7741
+ }
7742
+ if (typeof test === "function") {
7743
+ return castFactory(test);
7744
+ }
7745
+ throw new Error("Expected function, string, or array as test");
7746
+ }
7747
+ );
7403
7748
  function anyFactory(tests) {
7404
7749
  const checks2 = [];
7405
7750
  let index2 = -1;
@@ -7431,26 +7776,46 @@ function castFactory(check) {
7431
7776
  }
7432
7777
  function element(node) {
7433
7778
  return Boolean(
7434
- node && typeof node === "object" && node.type === "element" && typeof node.tagName === "string"
7779
+ node && typeof node === "object" && // @ts-expect-error Looks like a node.
7780
+ node.type === "element" && // @ts-expect-error Looks like an element.
7781
+ typeof node.tagName === "string"
7435
7782
  );
7436
7783
  }
7437
7784
 
7438
7785
  // ../../node_modules/unist-util-is/index.js
7439
- var convert = function(test) {
7440
- if (test === void 0 || test === null) {
7441
- return ok;
7442
- }
7443
- if (typeof test === "string") {
7444
- return typeFactory(test);
7445
- }
7446
- if (typeof test === "object") {
7447
- return Array.isArray(test) ? anyFactory2(test) : propsFactory(test);
7448
- }
7449
- if (typeof test === "function") {
7450
- return castFactory2(test);
7451
- }
7452
- throw new Error("Expected function, string, or object as test");
7453
- };
7786
+ var convert = (
7787
+ /**
7788
+ * @type {(
7789
+ * (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
7790
+ * ((test?: Test) => AssertAnything)
7791
+ * )}
7792
+ */
7793
+ /**
7794
+ * Generate an assertion from a check.
7795
+ * @param {Test} [test]
7796
+ * When nullish, checks if `node` is a `Node`.
7797
+ * When `string`, works like passing `function (node) {return node.type === test}`.
7798
+ * When `function` checks if function passed the node is true.
7799
+ * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
7800
+ * When `array`, checks any one of the subtests pass.
7801
+ * @returns {AssertAnything}
7802
+ */
7803
+ function(test) {
7804
+ if (test === void 0 || test === null) {
7805
+ return ok;
7806
+ }
7807
+ if (typeof test === "string") {
7808
+ return typeFactory(test);
7809
+ }
7810
+ if (typeof test === "object") {
7811
+ return Array.isArray(test) ? anyFactory2(test) : propsFactory(test);
7812
+ }
7813
+ if (typeof test === "function") {
7814
+ return castFactory2(test);
7815
+ }
7816
+ throw new Error("Expected function, string, or object as test");
7817
+ }
7818
+ );
7454
7819
  function anyFactory2(tests) {
7455
7820
  const checks2 = [];
7456
7821
  let index2 = -1;
@@ -7499,7 +7864,13 @@ var comment = convert("comment");
7499
7864
 
7500
7865
  // ../../node_modules/hast-util-whitespace/index.js
7501
7866
  function whitespace(thing) {
7502
- var value = thing && typeof thing === "object" && thing.type === "text" ? thing.value || "" : thing;
7867
+ var value = (
7868
+ // @ts-ignore looks like a node.
7869
+ thing && typeof thing === "object" && thing.type === "text" ? (
7870
+ // @ts-ignore looks like a text.
7871
+ thing.value || ""
7872
+ ) : thing
7873
+ );
7503
7874
  return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
7504
7875
  }
7505
7876
 
@@ -7605,7 +7976,8 @@ function p(_, index2, parent) {
7605
7976
  "section",
7606
7977
  "table",
7607
7978
  "ul"
7608
- ]) : !parent || !isElement(parent, [
7979
+ ]) : !parent || // Confusing parent.
7980
+ !isElement(parent, [
7609
7981
  "a",
7610
7982
  "audio",
7611
7983
  "del",
@@ -7762,6 +8134,7 @@ function core(value, options) {
7762
8134
  return value;
7763
8135
  }
7764
8136
  return value.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, surrogate).replace(
8137
+ // eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
7765
8138
  /[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,
7766
8139
  basic
7767
8140
  );
@@ -8244,19 +8617,23 @@ function ccount(value, character) {
8244
8617
 
8245
8618
  // ../../node_modules/hast-util-to-html/lib/constants.js
8246
8619
  var constants = {
8620
+ // See: <https://html.spec.whatwg.org/#attribute-name-state>.
8247
8621
  name: [
8248
8622
  [" \n\f\r &/=>".split(""), " \n\f\r \"&'/=>`".split("")],
8249
8623
  [`\0
8250
8624
  \f\r "&'/<=>`.split(""), "\0 \n\f\r \"&'/<=>`".split("")]
8251
8625
  ],
8626
+ // See: <https://html.spec.whatwg.org/#attribute-value-(unquoted)-state>.
8252
8627
  unquoted: [
8253
8628
  [" \n\f\r &>".split(""), "\0 \n\f\r \"&'<=>`".split("")],
8254
8629
  ["\0 \n\f\r \"&'<=>`".split(""), "\0 \n\f\r \"&'<=>`".split("")]
8255
8630
  ],
8631
+ // See: <https://html.spec.whatwg.org/#attribute-value-(single-quoted)-state>.
8256
8632
  single: [
8257
8633
  ["&'".split(""), "\"&'`".split("")],
8258
8634
  ["\0&'".split(""), "\0\"&'`".split("")]
8259
8635
  ],
8636
+ // See: <https://html.spec.whatwg.org/#attribute-value-(double-quoted)-state>.
8260
8637
  double: [
8261
8638
  ['"&'.split(""), "\"&'`".split("")],
8262
8639
  ['\0"&'.split(""), "\0\"&'`".split("")]
@@ -8284,7 +8661,8 @@ function doctype(ctx) {
8284
8661
 
8285
8662
  // ../../node_modules/hast-util-to-html/lib/text.js
8286
8663
  function text(ctx, node, _, parent) {
8287
- return parent && parent.type === "element" && (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
8664
+ return parent && parent.type === "element" && // @ts-expect-error: hush.
8665
+ (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
8288
8666
  node.value,
8289
8667
  Object.assign({}, ctx.entities, { subset: ["<", "&"] })
8290
8668
  );
@@ -8300,7 +8678,9 @@ var handlers = {
8300
8678
  comment: comment2,
8301
8679
  doctype,
8302
8680
  element: element2,
8681
+ // @ts-ignore `raw` is nonstandard
8303
8682
  raw,
8683
+ // @ts-ignore `root` is a parent.
8304
8684
  root: all,
8305
8685
  text
8306
8686
  };
@@ -8393,14 +8773,19 @@ function serializeAttribute(ctx, key2, value) {
8393
8773
  const name = stringifyEntities(
8394
8774
  info.attribute,
8395
8775
  Object.assign({}, ctx.entities, {
8776
+ // Always encode without parse errors in non-HTML.
8396
8777
  subset: constants.name[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe]
8397
8778
  })
8398
8779
  );
8399
8780
  if (value === true)
8400
8781
  return name;
8401
- value = typeof value === "object" && "length" in value ? (info.commaSeparated ? stringify2 : stringify)(value, {
8402
- padLeft: !ctx.tightLists
8403
- }) : String(value);
8782
+ value = typeof value === "object" && "length" in value ? (
8783
+ // `spaces` doesn’t accept a second argument, but it’s given here just to
8784
+ // keep the code cleaner.
8785
+ (info.commaSeparated ? stringify2 : stringify)(value, {
8786
+ padLeft: !ctx.tightLists
8787
+ })
8788
+ ) : String(value);
8404
8789
  if (ctx.collapseEmpty && !value)
8405
8790
  return name;
8406
8791
  if (ctx.unquoted) {
@@ -8419,6 +8804,7 @@ function serializeAttribute(ctx, key2, value) {
8419
8804
  result = quote + stringifyEntities(
8420
8805
  value,
8421
8806
  Object.assign({}, ctx.entities, {
8807
+ // Always encode without parse errors in non-HTML.
8422
8808
  subset: (quote === "'" ? constants.single : constants.double)[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe],
8423
8809
  attribute: true
8424
8810
  })
@@ -8458,6 +8844,7 @@ function toHtml(node, options = {}) {
8458
8844
  };
8459
8845
  return one(
8460
8846
  context,
8847
+ // @ts-ignore Assume `node` does not contain a root.
8461
8848
  Array.isArray(node) ? { type: "root", children: node } : node,
8462
8849
  null,
8463
8850
  null
@@ -8469,79 +8856,109 @@ var import_parser = __toESM(require_parser(), 1);
8469
8856
 
8470
8857
  // ../../node_modules/hast-util-parse-selector/index.js
8471
8858
  var search = /[#.]/g;
8472
- var parseSelector = function(selector, defaultTagName = "div") {
8473
- var value = selector || "";
8474
- var props = {};
8475
- var start = 0;
8476
- var subvalue;
8477
- var previous;
8478
- var match;
8479
- while (start < value.length) {
8480
- search.lastIndex = start;
8481
- match = search.exec(value);
8482
- subvalue = value.slice(start, match ? match.index : value.length);
8483
- if (subvalue) {
8484
- if (!previous) {
8485
- defaultTagName = subvalue;
8486
- } else if (previous === "#") {
8487
- props.id = subvalue;
8488
- } else if (Array.isArray(props.className)) {
8489
- props.className.push(subvalue);
8490
- } else {
8491
- props.className = [subvalue];
8859
+ var parseSelector = (
8860
+ /**
8861
+ * @type {(
8862
+ * <Selector extends string, DefaultTagName extends string = 'div'>(selector?: Selector, defaultTagName?: DefaultTagName) => Element & {tagName: import('./extract.js').ExtractTagName<Selector, DefaultTagName>}
8863
+ * )}
8864
+ */
8865
+ /**
8866
+ * @param {string} [selector]
8867
+ * @param {string} [defaultTagName='div']
8868
+ * @returns {Element}
8869
+ */
8870
+ function(selector, defaultTagName = "div") {
8871
+ var value = selector || "";
8872
+ var props = {};
8873
+ var start = 0;
8874
+ var subvalue;
8875
+ var previous;
8876
+ var match;
8877
+ while (start < value.length) {
8878
+ search.lastIndex = start;
8879
+ match = search.exec(value);
8880
+ subvalue = value.slice(start, match ? match.index : value.length);
8881
+ if (subvalue) {
8882
+ if (!previous) {
8883
+ defaultTagName = subvalue;
8884
+ } else if (previous === "#") {
8885
+ props.id = subvalue;
8886
+ } else if (Array.isArray(props.className)) {
8887
+ props.className.push(subvalue);
8888
+ } else {
8889
+ props.className = [subvalue];
8890
+ }
8891
+ start += subvalue.length;
8892
+ }
8893
+ if (match) {
8894
+ previous = match[0];
8895
+ start++;
8492
8896
  }
8493
- start += subvalue.length;
8494
- }
8495
- if (match) {
8496
- previous = match[0];
8497
- start++;
8498
8897
  }
8898
+ return {
8899
+ type: "element",
8900
+ tagName: defaultTagName,
8901
+ properties: props,
8902
+ children: []
8903
+ };
8499
8904
  }
8500
- return {
8501
- type: "element",
8502
- tagName: defaultTagName,
8503
- properties: props,
8504
- children: []
8505
- };
8506
- };
8905
+ );
8507
8906
 
8508
8907
  // ../../node_modules/hastscript/lib/core.js
8509
8908
  var buttonTypes = /* @__PURE__ */ new Set(["menu", "submit", "reset", "button"]);
8510
8909
  var own5 = {}.hasOwnProperty;
8511
8910
  function core2(schema, defaultTagName, caseSensitive) {
8512
8911
  const adjust = caseSensitive && createAdjustMap(caseSensitive);
8513
- const h2 = function(selector, properties, ...children) {
8514
- let index2 = -1;
8515
- let node;
8516
- if (selector === void 0 || selector === null) {
8517
- node = { type: "root", children: [] };
8518
- children.unshift(properties);
8519
- } else {
8520
- node = parseSelector(selector, defaultTagName);
8521
- node.tagName = node.tagName.toLowerCase();
8522
- if (adjust && own5.call(adjust, node.tagName)) {
8523
- node.tagName = adjust[node.tagName];
8524
- }
8525
- if (isProperties(properties, node.tagName)) {
8526
- let key2;
8527
- for (key2 in properties) {
8528
- if (own5.call(properties, key2)) {
8529
- addProperty(schema, node.properties, key2, properties[key2]);
8912
+ const h2 = (
8913
+ /**
8914
+ * @type {{
8915
+ * (): Root
8916
+ * (selector: null|undefined, ...children: Array<HChild>): Root
8917
+ * (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
8918
+ * (selector: string, ...children: Array<HChild>): Element
8919
+ * }}
8920
+ */
8921
+ /**
8922
+ * Hyperscript compatible DSL for creating virtual hast trees.
8923
+ *
8924
+ * @param {string|null} [selector]
8925
+ * @param {HProperties|HChild} [properties]
8926
+ * @param {Array<HChild>} children
8927
+ * @returns {HResult}
8928
+ */
8929
+ function(selector, properties, ...children) {
8930
+ let index2 = -1;
8931
+ let node;
8932
+ if (selector === void 0 || selector === null) {
8933
+ node = { type: "root", children: [] };
8934
+ children.unshift(properties);
8935
+ } else {
8936
+ node = parseSelector(selector, defaultTagName);
8937
+ node.tagName = node.tagName.toLowerCase();
8938
+ if (adjust && own5.call(adjust, node.tagName)) {
8939
+ node.tagName = adjust[node.tagName];
8940
+ }
8941
+ if (isProperties(properties, node.tagName)) {
8942
+ let key2;
8943
+ for (key2 in properties) {
8944
+ if (own5.call(properties, key2)) {
8945
+ addProperty(schema, node.properties, key2, properties[key2]);
8946
+ }
8530
8947
  }
8948
+ } else {
8949
+ children.unshift(properties);
8531
8950
  }
8532
- } else {
8533
- children.unshift(properties);
8534
8951
  }
8952
+ while (++index2 < children.length) {
8953
+ addChild(node.children, children[index2]);
8954
+ }
8955
+ if (node.type === "element" && node.tagName === "template") {
8956
+ node.content = { type: "root", children: node.children };
8957
+ node.children = [];
8958
+ }
8959
+ return node;
8535
8960
  }
8536
- while (++index2 < children.length) {
8537
- addChild(node.children, children[index2]);
8538
- }
8539
- if (node.type === "element" && node.tagName === "template") {
8540
- node.content = { type: "root", children: node.children };
8541
- node.children = [];
8542
- }
8543
- return node;
8544
- };
8961
+ );
8545
8962
  return h2;
8546
8963
  }
8547
8964
  function isProperties(value, name) {
@@ -9151,7 +9568,10 @@ var errors = {
9151
9568
  var base = "https://html.spec.whatwg.org/multipage/parsing.html#parse-error-";
9152
9569
  var fatalities = { 2: true, 1: false, 0: null };
9153
9570
  function rehypeParse(options) {
9154
- const processorSettings = this.data("settings");
9571
+ const processorSettings = (
9572
+ /** @type {Options} */
9573
+ this.data("settings")
9574
+ );
9155
9575
  const settings = Object.assign({}, processorSettings, options);
9156
9576
  Object.assign(this, { Parser: parser });
9157
9577
  function parser(doc, file) {
@@ -9283,7 +9703,10 @@ function wrap(middleware, callback) {
9283
9703
  try {
9284
9704
  result = middleware.apply(this, parameters);
9285
9705
  } catch (error) {
9286
- const exception = error;
9706
+ const exception = (
9707
+ /** @type {Error} */
9708
+ error
9709
+ );
9287
9710
  if (fnExpectsCallback && called) {
9288
9711
  throw exception;
9289
9712
  }
@@ -9341,10 +9764,25 @@ function index(value) {
9341
9764
 
9342
9765
  // ../../node_modules/vfile-message/index.js
9343
9766
  var VFileMessage = class extends Error {
9767
+ /**
9768
+ * Create a message for `reason` at `place` from `origin`.
9769
+ *
9770
+ * When an error is passed in as `reason`, the `stack` is copied.
9771
+ *
9772
+ * @param {string|Error|VFileMessage} reason
9773
+ * Reason for message.
9774
+ * Uses the stack and message of the error if given.
9775
+ * @param {Node|NodeLike|Position|Point} [place]
9776
+ * Place at which the message occurred in a file.
9777
+ * @param {string} [origin]
9778
+ * Place in code the message originates from (example `'my-package:my-rule-name'`)
9779
+ */
9344
9780
  constructor(reason, place, origin) {
9345
9781
  const parts = [null, null];
9346
9782
  let position3 = {
9783
+ // @ts-expect-error: we always follows the structure of `position`.
9347
9784
  start: { line: null, column: null },
9785
+ // @ts-expect-error: "
9348
9786
  end: { line: null, column: null }
9349
9787
  };
9350
9788
  super();
@@ -9415,12 +9853,31 @@ import { fileURLToPath } from "url";
9415
9853
 
9416
9854
  // ../../node_modules/vfile/lib/minurl.shared.js
9417
9855
  function isUrl(fileURLOrPath) {
9418
- return fileURLOrPath !== null && typeof fileURLOrPath === "object" && fileURLOrPath.href && fileURLOrPath.origin;
9856
+ return fileURLOrPath !== null && typeof fileURLOrPath === "object" && // @ts-expect-error: indexable.
9857
+ fileURLOrPath.href && // @ts-expect-error: indexable.
9858
+ fileURLOrPath.origin;
9419
9859
  }
9420
9860
 
9421
9861
  // ../../node_modules/vfile/lib/index.js
9422
9862
  var order = ["history", "path", "basename", "stem", "extname", "dirname"];
9423
9863
  var VFile = class {
9864
+ /**
9865
+ * Create a new virtual file.
9866
+ *
9867
+ * If `options` is `string` or `Buffer`, it’s treated as `{value: options}`.
9868
+ * If `options` is a `URL`, it’s treated as `{path: options}`.
9869
+ * If `options` is a `VFile`, shallow copies its data over to the new file.
9870
+ * All fields in `options` are set on the newly created `VFile`.
9871
+ *
9872
+ * Path related fields are set in the following order (least specific to
9873
+ * most specific): `history`, `path`, `basename`, `stem`, `extname`,
9874
+ * `dirname`.
9875
+ *
9876
+ * It’s not possible to set either `dirname` or `extname` without setting
9877
+ * either `history`, `path`, `basename`, or `stem` as well.
9878
+ *
9879
+ * @param {Compatible} [value]
9880
+ */
9424
9881
  constructor(value) {
9425
9882
  let options;
9426
9883
  if (!value) {
@@ -9453,9 +9910,20 @@ var VFile = class {
9453
9910
  this[prop] = options[prop];
9454
9911
  }
9455
9912
  }
9913
+ /**
9914
+ * Get the full path (example: `'~/index.min.js'`).
9915
+ * @returns {string}
9916
+ */
9456
9917
  get path() {
9457
9918
  return this.history[this.history.length - 1];
9458
9919
  }
9920
+ /**
9921
+ * Set the full path (example: `'~/index.min.js'`).
9922
+ * Cannot be nullified.
9923
+ * You can set a file URL (a `URL` object with a `file:` protocol) which will
9924
+ * be turned into a path with `url.fileURLToPath`.
9925
+ * @param {string|URL} path
9926
+ */
9459
9927
  set path(path) {
9460
9928
  if (isUrl(path)) {
9461
9929
  path = fileURLToPath(path);
@@ -9465,24 +9933,49 @@ var VFile = class {
9465
9933
  this.history.push(path);
9466
9934
  }
9467
9935
  }
9936
+ /**
9937
+ * Get the parent path (example: `'~'`).
9938
+ */
9468
9939
  get dirname() {
9469
9940
  return typeof this.path === "string" ? default2.dirname(this.path) : void 0;
9470
9941
  }
9942
+ /**
9943
+ * Set the parent path (example: `'~'`).
9944
+ * Cannot be set if there’s no `path` yet.
9945
+ */
9471
9946
  set dirname(dirname) {
9472
9947
  assertPath(this.basename, "dirname");
9473
9948
  this.path = default2.join(dirname || "", this.basename);
9474
9949
  }
9950
+ /**
9951
+ * Get the basename (including extname) (example: `'index.min.js'`).
9952
+ */
9475
9953
  get basename() {
9476
9954
  return typeof this.path === "string" ? default2.basename(this.path) : void 0;
9477
9955
  }
9956
+ /**
9957
+ * Set basename (including extname) (`'index.min.js'`).
9958
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
9959
+ * on windows).
9960
+ * Cannot be nullified (use `file.path = file.dirname` instead).
9961
+ */
9478
9962
  set basename(basename) {
9479
9963
  assertNonEmpty(basename, "basename");
9480
9964
  assertPart(basename, "basename");
9481
9965
  this.path = default2.join(this.dirname || "", basename);
9482
9966
  }
9967
+ /**
9968
+ * Get the extname (including dot) (example: `'.js'`).
9969
+ */
9483
9970
  get extname() {
9484
9971
  return typeof this.path === "string" ? default2.extname(this.path) : void 0;
9485
9972
  }
9973
+ /**
9974
+ * Set the extname (including dot) (example: `'.js'`).
9975
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
9976
+ * on windows).
9977
+ * Cannot be set if there’s no `path` yet.
9978
+ */
9486
9979
  set extname(extname) {
9487
9980
  assertPart(extname, "extname");
9488
9981
  assertPath(this.dirname, "extname");
@@ -9496,17 +9989,49 @@ var VFile = class {
9496
9989
  }
9497
9990
  this.path = default2.join(this.dirname, this.stem + (extname || ""));
9498
9991
  }
9992
+ /**
9993
+ * Get the stem (basename w/o extname) (example: `'index.min'`).
9994
+ */
9499
9995
  get stem() {
9500
9996
  return typeof this.path === "string" ? default2.basename(this.path, this.extname) : void 0;
9501
9997
  }
9998
+ /**
9999
+ * Set the stem (basename w/o extname) (example: `'index.min'`).
10000
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
10001
+ * on windows).
10002
+ * Cannot be nullified (use `file.path = file.dirname` instead).
10003
+ */
9502
10004
  set stem(stem) {
9503
10005
  assertNonEmpty(stem, "stem");
9504
10006
  assertPart(stem, "stem");
9505
10007
  this.path = default2.join(this.dirname || "", stem + (this.extname || ""));
9506
10008
  }
10009
+ /**
10010
+ * Serialize the file.
10011
+ *
10012
+ * @param {BufferEncoding} [encoding='utf8']
10013
+ * When `value` is a `Buffer`, `encoding` is a character encoding to
10014
+ * understand it as (default: `'utf8'`).
10015
+ * @returns {string}
10016
+ * Serialized file.
10017
+ */
9507
10018
  toString(encoding) {
9508
10019
  return (this.value || "").toString(encoding);
9509
10020
  }
10021
+ /**
10022
+ * Constructs a new `VFileMessage`, where `fatal` is set to `false`, and
10023
+ * associates it with the file by adding it to `vfile.messages` and setting
10024
+ * `message.file` to the current filepath.
10025
+ *
10026
+ * @param {string|Error|VFileMessage} reason
10027
+ * Human readable reason for the message, uses the stack and message of the error if given.
10028
+ * @param {Node|NodeLike|Position|Point} [place]
10029
+ * Place where the message occurred in the file.
10030
+ * @param {string} [origin]
10031
+ * Computer readable reason for the message
10032
+ * @returns {VFileMessage}
10033
+ * Message.
10034
+ */
9510
10035
  message(reason, place, origin) {
9511
10036
  const message = new VFileMessage(reason, place, origin);
9512
10037
  if (this.path) {
@@ -9517,11 +10042,39 @@ var VFile = class {
9517
10042
  this.messages.push(message);
9518
10043
  return message;
9519
10044
  }
10045
+ /**
10046
+ * Like `VFile#message()`, but associates an informational message where
10047
+ * `fatal` is set to `null`.
10048
+ *
10049
+ * @param {string|Error|VFileMessage} reason
10050
+ * Human readable reason for the message, uses the stack and message of the error if given.
10051
+ * @param {Node|NodeLike|Position|Point} [place]
10052
+ * Place where the message occurred in the file.
10053
+ * @param {string} [origin]
10054
+ * Computer readable reason for the message
10055
+ * @returns {VFileMessage}
10056
+ * Message.
10057
+ */
9520
10058
  info(reason, place, origin) {
9521
10059
  const message = this.message(reason, place, origin);
9522
10060
  message.fatal = null;
9523
10061
  return message;
9524
10062
  }
10063
+ /**
10064
+ * Like `VFile#message()`, but associates a fatal message where `fatal` is
10065
+ * set to `true`, and then immediately throws it.
10066
+ *
10067
+ * > 👉 **Note**: a fatal error means that a file is no longer processable.
10068
+ *
10069
+ * @param {string|Error|VFileMessage} reason
10070
+ * Human readable reason for the message, uses the stack and message of the error if given.
10071
+ * @param {Node|NodeLike|Position|Point} [place]
10072
+ * Place where the message occurred in the file.
10073
+ * @param {string} [origin]
10074
+ * Computer readable reason for the message
10075
+ * @returns {never}
10076
+ * Message.
10077
+ */
9525
10078
  fail(reason, place, origin) {
9526
10079
  const message = this.message(reason, place, origin);
9527
10080
  message.fatal = true;
@@ -9793,7 +10346,13 @@ function base2() {
9793
10346
  }
9794
10347
  }
9795
10348
  function newable(value, name) {
9796
- return typeof value === "function" && value.prototype && (keys(value.prototype) || name in value.prototype);
10349
+ return typeof value === "function" && // Prototypes do exist.
10350
+ // type-coverage:ignore-next-line
10351
+ value.prototype && // A function with keys in its prototype is probably a constructor.
10352
+ // Classes’ prototype methods are not enumerable, so we check if some value
10353
+ // exists in the prototype.
10354
+ // type-coverage:ignore-next-line
10355
+ (keys(value.prototype) || name in value.prototype);
9797
10356
  }
9798
10357
  function keys(value) {
9799
10358
  let key2;
@@ -9859,10 +10418,22 @@ function highlightWord(code) {
9859
10418
  export {
9860
10419
  highlightWord
9861
10420
  };
9862
- /*!
9863
- * Determine if an object is a Buffer
9864
- *
9865
- * @author Feross Aboukhadijeh <https://feross.org>
9866
- * @license MIT
9867
- */
10421
+ /*! Bundled license information:
10422
+
10423
+ is-buffer/index.js:
10424
+ (*!
10425
+ * Determine if an object is a Buffer
10426
+ *
10427
+ * @author Feross Aboukhadijeh <https://feross.org>
10428
+ * @license MIT
10429
+ *)
10430
+
10431
+ is-buffer/index.js:
10432
+ (*!
10433
+ * Determine if an object is a Buffer
10434
+ *
10435
+ * @author Feross Aboukhadijeh <https://feross.org>
10436
+ * @license MIT
10437
+ *)
10438
+ */
9868
10439
  //# sourceMappingURL=highlightWord.js.map