@tamagui/code-to-html 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/highlightLine.js +4 -0
- package/dist/cjs/highlightLine.js.map +1 -1
- package/dist/cjs/highlightWord.js +4 -0
- package/dist/cjs/highlightWord.js.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/highlightLine.js +694 -123
- package/dist/esm/highlightLine.js.map +1 -1
- package/dist/esm/highlightWord.js +694 -123
- package/dist/esm/highlightWord.js.map +1 -1
- package/dist/esm/index.js +1276 -132
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -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
|
));
|
|
@@ -130,11 +134,17 @@ var require_unicode = __commonJS({
|
|
|
130
134
|
};
|
|
131
135
|
exports.CODE_POINT_SEQUENCES = {
|
|
132
136
|
DASH_DASH_STRING: [45, 45],
|
|
137
|
+
//--
|
|
133
138
|
DOCTYPE_STRING: [68, 79, 67, 84, 89, 80, 69],
|
|
139
|
+
//DOCTYPE
|
|
134
140
|
CDATA_START_STRING: [91, 67, 68, 65, 84, 65, 91],
|
|
141
|
+
//[CDATA[
|
|
135
142
|
SCRIPT_STRING: [115, 99, 114, 105, 112, 116],
|
|
143
|
+
//script
|
|
136
144
|
PUBLIC_STRING: [80, 85, 66, 76, 73, 67],
|
|
145
|
+
//PUBLIC
|
|
137
146
|
SYSTEM_STRING: [83, 89, 83, 84, 69, 77]
|
|
147
|
+
//SYSTEM
|
|
138
148
|
};
|
|
139
149
|
exports.isSurrogate = function(cp) {
|
|
140
150
|
return cp >= 55296 && cp <= 57343;
|
|
@@ -537,6 +547,7 @@ var require_tokenizer = __commonJS({
|
|
|
537
547
|
this.currentToken = null;
|
|
538
548
|
this.currentAttr = null;
|
|
539
549
|
}
|
|
550
|
+
//Errors
|
|
540
551
|
_err() {
|
|
541
552
|
}
|
|
542
553
|
_errOnNextCodePoint(err) {
|
|
@@ -544,6 +555,7 @@ var require_tokenizer = __commonJS({
|
|
|
544
555
|
this._err(err);
|
|
545
556
|
this._unconsume();
|
|
546
557
|
}
|
|
558
|
+
//API
|
|
547
559
|
getNextToken() {
|
|
548
560
|
while (!this.tokenQueue.length && this.active) {
|
|
549
561
|
this.consumedAfterSnapshot = 0;
|
|
@@ -562,6 +574,7 @@ var require_tokenizer = __commonJS({
|
|
|
562
574
|
this.active = true;
|
|
563
575
|
this.preprocessor.insertHtmlAtCurrentPos(chunk);
|
|
564
576
|
}
|
|
577
|
+
//Hibernation
|
|
565
578
|
_ensureHibernation() {
|
|
566
579
|
if (this.preprocessor.endOfChunkHit) {
|
|
567
580
|
for (; this.consumedAfterSnapshot > 0; this.consumedAfterSnapshot--) {
|
|
@@ -573,6 +586,7 @@ var require_tokenizer = __commonJS({
|
|
|
573
586
|
}
|
|
574
587
|
return false;
|
|
575
588
|
}
|
|
589
|
+
//Consumption
|
|
576
590
|
_consume() {
|
|
577
591
|
this.consumedAfterSnapshot++;
|
|
578
592
|
return this.preprocessor.advance();
|
|
@@ -614,6 +628,7 @@ var require_tokenizer = __commonJS({
|
|
|
614
628
|
}
|
|
615
629
|
return isMatch;
|
|
616
630
|
}
|
|
631
|
+
//Temp buffer
|
|
617
632
|
_isTempBufferEqualToScriptString() {
|
|
618
633
|
if (this.tempBuff.length !== $$.SCRIPT_STRING.length) {
|
|
619
634
|
return false;
|
|
@@ -625,6 +640,7 @@ var require_tokenizer = __commonJS({
|
|
|
625
640
|
}
|
|
626
641
|
return true;
|
|
627
642
|
}
|
|
643
|
+
//Token creation
|
|
628
644
|
_createStartTagToken() {
|
|
629
645
|
this.currentToken = {
|
|
630
646
|
type: Tokenizer.START_TAG_TOKEN,
|
|
@@ -666,6 +682,7 @@ var require_tokenizer = __commonJS({
|
|
|
666
682
|
_createEOFToken() {
|
|
667
683
|
this.currentToken = { type: Tokenizer.EOF_TOKEN };
|
|
668
684
|
}
|
|
685
|
+
//Tag attributes
|
|
669
686
|
_createAttr(attrNameFirstCh) {
|
|
670
687
|
this.currentAttr = {
|
|
671
688
|
name: attrNameFirstCh,
|
|
@@ -683,6 +700,7 @@ var require_tokenizer = __commonJS({
|
|
|
683
700
|
_leaveAttrValue(toState) {
|
|
684
701
|
this.state = toState;
|
|
685
702
|
}
|
|
703
|
+
//Token emission
|
|
686
704
|
_emitCurrentToken() {
|
|
687
705
|
this._emitCurrentCharacterToken();
|
|
688
706
|
const ct = this.currentToken;
|
|
@@ -709,6 +727,15 @@ var require_tokenizer = __commonJS({
|
|
|
709
727
|
this._createEOFToken();
|
|
710
728
|
this._emitCurrentToken();
|
|
711
729
|
}
|
|
730
|
+
//Characters emission
|
|
731
|
+
//OPTIMIZATION: specification uses only one type of character tokens (one token per character).
|
|
732
|
+
//This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
|
|
733
|
+
//If we have a sequence of characters that belong to the same group, parser can process it
|
|
734
|
+
//as a single solid character token.
|
|
735
|
+
//So, there are 3 types of character tokens in parse5:
|
|
736
|
+
//1)NULL_CHARACTER_TOKEN - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
|
|
737
|
+
//2)WHITESPACE_CHARACTER_TOKEN - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
|
|
738
|
+
//3)CHARACTER_TOKEN - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
|
|
712
739
|
_appendCharToCurrentCharacterToken(type, ch) {
|
|
713
740
|
if (this.currentCharacterToken && this.currentCharacterToken.type !== type) {
|
|
714
741
|
this._emitCurrentCharacterToken();
|
|
@@ -733,9 +760,12 @@ var require_tokenizer = __commonJS({
|
|
|
733
760
|
this._emitCodePoint(codePoints[i]);
|
|
734
761
|
}
|
|
735
762
|
}
|
|
763
|
+
//NOTE: used then we emit character explicitly. This is always a non-whitespace and a non-null character.
|
|
764
|
+
//So we can avoid additional checks here.
|
|
736
765
|
_emitChars(ch) {
|
|
737
766
|
this._appendCharToCurrentCharacterToken(Tokenizer.CHARACTER_TOKEN, ch);
|
|
738
767
|
}
|
|
768
|
+
// Character reference helpers
|
|
739
769
|
_matchNamedCharacterReference(startCp) {
|
|
740
770
|
let result = null;
|
|
741
771
|
let excess = 1;
|
|
@@ -788,6 +818,9 @@ var require_tokenizer = __commonJS({
|
|
|
788
818
|
}
|
|
789
819
|
this.tempBuff = [];
|
|
790
820
|
}
|
|
821
|
+
// State machine
|
|
822
|
+
// Data state
|
|
823
|
+
//------------------------------------------------------------------
|
|
791
824
|
[DATA_STATE](cp) {
|
|
792
825
|
this.preprocessor.dropParsedChunk();
|
|
793
826
|
if (cp === $.LESS_THAN_SIGN) {
|
|
@@ -804,6 +837,8 @@ var require_tokenizer = __commonJS({
|
|
|
804
837
|
this._emitCodePoint(cp);
|
|
805
838
|
}
|
|
806
839
|
}
|
|
840
|
+
// RCDATA state
|
|
841
|
+
//------------------------------------------------------------------
|
|
807
842
|
[RCDATA_STATE](cp) {
|
|
808
843
|
this.preprocessor.dropParsedChunk();
|
|
809
844
|
if (cp === $.AMPERSAND) {
|
|
@@ -820,6 +855,8 @@ var require_tokenizer = __commonJS({
|
|
|
820
855
|
this._emitCodePoint(cp);
|
|
821
856
|
}
|
|
822
857
|
}
|
|
858
|
+
// RAWTEXT state
|
|
859
|
+
//------------------------------------------------------------------
|
|
823
860
|
[RAWTEXT_STATE](cp) {
|
|
824
861
|
this.preprocessor.dropParsedChunk();
|
|
825
862
|
if (cp === $.LESS_THAN_SIGN) {
|
|
@@ -833,6 +870,8 @@ var require_tokenizer = __commonJS({
|
|
|
833
870
|
this._emitCodePoint(cp);
|
|
834
871
|
}
|
|
835
872
|
}
|
|
873
|
+
// Script data state
|
|
874
|
+
//------------------------------------------------------------------
|
|
836
875
|
[SCRIPT_DATA_STATE](cp) {
|
|
837
876
|
this.preprocessor.dropParsedChunk();
|
|
838
877
|
if (cp === $.LESS_THAN_SIGN) {
|
|
@@ -846,6 +885,8 @@ var require_tokenizer = __commonJS({
|
|
|
846
885
|
this._emitCodePoint(cp);
|
|
847
886
|
}
|
|
848
887
|
}
|
|
888
|
+
// PLAINTEXT state
|
|
889
|
+
//------------------------------------------------------------------
|
|
849
890
|
[PLAINTEXT_STATE](cp) {
|
|
850
891
|
this.preprocessor.dropParsedChunk();
|
|
851
892
|
if (cp === $.NULL) {
|
|
@@ -857,6 +898,8 @@ var require_tokenizer = __commonJS({
|
|
|
857
898
|
this._emitCodePoint(cp);
|
|
858
899
|
}
|
|
859
900
|
}
|
|
901
|
+
// Tag open state
|
|
902
|
+
//------------------------------------------------------------------
|
|
860
903
|
[TAG_OPEN_STATE](cp) {
|
|
861
904
|
if (cp === $.EXCLAMATION_MARK) {
|
|
862
905
|
this.state = MARKUP_DECLARATION_OPEN_STATE;
|
|
@@ -879,6 +922,8 @@ var require_tokenizer = __commonJS({
|
|
|
879
922
|
this._reconsumeInState(DATA_STATE);
|
|
880
923
|
}
|
|
881
924
|
}
|
|
925
|
+
// End tag open state
|
|
926
|
+
//------------------------------------------------------------------
|
|
882
927
|
[END_TAG_OPEN_STATE](cp) {
|
|
883
928
|
if (isAsciiLetter(cp)) {
|
|
884
929
|
this._createEndTagToken();
|
|
@@ -896,6 +941,8 @@ var require_tokenizer = __commonJS({
|
|
|
896
941
|
this._reconsumeInState(BOGUS_COMMENT_STATE);
|
|
897
942
|
}
|
|
898
943
|
}
|
|
944
|
+
// Tag name state
|
|
945
|
+
//------------------------------------------------------------------
|
|
899
946
|
[TAG_NAME_STATE](cp) {
|
|
900
947
|
if (isWhitespace(cp)) {
|
|
901
948
|
this.state = BEFORE_ATTRIBUTE_NAME_STATE;
|
|
@@ -916,6 +963,8 @@ var require_tokenizer = __commonJS({
|
|
|
916
963
|
this.currentToken.tagName += toChar(cp);
|
|
917
964
|
}
|
|
918
965
|
}
|
|
966
|
+
// RCDATA less-than sign state
|
|
967
|
+
//------------------------------------------------------------------
|
|
919
968
|
[RCDATA_LESS_THAN_SIGN_STATE](cp) {
|
|
920
969
|
if (cp === $.SOLIDUS) {
|
|
921
970
|
this.tempBuff = [];
|
|
@@ -925,6 +974,8 @@ var require_tokenizer = __commonJS({
|
|
|
925
974
|
this._reconsumeInState(RCDATA_STATE);
|
|
926
975
|
}
|
|
927
976
|
}
|
|
977
|
+
// RCDATA end tag open state
|
|
978
|
+
//------------------------------------------------------------------
|
|
928
979
|
[RCDATA_END_TAG_OPEN_STATE](cp) {
|
|
929
980
|
if (isAsciiLetter(cp)) {
|
|
930
981
|
this._createEndTagToken();
|
|
@@ -934,6 +985,8 @@ var require_tokenizer = __commonJS({
|
|
|
934
985
|
this._reconsumeInState(RCDATA_STATE);
|
|
935
986
|
}
|
|
936
987
|
}
|
|
988
|
+
// RCDATA end tag name state
|
|
989
|
+
//------------------------------------------------------------------
|
|
937
990
|
[RCDATA_END_TAG_NAME_STATE](cp) {
|
|
938
991
|
if (isAsciiUpper(cp)) {
|
|
939
992
|
this.currentToken.tagName += toAsciiLowerChar(cp);
|
|
@@ -962,6 +1015,8 @@ var require_tokenizer = __commonJS({
|
|
|
962
1015
|
this._reconsumeInState(RCDATA_STATE);
|
|
963
1016
|
}
|
|
964
1017
|
}
|
|
1018
|
+
// RAWTEXT less-than sign state
|
|
1019
|
+
//------------------------------------------------------------------
|
|
965
1020
|
[RAWTEXT_LESS_THAN_SIGN_STATE](cp) {
|
|
966
1021
|
if (cp === $.SOLIDUS) {
|
|
967
1022
|
this.tempBuff = [];
|
|
@@ -971,6 +1026,8 @@ var require_tokenizer = __commonJS({
|
|
|
971
1026
|
this._reconsumeInState(RAWTEXT_STATE);
|
|
972
1027
|
}
|
|
973
1028
|
}
|
|
1029
|
+
// RAWTEXT end tag open state
|
|
1030
|
+
//------------------------------------------------------------------
|
|
974
1031
|
[RAWTEXT_END_TAG_OPEN_STATE](cp) {
|
|
975
1032
|
if (isAsciiLetter(cp)) {
|
|
976
1033
|
this._createEndTagToken();
|
|
@@ -980,6 +1037,8 @@ var require_tokenizer = __commonJS({
|
|
|
980
1037
|
this._reconsumeInState(RAWTEXT_STATE);
|
|
981
1038
|
}
|
|
982
1039
|
}
|
|
1040
|
+
// RAWTEXT end tag name state
|
|
1041
|
+
//------------------------------------------------------------------
|
|
983
1042
|
[RAWTEXT_END_TAG_NAME_STATE](cp) {
|
|
984
1043
|
if (isAsciiUpper(cp)) {
|
|
985
1044
|
this.currentToken.tagName += toAsciiLowerChar(cp);
|
|
@@ -1008,6 +1067,8 @@ var require_tokenizer = __commonJS({
|
|
|
1008
1067
|
this._reconsumeInState(RAWTEXT_STATE);
|
|
1009
1068
|
}
|
|
1010
1069
|
}
|
|
1070
|
+
// Script data less-than sign state
|
|
1071
|
+
//------------------------------------------------------------------
|
|
1011
1072
|
[SCRIPT_DATA_LESS_THAN_SIGN_STATE](cp) {
|
|
1012
1073
|
if (cp === $.SOLIDUS) {
|
|
1013
1074
|
this.tempBuff = [];
|
|
@@ -1020,6 +1081,8 @@ var require_tokenizer = __commonJS({
|
|
|
1020
1081
|
this._reconsumeInState(SCRIPT_DATA_STATE);
|
|
1021
1082
|
}
|
|
1022
1083
|
}
|
|
1084
|
+
// Script data end tag open state
|
|
1085
|
+
//------------------------------------------------------------------
|
|
1023
1086
|
[SCRIPT_DATA_END_TAG_OPEN_STATE](cp) {
|
|
1024
1087
|
if (isAsciiLetter(cp)) {
|
|
1025
1088
|
this._createEndTagToken();
|
|
@@ -1029,6 +1092,8 @@ var require_tokenizer = __commonJS({
|
|
|
1029
1092
|
this._reconsumeInState(SCRIPT_DATA_STATE);
|
|
1030
1093
|
}
|
|
1031
1094
|
}
|
|
1095
|
+
// Script data end tag name state
|
|
1096
|
+
//------------------------------------------------------------------
|
|
1032
1097
|
[SCRIPT_DATA_END_TAG_NAME_STATE](cp) {
|
|
1033
1098
|
if (isAsciiUpper(cp)) {
|
|
1034
1099
|
this.currentToken.tagName += toAsciiLowerChar(cp);
|
|
@@ -1055,6 +1120,8 @@ var require_tokenizer = __commonJS({
|
|
|
1055
1120
|
this._reconsumeInState(SCRIPT_DATA_STATE);
|
|
1056
1121
|
}
|
|
1057
1122
|
}
|
|
1123
|
+
// Script data escape start state
|
|
1124
|
+
//------------------------------------------------------------------
|
|
1058
1125
|
[SCRIPT_DATA_ESCAPE_START_STATE](cp) {
|
|
1059
1126
|
if (cp === $.HYPHEN_MINUS) {
|
|
1060
1127
|
this.state = SCRIPT_DATA_ESCAPE_START_DASH_STATE;
|
|
@@ -1063,6 +1130,8 @@ var require_tokenizer = __commonJS({
|
|
|
1063
1130
|
this._reconsumeInState(SCRIPT_DATA_STATE);
|
|
1064
1131
|
}
|
|
1065
1132
|
}
|
|
1133
|
+
// Script data escape start dash state
|
|
1134
|
+
//------------------------------------------------------------------
|
|
1066
1135
|
[SCRIPT_DATA_ESCAPE_START_DASH_STATE](cp) {
|
|
1067
1136
|
if (cp === $.HYPHEN_MINUS) {
|
|
1068
1137
|
this.state = SCRIPT_DATA_ESCAPED_DASH_DASH_STATE;
|
|
@@ -1071,6 +1140,8 @@ var require_tokenizer = __commonJS({
|
|
|
1071
1140
|
this._reconsumeInState(SCRIPT_DATA_STATE);
|
|
1072
1141
|
}
|
|
1073
1142
|
}
|
|
1143
|
+
// Script data escaped state
|
|
1144
|
+
//------------------------------------------------------------------
|
|
1074
1145
|
[SCRIPT_DATA_ESCAPED_STATE](cp) {
|
|
1075
1146
|
if (cp === $.HYPHEN_MINUS) {
|
|
1076
1147
|
this.state = SCRIPT_DATA_ESCAPED_DASH_STATE;
|
|
@@ -1087,6 +1158,8 @@ var require_tokenizer = __commonJS({
|
|
|
1087
1158
|
this._emitCodePoint(cp);
|
|
1088
1159
|
}
|
|
1089
1160
|
}
|
|
1161
|
+
// Script data escaped dash state
|
|
1162
|
+
//------------------------------------------------------------------
|
|
1090
1163
|
[SCRIPT_DATA_ESCAPED_DASH_STATE](cp) {
|
|
1091
1164
|
if (cp === $.HYPHEN_MINUS) {
|
|
1092
1165
|
this.state = SCRIPT_DATA_ESCAPED_DASH_DASH_STATE;
|
|
@@ -1105,6 +1178,8 @@ var require_tokenizer = __commonJS({
|
|
|
1105
1178
|
this._emitCodePoint(cp);
|
|
1106
1179
|
}
|
|
1107
1180
|
}
|
|
1181
|
+
// Script data escaped dash dash state
|
|
1182
|
+
//------------------------------------------------------------------
|
|
1108
1183
|
[SCRIPT_DATA_ESCAPED_DASH_DASH_STATE](cp) {
|
|
1109
1184
|
if (cp === $.HYPHEN_MINUS) {
|
|
1110
1185
|
this._emitChars("-");
|
|
@@ -1125,6 +1200,8 @@ var require_tokenizer = __commonJS({
|
|
|
1125
1200
|
this._emitCodePoint(cp);
|
|
1126
1201
|
}
|
|
1127
1202
|
}
|
|
1203
|
+
// Script data escaped less-than sign state
|
|
1204
|
+
//------------------------------------------------------------------
|
|
1128
1205
|
[SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE](cp) {
|
|
1129
1206
|
if (cp === $.SOLIDUS) {
|
|
1130
1207
|
this.tempBuff = [];
|
|
@@ -1138,6 +1215,8 @@ var require_tokenizer = __commonJS({
|
|
|
1138
1215
|
this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
|
|
1139
1216
|
}
|
|
1140
1217
|
}
|
|
1218
|
+
// Script data escaped end tag open state
|
|
1219
|
+
//------------------------------------------------------------------
|
|
1141
1220
|
[SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE](cp) {
|
|
1142
1221
|
if (isAsciiLetter(cp)) {
|
|
1143
1222
|
this._createEndTagToken();
|
|
@@ -1147,6 +1226,8 @@ var require_tokenizer = __commonJS({
|
|
|
1147
1226
|
this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
|
|
1148
1227
|
}
|
|
1149
1228
|
}
|
|
1229
|
+
// Script data escaped end tag name state
|
|
1230
|
+
//------------------------------------------------------------------
|
|
1150
1231
|
[SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE](cp) {
|
|
1151
1232
|
if (isAsciiUpper(cp)) {
|
|
1152
1233
|
this.currentToken.tagName += toAsciiLowerChar(cp);
|
|
@@ -1175,6 +1256,8 @@ var require_tokenizer = __commonJS({
|
|
|
1175
1256
|
this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
|
|
1176
1257
|
}
|
|
1177
1258
|
}
|
|
1259
|
+
// Script data double escape start state
|
|
1260
|
+
//------------------------------------------------------------------
|
|
1178
1261
|
[SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE](cp) {
|
|
1179
1262
|
if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) {
|
|
1180
1263
|
this.state = this._isTempBufferEqualToScriptString() ? SCRIPT_DATA_DOUBLE_ESCAPED_STATE : SCRIPT_DATA_ESCAPED_STATE;
|
|
@@ -1189,6 +1272,8 @@ var require_tokenizer = __commonJS({
|
|
|
1189
1272
|
this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE);
|
|
1190
1273
|
}
|
|
1191
1274
|
}
|
|
1275
|
+
// Script data double escaped state
|
|
1276
|
+
//------------------------------------------------------------------
|
|
1192
1277
|
[SCRIPT_DATA_DOUBLE_ESCAPED_STATE](cp) {
|
|
1193
1278
|
if (cp === $.HYPHEN_MINUS) {
|
|
1194
1279
|
this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE;
|
|
@@ -1206,6 +1291,8 @@ var require_tokenizer = __commonJS({
|
|
|
1206
1291
|
this._emitCodePoint(cp);
|
|
1207
1292
|
}
|
|
1208
1293
|
}
|
|
1294
|
+
// Script data double escaped dash state
|
|
1295
|
+
//------------------------------------------------------------------
|
|
1209
1296
|
[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE](cp) {
|
|
1210
1297
|
if (cp === $.HYPHEN_MINUS) {
|
|
1211
1298
|
this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE;
|
|
@@ -1225,6 +1312,8 @@ var require_tokenizer = __commonJS({
|
|
|
1225
1312
|
this._emitCodePoint(cp);
|
|
1226
1313
|
}
|
|
1227
1314
|
}
|
|
1315
|
+
// Script data double escaped dash dash state
|
|
1316
|
+
//------------------------------------------------------------------
|
|
1228
1317
|
[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE](cp) {
|
|
1229
1318
|
if (cp === $.HYPHEN_MINUS) {
|
|
1230
1319
|
this._emitChars("-");
|
|
@@ -1246,6 +1335,8 @@ var require_tokenizer = __commonJS({
|
|
|
1246
1335
|
this._emitCodePoint(cp);
|
|
1247
1336
|
}
|
|
1248
1337
|
}
|
|
1338
|
+
// Script data double escaped less-than sign state
|
|
1339
|
+
//------------------------------------------------------------------
|
|
1249
1340
|
[SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE](cp) {
|
|
1250
1341
|
if (cp === $.SOLIDUS) {
|
|
1251
1342
|
this.tempBuff = [];
|
|
@@ -1255,6 +1346,8 @@ var require_tokenizer = __commonJS({
|
|
|
1255
1346
|
this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE);
|
|
1256
1347
|
}
|
|
1257
1348
|
}
|
|
1349
|
+
// Script data double escape end state
|
|
1350
|
+
//------------------------------------------------------------------
|
|
1258
1351
|
[SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE](cp) {
|
|
1259
1352
|
if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) {
|
|
1260
1353
|
this.state = this._isTempBufferEqualToScriptString() ? SCRIPT_DATA_ESCAPED_STATE : SCRIPT_DATA_DOUBLE_ESCAPED_STATE;
|
|
@@ -1269,6 +1362,8 @@ var require_tokenizer = __commonJS({
|
|
|
1269
1362
|
this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE);
|
|
1270
1363
|
}
|
|
1271
1364
|
}
|
|
1365
|
+
// Before attribute name state
|
|
1366
|
+
//------------------------------------------------------------------
|
|
1272
1367
|
[BEFORE_ATTRIBUTE_NAME_STATE](cp) {
|
|
1273
1368
|
if (isWhitespace(cp)) {
|
|
1274
1369
|
return;
|
|
@@ -1284,6 +1379,8 @@ var require_tokenizer = __commonJS({
|
|
|
1284
1379
|
this._reconsumeInState(ATTRIBUTE_NAME_STATE);
|
|
1285
1380
|
}
|
|
1286
1381
|
}
|
|
1382
|
+
// Attribute name state
|
|
1383
|
+
//------------------------------------------------------------------
|
|
1287
1384
|
[ATTRIBUTE_NAME_STATE](cp) {
|
|
1288
1385
|
if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN || cp === $.EOF) {
|
|
1289
1386
|
this._leaveAttrName(AFTER_ATTRIBUTE_NAME_STATE);
|
|
@@ -1302,6 +1399,8 @@ var require_tokenizer = __commonJS({
|
|
|
1302
1399
|
this.currentAttr.name += toChar(cp);
|
|
1303
1400
|
}
|
|
1304
1401
|
}
|
|
1402
|
+
// After attribute name state
|
|
1403
|
+
//------------------------------------------------------------------
|
|
1305
1404
|
[AFTER_ATTRIBUTE_NAME_STATE](cp) {
|
|
1306
1405
|
if (isWhitespace(cp)) {
|
|
1307
1406
|
return;
|
|
@@ -1321,6 +1420,8 @@ var require_tokenizer = __commonJS({
|
|
|
1321
1420
|
this._reconsumeInState(ATTRIBUTE_NAME_STATE);
|
|
1322
1421
|
}
|
|
1323
1422
|
}
|
|
1423
|
+
// Before attribute value state
|
|
1424
|
+
//------------------------------------------------------------------
|
|
1324
1425
|
[BEFORE_ATTRIBUTE_VALUE_STATE](cp) {
|
|
1325
1426
|
if (isWhitespace(cp)) {
|
|
1326
1427
|
return;
|
|
@@ -1337,6 +1438,8 @@ var require_tokenizer = __commonJS({
|
|
|
1337
1438
|
this._reconsumeInState(ATTRIBUTE_VALUE_UNQUOTED_STATE);
|
|
1338
1439
|
}
|
|
1339
1440
|
}
|
|
1441
|
+
// Attribute value (double-quoted) state
|
|
1442
|
+
//------------------------------------------------------------------
|
|
1340
1443
|
[ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE](cp) {
|
|
1341
1444
|
if (cp === $.QUOTATION_MARK) {
|
|
1342
1445
|
this.state = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE;
|
|
@@ -1353,6 +1456,8 @@ var require_tokenizer = __commonJS({
|
|
|
1353
1456
|
this.currentAttr.value += toChar(cp);
|
|
1354
1457
|
}
|
|
1355
1458
|
}
|
|
1459
|
+
// Attribute value (single-quoted) state
|
|
1460
|
+
//------------------------------------------------------------------
|
|
1356
1461
|
[ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE](cp) {
|
|
1357
1462
|
if (cp === $.APOSTROPHE) {
|
|
1358
1463
|
this.state = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE;
|
|
@@ -1369,6 +1474,8 @@ var require_tokenizer = __commonJS({
|
|
|
1369
1474
|
this.currentAttr.value += toChar(cp);
|
|
1370
1475
|
}
|
|
1371
1476
|
}
|
|
1477
|
+
// Attribute value (unquoted) state
|
|
1478
|
+
//------------------------------------------------------------------
|
|
1372
1479
|
[ATTRIBUTE_VALUE_UNQUOTED_STATE](cp) {
|
|
1373
1480
|
if (isWhitespace(cp)) {
|
|
1374
1481
|
this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE);
|
|
@@ -1391,6 +1498,8 @@ var require_tokenizer = __commonJS({
|
|
|
1391
1498
|
this.currentAttr.value += toChar(cp);
|
|
1392
1499
|
}
|
|
1393
1500
|
}
|
|
1501
|
+
// After attribute value (quoted) state
|
|
1502
|
+
//------------------------------------------------------------------
|
|
1394
1503
|
[AFTER_ATTRIBUTE_VALUE_QUOTED_STATE](cp) {
|
|
1395
1504
|
if (isWhitespace(cp)) {
|
|
1396
1505
|
this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE);
|
|
@@ -1407,6 +1516,8 @@ var require_tokenizer = __commonJS({
|
|
|
1407
1516
|
this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE);
|
|
1408
1517
|
}
|
|
1409
1518
|
}
|
|
1519
|
+
// Self-closing start tag state
|
|
1520
|
+
//------------------------------------------------------------------
|
|
1410
1521
|
[SELF_CLOSING_START_TAG_STATE](cp) {
|
|
1411
1522
|
if (cp === $.GREATER_THAN_SIGN) {
|
|
1412
1523
|
this.currentToken.selfClosing = true;
|
|
@@ -1420,6 +1531,8 @@ var require_tokenizer = __commonJS({
|
|
|
1420
1531
|
this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE);
|
|
1421
1532
|
}
|
|
1422
1533
|
}
|
|
1534
|
+
// Bogus comment state
|
|
1535
|
+
//------------------------------------------------------------------
|
|
1423
1536
|
[BOGUS_COMMENT_STATE](cp) {
|
|
1424
1537
|
if (cp === $.GREATER_THAN_SIGN) {
|
|
1425
1538
|
this.state = DATA_STATE;
|
|
@@ -1434,6 +1547,8 @@ var require_tokenizer = __commonJS({
|
|
|
1434
1547
|
this.currentToken.data += toChar(cp);
|
|
1435
1548
|
}
|
|
1436
1549
|
}
|
|
1550
|
+
// Markup declaration open state
|
|
1551
|
+
//------------------------------------------------------------------
|
|
1437
1552
|
[MARKUP_DECLARATION_OPEN_STATE](cp) {
|
|
1438
1553
|
if (this._consumeSequenceIfMatch($$.DASH_DASH_STRING, cp, true)) {
|
|
1439
1554
|
this._createCommentToken();
|
|
@@ -1455,6 +1570,8 @@ var require_tokenizer = __commonJS({
|
|
|
1455
1570
|
this._reconsumeInState(BOGUS_COMMENT_STATE);
|
|
1456
1571
|
}
|
|
1457
1572
|
}
|
|
1573
|
+
// Comment start state
|
|
1574
|
+
//------------------------------------------------------------------
|
|
1458
1575
|
[COMMENT_START_STATE](cp) {
|
|
1459
1576
|
if (cp === $.HYPHEN_MINUS) {
|
|
1460
1577
|
this.state = COMMENT_START_DASH_STATE;
|
|
@@ -1466,6 +1583,8 @@ var require_tokenizer = __commonJS({
|
|
|
1466
1583
|
this._reconsumeInState(COMMENT_STATE);
|
|
1467
1584
|
}
|
|
1468
1585
|
}
|
|
1586
|
+
// Comment start dash state
|
|
1587
|
+
//------------------------------------------------------------------
|
|
1469
1588
|
[COMMENT_START_DASH_STATE](cp) {
|
|
1470
1589
|
if (cp === $.HYPHEN_MINUS) {
|
|
1471
1590
|
this.state = COMMENT_END_STATE;
|
|
@@ -1482,6 +1601,8 @@ var require_tokenizer = __commonJS({
|
|
|
1482
1601
|
this._reconsumeInState(COMMENT_STATE);
|
|
1483
1602
|
}
|
|
1484
1603
|
}
|
|
1604
|
+
// Comment state
|
|
1605
|
+
//------------------------------------------------------------------
|
|
1485
1606
|
[COMMENT_STATE](cp) {
|
|
1486
1607
|
if (cp === $.HYPHEN_MINUS) {
|
|
1487
1608
|
this.state = COMMENT_END_DASH_STATE;
|
|
@@ -1499,6 +1620,8 @@ var require_tokenizer = __commonJS({
|
|
|
1499
1620
|
this.currentToken.data += toChar(cp);
|
|
1500
1621
|
}
|
|
1501
1622
|
}
|
|
1623
|
+
// Comment less-than sign state
|
|
1624
|
+
//------------------------------------------------------------------
|
|
1502
1625
|
[COMMENT_LESS_THAN_SIGN_STATE](cp) {
|
|
1503
1626
|
if (cp === $.EXCLAMATION_MARK) {
|
|
1504
1627
|
this.currentToken.data += "!";
|
|
@@ -1509,6 +1632,8 @@ var require_tokenizer = __commonJS({
|
|
|
1509
1632
|
this._reconsumeInState(COMMENT_STATE);
|
|
1510
1633
|
}
|
|
1511
1634
|
}
|
|
1635
|
+
// Comment less-than sign bang state
|
|
1636
|
+
//------------------------------------------------------------------
|
|
1512
1637
|
[COMMENT_LESS_THAN_SIGN_BANG_STATE](cp) {
|
|
1513
1638
|
if (cp === $.HYPHEN_MINUS) {
|
|
1514
1639
|
this.state = COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE;
|
|
@@ -1516,6 +1641,8 @@ var require_tokenizer = __commonJS({
|
|
|
1516
1641
|
this._reconsumeInState(COMMENT_STATE);
|
|
1517
1642
|
}
|
|
1518
1643
|
}
|
|
1644
|
+
// Comment less-than sign bang dash state
|
|
1645
|
+
//------------------------------------------------------------------
|
|
1519
1646
|
[COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE](cp) {
|
|
1520
1647
|
if (cp === $.HYPHEN_MINUS) {
|
|
1521
1648
|
this.state = COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE;
|
|
@@ -1523,12 +1650,16 @@ var require_tokenizer = __commonJS({
|
|
|
1523
1650
|
this._reconsumeInState(COMMENT_END_DASH_STATE);
|
|
1524
1651
|
}
|
|
1525
1652
|
}
|
|
1653
|
+
// Comment less-than sign bang dash dash state
|
|
1654
|
+
//------------------------------------------------------------------
|
|
1526
1655
|
[COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE](cp) {
|
|
1527
1656
|
if (cp !== $.GREATER_THAN_SIGN && cp !== $.EOF) {
|
|
1528
1657
|
this._err(ERR.nestedComment);
|
|
1529
1658
|
}
|
|
1530
1659
|
this._reconsumeInState(COMMENT_END_STATE);
|
|
1531
1660
|
}
|
|
1661
|
+
// Comment end dash state
|
|
1662
|
+
//------------------------------------------------------------------
|
|
1532
1663
|
[COMMENT_END_DASH_STATE](cp) {
|
|
1533
1664
|
if (cp === $.HYPHEN_MINUS) {
|
|
1534
1665
|
this.state = COMMENT_END_STATE;
|
|
@@ -1541,6 +1672,8 @@ var require_tokenizer = __commonJS({
|
|
|
1541
1672
|
this._reconsumeInState(COMMENT_STATE);
|
|
1542
1673
|
}
|
|
1543
1674
|
}
|
|
1675
|
+
// Comment end state
|
|
1676
|
+
//------------------------------------------------------------------
|
|
1544
1677
|
[COMMENT_END_STATE](cp) {
|
|
1545
1678
|
if (cp === $.GREATER_THAN_SIGN) {
|
|
1546
1679
|
this.state = DATA_STATE;
|
|
@@ -1558,6 +1691,8 @@ var require_tokenizer = __commonJS({
|
|
|
1558
1691
|
this._reconsumeInState(COMMENT_STATE);
|
|
1559
1692
|
}
|
|
1560
1693
|
}
|
|
1694
|
+
// Comment end bang state
|
|
1695
|
+
//------------------------------------------------------------------
|
|
1561
1696
|
[COMMENT_END_BANG_STATE](cp) {
|
|
1562
1697
|
if (cp === $.HYPHEN_MINUS) {
|
|
1563
1698
|
this.currentToken.data += "--!";
|
|
@@ -1575,6 +1710,8 @@ var require_tokenizer = __commonJS({
|
|
|
1575
1710
|
this._reconsumeInState(COMMENT_STATE);
|
|
1576
1711
|
}
|
|
1577
1712
|
}
|
|
1713
|
+
// DOCTYPE state
|
|
1714
|
+
//------------------------------------------------------------------
|
|
1578
1715
|
[DOCTYPE_STATE](cp) {
|
|
1579
1716
|
if (isWhitespace(cp)) {
|
|
1580
1717
|
this.state = BEFORE_DOCTYPE_NAME_STATE;
|
|
@@ -1591,6 +1728,8 @@ var require_tokenizer = __commonJS({
|
|
|
1591
1728
|
this._reconsumeInState(BEFORE_DOCTYPE_NAME_STATE);
|
|
1592
1729
|
}
|
|
1593
1730
|
}
|
|
1731
|
+
// Before DOCTYPE name state
|
|
1732
|
+
//------------------------------------------------------------------
|
|
1594
1733
|
[BEFORE_DOCTYPE_NAME_STATE](cp) {
|
|
1595
1734
|
if (isWhitespace(cp)) {
|
|
1596
1735
|
return;
|
|
@@ -1619,6 +1758,8 @@ var require_tokenizer = __commonJS({
|
|
|
1619
1758
|
this.state = DOCTYPE_NAME_STATE;
|
|
1620
1759
|
}
|
|
1621
1760
|
}
|
|
1761
|
+
// DOCTYPE name state
|
|
1762
|
+
//------------------------------------------------------------------
|
|
1622
1763
|
[DOCTYPE_NAME_STATE](cp) {
|
|
1623
1764
|
if (isWhitespace(cp)) {
|
|
1624
1765
|
this.state = AFTER_DOCTYPE_NAME_STATE;
|
|
@@ -1639,6 +1780,8 @@ var require_tokenizer = __commonJS({
|
|
|
1639
1780
|
this.currentToken.name += toChar(cp);
|
|
1640
1781
|
}
|
|
1641
1782
|
}
|
|
1783
|
+
// After DOCTYPE name state
|
|
1784
|
+
//------------------------------------------------------------------
|
|
1642
1785
|
[AFTER_DOCTYPE_NAME_STATE](cp) {
|
|
1643
1786
|
if (isWhitespace(cp)) {
|
|
1644
1787
|
return;
|
|
@@ -1661,6 +1804,8 @@ var require_tokenizer = __commonJS({
|
|
|
1661
1804
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1662
1805
|
}
|
|
1663
1806
|
}
|
|
1807
|
+
// After DOCTYPE public keyword state
|
|
1808
|
+
//------------------------------------------------------------------
|
|
1664
1809
|
[AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE](cp) {
|
|
1665
1810
|
if (isWhitespace(cp)) {
|
|
1666
1811
|
this.state = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
|
|
@@ -1688,6 +1833,8 @@ var require_tokenizer = __commonJS({
|
|
|
1688
1833
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1689
1834
|
}
|
|
1690
1835
|
}
|
|
1836
|
+
// Before DOCTYPE public identifier state
|
|
1837
|
+
//------------------------------------------------------------------
|
|
1691
1838
|
[BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE](cp) {
|
|
1692
1839
|
if (isWhitespace(cp)) {
|
|
1693
1840
|
return;
|
|
@@ -1714,6 +1861,8 @@ var require_tokenizer = __commonJS({
|
|
|
1714
1861
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1715
1862
|
}
|
|
1716
1863
|
}
|
|
1864
|
+
// DOCTYPE public identifier (double-quoted) state
|
|
1865
|
+
//------------------------------------------------------------------
|
|
1717
1866
|
[DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE](cp) {
|
|
1718
1867
|
if (cp === $.QUOTATION_MARK) {
|
|
1719
1868
|
this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
|
|
@@ -1734,6 +1883,8 @@ var require_tokenizer = __commonJS({
|
|
|
1734
1883
|
this.currentToken.publicId += toChar(cp);
|
|
1735
1884
|
}
|
|
1736
1885
|
}
|
|
1886
|
+
// DOCTYPE public identifier (single-quoted) state
|
|
1887
|
+
//------------------------------------------------------------------
|
|
1737
1888
|
[DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE](cp) {
|
|
1738
1889
|
if (cp === $.APOSTROPHE) {
|
|
1739
1890
|
this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
|
|
@@ -1754,6 +1905,8 @@ var require_tokenizer = __commonJS({
|
|
|
1754
1905
|
this.currentToken.publicId += toChar(cp);
|
|
1755
1906
|
}
|
|
1756
1907
|
}
|
|
1908
|
+
// After DOCTYPE public identifier state
|
|
1909
|
+
//------------------------------------------------------------------
|
|
1757
1910
|
[AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE](cp) {
|
|
1758
1911
|
if (isWhitespace(cp)) {
|
|
1759
1912
|
this.state = BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE;
|
|
@@ -1779,6 +1932,8 @@ var require_tokenizer = __commonJS({
|
|
|
1779
1932
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1780
1933
|
}
|
|
1781
1934
|
}
|
|
1935
|
+
// Between DOCTYPE public and system identifiers state
|
|
1936
|
+
//------------------------------------------------------------------
|
|
1782
1937
|
[BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE](cp) {
|
|
1783
1938
|
if (isWhitespace(cp)) {
|
|
1784
1939
|
return;
|
|
@@ -1803,6 +1958,8 @@ var require_tokenizer = __commonJS({
|
|
|
1803
1958
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1804
1959
|
}
|
|
1805
1960
|
}
|
|
1961
|
+
// After DOCTYPE system keyword state
|
|
1962
|
+
//------------------------------------------------------------------
|
|
1806
1963
|
[AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE](cp) {
|
|
1807
1964
|
if (isWhitespace(cp)) {
|
|
1808
1965
|
this.state = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
|
|
@@ -1830,6 +1987,8 @@ var require_tokenizer = __commonJS({
|
|
|
1830
1987
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1831
1988
|
}
|
|
1832
1989
|
}
|
|
1990
|
+
// Before DOCTYPE system identifier state
|
|
1991
|
+
//------------------------------------------------------------------
|
|
1833
1992
|
[BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE](cp) {
|
|
1834
1993
|
if (isWhitespace(cp)) {
|
|
1835
1994
|
return;
|
|
@@ -1856,6 +2015,8 @@ var require_tokenizer = __commonJS({
|
|
|
1856
2015
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1857
2016
|
}
|
|
1858
2017
|
}
|
|
2018
|
+
// DOCTYPE system identifier (double-quoted) state
|
|
2019
|
+
//------------------------------------------------------------------
|
|
1859
2020
|
[DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE](cp) {
|
|
1860
2021
|
if (cp === $.QUOTATION_MARK) {
|
|
1861
2022
|
this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
|
|
@@ -1876,6 +2037,8 @@ var require_tokenizer = __commonJS({
|
|
|
1876
2037
|
this.currentToken.systemId += toChar(cp);
|
|
1877
2038
|
}
|
|
1878
2039
|
}
|
|
2040
|
+
// DOCTYPE system identifier (single-quoted) state
|
|
2041
|
+
//------------------------------------------------------------------
|
|
1879
2042
|
[DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE](cp) {
|
|
1880
2043
|
if (cp === $.APOSTROPHE) {
|
|
1881
2044
|
this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE;
|
|
@@ -1896,6 +2059,8 @@ var require_tokenizer = __commonJS({
|
|
|
1896
2059
|
this.currentToken.systemId += toChar(cp);
|
|
1897
2060
|
}
|
|
1898
2061
|
}
|
|
2062
|
+
// After DOCTYPE system identifier state
|
|
2063
|
+
//------------------------------------------------------------------
|
|
1899
2064
|
[AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE](cp) {
|
|
1900
2065
|
if (isWhitespace(cp)) {
|
|
1901
2066
|
return;
|
|
@@ -1913,6 +2078,8 @@ var require_tokenizer = __commonJS({
|
|
|
1913
2078
|
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
|
|
1914
2079
|
}
|
|
1915
2080
|
}
|
|
2081
|
+
// Bogus DOCTYPE state
|
|
2082
|
+
//------------------------------------------------------------------
|
|
1916
2083
|
[BOGUS_DOCTYPE_STATE](cp) {
|
|
1917
2084
|
if (cp === $.GREATER_THAN_SIGN) {
|
|
1918
2085
|
this._emitCurrentToken();
|
|
@@ -1924,6 +2091,8 @@ var require_tokenizer = __commonJS({
|
|
|
1924
2091
|
this._emitEOFToken();
|
|
1925
2092
|
}
|
|
1926
2093
|
}
|
|
2094
|
+
// CDATA section state
|
|
2095
|
+
//------------------------------------------------------------------
|
|
1927
2096
|
[CDATA_SECTION_STATE](cp) {
|
|
1928
2097
|
if (cp === $.RIGHT_SQUARE_BRACKET) {
|
|
1929
2098
|
this.state = CDATA_SECTION_BRACKET_STATE;
|
|
@@ -1934,6 +2103,8 @@ var require_tokenizer = __commonJS({
|
|
|
1934
2103
|
this._emitCodePoint(cp);
|
|
1935
2104
|
}
|
|
1936
2105
|
}
|
|
2106
|
+
// CDATA section bracket state
|
|
2107
|
+
//------------------------------------------------------------------
|
|
1937
2108
|
[CDATA_SECTION_BRACKET_STATE](cp) {
|
|
1938
2109
|
if (cp === $.RIGHT_SQUARE_BRACKET) {
|
|
1939
2110
|
this.state = CDATA_SECTION_END_STATE;
|
|
@@ -1942,6 +2113,8 @@ var require_tokenizer = __commonJS({
|
|
|
1942
2113
|
this._reconsumeInState(CDATA_SECTION_STATE);
|
|
1943
2114
|
}
|
|
1944
2115
|
}
|
|
2116
|
+
// CDATA section end state
|
|
2117
|
+
//------------------------------------------------------------------
|
|
1945
2118
|
[CDATA_SECTION_END_STATE](cp) {
|
|
1946
2119
|
if (cp === $.GREATER_THAN_SIGN) {
|
|
1947
2120
|
this.state = DATA_STATE;
|
|
@@ -1952,6 +2125,8 @@ var require_tokenizer = __commonJS({
|
|
|
1952
2125
|
this._reconsumeInState(CDATA_SECTION_STATE);
|
|
1953
2126
|
}
|
|
1954
2127
|
}
|
|
2128
|
+
// Character reference state
|
|
2129
|
+
//------------------------------------------------------------------
|
|
1955
2130
|
[CHARACTER_REFERENCE_STATE](cp) {
|
|
1956
2131
|
this.tempBuff = [$.AMPERSAND];
|
|
1957
2132
|
if (cp === $.NUMBER_SIGN) {
|
|
@@ -1964,6 +2139,8 @@ var require_tokenizer = __commonJS({
|
|
|
1964
2139
|
this._reconsumeInState(this.returnState);
|
|
1965
2140
|
}
|
|
1966
2141
|
}
|
|
2142
|
+
// Named character reference state
|
|
2143
|
+
//------------------------------------------------------------------
|
|
1967
2144
|
[NAMED_CHARACTER_REFERENCE_STATE](cp) {
|
|
1968
2145
|
const matchResult = this._matchNamedCharacterReference(cp);
|
|
1969
2146
|
if (this._ensureHibernation()) {
|
|
@@ -1983,6 +2160,8 @@ var require_tokenizer = __commonJS({
|
|
|
1983
2160
|
this.state = AMBIGUOUS_AMPERSAND_STATE;
|
|
1984
2161
|
}
|
|
1985
2162
|
}
|
|
2163
|
+
// Ambiguos ampersand state
|
|
2164
|
+
//------------------------------------------------------------------
|
|
1986
2165
|
[AMBIGUOUS_AMPERSAND_STATE](cp) {
|
|
1987
2166
|
if (isAsciiAlphaNumeric(cp)) {
|
|
1988
2167
|
if (this._isCharacterReferenceInAttribute()) {
|
|
@@ -1997,6 +2176,8 @@ var require_tokenizer = __commonJS({
|
|
|
1997
2176
|
this._reconsumeInState(this.returnState);
|
|
1998
2177
|
}
|
|
1999
2178
|
}
|
|
2179
|
+
// Numeric character reference state
|
|
2180
|
+
//------------------------------------------------------------------
|
|
2000
2181
|
[NUMERIC_CHARACTER_REFERENCE_STATE](cp) {
|
|
2001
2182
|
this.charRefCode = 0;
|
|
2002
2183
|
if (cp === $.LATIN_SMALL_X || cp === $.LATIN_CAPITAL_X) {
|
|
@@ -2006,6 +2187,8 @@ var require_tokenizer = __commonJS({
|
|
|
2006
2187
|
this._reconsumeInState(DECIMAL_CHARACTER_REFERENCE_START_STATE);
|
|
2007
2188
|
}
|
|
2008
2189
|
}
|
|
2190
|
+
// Hexademical character reference start state
|
|
2191
|
+
//------------------------------------------------------------------
|
|
2009
2192
|
[HEXADEMICAL_CHARACTER_REFERENCE_START_STATE](cp) {
|
|
2010
2193
|
if (isAsciiHexDigit(cp)) {
|
|
2011
2194
|
this._reconsumeInState(HEXADEMICAL_CHARACTER_REFERENCE_STATE);
|
|
@@ -2015,6 +2198,8 @@ var require_tokenizer = __commonJS({
|
|
|
2015
2198
|
this._reconsumeInState(this.returnState);
|
|
2016
2199
|
}
|
|
2017
2200
|
}
|
|
2201
|
+
// Decimal character reference start state
|
|
2202
|
+
//------------------------------------------------------------------
|
|
2018
2203
|
[DECIMAL_CHARACTER_REFERENCE_START_STATE](cp) {
|
|
2019
2204
|
if (isAsciiDigit(cp)) {
|
|
2020
2205
|
this._reconsumeInState(DECIMAL_CHARACTER_REFERENCE_STATE);
|
|
@@ -2024,6 +2209,8 @@ var require_tokenizer = __commonJS({
|
|
|
2024
2209
|
this._reconsumeInState(this.returnState);
|
|
2025
2210
|
}
|
|
2026
2211
|
}
|
|
2212
|
+
// Hexademical character reference state
|
|
2213
|
+
//------------------------------------------------------------------
|
|
2027
2214
|
[HEXADEMICAL_CHARACTER_REFERENCE_STATE](cp) {
|
|
2028
2215
|
if (isAsciiUpperHexDigit(cp)) {
|
|
2029
2216
|
this.charRefCode = this.charRefCode * 16 + cp - 55;
|
|
@@ -2038,6 +2225,8 @@ var require_tokenizer = __commonJS({
|
|
|
2038
2225
|
this._reconsumeInState(NUMERIC_CHARACTER_REFERENCE_END_STATE);
|
|
2039
2226
|
}
|
|
2040
2227
|
}
|
|
2228
|
+
// Decimal character reference state
|
|
2229
|
+
//------------------------------------------------------------------
|
|
2041
2230
|
[DECIMAL_CHARACTER_REFERENCE_STATE](cp) {
|
|
2042
2231
|
if (isAsciiDigit(cp)) {
|
|
2043
2232
|
this.charRefCode = this.charRefCode * 10 + cp - 48;
|
|
@@ -2048,6 +2237,8 @@ var require_tokenizer = __commonJS({
|
|
|
2048
2237
|
this._reconsumeInState(NUMERIC_CHARACTER_REFERENCE_END_STATE);
|
|
2049
2238
|
}
|
|
2050
2239
|
}
|
|
2240
|
+
// Numeric character reference end state
|
|
2241
|
+
//------------------------------------------------------------------
|
|
2051
2242
|
[NUMERIC_CHARACTER_REFERENCE_END_STATE]() {
|
|
2052
2243
|
if (this.charRefCode === $.NULL) {
|
|
2053
2244
|
this._err(ERR.nullCharacterReference);
|
|
@@ -2441,6 +2632,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2441
2632
|
this.tmplCount = 0;
|
|
2442
2633
|
this.treeAdapter = treeAdapter;
|
|
2443
2634
|
}
|
|
2635
|
+
//Index of element
|
|
2444
2636
|
_indexOf(element4) {
|
|
2445
2637
|
let idx = -1;
|
|
2446
2638
|
for (let i = this.stackTop; i >= 0; i--) {
|
|
@@ -2451,6 +2643,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2451
2643
|
}
|
|
2452
2644
|
return idx;
|
|
2453
2645
|
}
|
|
2646
|
+
//Update current element
|
|
2454
2647
|
_isInTemplate() {
|
|
2455
2648
|
return this.currentTagName === $.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
|
|
2456
2649
|
}
|
|
@@ -2459,6 +2652,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2459
2652
|
this.currentTagName = this.current && this.treeAdapter.getTagName(this.current);
|
|
2460
2653
|
this.currentTmplContent = this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : null;
|
|
2461
2654
|
}
|
|
2655
|
+
//Mutations
|
|
2462
2656
|
push(element4) {
|
|
2463
2657
|
this.items[++this.stackTop] = element4;
|
|
2464
2658
|
this._updateCurrentElement();
|
|
@@ -2555,6 +2749,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2555
2749
|
}
|
|
2556
2750
|
}
|
|
2557
2751
|
}
|
|
2752
|
+
//Search
|
|
2558
2753
|
tryPeekProperlyNestedBodyElement() {
|
|
2559
2754
|
const element4 = this.items[1];
|
|
2560
2755
|
return element4 && this.treeAdapter.getTagName(element4) === $.BODY ? element4 : null;
|
|
@@ -2569,6 +2764,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2569
2764
|
isRootHtmlElementCurrent() {
|
|
2570
2765
|
return this.stackTop === 0 && this.currentTagName === $.HTML;
|
|
2571
2766
|
}
|
|
2767
|
+
//Element in scope
|
|
2572
2768
|
hasInScope(tagName) {
|
|
2573
2769
|
for (let i = this.stackTop; i >= 0; i--) {
|
|
2574
2770
|
const tn = this.treeAdapter.getTagName(this.items[i]);
|
|
@@ -2669,6 +2865,7 @@ var require_open_element_stack = __commonJS({
|
|
|
2669
2865
|
}
|
|
2670
2866
|
return true;
|
|
2671
2867
|
}
|
|
2868
|
+
//Implied end tags
|
|
2672
2869
|
generateImpliedEndTags() {
|
|
2673
2870
|
while (isImpliedEndTagRequired(this.currentTagName)) {
|
|
2674
2871
|
this.pop();
|
|
@@ -2701,6 +2898,9 @@ var require_formatting_element_list = __commonJS({
|
|
|
2701
2898
|
this.treeAdapter = treeAdapter;
|
|
2702
2899
|
this.bookmark = null;
|
|
2703
2900
|
}
|
|
2901
|
+
//Noah Ark's condition
|
|
2902
|
+
//OPTIMIZATION: at first we try to find possible candidates for exclusion using
|
|
2903
|
+
//lightweight heuristics without thorough attributes check.
|
|
2704
2904
|
_getNoahArkConditionCandidates(newElement) {
|
|
2705
2905
|
const candidates = [];
|
|
2706
2906
|
if (this.length >= NOAH_ARK_CAPACITY) {
|
|
@@ -2751,6 +2951,7 @@ var require_formatting_element_list = __commonJS({
|
|
|
2751
2951
|
}
|
|
2752
2952
|
}
|
|
2753
2953
|
}
|
|
2954
|
+
//Mutations
|
|
2754
2955
|
insertMarker() {
|
|
2755
2956
|
this.entries.push({ type: FormattingElementList.MARKER_ENTRY });
|
|
2756
2957
|
this.length++;
|
|
@@ -2796,6 +2997,7 @@ var require_formatting_element_list = __commonJS({
|
|
|
2796
2997
|
}
|
|
2797
2998
|
}
|
|
2798
2999
|
}
|
|
3000
|
+
//Search
|
|
2799
3001
|
getElementEntryInScopeWithTagName(tagName) {
|
|
2800
3002
|
for (let i = this.length - 1; i >= 0; i--) {
|
|
2801
3003
|
const entry = this.entries[i];
|
|
@@ -3133,6 +3335,7 @@ var require_parser_mixin = __commonJS({
|
|
|
3133
3335
|
mxn._setEndLocation(this.openElements.items[i], mxn.currentToken);
|
|
3134
3336
|
}
|
|
3135
3337
|
},
|
|
3338
|
+
//Token processing
|
|
3136
3339
|
_processTokenInForeignContent(token) {
|
|
3137
3340
|
mxn.currentToken = token;
|
|
3138
3341
|
orig._processTokenInForeignContent.call(this, token);
|
|
@@ -3151,6 +3354,7 @@ var require_parser_mixin = __commonJS({
|
|
|
3151
3354
|
}
|
|
3152
3355
|
}
|
|
3153
3356
|
},
|
|
3357
|
+
//Doctype
|
|
3154
3358
|
_setDocumentType(token) {
|
|
3155
3359
|
orig._setDocumentType.call(this, token);
|
|
3156
3360
|
const documentChildren = this.treeAdapter.getChildNodes(this.document);
|
|
@@ -3163,6 +3367,7 @@ var require_parser_mixin = __commonJS({
|
|
|
3163
3367
|
}
|
|
3164
3368
|
}
|
|
3165
3369
|
},
|
|
3370
|
+
//Elements
|
|
3166
3371
|
_attachElementToTree(element4) {
|
|
3167
3372
|
mxn._setStartLocation(element4);
|
|
3168
3373
|
mxn.lastStartTagToken = null;
|
|
@@ -3186,12 +3391,14 @@ var require_parser_mixin = __commonJS({
|
|
|
3186
3391
|
orig._insertFakeRootElement.call(this);
|
|
3187
3392
|
this.treeAdapter.setNodeSourceCodeLocation(this.openElements.current, null);
|
|
3188
3393
|
},
|
|
3394
|
+
//Comments
|
|
3189
3395
|
_appendCommentNode(token, parent) {
|
|
3190
3396
|
orig._appendCommentNode.call(this, token, parent);
|
|
3191
3397
|
const children = this.treeAdapter.getChildNodes(parent);
|
|
3192
3398
|
const commentNode = children[children.length - 1];
|
|
3193
3399
|
this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
|
|
3194
3400
|
},
|
|
3401
|
+
//Text
|
|
3195
3402
|
_findFosterParentingLocation() {
|
|
3196
3403
|
mxn.lastFosterParentingLocation = orig._findFosterParentingLocation.call(this);
|
|
3197
3404
|
return mxn.lastFosterParentingLocation;
|
|
@@ -4228,6 +4435,7 @@ var require_parser = __commonJS({
|
|
|
4228
4435
|
Mixin.install(this, ErrorReportingParserMixin, { onParseError: this.options.onParseError });
|
|
4229
4436
|
}
|
|
4230
4437
|
}
|
|
4438
|
+
// API
|
|
4231
4439
|
parse(html5) {
|
|
4232
4440
|
const document2 = this.treeAdapter.createDocument();
|
|
4233
4441
|
this._bootstrap(document2, null);
|
|
@@ -4255,6 +4463,7 @@ var require_parser = __commonJS({
|
|
|
4255
4463
|
this._adoptNodes(rootElement, fragment);
|
|
4256
4464
|
return fragment;
|
|
4257
4465
|
}
|
|
4466
|
+
//Bootstrap parser
|
|
4258
4467
|
_bootstrap(document2, fragmentContext) {
|
|
4259
4468
|
this.tokenizer = new Tokenizer(this.options);
|
|
4260
4469
|
this.stopped = false;
|
|
@@ -4275,8 +4484,10 @@ var require_parser = __commonJS({
|
|
|
4275
4484
|
this.skipNextNewLine = false;
|
|
4276
4485
|
this.fosterParentingEnabled = false;
|
|
4277
4486
|
}
|
|
4487
|
+
//Errors
|
|
4278
4488
|
_err() {
|
|
4279
4489
|
}
|
|
4490
|
+
//Parsing loop
|
|
4280
4491
|
_runParsingLoop(scriptHandler) {
|
|
4281
4492
|
while (!this.stopped) {
|
|
4282
4493
|
this._setupTokenizerCDATAMode();
|
|
@@ -4311,6 +4522,7 @@ var require_parser = __commonJS({
|
|
|
4311
4522
|
writeCallback();
|
|
4312
4523
|
}
|
|
4313
4524
|
}
|
|
4525
|
+
//Text parsing
|
|
4314
4526
|
_setupTokenizerCDATAMode() {
|
|
4315
4527
|
const current = this._getAdjustedCurrentElement();
|
|
4316
4528
|
this.tokenizer.allowCDATA = current && current !== this.document && this.treeAdapter.getNamespaceURI(current) !== NS.HTML && !this._isIntegrationPoint(current);
|
|
@@ -4326,6 +4538,7 @@ var require_parser = __commonJS({
|
|
|
4326
4538
|
this.originalInsertionMode = IN_BODY_MODE;
|
|
4327
4539
|
this.tokenizer.state = Tokenizer.MODE.PLAINTEXT;
|
|
4328
4540
|
}
|
|
4541
|
+
//Fragment parsing
|
|
4329
4542
|
_getAdjustedCurrentElement() {
|
|
4330
4543
|
return this.openElements.stackTop === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.current;
|
|
4331
4544
|
}
|
|
@@ -4353,6 +4566,7 @@ var require_parser = __commonJS({
|
|
|
4353
4566
|
}
|
|
4354
4567
|
}
|
|
4355
4568
|
}
|
|
4569
|
+
//Tree mutation
|
|
4356
4570
|
_setDocumentType(token) {
|
|
4357
4571
|
const name = token.name || "";
|
|
4358
4572
|
const publicId = token.publicId || "";
|
|
@@ -4411,6 +4625,7 @@ var require_parser = __commonJS({
|
|
|
4411
4625
|
this.treeAdapter.appendChild(recipient, child);
|
|
4412
4626
|
}
|
|
4413
4627
|
}
|
|
4628
|
+
//Token processing
|
|
4414
4629
|
_shouldProcessTokenInForeignContent(token) {
|
|
4415
4630
|
const current = this._getAdjustedCurrentElement();
|
|
4416
4631
|
if (!current || current === this.document) {
|
|
@@ -4464,12 +4679,14 @@ var require_parser = __commonJS({
|
|
|
4464
4679
|
this._err(ERR.nonVoidHtmlElementStartTagWithTrailingSolidus);
|
|
4465
4680
|
}
|
|
4466
4681
|
}
|
|
4682
|
+
//Integration points
|
|
4467
4683
|
_isIntegrationPoint(element4, foreignNS) {
|
|
4468
4684
|
const tn = this.treeAdapter.getTagName(element4);
|
|
4469
4685
|
const ns = this.treeAdapter.getNamespaceURI(element4);
|
|
4470
4686
|
const attrs = this.treeAdapter.getAttrList(element4);
|
|
4471
4687
|
return foreignContent.isIntegrationPoint(tn, ns, attrs, foreignNS);
|
|
4472
4688
|
}
|
|
4689
|
+
//Active formatting elements reconstruction
|
|
4473
4690
|
_reconstructActiveFormattingElements() {
|
|
4474
4691
|
const listLength = this.activeFormattingElements.length;
|
|
4475
4692
|
if (listLength) {
|
|
@@ -4490,6 +4707,7 @@ var require_parser = __commonJS({
|
|
|
4490
4707
|
}
|
|
4491
4708
|
}
|
|
4492
4709
|
}
|
|
4710
|
+
//Close elements
|
|
4493
4711
|
_closeTableCell() {
|
|
4494
4712
|
this.openElements.generateImpliedEndTags();
|
|
4495
4713
|
this.openElements.popUntilTableCellPopped();
|
|
@@ -4500,6 +4718,7 @@ var require_parser = __commonJS({
|
|
|
4500
4718
|
this.openElements.generateImpliedEndTagsWithExclusion($.P);
|
|
4501
4719
|
this.openElements.popUntilTagNamePopped($.P);
|
|
4502
4720
|
}
|
|
4721
|
+
//Insertion modes
|
|
4503
4722
|
_resetInsertionMode() {
|
|
4504
4723
|
for (let i = this.openElements.stackTop, last = false; i >= 0; i--) {
|
|
4505
4724
|
let element4 = this.openElements.items[i];
|
|
@@ -4560,6 +4779,7 @@ var require_parser = __commonJS({
|
|
|
4560
4779
|
this.tmplInsertionModeStackTop--;
|
|
4561
4780
|
this.currentTmplInsertionMode = this.tmplInsertionModeStack[this.tmplInsertionModeStackTop];
|
|
4562
4781
|
}
|
|
4782
|
+
//Foster parenting
|
|
4563
4783
|
_isElementCausesFosterParenting(element4) {
|
|
4564
4784
|
const tn = this.treeAdapter.getTagName(element4);
|
|
4565
4785
|
return tn === $.TABLE || tn === $.TBODY || tn === $.TFOOT || tn === $.THEAD || tn === $.TR;
|
|
@@ -4610,6 +4830,7 @@ var require_parser = __commonJS({
|
|
|
4610
4830
|
this.treeAdapter.insertText(location2.parent, chars);
|
|
4611
4831
|
}
|
|
4612
4832
|
}
|
|
4833
|
+
//Special elements
|
|
4613
4834
|
_isSpecialElement(element4) {
|
|
4614
4835
|
const tn = this.treeAdapter.getTagName(element4);
|
|
4615
4836
|
const ns = this.treeAdapter.getNamespaceURI(element4);
|
|
@@ -6258,6 +6479,12 @@ var require_is_buffer2 = __commonJS({
|
|
|
6258
6479
|
|
|
6259
6480
|
// ../../node_modules/property-information/lib/util/schema.js
|
|
6260
6481
|
var Schema = class {
|
|
6482
|
+
/**
|
|
6483
|
+
* @constructor
|
|
6484
|
+
* @param {Properties} property
|
|
6485
|
+
* @param {Normal} normal
|
|
6486
|
+
* @param {string} [space]
|
|
6487
|
+
*/
|
|
6261
6488
|
constructor(property, normal, space) {
|
|
6262
6489
|
this.property = property;
|
|
6263
6490
|
this.normal = normal;
|
|
@@ -6289,6 +6516,11 @@ function normalize(value) {
|
|
|
6289
6516
|
|
|
6290
6517
|
// ../../node_modules/property-information/lib/util/info.js
|
|
6291
6518
|
var Info = class {
|
|
6519
|
+
/**
|
|
6520
|
+
* @constructor
|
|
6521
|
+
* @param {string} property
|
|
6522
|
+
* @param {string} attribute
|
|
6523
|
+
*/
|
|
6292
6524
|
constructor(property, attribute) {
|
|
6293
6525
|
this.property = property;
|
|
6294
6526
|
this.attribute = attribute;
|
|
@@ -6331,6 +6563,13 @@ function increment() {
|
|
|
6331
6563
|
// ../../node_modules/property-information/lib/util/defined-info.js
|
|
6332
6564
|
var checks = Object.keys(types_exports);
|
|
6333
6565
|
var DefinedInfo = class extends Info {
|
|
6566
|
+
/**
|
|
6567
|
+
* @constructor
|
|
6568
|
+
* @param {string} property
|
|
6569
|
+
* @param {string} attribute
|
|
6570
|
+
* @param {number|null} [mask]
|
|
6571
|
+
* @param {string} [space]
|
|
6572
|
+
*/
|
|
6334
6573
|
constructor(property, attribute, mask, space) {
|
|
6335
6574
|
let index2 = -1;
|
|
6336
6575
|
super(property, attribute);
|
|
@@ -6490,6 +6729,7 @@ var html = create({
|
|
|
6490
6729
|
transform: caseInsensitiveTransform,
|
|
6491
6730
|
mustUseProperty: ["checked", "multiple", "muted", "selected"],
|
|
6492
6731
|
properties: {
|
|
6732
|
+
// Standard Properties.
|
|
6493
6733
|
abbr: null,
|
|
6494
6734
|
accept: commaSeparated,
|
|
6495
6735
|
acceptCharset: spaceSeparated,
|
|
@@ -6708,59 +6948,115 @@ var html = create({
|
|
|
6708
6948
|
value: booleanish,
|
|
6709
6949
|
width: number,
|
|
6710
6950
|
wrap: null,
|
|
6951
|
+
// Legacy.
|
|
6952
|
+
// See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis
|
|
6711
6953
|
align: null,
|
|
6954
|
+
// Several. Use CSS `text-align` instead,
|
|
6712
6955
|
aLink: null,
|
|
6956
|
+
// `<body>`. Use CSS `a:active {color}` instead
|
|
6713
6957
|
archive: spaceSeparated,
|
|
6958
|
+
// `<object>`. List of URIs to archives
|
|
6714
6959
|
axis: null,
|
|
6960
|
+
// `<td>` and `<th>`. Use `scope` on `<th>`
|
|
6715
6961
|
background: null,
|
|
6962
|
+
// `<body>`. Use CSS `background-image` instead
|
|
6716
6963
|
bgColor: null,
|
|
6964
|
+
// `<body>` and table elements. Use CSS `background-color` instead
|
|
6717
6965
|
border: number,
|
|
6966
|
+
// `<table>`. Use CSS `border-width` instead,
|
|
6718
6967
|
borderColor: null,
|
|
6968
|
+
// `<table>`. Use CSS `border-color` instead,
|
|
6719
6969
|
bottomMargin: number,
|
|
6970
|
+
// `<body>`
|
|
6720
6971
|
cellPadding: null,
|
|
6972
|
+
// `<table>`
|
|
6721
6973
|
cellSpacing: null,
|
|
6974
|
+
// `<table>`
|
|
6722
6975
|
char: null,
|
|
6976
|
+
// Several table elements. When `align=char`, sets the character to align on
|
|
6723
6977
|
charOff: null,
|
|
6978
|
+
// Several table elements. When `char`, offsets the alignment
|
|
6724
6979
|
classId: null,
|
|
6980
|
+
// `<object>`
|
|
6725
6981
|
clear: null,
|
|
6982
|
+
// `<br>`. Use CSS `clear` instead
|
|
6726
6983
|
code: null,
|
|
6984
|
+
// `<object>`
|
|
6727
6985
|
codeBase: null,
|
|
6986
|
+
// `<object>`
|
|
6728
6987
|
codeType: null,
|
|
6988
|
+
// `<object>`
|
|
6729
6989
|
color: null,
|
|
6990
|
+
// `<font>` and `<hr>`. Use CSS instead
|
|
6730
6991
|
compact: boolean,
|
|
6992
|
+
// Lists. Use CSS to reduce space between items instead
|
|
6731
6993
|
declare: boolean,
|
|
6994
|
+
// `<object>`
|
|
6732
6995
|
event: null,
|
|
6996
|
+
// `<script>`
|
|
6733
6997
|
face: null,
|
|
6998
|
+
// `<font>`. Use CSS instead
|
|
6734
6999
|
frame: null,
|
|
7000
|
+
// `<table>`
|
|
6735
7001
|
frameBorder: null,
|
|
7002
|
+
// `<iframe>`. Use CSS `border` instead
|
|
6736
7003
|
hSpace: number,
|
|
7004
|
+
// `<img>` and `<object>`
|
|
6737
7005
|
leftMargin: number,
|
|
7006
|
+
// `<body>`
|
|
6738
7007
|
link: null,
|
|
7008
|
+
// `<body>`. Use CSS `a:link {color: *}` instead
|
|
6739
7009
|
longDesc: null,
|
|
7010
|
+
// `<frame>`, `<iframe>`, and `<img>`. Use an `<a>`
|
|
6740
7011
|
lowSrc: null,
|
|
7012
|
+
// `<img>`. Use a `<picture>`
|
|
6741
7013
|
marginHeight: number,
|
|
7014
|
+
// `<body>`
|
|
6742
7015
|
marginWidth: number,
|
|
7016
|
+
// `<body>`
|
|
6743
7017
|
noResize: boolean,
|
|
7018
|
+
// `<frame>`
|
|
6744
7019
|
noHref: boolean,
|
|
7020
|
+
// `<area>`. Use no href instead of an explicit `nohref`
|
|
6745
7021
|
noShade: boolean,
|
|
7022
|
+
// `<hr>`. Use background-color and height instead of borders
|
|
6746
7023
|
noWrap: boolean,
|
|
7024
|
+
// `<td>` and `<th>`
|
|
6747
7025
|
object: null,
|
|
7026
|
+
// `<applet>`
|
|
6748
7027
|
profile: null,
|
|
7028
|
+
// `<head>`
|
|
6749
7029
|
prompt: null,
|
|
7030
|
+
// `<isindex>`
|
|
6750
7031
|
rev: null,
|
|
7032
|
+
// `<link>`
|
|
6751
7033
|
rightMargin: number,
|
|
7034
|
+
// `<body>`
|
|
6752
7035
|
rules: null,
|
|
7036
|
+
// `<table>`
|
|
6753
7037
|
scheme: null,
|
|
7038
|
+
// `<meta>`
|
|
6754
7039
|
scrolling: booleanish,
|
|
7040
|
+
// `<frame>`. Use overflow in the child context
|
|
6755
7041
|
standby: null,
|
|
7042
|
+
// `<object>`
|
|
6756
7043
|
summary: null,
|
|
7044
|
+
// `<table>`
|
|
6757
7045
|
text: null,
|
|
7046
|
+
// `<body>`. Use CSS `color` instead
|
|
6758
7047
|
topMargin: number,
|
|
7048
|
+
// `<body>`
|
|
6759
7049
|
valueType: null,
|
|
7050
|
+
// `<param>`
|
|
6760
7051
|
version: null,
|
|
7052
|
+
// `<html>`. Use a doctype.
|
|
6761
7053
|
vAlign: null,
|
|
7054
|
+
// Several. Use CSS `vertical-align` instead
|
|
6762
7055
|
vLink: null,
|
|
7056
|
+
// `<body>`. Use CSS `a:visited {color}` instead
|
|
6763
7057
|
vSpace: number,
|
|
7058
|
+
// `<img>` and `<object>`
|
|
7059
|
+
// Non-standard Properties.
|
|
6764
7060
|
allowTransparency: null,
|
|
6765
7061
|
autoCorrect: null,
|
|
6766
7062
|
autoSave: null,
|
|
@@ -6947,6 +7243,7 @@ var svg = create({
|
|
|
6947
7243
|
wordSpacing: "word-spacing",
|
|
6948
7244
|
writingMode: "writing-mode",
|
|
6949
7245
|
xHeight: "x-height",
|
|
7246
|
+
// These were camelcased in Tiny. Now lowercased in SVG 2
|
|
6950
7247
|
playbackOrder: "playbackorder",
|
|
6951
7248
|
timelineBegin: "timelinebegin"
|
|
6952
7249
|
},
|
|
@@ -7067,8 +7364,11 @@ var svg = create({
|
|
|
7067
7364
|
kernelMatrix: commaOrSpaceSeparated,
|
|
7068
7365
|
kernelUnitLength: null,
|
|
7069
7366
|
keyPoints: null,
|
|
7367
|
+
// SEMI_COLON_SEPARATED
|
|
7070
7368
|
keySplines: null,
|
|
7369
|
+
// SEMI_COLON_SEPARATED
|
|
7071
7370
|
keyTimes: null,
|
|
7371
|
+
// SEMI_COLON_SEPARATED
|
|
7072
7372
|
kerning: null,
|
|
7073
7373
|
lang: null,
|
|
7074
7374
|
lengthAdjust: null,
|
|
@@ -7398,37 +7698,82 @@ var htmlVoidElements = [
|
|
|
7398
7698
|
];
|
|
7399
7699
|
|
|
7400
7700
|
// ../../node_modules/hast-util-is-element/index.js
|
|
7401
|
-
var isElement =
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
}
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7701
|
+
var isElement = (
|
|
7702
|
+
/**
|
|
7703
|
+
* Check if a node is an element and passes a test.
|
|
7704
|
+
* When a `parent` node is known the `index` of node should also be given.
|
|
7705
|
+
*
|
|
7706
|
+
* @type {(
|
|
7707
|
+
* (() => false) &
|
|
7708
|
+
* (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
|
|
7709
|
+
* ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
|
|
7710
|
+
* )}
|
|
7711
|
+
*/
|
|
7712
|
+
/**
|
|
7713
|
+
* Check if a node passes a test.
|
|
7714
|
+
* When a `parent` node is known the `index` of node should also be given.
|
|
7715
|
+
*
|
|
7716
|
+
* @param {unknown} [node] Node to check
|
|
7717
|
+
* @param {Test} [test] When nullish, checks if `node` is a `Node`.
|
|
7718
|
+
* When `string`, works like passing `function (node) {return node.type === test}`.
|
|
7719
|
+
* When `function` checks if function passed the node is true.
|
|
7720
|
+
* When `array`, checks any one of the subtests pass.
|
|
7721
|
+
* @param {number} [index] Position of `node` in `parent`
|
|
7722
|
+
* @param {Parent} [parent] Parent of `node`
|
|
7723
|
+
* @param {unknown} [context] Context object to invoke `test` with
|
|
7724
|
+
* @returns {boolean} Whether test passed and `node` is an `Element` (object with `type` set to `element` and `tagName` set to a non-empty string).
|
|
7725
|
+
*/
|
|
7726
|
+
// eslint-disable-next-line max-params
|
|
7727
|
+
function(node, test, index2, parent, context) {
|
|
7728
|
+
const check = convertElement(test);
|
|
7729
|
+
if (index2 !== void 0 && index2 !== null && (typeof index2 !== "number" || index2 < 0 || index2 === Number.POSITIVE_INFINITY)) {
|
|
7730
|
+
throw new Error("Expected positive finite index for child node");
|
|
7731
|
+
}
|
|
7732
|
+
if (parent !== void 0 && parent !== null && (!parent.type || !parent.children)) {
|
|
7733
|
+
throw new Error("Expected parent node");
|
|
7734
|
+
}
|
|
7735
|
+
if (!node || !node.type || typeof node.type !== "string") {
|
|
7736
|
+
return false;
|
|
7737
|
+
}
|
|
7738
|
+
if ((parent === void 0 || parent === null) !== (index2 === void 0 || index2 === null)) {
|
|
7739
|
+
throw new Error("Expected both parent and index");
|
|
7740
|
+
}
|
|
7741
|
+
return check.call(context, node, index2, parent);
|
|
7426
7742
|
}
|
|
7427
|
-
|
|
7428
|
-
|
|
7743
|
+
);
|
|
7744
|
+
var convertElement = (
|
|
7745
|
+
/**
|
|
7746
|
+
* @type {(
|
|
7747
|
+
* (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
|
|
7748
|
+
* ((test?: Test) => AssertAnything)
|
|
7749
|
+
* )}
|
|
7750
|
+
*/
|
|
7751
|
+
/**
|
|
7752
|
+
* Generate an assertion from a check.
|
|
7753
|
+
* @param {Test} [test]
|
|
7754
|
+
* When nullish, checks if `node` is a `Node`.
|
|
7755
|
+
* When `string`, works like passing `function (node) {return node.type === test}`.
|
|
7756
|
+
* When `function` checks if function passed the node is true.
|
|
7757
|
+
* When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
|
|
7758
|
+
* When `array`, checks any one of the subtests pass.
|
|
7759
|
+
* @returns {AssertAnything}
|
|
7760
|
+
*/
|
|
7761
|
+
function(test) {
|
|
7762
|
+
if (test === void 0 || test === null) {
|
|
7763
|
+
return element;
|
|
7764
|
+
}
|
|
7765
|
+
if (typeof test === "string") {
|
|
7766
|
+
return tagNameFactory(test);
|
|
7767
|
+
}
|
|
7768
|
+
if (typeof test === "object") {
|
|
7769
|
+
return anyFactory(test);
|
|
7770
|
+
}
|
|
7771
|
+
if (typeof test === "function") {
|
|
7772
|
+
return castFactory(test);
|
|
7773
|
+
}
|
|
7774
|
+
throw new Error("Expected function, string, or array as test");
|
|
7429
7775
|
}
|
|
7430
|
-
|
|
7431
|
-
};
|
|
7776
|
+
);
|
|
7432
7777
|
function anyFactory(tests) {
|
|
7433
7778
|
const checks2 = [];
|
|
7434
7779
|
let index2 = -1;
|
|
@@ -7460,26 +7805,46 @@ function castFactory(check) {
|
|
|
7460
7805
|
}
|
|
7461
7806
|
function element(node) {
|
|
7462
7807
|
return Boolean(
|
|
7463
|
-
node && typeof node === "object" &&
|
|
7808
|
+
node && typeof node === "object" && // @ts-expect-error Looks like a node.
|
|
7809
|
+
node.type === "element" && // @ts-expect-error Looks like an element.
|
|
7810
|
+
typeof node.tagName === "string"
|
|
7464
7811
|
);
|
|
7465
7812
|
}
|
|
7466
7813
|
|
|
7467
7814
|
// ../../node_modules/unist-util-is/index.js
|
|
7468
|
-
var convert =
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7815
|
+
var convert = (
|
|
7816
|
+
/**
|
|
7817
|
+
* @type {(
|
|
7818
|
+
* (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
|
|
7819
|
+
* ((test?: Test) => AssertAnything)
|
|
7820
|
+
* )}
|
|
7821
|
+
*/
|
|
7822
|
+
/**
|
|
7823
|
+
* Generate an assertion from a check.
|
|
7824
|
+
* @param {Test} [test]
|
|
7825
|
+
* When nullish, checks if `node` is a `Node`.
|
|
7826
|
+
* When `string`, works like passing `function (node) {return node.type === test}`.
|
|
7827
|
+
* When `function` checks if function passed the node is true.
|
|
7828
|
+
* When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
|
|
7829
|
+
* When `array`, checks any one of the subtests pass.
|
|
7830
|
+
* @returns {AssertAnything}
|
|
7831
|
+
*/
|
|
7832
|
+
function(test) {
|
|
7833
|
+
if (test === void 0 || test === null) {
|
|
7834
|
+
return ok;
|
|
7835
|
+
}
|
|
7836
|
+
if (typeof test === "string") {
|
|
7837
|
+
return typeFactory(test);
|
|
7838
|
+
}
|
|
7839
|
+
if (typeof test === "object") {
|
|
7840
|
+
return Array.isArray(test) ? anyFactory2(test) : propsFactory(test);
|
|
7841
|
+
}
|
|
7842
|
+
if (typeof test === "function") {
|
|
7843
|
+
return castFactory2(test);
|
|
7844
|
+
}
|
|
7845
|
+
throw new Error("Expected function, string, or object as test");
|
|
7474
7846
|
}
|
|
7475
|
-
|
|
7476
|
-
return Array.isArray(test) ? anyFactory2(test) : propsFactory(test);
|
|
7477
|
-
}
|
|
7478
|
-
if (typeof test === "function") {
|
|
7479
|
-
return castFactory2(test);
|
|
7480
|
-
}
|
|
7481
|
-
throw new Error("Expected function, string, or object as test");
|
|
7482
|
-
};
|
|
7847
|
+
);
|
|
7483
7848
|
function anyFactory2(tests) {
|
|
7484
7849
|
const checks2 = [];
|
|
7485
7850
|
let index2 = -1;
|
|
@@ -7528,7 +7893,13 @@ var comment = convert("comment");
|
|
|
7528
7893
|
|
|
7529
7894
|
// ../../node_modules/hast-util-whitespace/index.js
|
|
7530
7895
|
function whitespace(thing) {
|
|
7531
|
-
var value =
|
|
7896
|
+
var value = (
|
|
7897
|
+
// @ts-ignore looks like a node.
|
|
7898
|
+
thing && typeof thing === "object" && thing.type === "text" ? (
|
|
7899
|
+
// @ts-ignore looks like a text.
|
|
7900
|
+
thing.value || ""
|
|
7901
|
+
) : thing
|
|
7902
|
+
);
|
|
7532
7903
|
return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
|
|
7533
7904
|
}
|
|
7534
7905
|
|
|
@@ -7634,7 +8005,8 @@ function p(_2, index2, parent) {
|
|
|
7634
8005
|
"section",
|
|
7635
8006
|
"table",
|
|
7636
8007
|
"ul"
|
|
7637
|
-
]) : !parent ||
|
|
8008
|
+
]) : !parent || // Confusing parent.
|
|
8009
|
+
!isElement(parent, [
|
|
7638
8010
|
"a",
|
|
7639
8011
|
"audio",
|
|
7640
8012
|
"del",
|
|
@@ -7791,6 +8163,7 @@ function core(value, options) {
|
|
|
7791
8163
|
return value;
|
|
7792
8164
|
}
|
|
7793
8165
|
return value.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, surrogate).replace(
|
|
8166
|
+
// eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
|
|
7794
8167
|
/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,
|
|
7795
8168
|
basic2
|
|
7796
8169
|
);
|
|
@@ -8273,19 +8646,23 @@ function ccount(value, character) {
|
|
|
8273
8646
|
|
|
8274
8647
|
// ../../node_modules/hast-util-to-html/lib/constants.js
|
|
8275
8648
|
var constants = {
|
|
8649
|
+
// See: <https://html.spec.whatwg.org/#attribute-name-state>.
|
|
8276
8650
|
name: [
|
|
8277
8651
|
[" \n\f\r &/=>".split(""), " \n\f\r \"&'/=>`".split("")],
|
|
8278
8652
|
[`\0
|
|
8279
8653
|
\f\r "&'/<=>`.split(""), "\0 \n\f\r \"&'/<=>`".split("")]
|
|
8280
8654
|
],
|
|
8655
|
+
// See: <https://html.spec.whatwg.org/#attribute-value-(unquoted)-state>.
|
|
8281
8656
|
unquoted: [
|
|
8282
8657
|
[" \n\f\r &>".split(""), "\0 \n\f\r \"&'<=>`".split("")],
|
|
8283
8658
|
["\0 \n\f\r \"&'<=>`".split(""), "\0 \n\f\r \"&'<=>`".split("")]
|
|
8284
8659
|
],
|
|
8660
|
+
// See: <https://html.spec.whatwg.org/#attribute-value-(single-quoted)-state>.
|
|
8285
8661
|
single: [
|
|
8286
8662
|
["&'".split(""), "\"&'`".split("")],
|
|
8287
8663
|
["\0&'".split(""), "\0\"&'`".split("")]
|
|
8288
8664
|
],
|
|
8665
|
+
// See: <https://html.spec.whatwg.org/#attribute-value-(double-quoted)-state>.
|
|
8289
8666
|
double: [
|
|
8290
8667
|
['"&'.split(""), "\"&'`".split("")],
|
|
8291
8668
|
['\0"&'.split(""), "\0\"&'`".split("")]
|
|
@@ -8313,7 +8690,8 @@ function doctype(ctx) {
|
|
|
8313
8690
|
|
|
8314
8691
|
// ../../node_modules/hast-util-to-html/lib/text.js
|
|
8315
8692
|
function text(ctx, node, _2, parent) {
|
|
8316
|
-
return parent && parent.type === "element" &&
|
|
8693
|
+
return parent && parent.type === "element" && // @ts-expect-error: hush.
|
|
8694
|
+
(parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
|
|
8317
8695
|
node.value,
|
|
8318
8696
|
Object.assign({}, ctx.entities, { subset: ["<", "&"] })
|
|
8319
8697
|
);
|
|
@@ -8329,7 +8707,9 @@ var handlers = {
|
|
|
8329
8707
|
comment: comment2,
|
|
8330
8708
|
doctype,
|
|
8331
8709
|
element: element2,
|
|
8710
|
+
// @ts-ignore `raw` is nonstandard
|
|
8332
8711
|
raw,
|
|
8712
|
+
// @ts-ignore `root` is a parent.
|
|
8333
8713
|
root: all,
|
|
8334
8714
|
text
|
|
8335
8715
|
};
|
|
@@ -8422,14 +8802,19 @@ function serializeAttribute(ctx, key2, value) {
|
|
|
8422
8802
|
const name = stringifyEntities(
|
|
8423
8803
|
info.attribute,
|
|
8424
8804
|
Object.assign({}, ctx.entities, {
|
|
8805
|
+
// Always encode without parse errors in non-HTML.
|
|
8425
8806
|
subset: constants.name[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe]
|
|
8426
8807
|
})
|
|
8427
8808
|
);
|
|
8428
8809
|
if (value === true)
|
|
8429
8810
|
return name;
|
|
8430
|
-
value = typeof value === "object" && "length" in value ? (
|
|
8431
|
-
|
|
8432
|
-
|
|
8811
|
+
value = typeof value === "object" && "length" in value ? (
|
|
8812
|
+
// `spaces` doesn’t accept a second argument, but it’s given here just to
|
|
8813
|
+
// keep the code cleaner.
|
|
8814
|
+
(info.commaSeparated ? stringify2 : stringify)(value, {
|
|
8815
|
+
padLeft: !ctx.tightLists
|
|
8816
|
+
})
|
|
8817
|
+
) : String(value);
|
|
8433
8818
|
if (ctx.collapseEmpty && !value)
|
|
8434
8819
|
return name;
|
|
8435
8820
|
if (ctx.unquoted) {
|
|
@@ -8448,6 +8833,7 @@ function serializeAttribute(ctx, key2, value) {
|
|
|
8448
8833
|
result = quote + stringifyEntities(
|
|
8449
8834
|
value,
|
|
8450
8835
|
Object.assign({}, ctx.entities, {
|
|
8836
|
+
// Always encode without parse errors in non-HTML.
|
|
8451
8837
|
subset: (quote === "'" ? constants.single : constants.double)[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe],
|
|
8452
8838
|
attribute: true
|
|
8453
8839
|
})
|
|
@@ -8487,6 +8873,7 @@ function toHtml(node, options = {}) {
|
|
|
8487
8873
|
};
|
|
8488
8874
|
return one(
|
|
8489
8875
|
context,
|
|
8876
|
+
// @ts-ignore Assume `node` does not contain a root.
|
|
8490
8877
|
Array.isArray(node) ? { type: "root", children: node } : node,
|
|
8491
8878
|
null,
|
|
8492
8879
|
null
|
|
@@ -8544,6 +8931,7 @@ function c(Prism2) {
|
|
|
8544
8931
|
greedy: true
|
|
8545
8932
|
},
|
|
8546
8933
|
string: {
|
|
8934
|
+
// https://en.cppreference.com/w/c/language/string_literal
|
|
8547
8935
|
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
8548
8936
|
greedy: true
|
|
8549
8937
|
},
|
|
@@ -8558,12 +8946,15 @@ function c(Prism2) {
|
|
|
8558
8946
|
});
|
|
8559
8947
|
Prism2.languages.insertBefore("c", "string", {
|
|
8560
8948
|
char: {
|
|
8949
|
+
// https://en.cppreference.com/w/c/language/character_constant
|
|
8561
8950
|
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
8562
8951
|
greedy: true
|
|
8563
8952
|
}
|
|
8564
8953
|
});
|
|
8565
8954
|
Prism2.languages.insertBefore("c", "string", {
|
|
8566
8955
|
macro: {
|
|
8956
|
+
// allow for multiline macro definitions
|
|
8957
|
+
// spaces after the # character compile fine with gcc
|
|
8567
8958
|
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
8568
8959
|
lookbehind: true,
|
|
8569
8960
|
greedy: true,
|
|
@@ -8571,6 +8962,7 @@ function c(Prism2) {
|
|
|
8571
8962
|
inside: {
|
|
8572
8963
|
string: [
|
|
8573
8964
|
{
|
|
8965
|
+
// highlight the path of the include statement as a string
|
|
8574
8966
|
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
8575
8967
|
lookbehind: true
|
|
8576
8968
|
},
|
|
@@ -8589,6 +8981,7 @@ function c(Prism2) {
|
|
|
8589
8981
|
alias: "function"
|
|
8590
8982
|
}
|
|
8591
8983
|
],
|
|
8984
|
+
// highlight macro directives as keywords
|
|
8592
8985
|
directive: {
|
|
8593
8986
|
pattern: /^(#\s*)[a-z]+/,
|
|
8594
8987
|
lookbehind: true,
|
|
@@ -8604,6 +8997,7 @@ function c(Prism2) {
|
|
|
8604
8997
|
}
|
|
8605
8998
|
});
|
|
8606
8999
|
Prism2.languages.insertBefore("c", "function", {
|
|
9000
|
+
// highlight predefined macros as constants
|
|
8607
9001
|
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
8608
9002
|
});
|
|
8609
9003
|
delete Prism2.languages.c["boolean"];
|
|
@@ -8635,8 +9029,16 @@ function cpp(Prism2) {
|
|
|
8635
9029
|
),
|
|
8636
9030
|
lookbehind: true
|
|
8637
9031
|
},
|
|
9032
|
+
// This is intended to capture the class name of method implementations like:
|
|
9033
|
+
// void foo::bar() const {}
|
|
9034
|
+
// However! The `foo` in the above example could also be a namespace, so we only capture the class name if
|
|
9035
|
+
// it starts with an uppercase letter. This approximation should give decent results.
|
|
8638
9036
|
/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
|
|
9037
|
+
// This will capture the class name before destructors like:
|
|
9038
|
+
// Foo::~Foo() {}
|
|
8639
9039
|
/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
|
|
9040
|
+
// This also intends to capture the class name of method implementations but here the class has template
|
|
9041
|
+
// parameters, so it can't be a namespace (until C++ adds generic namespaces).
|
|
8640
9042
|
/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
|
|
8641
9043
|
],
|
|
8642
9044
|
keyword,
|
|
@@ -8649,8 +9051,11 @@ function cpp(Prism2) {
|
|
|
8649
9051
|
});
|
|
8650
9052
|
Prism3.languages.insertBefore("cpp", "string", {
|
|
8651
9053
|
module: {
|
|
9054
|
+
// https://en.cppreference.com/w/cpp/language/modules
|
|
8652
9055
|
pattern: RegExp(
|
|
8653
|
-
/(\b(?:import|module)\s+)/.source + "(?:" +
|
|
9056
|
+
/(\b(?:import|module)\s+)/.source + "(?:" + // header-name
|
|
9057
|
+
/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + "|" + // module name or partition or both
|
|
9058
|
+
/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(
|
|
8654
9059
|
/<mod-name>/g,
|
|
8655
9060
|
function() {
|
|
8656
9061
|
return modName;
|
|
@@ -8691,6 +9096,8 @@ function cpp(Prism2) {
|
|
|
8691
9096
|
}
|
|
8692
9097
|
});
|
|
8693
9098
|
Prism3.languages.insertBefore("cpp", "class-name", {
|
|
9099
|
+
// the base clause is an optional list of parent classes
|
|
9100
|
+
// https://en.cppreference.com/w/cpp/language/class
|
|
8694
9101
|
"base-clause": {
|
|
8695
9102
|
pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
|
|
8696
9103
|
lookbehind: true,
|
|
@@ -8702,6 +9109,7 @@ function cpp(Prism2) {
|
|
|
8702
9109
|
"inside",
|
|
8703
9110
|
"double-colon",
|
|
8704
9111
|
{
|
|
9112
|
+
// All untokenized words that are not namespaces should be class names
|
|
8705
9113
|
"class-name": /\b[a-z_]\w*\b(?!\s*::)/i
|
|
8706
9114
|
},
|
|
8707
9115
|
Prism3.languages.cpp["base-clause"]
|
|
@@ -8733,7 +9141,9 @@ function bash(Prism2) {
|
|
|
8733
9141
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
8734
9142
|
lookbehind: true,
|
|
8735
9143
|
alias: "punctuation",
|
|
9144
|
+
// this looks reasonably well in all themes
|
|
8736
9145
|
inside: null
|
|
9146
|
+
// see below
|
|
8737
9147
|
};
|
|
8738
9148
|
var insideString = {
|
|
8739
9149
|
bash: commandAfterHeredoc,
|
|
@@ -8742,10 +9152,12 @@ function bash(Prism2) {
|
|
|
8742
9152
|
alias: "constant"
|
|
8743
9153
|
},
|
|
8744
9154
|
variable: [
|
|
9155
|
+
// [0]: Arithmetic Environment
|
|
8745
9156
|
{
|
|
8746
9157
|
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
8747
9158
|
greedy: true,
|
|
8748
9159
|
inside: {
|
|
9160
|
+
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
8749
9161
|
variable: [
|
|
8750
9162
|
{
|
|
8751
9163
|
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
@@ -8754,10 +9166,13 @@ function bash(Prism2) {
|
|
|
8754
9166
|
/^\$\(\(/
|
|
8755
9167
|
],
|
|
8756
9168
|
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
9169
|
+
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
8757
9170
|
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
9171
|
+
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
8758
9172
|
punctuation: /\(\(?|\)\)?|,|;/
|
|
8759
9173
|
}
|
|
8760
9174
|
},
|
|
9175
|
+
// [1]: Command Substitution
|
|
8761
9176
|
{
|
|
8762
9177
|
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
8763
9178
|
greedy: true,
|
|
@@ -8765,6 +9180,7 @@ function bash(Prism2) {
|
|
|
8765
9180
|
variable: /^\$\(|^`|\)$|`$/
|
|
8766
9181
|
}
|
|
8767
9182
|
},
|
|
9183
|
+
// [2]: Brace expansion
|
|
8768
9184
|
{
|
|
8769
9185
|
pattern: /\$\{[^}]+\}/,
|
|
8770
9186
|
greedy: true,
|
|
@@ -8780,6 +9196,7 @@ function bash(Prism2) {
|
|
|
8780
9196
|
},
|
|
8781
9197
|
/\$(?:\w+|[#?*!@$])/
|
|
8782
9198
|
],
|
|
9199
|
+
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
8783
9200
|
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
8784
9201
|
};
|
|
8785
9202
|
Prism3.languages.bash = {
|
|
@@ -8792,21 +9209,30 @@ function bash(Prism2) {
|
|
|
8792
9209
|
lookbehind: true
|
|
8793
9210
|
},
|
|
8794
9211
|
"function-name": [
|
|
9212
|
+
// a) function foo {
|
|
9213
|
+
// b) foo() {
|
|
9214
|
+
// c) function foo() {
|
|
9215
|
+
// but not “foo {”
|
|
8795
9216
|
{
|
|
9217
|
+
// a) and c)
|
|
8796
9218
|
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
8797
9219
|
lookbehind: true,
|
|
8798
9220
|
alias: "function"
|
|
8799
9221
|
},
|
|
8800
9222
|
{
|
|
9223
|
+
// b)
|
|
8801
9224
|
pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
|
|
8802
9225
|
alias: "function"
|
|
8803
9226
|
}
|
|
8804
9227
|
],
|
|
9228
|
+
// Highlight variable names as variables in for and select beginnings.
|
|
8805
9229
|
"for-or-select": {
|
|
8806
9230
|
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
8807
9231
|
alias: "variable",
|
|
8808
9232
|
lookbehind: true
|
|
8809
9233
|
},
|
|
9234
|
+
// Highlight variable names as variables in the left-hand part
|
|
9235
|
+
// of assignments (“=” and “+=”).
|
|
8810
9236
|
"assign-left": {
|
|
8811
9237
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
8812
9238
|
inside: {
|
|
@@ -8819,18 +9245,22 @@ function bash(Prism2) {
|
|
|
8819
9245
|
alias: "variable",
|
|
8820
9246
|
lookbehind: true
|
|
8821
9247
|
},
|
|
9248
|
+
// Highlight parameter names as variables
|
|
8822
9249
|
parameter: {
|
|
8823
9250
|
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
8824
9251
|
alias: "variable",
|
|
8825
9252
|
lookbehind: true
|
|
8826
9253
|
},
|
|
8827
9254
|
string: [
|
|
9255
|
+
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
8828
9256
|
{
|
|
8829
9257
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
8830
9258
|
lookbehind: true,
|
|
8831
9259
|
greedy: true,
|
|
8832
9260
|
inside: insideString
|
|
8833
9261
|
},
|
|
9262
|
+
// Here-document with quotes around the tag
|
|
9263
|
+
// → No expansion (so no “inside”).
|
|
8834
9264
|
{
|
|
8835
9265
|
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
8836
9266
|
lookbehind: true,
|
|
@@ -8839,18 +9269,22 @@ function bash(Prism2) {
|
|
|
8839
9269
|
bash: commandAfterHeredoc
|
|
8840
9270
|
}
|
|
8841
9271
|
},
|
|
9272
|
+
// “Normal” string
|
|
8842
9273
|
{
|
|
9274
|
+
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
8843
9275
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
8844
9276
|
lookbehind: true,
|
|
8845
9277
|
greedy: true,
|
|
8846
9278
|
inside: insideString
|
|
8847
9279
|
},
|
|
8848
9280
|
{
|
|
9281
|
+
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
8849
9282
|
pattern: /(^|[^$\\])'[^']*'/,
|
|
8850
9283
|
lookbehind: true,
|
|
8851
9284
|
greedy: true
|
|
8852
9285
|
},
|
|
8853
9286
|
{
|
|
9287
|
+
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
8854
9288
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
8855
9289
|
greedy: true,
|
|
8856
9290
|
inside: {
|
|
@@ -8871,9 +9305,11 @@ function bash(Prism2) {
|
|
|
8871
9305
|
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
8872
9306
|
lookbehind: true
|
|
8873
9307
|
},
|
|
9308
|
+
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
8874
9309
|
builtin: {
|
|
8875
9310
|
pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
|
8876
9311
|
lookbehind: true,
|
|
9312
|
+
// Alias added to make those easier to distinguish from strings.
|
|
8877
9313
|
alias: "class-name"
|
|
8878
9314
|
},
|
|
8879
9315
|
boolean: {
|
|
@@ -8885,6 +9321,7 @@ function bash(Prism2) {
|
|
|
8885
9321
|
alias: "important"
|
|
8886
9322
|
},
|
|
8887
9323
|
operator: {
|
|
9324
|
+
// Lots of redirections here, but not just that.
|
|
8888
9325
|
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
8889
9326
|
inside: {
|
|
8890
9327
|
"file-descriptor": {
|
|
@@ -8949,9 +9386,14 @@ function csharp(Prism2) {
|
|
|
8949
9386
|
return pattern.replace(/<<self>>/g, "[^\\s\\S]");
|
|
8950
9387
|
}
|
|
8951
9388
|
var keywordKinds = {
|
|
9389
|
+
// keywords which represent a return or variable type
|
|
8952
9390
|
type: "bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",
|
|
9391
|
+
// keywords which are used to declare a type
|
|
8953
9392
|
typeDeclaration: "class enum interface record struct",
|
|
9393
|
+
// contextual keywords
|
|
9394
|
+
// ("var" and "dynamic" are missing because they are used like types)
|
|
8954
9395
|
contextual: "add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",
|
|
9396
|
+
// all other keywords
|
|
8955
9397
|
other: "abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield"
|
|
8956
9398
|
};
|
|
8957
9399
|
function keywordsToPattern(words) {
|
|
@@ -9015,6 +9457,8 @@ function csharp(Prism2) {
|
|
|
9015
9457
|
],
|
|
9016
9458
|
"class-name": [
|
|
9017
9459
|
{
|
|
9460
|
+
// Using static
|
|
9461
|
+
// using static System.Math;
|
|
9018
9462
|
pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [
|
|
9019
9463
|
identifier
|
|
9020
9464
|
]),
|
|
@@ -9022,6 +9466,8 @@ function csharp(Prism2) {
|
|
|
9022
9466
|
inside: typeInside
|
|
9023
9467
|
},
|
|
9024
9468
|
{
|
|
9469
|
+
// Using alias (type)
|
|
9470
|
+
// using Project = PC.MyCompany.Project;
|
|
9025
9471
|
pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [
|
|
9026
9472
|
name,
|
|
9027
9473
|
typeExpression
|
|
@@ -9030,10 +9476,15 @@ function csharp(Prism2) {
|
|
|
9030
9476
|
inside: typeInside
|
|
9031
9477
|
},
|
|
9032
9478
|
{
|
|
9479
|
+
// Using alias (alias)
|
|
9480
|
+
// using Project = PC.MyCompany.Project;
|
|
9033
9481
|
pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
|
|
9034
9482
|
lookbehind: true
|
|
9035
9483
|
},
|
|
9036
9484
|
{
|
|
9485
|
+
// Type declarations
|
|
9486
|
+
// class Foo<A, B>
|
|
9487
|
+
// interface Foo<out A, B>
|
|
9037
9488
|
pattern: re(/(\b<<0>>\s+)<<1>>/.source, [
|
|
9038
9489
|
typeDeclarationKeywords,
|
|
9039
9490
|
genericName
|
|
@@ -9042,15 +9493,23 @@ function csharp(Prism2) {
|
|
|
9042
9493
|
inside: typeInside
|
|
9043
9494
|
},
|
|
9044
9495
|
{
|
|
9496
|
+
// Single catch exception declaration
|
|
9497
|
+
// catch(Foo)
|
|
9498
|
+
// (things like catch(Foo e) is covered by variable declaration)
|
|
9045
9499
|
pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
|
|
9046
9500
|
lookbehind: true,
|
|
9047
9501
|
inside: typeInside
|
|
9048
9502
|
},
|
|
9049
9503
|
{
|
|
9504
|
+
// Name of the type parameter of generic constraints
|
|
9505
|
+
// where Foo : class
|
|
9050
9506
|
pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
|
|
9051
9507
|
lookbehind: true
|
|
9052
9508
|
},
|
|
9053
9509
|
{
|
|
9510
|
+
// Casts and checks via as and is.
|
|
9511
|
+
// as Foo<A>, is Bar<B>
|
|
9512
|
+
// (things like if(a is Foo b) is covered by variable declaration)
|
|
9054
9513
|
pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [
|
|
9055
9514
|
typeExpressionWithoutTuple
|
|
9056
9515
|
]),
|
|
@@ -9058,6 +9517,8 @@ function csharp(Prism2) {
|
|
|
9058
9517
|
inside: typeInside
|
|
9059
9518
|
},
|
|
9060
9519
|
{
|
|
9520
|
+
// Variable, field and parameter declaration
|
|
9521
|
+
// (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
|
|
9061
9522
|
pattern: re(
|
|
9062
9523
|
/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source,
|
|
9063
9524
|
[typeExpression, nonContextualKeywords, name]
|
|
@@ -9066,6 +9527,7 @@ function csharp(Prism2) {
|
|
|
9066
9527
|
}
|
|
9067
9528
|
],
|
|
9068
9529
|
keyword: keywords,
|
|
9530
|
+
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
|
|
9069
9531
|
number: /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
|
|
9070
9532
|
operator: />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
|
|
9071
9533
|
punctuation: /\?\.?|::|[{}[\];(),.:]/
|
|
@@ -9085,6 +9547,8 @@ function csharp(Prism2) {
|
|
|
9085
9547
|
});
|
|
9086
9548
|
Prism3.languages.insertBefore("csharp", "class-name", {
|
|
9087
9549
|
namespace: {
|
|
9550
|
+
// namespace Foo.Bar {}
|
|
9551
|
+
// using Foo.Bar;
|
|
9088
9552
|
pattern: re(
|
|
9089
9553
|
/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source,
|
|
9090
9554
|
[name]
|
|
@@ -9095,6 +9559,7 @@ function csharp(Prism2) {
|
|
|
9095
9559
|
}
|
|
9096
9560
|
},
|
|
9097
9561
|
"type-expression": {
|
|
9562
|
+
// default(Foo), typeof(Foo<Bar>), sizeof(int)
|
|
9098
9563
|
pattern: re(
|
|
9099
9564
|
/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source,
|
|
9100
9565
|
[nestedRound]
|
|
@@ -9104,6 +9569,9 @@ function csharp(Prism2) {
|
|
|
9104
9569
|
inside: typeInside
|
|
9105
9570
|
},
|
|
9106
9571
|
"return-type": {
|
|
9572
|
+
// Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
|
|
9573
|
+
// int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
|
|
9574
|
+
// int Foo => 0; int Foo { get; set } = 0;
|
|
9107
9575
|
pattern: re(
|
|
9108
9576
|
/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source,
|
|
9109
9577
|
[typeExpression, identifier]
|
|
@@ -9112,12 +9580,20 @@ function csharp(Prism2) {
|
|
|
9112
9580
|
alias: "class-name"
|
|
9113
9581
|
},
|
|
9114
9582
|
"constructor-invocation": {
|
|
9583
|
+
// new List<Foo<Bar[]>> { }
|
|
9115
9584
|
pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
|
|
9116
9585
|
lookbehind: true,
|
|
9117
9586
|
inside: typeInside,
|
|
9118
9587
|
alias: "class-name"
|
|
9119
9588
|
},
|
|
9589
|
+
/*'explicit-implementation': {
|
|
9590
|
+
// int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
|
|
9591
|
+
pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
|
|
9592
|
+
inside: classNameInside,
|
|
9593
|
+
alias: 'class-name'
|
|
9594
|
+
},*/
|
|
9120
9595
|
"generic-method": {
|
|
9596
|
+
// foo<Bar>()
|
|
9121
9597
|
pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [name, generic]),
|
|
9122
9598
|
inside: {
|
|
9123
9599
|
function: re(/^<<0>>/.source, [name]),
|
|
@@ -9129,6 +9605,9 @@ function csharp(Prism2) {
|
|
|
9129
9605
|
}
|
|
9130
9606
|
},
|
|
9131
9607
|
"type-list": {
|
|
9608
|
+
// The list of types inherited or of generic constraints
|
|
9609
|
+
// class Foo<F> : Bar, IList<FooBar>
|
|
9610
|
+
// where F : Bar, IList<int>
|
|
9132
9611
|
pattern: re(
|
|
9133
9612
|
/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,
|
|
9134
9613
|
[
|
|
@@ -9166,6 +9645,7 @@ function csharp(Prism2) {
|
|
|
9166
9645
|
lookbehind: true,
|
|
9167
9646
|
alias: "property",
|
|
9168
9647
|
inside: {
|
|
9648
|
+
// highlight preprocessor directives as keywords
|
|
9169
9649
|
directive: {
|
|
9170
9650
|
pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
|
|
9171
9651
|
lookbehind: true,
|
|
@@ -9192,6 +9672,8 @@ function csharp(Prism2) {
|
|
|
9192
9672
|
]);
|
|
9193
9673
|
Prism3.languages.insertBefore("csharp", "class-name", {
|
|
9194
9674
|
attribute: {
|
|
9675
|
+
// Attributes
|
|
9676
|
+
// [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
|
|
9195
9677
|
pattern: re(
|
|
9196
9678
|
/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source,
|
|
9197
9679
|
[attrTarget, attr]
|
|
@@ -9309,6 +9791,7 @@ function markup(Prism2) {
|
|
|
9309
9791
|
greedy: true
|
|
9310
9792
|
},
|
|
9311
9793
|
doctype: {
|
|
9794
|
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
9312
9795
|
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
9313
9796
|
greedy: true,
|
|
9314
9797
|
inside: {
|
|
@@ -9317,6 +9800,7 @@ function markup(Prism2) {
|
|
|
9317
9800
|
lookbehind: true,
|
|
9318
9801
|
greedy: true,
|
|
9319
9802
|
inside: null
|
|
9803
|
+
// see below
|
|
9320
9804
|
},
|
|
9321
9805
|
string: {
|
|
9322
9806
|
pattern: /"[^"]*"|'[^']*'/,
|
|
@@ -9383,6 +9867,17 @@ function markup(Prism2) {
|
|
|
9383
9867
|
}
|
|
9384
9868
|
});
|
|
9385
9869
|
Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
|
|
9870
|
+
/**
|
|
9871
|
+
* Adds an inlined language to markup.
|
|
9872
|
+
*
|
|
9873
|
+
* An example of an inlined language is CSS with `<style>` tags.
|
|
9874
|
+
*
|
|
9875
|
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
9876
|
+
* case insensitive.
|
|
9877
|
+
* @param {string} lang The language key.
|
|
9878
|
+
* @example
|
|
9879
|
+
* addInlined('style', 'css');
|
|
9880
|
+
*/
|
|
9386
9881
|
value: function addInlined(tagName, lang) {
|
|
9387
9882
|
var includedCdataInside = {};
|
|
9388
9883
|
includedCdataInside["language-" + lang] = {
|
|
@@ -9420,6 +9915,17 @@ function markup(Prism2) {
|
|
|
9420
9915
|
}
|
|
9421
9916
|
});
|
|
9422
9917
|
Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
|
|
9918
|
+
/**
|
|
9919
|
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
9920
|
+
*
|
|
9921
|
+
* An example of an inlined language is CSS with `style` attributes.
|
|
9922
|
+
*
|
|
9923
|
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
9924
|
+
* case insensitive.
|
|
9925
|
+
* @param {string} lang The language key.
|
|
9926
|
+
* @example
|
|
9927
|
+
* addAttribute('style', 'css');
|
|
9928
|
+
*/
|
|
9423
9929
|
value: function(attrName, lang) {
|
|
9424
9930
|
Prism2.languages.markup.tag.inside["special-attr"].push({
|
|
9425
9931
|
pattern: RegExp(
|
|
@@ -9484,9 +9990,11 @@ function css(Prism2) {
|
|
|
9484
9990
|
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
9485
9991
|
lookbehind: true
|
|
9486
9992
|
}
|
|
9993
|
+
// See rest below
|
|
9487
9994
|
}
|
|
9488
9995
|
},
|
|
9489
9996
|
url: {
|
|
9997
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
9490
9998
|
pattern: RegExp(
|
|
9491
9999
|
"\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)",
|
|
9492
10000
|
"i"
|
|
@@ -9539,10 +10047,14 @@ function diff(Prism2) {
|
|
|
9539
10047
|
(function(Prism3) {
|
|
9540
10048
|
Prism3.languages.diff = {
|
|
9541
10049
|
coord: [
|
|
10050
|
+
// Match all kinds of coord lines (prefixed by "+++", "---" or "***").
|
|
9542
10051
|
/^(?:\*{3}|-{3}|\+{3}).*$/m,
|
|
10052
|
+
// Match "@@ ... @@" coord lines in unified diff.
|
|
9543
10053
|
/^@@.*@@$/m,
|
|
10054
|
+
// Match coord lines in normal diff (starts with a number).
|
|
9544
10055
|
/^\d.*$/m
|
|
9545
10056
|
]
|
|
10057
|
+
// deleted, inserted, unchanged, diff
|
|
9546
10058
|
};
|
|
9547
10059
|
var PREFIXES = {
|
|
9548
10060
|
"deleted-sign": "-",
|
|
@@ -9599,8 +10111,11 @@ function go(Prism2) {
|
|
|
9599
10111
|
keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
9600
10112
|
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
9601
10113
|
number: [
|
|
10114
|
+
// binary and octal integers
|
|
9602
10115
|
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
10116
|
+
// hexadecimal integers and floats
|
|
9603
10117
|
/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
|
|
10118
|
+
// decimal integers and floats
|
|
9604
10119
|
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
9605
10120
|
],
|
|
9606
10121
|
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
@@ -9620,6 +10135,11 @@ ini.displayName = "ini";
|
|
|
9620
10135
|
ini.aliases = [];
|
|
9621
10136
|
function ini(Prism2) {
|
|
9622
10137
|
Prism2.languages.ini = {
|
|
10138
|
+
/**
|
|
10139
|
+
* The component mimics the behavior of the Win32 API parser.
|
|
10140
|
+
*
|
|
10141
|
+
* @see {@link https://github.com/PrismJS/prism/issues/2775#issuecomment-787477723}
|
|
10142
|
+
*/
|
|
9623
10143
|
comment: {
|
|
9624
10144
|
pattern: /(^[ \f\t\v]*)[#;][^\n\r]*/m,
|
|
9625
10145
|
lookbehind: true
|
|
@@ -9688,6 +10208,8 @@ function java(Prism2) {
|
|
|
9688
10208
|
"class-name": [
|
|
9689
10209
|
className,
|
|
9690
10210
|
{
|
|
10211
|
+
// variables, parameters, and constructor references
|
|
10212
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
9691
10213
|
pattern: RegExp(
|
|
9692
10214
|
/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source
|
|
9693
10215
|
),
|
|
@@ -9695,6 +10217,8 @@ function java(Prism2) {
|
|
|
9695
10217
|
inside: className.inside
|
|
9696
10218
|
},
|
|
9697
10219
|
{
|
|
10220
|
+
// class names based on keyword
|
|
10221
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
9698
10222
|
pattern: RegExp(
|
|
9699
10223
|
/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source
|
|
9700
10224
|
),
|
|
@@ -9719,6 +10243,7 @@ function java(Prism2) {
|
|
|
9719
10243
|
});
|
|
9720
10244
|
Prism3.languages.insertBefore("java", "string", {
|
|
9721
10245
|
"triple-quoted-string": {
|
|
10246
|
+
// http://openjdk.java.net/jeps/355#Description
|
|
9722
10247
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
9723
10248
|
greedy: true,
|
|
9724
10249
|
alias: "string"
|
|
@@ -9848,6 +10373,7 @@ function regex(Prism2) {
|
|
|
9848
10373
|
"char-set": charSet,
|
|
9849
10374
|
backreference: [
|
|
9850
10375
|
{
|
|
10376
|
+
// a backreference which is not an octal escape
|
|
9851
10377
|
pattern: /\\(?![123][0-7]{2})[1-9]/,
|
|
9852
10378
|
alias: "keyword"
|
|
9853
10379
|
},
|
|
@@ -9866,6 +10392,9 @@ function regex(Prism2) {
|
|
|
9866
10392
|
escape,
|
|
9867
10393
|
group: [
|
|
9868
10394
|
{
|
|
10395
|
+
// https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html
|
|
10396
|
+
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference?view=netframework-4.7.2#grouping-constructs
|
|
10397
|
+
// (), (?<name>), (?'name'), (?>), (?:), (?=), (?!), (?<=), (?<!), (?is-m), (?i-m:)
|
|
9869
10398
|
pattern: /\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/,
|
|
9870
10399
|
alias: "punctuation",
|
|
9871
10400
|
inside: {
|
|
@@ -9912,10 +10441,17 @@ function javascript(Prism2) {
|
|
|
9912
10441
|
lookbehind: true
|
|
9913
10442
|
}
|
|
9914
10443
|
],
|
|
10444
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
9915
10445
|
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
9916
10446
|
number: {
|
|
9917
10447
|
pattern: RegExp(
|
|
9918
|
-
/(^|[^\w$])/.source + "(?:" +
|
|
10448
|
+
/(^|[^\w$])/.source + "(?:" + // constant
|
|
10449
|
+
(/NaN|Infinity/.source + "|" + // binary integer
|
|
10450
|
+
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
10451
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
10452
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
10453
|
+
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
10454
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
9919
10455
|
),
|
|
9920
10456
|
lookbehind: true
|
|
9921
10457
|
},
|
|
@@ -9925,7 +10461,15 @@ function javascript(Prism2) {
|
|
|
9925
10461
|
Prism2.languages.insertBefore("javascript", "keyword", {
|
|
9926
10462
|
regex: {
|
|
9927
10463
|
pattern: RegExp(
|
|
9928
|
-
|
|
10464
|
+
// lookbehind
|
|
10465
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
10466
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
10467
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
10468
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
10469
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
10470
|
+
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
10471
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
10472
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
9929
10473
|
),
|
|
9930
10474
|
lookbehind: true,
|
|
9931
10475
|
greedy: true,
|
|
@@ -9940,6 +10484,7 @@ function javascript(Prism2) {
|
|
|
9940
10484
|
"regex-flags": /^[a-z]+$/
|
|
9941
10485
|
}
|
|
9942
10486
|
},
|
|
10487
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
9943
10488
|
"function-variable": {
|
|
9944
10489
|
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
9945
10490
|
alias: "function"
|
|
@@ -10059,6 +10604,7 @@ function kotlin(Prism2) {
|
|
|
10059
10604
|
(function(Prism3) {
|
|
10060
10605
|
Prism3.languages.kotlin = Prism3.languages.extend("clike", {
|
|
10061
10606
|
keyword: {
|
|
10607
|
+
// The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
|
|
10062
10608
|
pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
|
|
10063
10609
|
lookbehind: true
|
|
10064
10610
|
},
|
|
@@ -10088,6 +10634,7 @@ function kotlin(Prism2) {
|
|
|
10088
10634
|
}
|
|
10089
10635
|
};
|
|
10090
10636
|
Prism3.languages.insertBefore("kotlin", "string", {
|
|
10637
|
+
// https://kotlinlang.org/spec/expressions.html#string-interpolation-expressions
|
|
10091
10638
|
"string-literal": [
|
|
10092
10639
|
{
|
|
10093
10640
|
pattern: /"""(?:[^$]|\$(?:(?!\{)|\{[^{}]*\}))*?"""/,
|
|
@@ -10114,6 +10661,7 @@ function kotlin(Prism2) {
|
|
|
10114
10661
|
}
|
|
10115
10662
|
],
|
|
10116
10663
|
char: {
|
|
10664
|
+
// https://kotlinlang.org/spec/expressions.html#character-literals
|
|
10117
10665
|
pattern: /'(?:[^'\\\r\n]|\\(?:.|u[a-fA-F0-9]{0,4}))'/,
|
|
10118
10666
|
greedy: true
|
|
10119
10667
|
}
|
|
@@ -10155,9 +10703,11 @@ function less(Prism2) {
|
|
|
10155
10703
|
punctuation: /[:()]/
|
|
10156
10704
|
}
|
|
10157
10705
|
},
|
|
10706
|
+
// selectors and mixins are considered the same
|
|
10158
10707
|
selector: {
|
|
10159
10708
|
pattern: /(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};@\s]|\s+(?!\s))*?(?=\s*\{)/,
|
|
10160
10709
|
inside: {
|
|
10710
|
+
// mixin parameters
|
|
10161
10711
|
variable: /@+[\w-]+/
|
|
10162
10712
|
}
|
|
10163
10713
|
},
|
|
@@ -10166,12 +10716,14 @@ function less(Prism2) {
|
|
|
10166
10716
|
});
|
|
10167
10717
|
Prism2.languages.insertBefore("less", "property", {
|
|
10168
10718
|
variable: [
|
|
10719
|
+
// Variable declaration (the colon must be consumed!)
|
|
10169
10720
|
{
|
|
10170
10721
|
pattern: /@[\w-]+\s*:/,
|
|
10171
10722
|
inside: {
|
|
10172
10723
|
punctuation: /:/
|
|
10173
10724
|
}
|
|
10174
10725
|
},
|
|
10726
|
+
// Variable usage
|
|
10175
10727
|
/@@?[\w-]+/
|
|
10176
10728
|
],
|
|
10177
10729
|
"mixin-usage": {
|
|
@@ -10188,6 +10740,7 @@ lua.aliases = [];
|
|
|
10188
10740
|
function lua(Prism2) {
|
|
10189
10741
|
Prism2.languages.lua = {
|
|
10190
10742
|
comment: /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
|
|
10743
|
+
// \z may be used to skip the following space
|
|
10191
10744
|
string: {
|
|
10192
10745
|
pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[^z]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
|
|
10193
10746
|
greedy: true
|
|
@@ -10198,6 +10751,7 @@ function lua(Prism2) {
|
|
|
10198
10751
|
operator: [
|
|
10199
10752
|
/[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
|
|
10200
10753
|
{
|
|
10754
|
+
// Match ".." but don't break "..."
|
|
10201
10755
|
pattern: /(^|[^.])\.\.(?!\.)/,
|
|
10202
10756
|
lookbehind: true
|
|
10203
10757
|
}
|
|
@@ -10231,6 +10785,7 @@ function makefile(Prism2) {
|
|
|
10231
10785
|
}
|
|
10232
10786
|
},
|
|
10233
10787
|
variable: /\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
|
|
10788
|
+
// Directives
|
|
10234
10789
|
keyword: /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
|
|
10235
10790
|
function: {
|
|
10236
10791
|
pattern: /(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,
|
|
@@ -10371,6 +10926,7 @@ function markdown(Prism2) {
|
|
|
10371
10926
|
}
|
|
10372
10927
|
},
|
|
10373
10928
|
blockquote: {
|
|
10929
|
+
// > ...
|
|
10374
10930
|
pattern: /^>(?:[\t ]*>)*/m,
|
|
10375
10931
|
alias: "punctuation"
|
|
10376
10932
|
},
|
|
@@ -10415,11 +10971,15 @@ function markdown(Prism2) {
|
|
|
10415
10971
|
},
|
|
10416
10972
|
code: [
|
|
10417
10973
|
{
|
|
10974
|
+
// Prefixed by 4 spaces or 1 tab and preceded by an empty line
|
|
10418
10975
|
pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
|
|
10419
10976
|
lookbehind: true,
|
|
10420
10977
|
alias: "keyword"
|
|
10421
10978
|
},
|
|
10422
10979
|
{
|
|
10980
|
+
// ```optional language
|
|
10981
|
+
// code block
|
|
10982
|
+
// ```
|
|
10423
10983
|
pattern: /^```[\s\S]*?^```$/m,
|
|
10424
10984
|
greedy: true,
|
|
10425
10985
|
inside: {
|
|
@@ -10437,6 +10997,10 @@ function markdown(Prism2) {
|
|
|
10437
10997
|
],
|
|
10438
10998
|
title: [
|
|
10439
10999
|
{
|
|
11000
|
+
// title 1
|
|
11001
|
+
// =======
|
|
11002
|
+
// title 2
|
|
11003
|
+
// -------
|
|
10440
11004
|
pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
|
|
10441
11005
|
alias: "important",
|
|
10442
11006
|
inside: {
|
|
@@ -10444,6 +11008,8 @@ function markdown(Prism2) {
|
|
|
10444
11008
|
}
|
|
10445
11009
|
},
|
|
10446
11010
|
{
|
|
11011
|
+
// # title 1
|
|
11012
|
+
// ###### title 6
|
|
10447
11013
|
pattern: /(^\s*)#.+/m,
|
|
10448
11014
|
lookbehind: true,
|
|
10449
11015
|
alias: "important",
|
|
@@ -10453,16 +11019,28 @@ function markdown(Prism2) {
|
|
|
10453
11019
|
}
|
|
10454
11020
|
],
|
|
10455
11021
|
hr: {
|
|
11022
|
+
// ***
|
|
11023
|
+
// ---
|
|
11024
|
+
// * * *
|
|
11025
|
+
// -----------
|
|
10456
11026
|
pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
|
|
10457
11027
|
lookbehind: true,
|
|
10458
11028
|
alias: "punctuation"
|
|
10459
11029
|
},
|
|
10460
11030
|
list: {
|
|
11031
|
+
// * item
|
|
11032
|
+
// + item
|
|
11033
|
+
// - item
|
|
11034
|
+
// 1. item
|
|
10461
11035
|
pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
|
|
10462
11036
|
lookbehind: true,
|
|
10463
11037
|
alias: "punctuation"
|
|
10464
11038
|
},
|
|
10465
11039
|
"url-reference": {
|
|
11040
|
+
// [id]: http://example.com "Optional title"
|
|
11041
|
+
// [id]: http://example.com 'Optional title'
|
|
11042
|
+
// [id]: http://example.com (Optional title)
|
|
11043
|
+
// [id]: <http://example.com> "Optional title"
|
|
10466
11044
|
pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
|
|
10467
11045
|
inside: {
|
|
10468
11046
|
variable: {
|
|
@@ -10475,6 +11053,9 @@ function markdown(Prism2) {
|
|
|
10475
11053
|
alias: "url"
|
|
10476
11054
|
},
|
|
10477
11055
|
bold: {
|
|
11056
|
+
// **strong**
|
|
11057
|
+
// __strong__
|
|
11058
|
+
// allow one nested instance of italic text using the same delimiter
|
|
10478
11059
|
pattern: createInline(
|
|
10479
11060
|
/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source
|
|
10480
11061
|
),
|
|
@@ -10485,11 +11066,15 @@ function markdown(Prism2) {
|
|
|
10485
11066
|
pattern: /(^..)[\s\S]+(?=..$)/,
|
|
10486
11067
|
lookbehind: true,
|
|
10487
11068
|
inside: {}
|
|
11069
|
+
// see below
|
|
10488
11070
|
},
|
|
10489
11071
|
punctuation: /\*\*|__/
|
|
10490
11072
|
}
|
|
10491
11073
|
},
|
|
10492
11074
|
italic: {
|
|
11075
|
+
// *em*
|
|
11076
|
+
// _em_
|
|
11077
|
+
// allow one nested instance of bold text using the same delimiter
|
|
10493
11078
|
pattern: createInline(
|
|
10494
11079
|
/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source
|
|
10495
11080
|
),
|
|
@@ -10500,11 +11085,15 @@ function markdown(Prism2) {
|
|
|
10500
11085
|
pattern: /(^.)[\s\S]+(?=.$)/,
|
|
10501
11086
|
lookbehind: true,
|
|
10502
11087
|
inside: {}
|
|
11088
|
+
// see below
|
|
10503
11089
|
},
|
|
10504
11090
|
punctuation: /[*_]/
|
|
10505
11091
|
}
|
|
10506
11092
|
},
|
|
10507
11093
|
strike: {
|
|
11094
|
+
// ~~strike through~~
|
|
11095
|
+
// ~strike~
|
|
11096
|
+
// eslint-disable-next-line regexp/strict
|
|
10508
11097
|
pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
|
|
10509
11098
|
lookbehind: true,
|
|
10510
11099
|
greedy: true,
|
|
@@ -10513,17 +11102,23 @@ function markdown(Prism2) {
|
|
|
10513
11102
|
pattern: /(^~~?)[\s\S]+(?=\1$)/,
|
|
10514
11103
|
lookbehind: true,
|
|
10515
11104
|
inside: {}
|
|
11105
|
+
// see below
|
|
10516
11106
|
},
|
|
10517
11107
|
punctuation: /~~?/
|
|
10518
11108
|
}
|
|
10519
11109
|
},
|
|
10520
11110
|
"code-snippet": {
|
|
11111
|
+
// `code`
|
|
11112
|
+
// ``code``
|
|
10521
11113
|
pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,
|
|
10522
11114
|
lookbehind: true,
|
|
10523
11115
|
greedy: true,
|
|
10524
11116
|
alias: ["code", "keyword"]
|
|
10525
11117
|
},
|
|
10526
11118
|
url: {
|
|
11119
|
+
// [example](http://example.com "Optional title")
|
|
11120
|
+
// [example][id]
|
|
11121
|
+
// [example] [id]
|
|
10527
11122
|
pattern: createInline(
|
|
10528
11123
|
/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source
|
|
10529
11124
|
),
|
|
@@ -10535,6 +11130,7 @@ function markdown(Prism2) {
|
|
|
10535
11130
|
pattern: /(^\[)[^\]]+(?=\])/,
|
|
10536
11131
|
lookbehind: true,
|
|
10537
11132
|
inside: {}
|
|
11133
|
+
// see below
|
|
10538
11134
|
},
|
|
10539
11135
|
variable: {
|
|
10540
11136
|
pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/,
|
|
@@ -10607,7 +11203,7 @@ function markdown(Prism2) {
|
|
|
10607
11203
|
var grammar = Prism3.languages[codeLang];
|
|
10608
11204
|
if (!grammar) {
|
|
10609
11205
|
if (codeLang && codeLang !== "none" && Prism3.plugins.autoloader) {
|
|
10610
|
-
var id = "md-" + new Date().valueOf() + "-" + Math.floor(Math.random() * 1e16);
|
|
11206
|
+
var id = "md-" + (/* @__PURE__ */ new Date()).valueOf() + "-" + Math.floor(Math.random() * 1e16);
|
|
10611
11207
|
env.attributes["id"] = id;
|
|
10612
11208
|
Prism3.plugins.autoloader.loadLanguages(codeLang, function() {
|
|
10613
11209
|
var ele = document.getElementById(id);
|
|
@@ -10689,6 +11285,7 @@ function perl(Prism2) {
|
|
|
10689
11285
|
Prism3.languages.perl = {
|
|
10690
11286
|
comment: [
|
|
10691
11287
|
{
|
|
11288
|
+
// POD
|
|
10692
11289
|
pattern: /(^\s*)=\w[\s\S]*?=cut.*/m,
|
|
10693
11290
|
lookbehind: true,
|
|
10694
11291
|
greedy: true
|
|
@@ -10699,21 +11296,32 @@ function perl(Prism2) {
|
|
|
10699
11296
|
greedy: true
|
|
10700
11297
|
}
|
|
10701
11298
|
],
|
|
11299
|
+
// TODO Could be nice to handle Heredoc too.
|
|
10702
11300
|
string: [
|
|
10703
11301
|
{
|
|
10704
11302
|
pattern: RegExp(
|
|
10705
11303
|
/\b(?:q|qq|qw|qx)(?![a-zA-Z0-9])\s*/.source + "(?:" + [
|
|
11304
|
+
// q/.../
|
|
10706
11305
|
/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
|
|
11306
|
+
// q a...a
|
|
11307
|
+
// eslint-disable-next-line regexp/strict
|
|
10707
11308
|
/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
|
|
11309
|
+
// q(...)
|
|
11310
|
+
// q{...}
|
|
11311
|
+
// q[...]
|
|
11312
|
+
// q<...>
|
|
10708
11313
|
brackets
|
|
10709
11314
|
].join("|") + ")"
|
|
10710
11315
|
),
|
|
10711
11316
|
greedy: true
|
|
10712
11317
|
},
|
|
11318
|
+
// "...", `...`
|
|
10713
11319
|
{
|
|
10714
11320
|
pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
|
|
10715
11321
|
greedy: true
|
|
10716
11322
|
},
|
|
11323
|
+
// '...'
|
|
11324
|
+
// FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
|
|
10717
11325
|
{
|
|
10718
11326
|
pattern: /'(?:[^'\\\r\n]|\\.)*'/,
|
|
10719
11327
|
greedy: true
|
|
@@ -10723,42 +11331,73 @@ function perl(Prism2) {
|
|
|
10723
11331
|
{
|
|
10724
11332
|
pattern: RegExp(
|
|
10725
11333
|
/\b(?:m|qr)(?![a-zA-Z0-9])\s*/.source + "(?:" + [
|
|
11334
|
+
// m/.../
|
|
10726
11335
|
/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
|
|
11336
|
+
// m a...a
|
|
11337
|
+
// eslint-disable-next-line regexp/strict
|
|
10727
11338
|
/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
|
|
11339
|
+
// m(...)
|
|
11340
|
+
// m{...}
|
|
11341
|
+
// m[...]
|
|
11342
|
+
// m<...>
|
|
10728
11343
|
brackets
|
|
10729
11344
|
].join("|") + ")" + /[msixpodualngc]*/.source
|
|
10730
11345
|
),
|
|
10731
11346
|
greedy: true
|
|
10732
11347
|
},
|
|
11348
|
+
// The lookbehinds prevent -s from breaking
|
|
10733
11349
|
{
|
|
10734
11350
|
pattern: RegExp(
|
|
10735
11351
|
/(^|[^-])\b(?:s|tr|y)(?![a-zA-Z0-9])\s*/.source + "(?:" + [
|
|
11352
|
+
// s/.../.../
|
|
11353
|
+
// eslint-disable-next-line regexp/strict
|
|
10736
11354
|
/([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
|
|
11355
|
+
// s a...a...a
|
|
11356
|
+
// eslint-disable-next-line regexp/strict
|
|
10737
11357
|
/([a-zA-Z0-9])(?:(?!\3)[^\\]|\\[\s\S])*\3(?:(?!\3)[^\\]|\\[\s\S])*\3/.source,
|
|
11358
|
+
// s(...)(...)
|
|
11359
|
+
// s{...}{...}
|
|
11360
|
+
// s[...][...]
|
|
11361
|
+
// s<...><...>
|
|
11362
|
+
// s(...)[...]
|
|
10738
11363
|
brackets + /\s*/.source + brackets
|
|
10739
11364
|
].join("|") + ")" + /[msixpodualngcer]*/.source
|
|
10740
11365
|
),
|
|
10741
11366
|
lookbehind: true,
|
|
10742
11367
|
greedy: true
|
|
10743
11368
|
},
|
|
11369
|
+
// /.../
|
|
11370
|
+
// The look-ahead tries to prevent two divisions on
|
|
11371
|
+
// the same line from being highlighted as regex.
|
|
11372
|
+
// This does not support multi-line regex.
|
|
10744
11373
|
{
|
|
10745
11374
|
pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|x|xor)\b))/,
|
|
10746
11375
|
greedy: true
|
|
10747
11376
|
}
|
|
10748
11377
|
],
|
|
11378
|
+
// FIXME Not sure about the handling of ::, ', and #
|
|
10749
11379
|
variable: [
|
|
11380
|
+
// ${^POSTMATCH}
|
|
10750
11381
|
/[&*$@%]\{\^[A-Z]+\}/,
|
|
11382
|
+
// $^V
|
|
10751
11383
|
/[&*$@%]\^[A-Z_]/,
|
|
11384
|
+
// ${...}
|
|
10752
11385
|
/[&*$@%]#?(?=\{)/,
|
|
11386
|
+
// $foo
|
|
10753
11387
|
/[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+(?![\w$]))+(?:::)*/,
|
|
11388
|
+
// $1
|
|
10754
11389
|
/[&*$@%]\d+/,
|
|
11390
|
+
// $_, @_, %!
|
|
11391
|
+
// The negative lookahead prevents from breaking the %= operator
|
|
10755
11392
|
/(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
|
|
10756
11393
|
],
|
|
10757
11394
|
filehandle: {
|
|
11395
|
+
// <>, <FOO>, _
|
|
10758
11396
|
pattern: /<(?![<=])\S*?>|\b_\b/,
|
|
10759
11397
|
alias: "symbol"
|
|
10760
11398
|
},
|
|
10761
11399
|
"v-string": {
|
|
11400
|
+
// v1.2, 1.2.3
|
|
10762
11401
|
pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
|
|
10763
11402
|
alias: "string"
|
|
10764
11403
|
},
|
|
@@ -10785,6 +11424,17 @@ function markupTemplating(Prism2) {
|
|
|
10785
11424
|
}
|
|
10786
11425
|
Object.defineProperties(Prism3.languages["markup-templating"] = {}, {
|
|
10787
11426
|
buildPlaceholders: {
|
|
11427
|
+
/**
|
|
11428
|
+
* Tokenize all inline templating expressions matching `placeholderPattern`.
|
|
11429
|
+
*
|
|
11430
|
+
* If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
|
|
11431
|
+
* `true` will be replaced.
|
|
11432
|
+
*
|
|
11433
|
+
* @param {object} env The environment of the `before-tokenize` hook.
|
|
11434
|
+
* @param {string} language The language id.
|
|
11435
|
+
* @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
|
|
11436
|
+
* @param {(match: string) => boolean} [replaceFilter]
|
|
11437
|
+
*/
|
|
10788
11438
|
value: function(env, language, placeholderPattern, replaceFilter) {
|
|
10789
11439
|
if (env.language !== language) {
|
|
10790
11440
|
return;
|
|
@@ -10806,6 +11456,12 @@ function markupTemplating(Prism2) {
|
|
|
10806
11456
|
}
|
|
10807
11457
|
},
|
|
10808
11458
|
tokenizePlaceholders: {
|
|
11459
|
+
/**
|
|
11460
|
+
* Replace placeholders with proper tokens after tokenizing.
|
|
11461
|
+
*
|
|
11462
|
+
* @param {object} env The environment of the `after-tokenize` hook.
|
|
11463
|
+
* @param {string} language The language id.
|
|
11464
|
+
*/
|
|
10809
11465
|
value: function(env, language) {
|
|
10810
11466
|
if (env.language !== language || !env.tokenStack) {
|
|
10811
11467
|
return;
|
|
@@ -10950,11 +11606,17 @@ function php(Prism2) {
|
|
|
10950
11606
|
greedy: true
|
|
10951
11607
|
},
|
|
10952
11608
|
{
|
|
11609
|
+
// yield from
|
|
10953
11610
|
pattern: /(\byield\s+)from\b/i,
|
|
10954
11611
|
lookbehind: true
|
|
10955
11612
|
},
|
|
11613
|
+
// `class` is always a keyword unlike other keywords
|
|
10956
11614
|
/\bclass\b/i,
|
|
10957
11615
|
{
|
|
11616
|
+
// https://www.php.net/manual/en/reserved.keywords.php
|
|
11617
|
+
//
|
|
11618
|
+
// keywords cannot be preceded by "->"
|
|
11619
|
+
// the complex lookbehind means `(?<!(?:->|::)\s*)`
|
|
10958
11620
|
pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
|
|
10959
11621
|
lookbehind: true
|
|
10960
11622
|
}
|
|
@@ -11140,6 +11802,7 @@ function php(Prism2) {
|
|
|
11140
11802
|
"attribute-content": {
|
|
11141
11803
|
pattern: /^(#\[)[\s\S]+(?=\]$)/,
|
|
11142
11804
|
lookbehind: true,
|
|
11805
|
+
// inside can appear subset of php
|
|
11143
11806
|
inside: {
|
|
11144
11807
|
comment: comment4,
|
|
11145
11808
|
string,
|
|
@@ -11205,6 +11868,7 @@ function python(Prism2) {
|
|
|
11205
11868
|
greedy: true,
|
|
11206
11869
|
inside: {
|
|
11207
11870
|
interpolation: {
|
|
11871
|
+
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
11208
11872
|
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
11209
11873
|
lookbehind: true,
|
|
11210
11874
|
inside: {
|
|
@@ -11269,6 +11933,8 @@ function r(Prism2) {
|
|
|
11269
11933
|
greedy: true
|
|
11270
11934
|
},
|
|
11271
11935
|
"percent-operator": {
|
|
11936
|
+
// Includes user-defined operators
|
|
11937
|
+
// and %%, %*%, %/%, %in%, %o%, %x%
|
|
11272
11938
|
pattern: /%[^%\s]*%/,
|
|
11273
11939
|
alias: "operator"
|
|
11274
11940
|
},
|
|
@@ -11510,8 +12176,10 @@ function rust(Prism2) {
|
|
|
11510
12176
|
alias: "attr-name",
|
|
11511
12177
|
inside: {
|
|
11512
12178
|
string: null
|
|
12179
|
+
// see below
|
|
11513
12180
|
}
|
|
11514
12181
|
},
|
|
12182
|
+
// Closure params should not be confused with bitwise OR |
|
|
11515
12183
|
"closure-params": {
|
|
11516
12184
|
pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
|
|
11517
12185
|
lookbehind: true,
|
|
@@ -11522,6 +12190,7 @@ function rust(Prism2) {
|
|
|
11522
12190
|
alias: "punctuation"
|
|
11523
12191
|
},
|
|
11524
12192
|
rest: null
|
|
12193
|
+
// see below
|
|
11525
12194
|
}
|
|
11526
12195
|
},
|
|
11527
12196
|
"lifetime-annotation": {
|
|
@@ -11560,9 +12229,15 @@ function rust(Prism2) {
|
|
|
11560
12229
|
}
|
|
11561
12230
|
],
|
|
11562
12231
|
keyword: [
|
|
12232
|
+
// https://github.com/rust-lang/reference/blob/master/src/keywords.md
|
|
11563
12233
|
/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
|
|
12234
|
+
// primitives and str
|
|
12235
|
+
// https://doc.rust-lang.org/stable/rust-by-example/primitives.html
|
|
11564
12236
|
/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
|
|
11565
12237
|
],
|
|
12238
|
+
// functions can technically start with an upper-case letter, but this will introduce a lot of false positives
|
|
12239
|
+
// and Rust's naming conventions recommend snake_case anyway.
|
|
12240
|
+
// https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
|
|
11566
12241
|
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
11567
12242
|
macro: {
|
|
11568
12243
|
pattern: /\b\w+!/,
|
|
@@ -11576,6 +12251,7 @@ function rust(Prism2) {
|
|
|
11576
12251
|
punctuation: /::/
|
|
11577
12252
|
}
|
|
11578
12253
|
},
|
|
12254
|
+
// Hex, oct, bin, dec numbers with visual separators and type suffix
|
|
11579
12255
|
number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
|
|
11580
12256
|
boolean: /\b(?:false|true)\b/,
|
|
11581
12257
|
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
@@ -11593,6 +12269,7 @@ function sass(Prism2) {
|
|
|
11593
12269
|
Prism2.register(css);
|
|
11594
12270
|
(function(Prism3) {
|
|
11595
12271
|
Prism3.languages.sass = Prism3.languages.extend("css", {
|
|
12272
|
+
// Sass comments don't need to be closed, only indented
|
|
11596
12273
|
comment: {
|
|
11597
12274
|
pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,
|
|
11598
12275
|
lookbehind: true,
|
|
@@ -11600,7 +12277,9 @@ function sass(Prism2) {
|
|
|
11600
12277
|
}
|
|
11601
12278
|
});
|
|
11602
12279
|
Prism3.languages.insertBefore("sass", "atrule", {
|
|
12280
|
+
// We want to consume the whole line
|
|
11603
12281
|
"atrule-line": {
|
|
12282
|
+
// Includes support for = and + shortcuts
|
|
11604
12283
|
pattern: /^(?:[ \t]*)[@+=].+/m,
|
|
11605
12284
|
greedy: true,
|
|
11606
12285
|
inside: {
|
|
@@ -11618,6 +12297,7 @@ function sass(Prism2) {
|
|
|
11618
12297
|
}
|
|
11619
12298
|
];
|
|
11620
12299
|
Prism3.languages.insertBefore("sass", "property", {
|
|
12300
|
+
// We want to consume the whole line
|
|
11621
12301
|
"variable-line": {
|
|
11622
12302
|
pattern: /^[ \t]*\$.+/m,
|
|
11623
12303
|
greedy: true,
|
|
@@ -11627,6 +12307,7 @@ function sass(Prism2) {
|
|
|
11627
12307
|
operator
|
|
11628
12308
|
}
|
|
11629
12309
|
},
|
|
12310
|
+
// We want to consume the whole line
|
|
11630
12311
|
"property-line": {
|
|
11631
12312
|
pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,
|
|
11632
12313
|
greedy: true,
|
|
@@ -11671,10 +12352,20 @@ function scss(Prism2) {
|
|
|
11671
12352
|
pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
|
|
11672
12353
|
inside: {
|
|
11673
12354
|
rule: /@[\w-]+/
|
|
12355
|
+
// See rest below
|
|
11674
12356
|
}
|
|
11675
12357
|
},
|
|
12358
|
+
// url, compassified
|
|
11676
12359
|
url: /(?:[-a-z]+-)?url(?=\()/i,
|
|
12360
|
+
// CSS selector regex is not appropriate for Sass
|
|
12361
|
+
// since there can be lot more things (var, @ directive, nesting..)
|
|
12362
|
+
// a selector must start at the end of a property or after a brace (end of other rules or nesting)
|
|
12363
|
+
// it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
|
|
12364
|
+
// the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
|
|
12365
|
+
// can "pass" as a selector- e.g: proper#{$erty})
|
|
12366
|
+
// this one was hard to do, so please be careful if you edit this one :)
|
|
11677
12367
|
selector: {
|
|
12368
|
+
// Initial look-ahead is used to prevent matching of blank selectors
|
|
11678
12369
|
pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
|
|
11679
12370
|
inside: {
|
|
11680
12371
|
parent: {
|
|
@@ -11702,6 +12393,7 @@ function scss(Prism2) {
|
|
|
11702
12393
|
]
|
|
11703
12394
|
});
|
|
11704
12395
|
Prism2.languages.insertBefore("scss", "important", {
|
|
12396
|
+
// var and interpolated vars
|
|
11705
12397
|
variable: /\$[-\w]+|#\{\$[-\w]+\}/
|
|
11706
12398
|
});
|
|
11707
12399
|
Prism2.languages.insertBefore("scss", "function", {
|
|
@@ -11760,6 +12452,7 @@ function sql(Prism2) {
|
|
|
11760
12452
|
}
|
|
11761
12453
|
},
|
|
11762
12454
|
function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
12455
|
+
// Should we highlight user defined functions too?
|
|
11763
12456
|
keyword: /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
|
|
11764
12457
|
boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
11765
12458
|
number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
@@ -11774,14 +12467,18 @@ swift.aliases = [];
|
|
|
11774
12467
|
function swift(Prism2) {
|
|
11775
12468
|
Prism2.languages.swift = {
|
|
11776
12469
|
comment: {
|
|
12470
|
+
// Nested comments are supported up to 2 levels
|
|
11777
12471
|
pattern: /(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,
|
|
11778
12472
|
lookbehind: true,
|
|
11779
12473
|
greedy: true
|
|
11780
12474
|
},
|
|
11781
12475
|
"string-literal": [
|
|
12476
|
+
// https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
|
|
11782
12477
|
{
|
|
11783
12478
|
pattern: RegExp(
|
|
11784
|
-
/(^|[^"#])/.source + "(?:" +
|
|
12479
|
+
/(^|[^"#])/.source + "(?:" + // single-line string
|
|
12480
|
+
/"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source + "|" + // multi-line string
|
|
12481
|
+
/"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source + ")" + /(?!["#])/.source
|
|
11785
12482
|
),
|
|
11786
12483
|
lookbehind: true,
|
|
11787
12484
|
greedy: true,
|
|
@@ -11790,6 +12487,7 @@ function swift(Prism2) {
|
|
|
11790
12487
|
pattern: /(\\\()(?:[^()]|\([^()]*\))*(?=\))/,
|
|
11791
12488
|
lookbehind: true,
|
|
11792
12489
|
inside: null
|
|
12490
|
+
// see below
|
|
11793
12491
|
},
|
|
11794
12492
|
"interpolation-punctuation": {
|
|
11795
12493
|
pattern: /^\)|\\\($/,
|
|
@@ -11801,7 +12499,9 @@ function swift(Prism2) {
|
|
|
11801
12499
|
},
|
|
11802
12500
|
{
|
|
11803
12501
|
pattern: RegExp(
|
|
11804
|
-
/(^|[^"#])(#+)/.source + "(?:" +
|
|
12502
|
+
/(^|[^"#])(#+)/.source + "(?:" + // single-line string
|
|
12503
|
+
/"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source + "|" + // multi-line string
|
|
12504
|
+
/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source + ")\\2"
|
|
11805
12505
|
),
|
|
11806
12506
|
lookbehind: true,
|
|
11807
12507
|
greedy: true,
|
|
@@ -11810,6 +12510,7 @@ function swift(Prism2) {
|
|
|
11810
12510
|
pattern: /(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,
|
|
11811
12511
|
lookbehind: true,
|
|
11812
12512
|
inside: null
|
|
12513
|
+
// see below
|
|
11813
12514
|
},
|
|
11814
12515
|
"interpolation-punctuation": {
|
|
11815
12516
|
pattern: /^\)|\\#+\($/,
|
|
@@ -11820,8 +12521,12 @@ function swift(Prism2) {
|
|
|
11820
12521
|
}
|
|
11821
12522
|
],
|
|
11822
12523
|
directive: {
|
|
12524
|
+
// directives with conditions
|
|
11823
12525
|
pattern: RegExp(
|
|
11824
|
-
/#/.source + "(?:" + (/(?:elseif|if)\b/.source + "(?:[ ]*" +
|
|
12526
|
+
/#/.source + "(?:" + (/(?:elseif|if)\b/.source + "(?:[ ]*" + // This regex is a little complex. It's equivalent to this:
|
|
12527
|
+
// (?:![ \t]*)?(?:\b\w+\b(?:[ \t]*<round>)?|<round>)(?:[ \t]*(?:&&|\|\|))?
|
|
12528
|
+
// where <round> is a general parentheses expression.
|
|
12529
|
+
/(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source + ")+") + "|" + /(?:else|endif)\b/.source + ")"
|
|
11825
12530
|
),
|
|
11826
12531
|
alias: "property",
|
|
11827
12532
|
inside: {
|
|
@@ -11850,6 +12555,7 @@ function swift(Prism2) {
|
|
|
11850
12555
|
alias: "function"
|
|
11851
12556
|
},
|
|
11852
12557
|
label: {
|
|
12558
|
+
// https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID141
|
|
11853
12559
|
pattern: /\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,
|
|
11854
12560
|
lookbehind: true,
|
|
11855
12561
|
alias: "important"
|
|
@@ -11866,9 +12572,13 @@ function swift(Prism2) {
|
|
|
11866
12572
|
alias: "keyword"
|
|
11867
12573
|
},
|
|
11868
12574
|
number: /\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,
|
|
12575
|
+
// A class name must start with an upper-case letter and be either 1 letter long or contain a lower-case letter.
|
|
11869
12576
|
"class-name": /\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,
|
|
11870
12577
|
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
11871
12578
|
constant: /\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,
|
|
12579
|
+
// Operators are generic in Swift. Developers can even create new operators (e.g. +++).
|
|
12580
|
+
// https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html#ID481
|
|
12581
|
+
// This regex only supports ASCII operators.
|
|
11872
12582
|
operator: /[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,
|
|
11873
12583
|
punctuation: /[{}[\]();,.:\\]/
|
|
11874
12584
|
};
|
|
@@ -11889,12 +12599,15 @@ function typescript(Prism2) {
|
|
|
11889
12599
|
lookbehind: true,
|
|
11890
12600
|
greedy: true,
|
|
11891
12601
|
inside: null
|
|
12602
|
+
// see below
|
|
11892
12603
|
},
|
|
11893
12604
|
builtin: /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/
|
|
11894
12605
|
});
|
|
11895
12606
|
Prism3.languages.typescript.keyword.push(
|
|
11896
12607
|
/\b(?:abstract|declare|is|keyof|readonly|require)\b/,
|
|
12608
|
+
// keywords that have to be followed by an identifier
|
|
11897
12609
|
/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
|
|
12610
|
+
// This is for `import type *, {}`
|
|
11898
12611
|
/\btype\b(?=\s*(?:[\{*]|$))/
|
|
11899
12612
|
);
|
|
11900
12613
|
delete Prism3.languages.typescript["parameter"];
|
|
@@ -11914,12 +12627,14 @@ function typescript(Prism2) {
|
|
|
11914
12627
|
}
|
|
11915
12628
|
},
|
|
11916
12629
|
"generic-function": {
|
|
12630
|
+
// e.g. foo<T extends "bar" | "baz">( ...
|
|
11917
12631
|
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
|
|
11918
12632
|
greedy: true,
|
|
11919
12633
|
inside: {
|
|
11920
12634
|
function: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
|
|
11921
12635
|
generic: {
|
|
11922
12636
|
pattern: /<[\s\S]+/,
|
|
12637
|
+
// everything after the first <
|
|
11923
12638
|
alias: "class-name",
|
|
11924
12639
|
inside: typeInside
|
|
11925
12640
|
}
|
|
@@ -11984,79 +12699,109 @@ function vbnet(Prism2) {
|
|
|
11984
12699
|
|
|
11985
12700
|
// ../../node_modules/hast-util-parse-selector/index.js
|
|
11986
12701
|
var search = /[#.]/g;
|
|
11987
|
-
var parseSelector =
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12702
|
+
var parseSelector = (
|
|
12703
|
+
/**
|
|
12704
|
+
* @type {(
|
|
12705
|
+
* <Selector extends string, DefaultTagName extends string = 'div'>(selector?: Selector, defaultTagName?: DefaultTagName) => Element & {tagName: import('./extract.js').ExtractTagName<Selector, DefaultTagName>}
|
|
12706
|
+
* )}
|
|
12707
|
+
*/
|
|
12708
|
+
/**
|
|
12709
|
+
* @param {string} [selector]
|
|
12710
|
+
* @param {string} [defaultTagName='div']
|
|
12711
|
+
* @returns {Element}
|
|
12712
|
+
*/
|
|
12713
|
+
function(selector, defaultTagName = "div") {
|
|
12714
|
+
var value = selector || "";
|
|
12715
|
+
var props = {};
|
|
12716
|
+
var start = 0;
|
|
12717
|
+
var subvalue;
|
|
12718
|
+
var previous;
|
|
12719
|
+
var match;
|
|
12720
|
+
while (start < value.length) {
|
|
12721
|
+
search.lastIndex = start;
|
|
12722
|
+
match = search.exec(value);
|
|
12723
|
+
subvalue = value.slice(start, match ? match.index : value.length);
|
|
12724
|
+
if (subvalue) {
|
|
12725
|
+
if (!previous) {
|
|
12726
|
+
defaultTagName = subvalue;
|
|
12727
|
+
} else if (previous === "#") {
|
|
12728
|
+
props.id = subvalue;
|
|
12729
|
+
} else if (Array.isArray(props.className)) {
|
|
12730
|
+
props.className.push(subvalue);
|
|
12731
|
+
} else {
|
|
12732
|
+
props.className = [subvalue];
|
|
12733
|
+
}
|
|
12734
|
+
start += subvalue.length;
|
|
12735
|
+
}
|
|
12736
|
+
if (match) {
|
|
12737
|
+
previous = match[0];
|
|
12738
|
+
start++;
|
|
12007
12739
|
}
|
|
12008
|
-
start += subvalue.length;
|
|
12009
|
-
}
|
|
12010
|
-
if (match) {
|
|
12011
|
-
previous = match[0];
|
|
12012
|
-
start++;
|
|
12013
12740
|
}
|
|
12741
|
+
return {
|
|
12742
|
+
type: "element",
|
|
12743
|
+
tagName: defaultTagName,
|
|
12744
|
+
properties: props,
|
|
12745
|
+
children: []
|
|
12746
|
+
};
|
|
12014
12747
|
}
|
|
12015
|
-
|
|
12016
|
-
type: "element",
|
|
12017
|
-
tagName: defaultTagName,
|
|
12018
|
-
properties: props,
|
|
12019
|
-
children: []
|
|
12020
|
-
};
|
|
12021
|
-
};
|
|
12748
|
+
);
|
|
12022
12749
|
|
|
12023
12750
|
// ../../node_modules/hastscript/lib/core.js
|
|
12024
12751
|
var buttonTypes = /* @__PURE__ */ new Set(["menu", "submit", "reset", "button"]);
|
|
12025
12752
|
var own5 = {}.hasOwnProperty;
|
|
12026
12753
|
function core2(schema, defaultTagName, caseSensitive) {
|
|
12027
12754
|
const adjust = caseSensitive && createAdjustMap(caseSensitive);
|
|
12028
|
-
const h2 =
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12755
|
+
const h2 = (
|
|
12756
|
+
/**
|
|
12757
|
+
* @type {{
|
|
12758
|
+
* (): Root
|
|
12759
|
+
* (selector: null|undefined, ...children: Array<HChild>): Root
|
|
12760
|
+
* (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
|
|
12761
|
+
* (selector: string, ...children: Array<HChild>): Element
|
|
12762
|
+
* }}
|
|
12763
|
+
*/
|
|
12764
|
+
/**
|
|
12765
|
+
* Hyperscript compatible DSL for creating virtual hast trees.
|
|
12766
|
+
*
|
|
12767
|
+
* @param {string|null} [selector]
|
|
12768
|
+
* @param {HProperties|HChild} [properties]
|
|
12769
|
+
* @param {Array<HChild>} children
|
|
12770
|
+
* @returns {HResult}
|
|
12771
|
+
*/
|
|
12772
|
+
function(selector, properties, ...children) {
|
|
12773
|
+
let index2 = -1;
|
|
12774
|
+
let node;
|
|
12775
|
+
if (selector === void 0 || selector === null) {
|
|
12776
|
+
node = { type: "root", children: [] };
|
|
12777
|
+
children.unshift(properties);
|
|
12778
|
+
} else {
|
|
12779
|
+
node = parseSelector(selector, defaultTagName);
|
|
12780
|
+
node.tagName = node.tagName.toLowerCase();
|
|
12781
|
+
if (adjust && own5.call(adjust, node.tagName)) {
|
|
12782
|
+
node.tagName = adjust[node.tagName];
|
|
12783
|
+
}
|
|
12784
|
+
if (isProperties(properties, node.tagName)) {
|
|
12785
|
+
let key2;
|
|
12786
|
+
for (key2 in properties) {
|
|
12787
|
+
if (own5.call(properties, key2)) {
|
|
12788
|
+
addProperty(schema, node.properties, key2, properties[key2]);
|
|
12789
|
+
}
|
|
12045
12790
|
}
|
|
12791
|
+
} else {
|
|
12792
|
+
children.unshift(properties);
|
|
12046
12793
|
}
|
|
12047
|
-
} else {
|
|
12048
|
-
children.unshift(properties);
|
|
12049
12794
|
}
|
|
12795
|
+
while (++index2 < children.length) {
|
|
12796
|
+
addChild(node.children, children[index2]);
|
|
12797
|
+
}
|
|
12798
|
+
if (node.type === "element" && node.tagName === "template") {
|
|
12799
|
+
node.content = { type: "root", children: node.children };
|
|
12800
|
+
node.children = [];
|
|
12801
|
+
}
|
|
12802
|
+
return node;
|
|
12050
12803
|
}
|
|
12051
|
-
|
|
12052
|
-
addChild(node.children, children[index2]);
|
|
12053
|
-
}
|
|
12054
|
-
if (node.type === "element" && node.tagName === "template") {
|
|
12055
|
-
node.content = { type: "root", children: node.children };
|
|
12056
|
-
node.children = [];
|
|
12057
|
-
}
|
|
12058
|
-
return node;
|
|
12059
|
-
};
|
|
12804
|
+
);
|
|
12060
12805
|
return h2;
|
|
12061
12806
|
}
|
|
12062
12807
|
function isProperties(value, name) {
|
|
@@ -14405,12 +15150,19 @@ function decodeNamedCharacterReference(value) {
|
|
|
14405
15150
|
var fromCharCode = String.fromCharCode;
|
|
14406
15151
|
var messages = [
|
|
14407
15152
|
"",
|
|
15153
|
+
/* 1: Non terminated (named) */
|
|
14408
15154
|
"Named character references must be terminated by a semicolon",
|
|
15155
|
+
/* 2: Non terminated (numeric) */
|
|
14409
15156
|
"Numeric character references must be terminated by a semicolon",
|
|
15157
|
+
/* 3: Empty (named) */
|
|
14410
15158
|
"Named character references cannot be empty",
|
|
15159
|
+
/* 4: Empty (numeric) */
|
|
14411
15160
|
"Numeric character references cannot be empty",
|
|
15161
|
+
/* 5: Unknown (named) */
|
|
14412
15162
|
"Named character references must be known",
|
|
15163
|
+
/* 6: Disallowed (numeric) */
|
|
14413
15164
|
"Numeric character references cannot be disallowed",
|
|
15165
|
+
/* 7: Prohibited (numeric) */
|
|
14414
15166
|
"Numeric character references cannot be outside the permissible Unicode range"
|
|
14415
15167
|
];
|
|
14416
15168
|
function parseEntities(value, options = {}) {
|
|
@@ -14531,7 +15283,10 @@ function parseEntities(value, options = {}) {
|
|
|
14531
15283
|
);
|
|
14532
15284
|
if (prohibited(referenceCode)) {
|
|
14533
15285
|
warning(7, diff2);
|
|
14534
|
-
reference = fromCharCode(
|
|
15286
|
+
reference = fromCharCode(
|
|
15287
|
+
65533
|
|
15288
|
+
/* `�` */
|
|
15289
|
+
);
|
|
14535
15290
|
} else if (referenceCode in characterReferenceInvalid) {
|
|
14536
15291
|
warning(6, diff2);
|
|
14537
15292
|
reference = characterReferenceInvalid[referenceCode];
|
|
@@ -14631,16 +15386,57 @@ function disallowed(code) {
|
|
|
14631
15386
|
var uniqueId = 0;
|
|
14632
15387
|
var plainTextGrammar = {};
|
|
14633
15388
|
var _ = {
|
|
15389
|
+
/**
|
|
15390
|
+
* A namespace for utility methods.
|
|
15391
|
+
*
|
|
15392
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
15393
|
+
* change or disappear at any time.
|
|
15394
|
+
*
|
|
15395
|
+
* @namespace
|
|
15396
|
+
* @memberof Prism
|
|
15397
|
+
*/
|
|
14634
15398
|
util: {
|
|
15399
|
+
/**
|
|
15400
|
+
* Returns the name of the type of the given value.
|
|
15401
|
+
*
|
|
15402
|
+
* @param {any} o
|
|
15403
|
+
* @returns {string}
|
|
15404
|
+
* @example
|
|
15405
|
+
* type(null) === 'Null'
|
|
15406
|
+
* type(undefined) === 'Undefined'
|
|
15407
|
+
* type(123) === 'Number'
|
|
15408
|
+
* type('foo') === 'String'
|
|
15409
|
+
* type(true) === 'Boolean'
|
|
15410
|
+
* type([1, 2]) === 'Array'
|
|
15411
|
+
* type({}) === 'Object'
|
|
15412
|
+
* type(String) === 'Function'
|
|
15413
|
+
* type(/abc+/) === 'RegExp'
|
|
15414
|
+
*/
|
|
14635
15415
|
type: function(o) {
|
|
14636
15416
|
return Object.prototype.toString.call(o).slice(8, -1);
|
|
14637
15417
|
},
|
|
15418
|
+
/**
|
|
15419
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
15420
|
+
*
|
|
15421
|
+
* @param {Object} obj
|
|
15422
|
+
* @returns {number}
|
|
15423
|
+
*/
|
|
14638
15424
|
objId: function(obj) {
|
|
14639
15425
|
if (!obj["__id"]) {
|
|
14640
15426
|
Object.defineProperty(obj, "__id", { value: ++uniqueId });
|
|
14641
15427
|
}
|
|
14642
15428
|
return obj["__id"];
|
|
14643
15429
|
},
|
|
15430
|
+
/**
|
|
15431
|
+
* Creates a deep clone of the given object.
|
|
15432
|
+
*
|
|
15433
|
+
* The main intended use of this function is to clone language definitions.
|
|
15434
|
+
*
|
|
15435
|
+
* @param {T} o
|
|
15436
|
+
* @param {Record<number, any>} [visited]
|
|
15437
|
+
* @returns {T}
|
|
15438
|
+
* @template T
|
|
15439
|
+
*/
|
|
14644
15440
|
clone: function deepClone(o, visited) {
|
|
14645
15441
|
visited = visited || {};
|
|
14646
15442
|
var clone;
|
|
@@ -14651,14 +15447,18 @@ var _ = {
|
|
|
14651
15447
|
if (visited[id]) {
|
|
14652
15448
|
return visited[id];
|
|
14653
15449
|
}
|
|
14654
|
-
clone = {}
|
|
15450
|
+
clone = /** @type {Record<string, any>} */
|
|
15451
|
+
{};
|
|
14655
15452
|
visited[id] = clone;
|
|
14656
15453
|
for (var key2 in o) {
|
|
14657
15454
|
if (o.hasOwnProperty(key2)) {
|
|
14658
15455
|
clone[key2] = deepClone(o[key2], visited);
|
|
14659
15456
|
}
|
|
14660
15457
|
}
|
|
14661
|
-
return
|
|
15458
|
+
return (
|
|
15459
|
+
/** @type {any} */
|
|
15460
|
+
clone
|
|
15461
|
+
);
|
|
14662
15462
|
case "Array":
|
|
14663
15463
|
id = _.util.objId(o);
|
|
14664
15464
|
if (visited[id]) {
|
|
@@ -14669,17 +15469,58 @@ var _ = {
|
|
|
14669
15469
|
o.forEach(function(v, i) {
|
|
14670
15470
|
clone[i] = deepClone(v, visited);
|
|
14671
15471
|
});
|
|
14672
|
-
return
|
|
15472
|
+
return (
|
|
15473
|
+
/** @type {any} */
|
|
15474
|
+
clone
|
|
15475
|
+
);
|
|
14673
15476
|
default:
|
|
14674
15477
|
return o;
|
|
14675
15478
|
}
|
|
14676
15479
|
}
|
|
14677
15480
|
},
|
|
15481
|
+
/**
|
|
15482
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
15483
|
+
*
|
|
15484
|
+
* @namespace
|
|
15485
|
+
* @memberof Prism
|
|
15486
|
+
* @public
|
|
15487
|
+
*/
|
|
14678
15488
|
languages: {
|
|
15489
|
+
/**
|
|
15490
|
+
* The grammar for plain, unformatted text.
|
|
15491
|
+
*/
|
|
14679
15492
|
plain: plainTextGrammar,
|
|
14680
15493
|
plaintext: plainTextGrammar,
|
|
14681
15494
|
text: plainTextGrammar,
|
|
14682
15495
|
txt: plainTextGrammar,
|
|
15496
|
+
/**
|
|
15497
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
15498
|
+
*
|
|
15499
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
15500
|
+
* will be overwritten at its original position.
|
|
15501
|
+
*
|
|
15502
|
+
* ## Best practices
|
|
15503
|
+
*
|
|
15504
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
15505
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
15506
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
15507
|
+
*
|
|
15508
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
15509
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
15510
|
+
*
|
|
15511
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
15512
|
+
* @param {Grammar} redef The new tokens to append.
|
|
15513
|
+
* @returns {Grammar} The new language created.
|
|
15514
|
+
* @public
|
|
15515
|
+
* @example
|
|
15516
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
15517
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
15518
|
+
* // at its original position
|
|
15519
|
+
* 'comment': { ... },
|
|
15520
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
15521
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
15522
|
+
* });
|
|
15523
|
+
*/
|
|
14683
15524
|
extend: function(id, redef) {
|
|
14684
15525
|
var lang = _.util.clone(_.languages[id]);
|
|
14685
15526
|
for (var key2 in redef) {
|
|
@@ -14687,8 +15528,84 @@ var _ = {
|
|
|
14687
15528
|
}
|
|
14688
15529
|
return lang;
|
|
14689
15530
|
},
|
|
15531
|
+
/**
|
|
15532
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
15533
|
+
*
|
|
15534
|
+
* ## Usage
|
|
15535
|
+
*
|
|
15536
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
15537
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
15538
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
15539
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
15540
|
+
* this:
|
|
15541
|
+
*
|
|
15542
|
+
* ```js
|
|
15543
|
+
* Prism.languages.markup.style = {
|
|
15544
|
+
* // token
|
|
15545
|
+
* };
|
|
15546
|
+
* ```
|
|
15547
|
+
*
|
|
15548
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
15549
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
15550
|
+
*
|
|
15551
|
+
* ```js
|
|
15552
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
15553
|
+
* 'style': {
|
|
15554
|
+
* // token
|
|
15555
|
+
* }
|
|
15556
|
+
* });
|
|
15557
|
+
* ```
|
|
15558
|
+
*
|
|
15559
|
+
* ## Special cases
|
|
15560
|
+
*
|
|
15561
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
15562
|
+
* will be ignored.
|
|
15563
|
+
*
|
|
15564
|
+
* This behavior can be used to insert tokens after `before`:
|
|
15565
|
+
*
|
|
15566
|
+
* ```js
|
|
15567
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
15568
|
+
* 'comment': Prism.languages.markup.comment,
|
|
15569
|
+
* // tokens after 'comment'
|
|
15570
|
+
* });
|
|
15571
|
+
* ```
|
|
15572
|
+
*
|
|
15573
|
+
* ## Limitations
|
|
15574
|
+
*
|
|
15575
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
15576
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
15577
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
15578
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
15579
|
+
*
|
|
15580
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
15581
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
15582
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
15583
|
+
*
|
|
15584
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
15585
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
15586
|
+
*
|
|
15587
|
+
* ```js
|
|
15588
|
+
* var oldMarkup = Prism.languages.markup;
|
|
15589
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
15590
|
+
*
|
|
15591
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
15592
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
15593
|
+
* ```
|
|
15594
|
+
*
|
|
15595
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
15596
|
+
* object to be modified.
|
|
15597
|
+
* @param {string} before The key to insert before.
|
|
15598
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
15599
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
15600
|
+
* object to be modified.
|
|
15601
|
+
*
|
|
15602
|
+
* Defaults to `Prism.languages`.
|
|
15603
|
+
* @returns {Grammar} The new grammar object.
|
|
15604
|
+
* @public
|
|
15605
|
+
*/
|
|
14690
15606
|
insertBefore: function(inside, before, insert, root2) {
|
|
14691
|
-
root2 = root2 ||
|
|
15607
|
+
root2 = root2 || /** @type {any} */
|
|
15608
|
+
_.languages;
|
|
14692
15609
|
var grammar = root2[inside];
|
|
14693
15610
|
var ret = {};
|
|
14694
15611
|
for (var token in grammar) {
|
|
@@ -14714,6 +15631,7 @@ var _ = {
|
|
|
14714
15631
|
});
|
|
14715
15632
|
return ret;
|
|
14716
15633
|
},
|
|
15634
|
+
// Traverse a language definition with Depth First Search
|
|
14717
15635
|
DFS: function DFS(o, callback, type, visited) {
|
|
14718
15636
|
visited = visited || {};
|
|
14719
15637
|
var objId = _.util.objId;
|
|
@@ -14734,6 +15652,26 @@ var _ = {
|
|
|
14734
15652
|
}
|
|
14735
15653
|
},
|
|
14736
15654
|
plugins: {},
|
|
15655
|
+
/**
|
|
15656
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
15657
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
15658
|
+
*
|
|
15659
|
+
* The following hooks will be run:
|
|
15660
|
+
* 1. `before-tokenize`
|
|
15661
|
+
* 2. `after-tokenize`
|
|
15662
|
+
* 3. `wrap`: On each {@link Token}.
|
|
15663
|
+
*
|
|
15664
|
+
* @param {string} text A string with the code to be highlighted.
|
|
15665
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
15666
|
+
*
|
|
15667
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
15668
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
15669
|
+
* @returns {string} The highlighted HTML.
|
|
15670
|
+
* @memberof Prism
|
|
15671
|
+
* @public
|
|
15672
|
+
* @example
|
|
15673
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
15674
|
+
*/
|
|
14737
15675
|
highlight: function(text3, grammar, language) {
|
|
14738
15676
|
var env = {
|
|
14739
15677
|
code: text3,
|
|
@@ -14748,6 +15686,30 @@ var _ = {
|
|
|
14748
15686
|
_.hooks.run("after-tokenize", env);
|
|
14749
15687
|
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
14750
15688
|
},
|
|
15689
|
+
/**
|
|
15690
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
15691
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
15692
|
+
*
|
|
15693
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
15694
|
+
*
|
|
15695
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
15696
|
+
*
|
|
15697
|
+
* @param {string} text A string with the code to be highlighted.
|
|
15698
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
15699
|
+
*
|
|
15700
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
15701
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
15702
|
+
* @memberof Prism
|
|
15703
|
+
* @public
|
|
15704
|
+
* @example
|
|
15705
|
+
* let code = `var foo = 0;`;
|
|
15706
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
15707
|
+
* tokens.forEach(token => {
|
|
15708
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
15709
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
15710
|
+
* }
|
|
15711
|
+
* });
|
|
15712
|
+
*/
|
|
14751
15713
|
tokenize: function(text3, grammar) {
|
|
14752
15714
|
var rest = grammar.rest;
|
|
14753
15715
|
if (rest) {
|
|
@@ -14761,13 +15723,39 @@ var _ = {
|
|
|
14761
15723
|
matchGrammar(text3, tokenList, grammar, tokenList.head, 0);
|
|
14762
15724
|
return toArray(tokenList);
|
|
14763
15725
|
},
|
|
15726
|
+
/**
|
|
15727
|
+
* @namespace
|
|
15728
|
+
* @memberof Prism
|
|
15729
|
+
* @public
|
|
15730
|
+
*/
|
|
14764
15731
|
hooks: {
|
|
14765
15732
|
all: {},
|
|
15733
|
+
/**
|
|
15734
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
15735
|
+
*
|
|
15736
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
15737
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
15738
|
+
*
|
|
15739
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
15740
|
+
*
|
|
15741
|
+
* @param {string} name The name of the hook.
|
|
15742
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
15743
|
+
* @public
|
|
15744
|
+
*/
|
|
14766
15745
|
add: function(name, callback) {
|
|
14767
15746
|
var hooks = _.hooks.all;
|
|
14768
15747
|
hooks[name] = hooks[name] || [];
|
|
14769
15748
|
hooks[name].push(callback);
|
|
14770
15749
|
},
|
|
15750
|
+
/**
|
|
15751
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
15752
|
+
*
|
|
15753
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
15754
|
+
*
|
|
15755
|
+
* @param {string} name The name of the hook.
|
|
15756
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
15757
|
+
* @public
|
|
15758
|
+
*/
|
|
14771
15759
|
run: function(name, env) {
|
|
14772
15760
|
var callbacks = _.hooks.all[name];
|
|
14773
15761
|
if (!callbacks || !callbacks.length) {
|
|
@@ -14976,6 +15964,7 @@ function highlight(value, language) {
|
|
|
14976
15964
|
}
|
|
14977
15965
|
return {
|
|
14978
15966
|
type: "root",
|
|
15967
|
+
// @ts-expect-error: we hacked Prism to accept and return the things we want.
|
|
14979
15968
|
children: Prism.highlight.call(refractor, value, grammar, name)
|
|
14980
15969
|
};
|
|
14981
15970
|
}
|
|
@@ -15159,6 +16148,7 @@ function jsx(Prism2) {
|
|
|
15159
16148
|
"special-attr",
|
|
15160
16149
|
{
|
|
15161
16150
|
script: {
|
|
16151
|
+
// Allow for two levels of nesting
|
|
15162
16152
|
pattern: re(/=<BRACES>/.source),
|
|
15163
16153
|
alias: "language-javascript",
|
|
15164
16154
|
inside: {
|
|
@@ -15724,7 +16714,10 @@ var errors = {
|
|
|
15724
16714
|
var base = "https://html.spec.whatwg.org/multipage/parsing.html#parse-error-";
|
|
15725
16715
|
var fatalities = { 2: true, 1: false, 0: null };
|
|
15726
16716
|
function rehypeParse(options) {
|
|
15727
|
-
const processorSettings =
|
|
16717
|
+
const processorSettings = (
|
|
16718
|
+
/** @type {Options} */
|
|
16719
|
+
this.data("settings")
|
|
16720
|
+
);
|
|
15728
16721
|
const settings = Object.assign({}, processorSettings, options);
|
|
15729
16722
|
Object.assign(this, { Parser: parser });
|
|
15730
16723
|
function parser(doc, file) {
|
|
@@ -15856,7 +16849,10 @@ function wrap(middleware, callback) {
|
|
|
15856
16849
|
try {
|
|
15857
16850
|
result = middleware.apply(this, parameters);
|
|
15858
16851
|
} catch (error) {
|
|
15859
|
-
const exception =
|
|
16852
|
+
const exception = (
|
|
16853
|
+
/** @type {Error} */
|
|
16854
|
+
error
|
|
16855
|
+
);
|
|
15860
16856
|
if (fnExpectsCallback && called) {
|
|
15861
16857
|
throw exception;
|
|
15862
16858
|
}
|
|
@@ -15914,10 +16910,25 @@ function index(value) {
|
|
|
15914
16910
|
|
|
15915
16911
|
// ../../node_modules/vfile-message/index.js
|
|
15916
16912
|
var VFileMessage = class extends Error {
|
|
16913
|
+
/**
|
|
16914
|
+
* Create a message for `reason` at `place` from `origin`.
|
|
16915
|
+
*
|
|
16916
|
+
* When an error is passed in as `reason`, the `stack` is copied.
|
|
16917
|
+
*
|
|
16918
|
+
* @param {string|Error|VFileMessage} reason
|
|
16919
|
+
* Reason for message.
|
|
16920
|
+
* Uses the stack and message of the error if given.
|
|
16921
|
+
* @param {Node|NodeLike|Position|Point} [place]
|
|
16922
|
+
* Place at which the message occurred in a file.
|
|
16923
|
+
* @param {string} [origin]
|
|
16924
|
+
* Place in code the message originates from (example `'my-package:my-rule-name'`)
|
|
16925
|
+
*/
|
|
15917
16926
|
constructor(reason, place, origin) {
|
|
15918
16927
|
const parts = [null, null];
|
|
15919
16928
|
let position3 = {
|
|
16929
|
+
// @ts-expect-error: we always follows the structure of `position`.
|
|
15920
16930
|
start: { line: null, column: null },
|
|
16931
|
+
// @ts-expect-error: "
|
|
15921
16932
|
end: { line: null, column: null }
|
|
15922
16933
|
};
|
|
15923
16934
|
super();
|
|
@@ -15988,12 +16999,31 @@ import { fileURLToPath } from "url";
|
|
|
15988
16999
|
|
|
15989
17000
|
// ../../node_modules/vfile/lib/minurl.shared.js
|
|
15990
17001
|
function isUrl(fileURLOrPath) {
|
|
15991
|
-
return fileURLOrPath !== null && typeof fileURLOrPath === "object" &&
|
|
17002
|
+
return fileURLOrPath !== null && typeof fileURLOrPath === "object" && // @ts-expect-error: indexable.
|
|
17003
|
+
fileURLOrPath.href && // @ts-expect-error: indexable.
|
|
17004
|
+
fileURLOrPath.origin;
|
|
15992
17005
|
}
|
|
15993
17006
|
|
|
15994
17007
|
// ../../node_modules/vfile/lib/index.js
|
|
15995
17008
|
var order = ["history", "path", "basename", "stem", "extname", "dirname"];
|
|
15996
17009
|
var VFile = class {
|
|
17010
|
+
/**
|
|
17011
|
+
* Create a new virtual file.
|
|
17012
|
+
*
|
|
17013
|
+
* If `options` is `string` or `Buffer`, it’s treated as `{value: options}`.
|
|
17014
|
+
* If `options` is a `URL`, it’s treated as `{path: options}`.
|
|
17015
|
+
* If `options` is a `VFile`, shallow copies its data over to the new file.
|
|
17016
|
+
* All fields in `options` are set on the newly created `VFile`.
|
|
17017
|
+
*
|
|
17018
|
+
* Path related fields are set in the following order (least specific to
|
|
17019
|
+
* most specific): `history`, `path`, `basename`, `stem`, `extname`,
|
|
17020
|
+
* `dirname`.
|
|
17021
|
+
*
|
|
17022
|
+
* It’s not possible to set either `dirname` or `extname` without setting
|
|
17023
|
+
* either `history`, `path`, `basename`, or `stem` as well.
|
|
17024
|
+
*
|
|
17025
|
+
* @param {Compatible} [value]
|
|
17026
|
+
*/
|
|
15997
17027
|
constructor(value) {
|
|
15998
17028
|
let options;
|
|
15999
17029
|
if (!value) {
|
|
@@ -16026,9 +17056,20 @@ var VFile = class {
|
|
|
16026
17056
|
this[prop] = options[prop];
|
|
16027
17057
|
}
|
|
16028
17058
|
}
|
|
17059
|
+
/**
|
|
17060
|
+
* Get the full path (example: `'~/index.min.js'`).
|
|
17061
|
+
* @returns {string}
|
|
17062
|
+
*/
|
|
16029
17063
|
get path() {
|
|
16030
17064
|
return this.history[this.history.length - 1];
|
|
16031
17065
|
}
|
|
17066
|
+
/**
|
|
17067
|
+
* Set the full path (example: `'~/index.min.js'`).
|
|
17068
|
+
* Cannot be nullified.
|
|
17069
|
+
* You can set a file URL (a `URL` object with a `file:` protocol) which will
|
|
17070
|
+
* be turned into a path with `url.fileURLToPath`.
|
|
17071
|
+
* @param {string|URL} path
|
|
17072
|
+
*/
|
|
16032
17073
|
set path(path) {
|
|
16033
17074
|
if (isUrl(path)) {
|
|
16034
17075
|
path = fileURLToPath(path);
|
|
@@ -16038,24 +17079,49 @@ var VFile = class {
|
|
|
16038
17079
|
this.history.push(path);
|
|
16039
17080
|
}
|
|
16040
17081
|
}
|
|
17082
|
+
/**
|
|
17083
|
+
* Get the parent path (example: `'~'`).
|
|
17084
|
+
*/
|
|
16041
17085
|
get dirname() {
|
|
16042
17086
|
return typeof this.path === "string" ? default2.dirname(this.path) : void 0;
|
|
16043
17087
|
}
|
|
17088
|
+
/**
|
|
17089
|
+
* Set the parent path (example: `'~'`).
|
|
17090
|
+
* Cannot be set if there’s no `path` yet.
|
|
17091
|
+
*/
|
|
16044
17092
|
set dirname(dirname) {
|
|
16045
17093
|
assertPath(this.basename, "dirname");
|
|
16046
17094
|
this.path = default2.join(dirname || "", this.basename);
|
|
16047
17095
|
}
|
|
17096
|
+
/**
|
|
17097
|
+
* Get the basename (including extname) (example: `'index.min.js'`).
|
|
17098
|
+
*/
|
|
16048
17099
|
get basename() {
|
|
16049
17100
|
return typeof this.path === "string" ? default2.basename(this.path) : void 0;
|
|
16050
17101
|
}
|
|
17102
|
+
/**
|
|
17103
|
+
* Set basename (including extname) (`'index.min.js'`).
|
|
17104
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
17105
|
+
* on windows).
|
|
17106
|
+
* Cannot be nullified (use `file.path = file.dirname` instead).
|
|
17107
|
+
*/
|
|
16051
17108
|
set basename(basename) {
|
|
16052
17109
|
assertNonEmpty(basename, "basename");
|
|
16053
17110
|
assertPart(basename, "basename");
|
|
16054
17111
|
this.path = default2.join(this.dirname || "", basename);
|
|
16055
17112
|
}
|
|
17113
|
+
/**
|
|
17114
|
+
* Get the extname (including dot) (example: `'.js'`).
|
|
17115
|
+
*/
|
|
16056
17116
|
get extname() {
|
|
16057
17117
|
return typeof this.path === "string" ? default2.extname(this.path) : void 0;
|
|
16058
17118
|
}
|
|
17119
|
+
/**
|
|
17120
|
+
* Set the extname (including dot) (example: `'.js'`).
|
|
17121
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
17122
|
+
* on windows).
|
|
17123
|
+
* Cannot be set if there’s no `path` yet.
|
|
17124
|
+
*/
|
|
16059
17125
|
set extname(extname) {
|
|
16060
17126
|
assertPart(extname, "extname");
|
|
16061
17127
|
assertPath(this.dirname, "extname");
|
|
@@ -16069,17 +17135,49 @@ var VFile = class {
|
|
|
16069
17135
|
}
|
|
16070
17136
|
this.path = default2.join(this.dirname, this.stem + (extname || ""));
|
|
16071
17137
|
}
|
|
17138
|
+
/**
|
|
17139
|
+
* Get the stem (basename w/o extname) (example: `'index.min'`).
|
|
17140
|
+
*/
|
|
16072
17141
|
get stem() {
|
|
16073
17142
|
return typeof this.path === "string" ? default2.basename(this.path, this.extname) : void 0;
|
|
16074
17143
|
}
|
|
17144
|
+
/**
|
|
17145
|
+
* Set the stem (basename w/o extname) (example: `'index.min'`).
|
|
17146
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
17147
|
+
* on windows).
|
|
17148
|
+
* Cannot be nullified (use `file.path = file.dirname` instead).
|
|
17149
|
+
*/
|
|
16075
17150
|
set stem(stem) {
|
|
16076
17151
|
assertNonEmpty(stem, "stem");
|
|
16077
17152
|
assertPart(stem, "stem");
|
|
16078
17153
|
this.path = default2.join(this.dirname || "", stem + (this.extname || ""));
|
|
16079
17154
|
}
|
|
17155
|
+
/**
|
|
17156
|
+
* Serialize the file.
|
|
17157
|
+
*
|
|
17158
|
+
* @param {BufferEncoding} [encoding='utf8']
|
|
17159
|
+
* When `value` is a `Buffer`, `encoding` is a character encoding to
|
|
17160
|
+
* understand it as (default: `'utf8'`).
|
|
17161
|
+
* @returns {string}
|
|
17162
|
+
* Serialized file.
|
|
17163
|
+
*/
|
|
16080
17164
|
toString(encoding) {
|
|
16081
17165
|
return (this.value || "").toString(encoding);
|
|
16082
17166
|
}
|
|
17167
|
+
/**
|
|
17168
|
+
* Constructs a new `VFileMessage`, where `fatal` is set to `false`, and
|
|
17169
|
+
* associates it with the file by adding it to `vfile.messages` and setting
|
|
17170
|
+
* `message.file` to the current filepath.
|
|
17171
|
+
*
|
|
17172
|
+
* @param {string|Error|VFileMessage} reason
|
|
17173
|
+
* Human readable reason for the message, uses the stack and message of the error if given.
|
|
17174
|
+
* @param {Node|NodeLike|Position|Point} [place]
|
|
17175
|
+
* Place where the message occurred in the file.
|
|
17176
|
+
* @param {string} [origin]
|
|
17177
|
+
* Computer readable reason for the message
|
|
17178
|
+
* @returns {VFileMessage}
|
|
17179
|
+
* Message.
|
|
17180
|
+
*/
|
|
16083
17181
|
message(reason, place, origin) {
|
|
16084
17182
|
const message = new VFileMessage(reason, place, origin);
|
|
16085
17183
|
if (this.path) {
|
|
@@ -16090,11 +17188,39 @@ var VFile = class {
|
|
|
16090
17188
|
this.messages.push(message);
|
|
16091
17189
|
return message;
|
|
16092
17190
|
}
|
|
17191
|
+
/**
|
|
17192
|
+
* Like `VFile#message()`, but associates an informational message where
|
|
17193
|
+
* `fatal` is set to `null`.
|
|
17194
|
+
*
|
|
17195
|
+
* @param {string|Error|VFileMessage} reason
|
|
17196
|
+
* Human readable reason for the message, uses the stack and message of the error if given.
|
|
17197
|
+
* @param {Node|NodeLike|Position|Point} [place]
|
|
17198
|
+
* Place where the message occurred in the file.
|
|
17199
|
+
* @param {string} [origin]
|
|
17200
|
+
* Computer readable reason for the message
|
|
17201
|
+
* @returns {VFileMessage}
|
|
17202
|
+
* Message.
|
|
17203
|
+
*/
|
|
16093
17204
|
info(reason, place, origin) {
|
|
16094
17205
|
const message = this.message(reason, place, origin);
|
|
16095
17206
|
message.fatal = null;
|
|
16096
17207
|
return message;
|
|
16097
17208
|
}
|
|
17209
|
+
/**
|
|
17210
|
+
* Like `VFile#message()`, but associates a fatal message where `fatal` is
|
|
17211
|
+
* set to `true`, and then immediately throws it.
|
|
17212
|
+
*
|
|
17213
|
+
* > 👉 **Note**: a fatal error means that a file is no longer processable.
|
|
17214
|
+
*
|
|
17215
|
+
* @param {string|Error|VFileMessage} reason
|
|
17216
|
+
* Human readable reason for the message, uses the stack and message of the error if given.
|
|
17217
|
+
* @param {Node|NodeLike|Position|Point} [place]
|
|
17218
|
+
* Place where the message occurred in the file.
|
|
17219
|
+
* @param {string} [origin]
|
|
17220
|
+
* Computer readable reason for the message
|
|
17221
|
+
* @returns {never}
|
|
17222
|
+
* Message.
|
|
17223
|
+
*/
|
|
16098
17224
|
fail(reason, place, origin) {
|
|
16099
17225
|
const message = this.message(reason, place, origin);
|
|
16100
17226
|
message.fatal = true;
|
|
@@ -16366,7 +17492,13 @@ function base2() {
|
|
|
16366
17492
|
}
|
|
16367
17493
|
}
|
|
16368
17494
|
function newable(value, name) {
|
|
16369
|
-
return typeof value === "function" &&
|
|
17495
|
+
return typeof value === "function" && // Prototypes do exist.
|
|
17496
|
+
// type-coverage:ignore-next-line
|
|
17497
|
+
value.prototype && // A function with keys in its prototype is probably a constructor.
|
|
17498
|
+
// Classes’ prototype methods are not enumerable, so we check if some value
|
|
17499
|
+
// exists in the prototype.
|
|
17500
|
+
// type-coverage:ignore-next-line
|
|
17501
|
+
(keys(value.prototype) || name in value.prototype);
|
|
16370
17502
|
}
|
|
16371
17503
|
function keys(value) {
|
|
16372
17504
|
let key2;
|
|
@@ -16536,10 +17668,22 @@ function codeToHTML(source, language, line = "0") {
|
|
|
16536
17668
|
export {
|
|
16537
17669
|
codeToHTML
|
|
16538
17670
|
};
|
|
16539
|
-
/*!
|
|
16540
|
-
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
17671
|
+
/*! Bundled license information:
|
|
17672
|
+
|
|
17673
|
+
is-buffer/index.js:
|
|
17674
|
+
(*!
|
|
17675
|
+
* Determine if an object is a Buffer
|
|
17676
|
+
*
|
|
17677
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
17678
|
+
* @license MIT
|
|
17679
|
+
*)
|
|
17680
|
+
|
|
17681
|
+
is-buffer/index.js:
|
|
17682
|
+
(*!
|
|
17683
|
+
* Determine if an object is a Buffer
|
|
17684
|
+
*
|
|
17685
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
17686
|
+
* @license MIT
|
|
17687
|
+
*)
|
|
17688
|
+
*/
|
|
16545
17689
|
//# sourceMappingURL=index.js.map
|