satorigear 0.0.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/dist/index.d.mts +37 -0
- package/dist/index.mjs +1225 -1191
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { htmlBlockNames, htmlRawNames } from "micromark-util-html-tag-name";
|
|
2
2
|
// src/profile/utils.ts
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const maximumLabelUnits = 1998;
|
|
4
|
+
const malformedLabel = /^.{1000,}/su;
|
|
5
|
+
function referenceIdentifier(label) {
|
|
6
|
+
if (label.length > 999 && (label.length > 1998 || malformedLabel.test(label.replaceAll("\r\n", "\n")))) return "";
|
|
7
|
+
return normalizeIdentifier(label);
|
|
8
|
+
}
|
|
5
9
|
function isAsciiDigit(code) {
|
|
6
10
|
return code >= 48 && code <= 57;
|
|
7
11
|
}
|
|
8
12
|
function isAsciiLetter(code) {
|
|
9
13
|
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
10
14
|
}
|
|
15
|
+
function isLowercaseLetter(code) {
|
|
16
|
+
return code >= 97 && code <= 122;
|
|
17
|
+
}
|
|
18
|
+
function isUppercaseLetter(code) {
|
|
19
|
+
return code >= 65 && code <= 90;
|
|
20
|
+
}
|
|
11
21
|
function isAsciiPunctuation(code) {
|
|
12
22
|
return code >= 33 && code <= 47 || code >= 58 && code <= 64 || code >= 91 && code <= 96 || code >= 123 && code <= 126;
|
|
13
23
|
}
|
|
@@ -20,34 +30,26 @@ function isSpaceOrLineEnding(code) {
|
|
|
20
30
|
function isSpaceTabOrLineEnding(code) {
|
|
21
31
|
return code === 32 || code === 10 || code === 13 || code === 9;
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
if (start <= 0) return true;
|
|
25
|
-
const previous = source[start - 1];
|
|
26
|
-
return previous !== ":" && inlineColonBoundary.test(previous);
|
|
27
|
-
}
|
|
33
|
+
const nonSpaceAndLineEnding = /[^ \r\n]/;
|
|
28
34
|
function hasInlinePadding(value) {
|
|
29
35
|
return isSpaceOrLineEnding(value.charCodeAt(0)) && isSpaceOrLineEnding(value.charCodeAt(value.length - 1)) && nonSpaceAndLineEnding.test(value);
|
|
30
36
|
}
|
|
31
37
|
const identifierNeedsCleanup = /[^\x20-\x7E]|^ | $| {2}/;
|
|
32
38
|
const identifierWhitespace = /[ \t\r\n]+/g;
|
|
39
|
+
const identifierPadding = /^ | $/g;
|
|
33
40
|
function normalizeIdentifier(identifier) {
|
|
34
|
-
return identifierNeedsCleanup.test(identifier) ? identifier.
|
|
41
|
+
return (identifierNeedsCleanup.test(identifier) ? identifier.replace(identifierWhitespace, " ").replace(identifierPadding, "").toLowerCase().toUpperCase() : identifier).toLowerCase();
|
|
35
42
|
}
|
|
36
43
|
// src/inline/entities.ts
|
|
37
44
|
const entities = {
|
|
38
45
|
__proto__: null,
|
|
39
|
-
AEli: "Æ",
|
|
40
46
|
AElig: "Æ",
|
|
41
|
-
AM: "&",
|
|
42
47
|
AMP: "&",
|
|
43
|
-
Aacut: "Á",
|
|
44
48
|
Aacute: "Á",
|
|
45
49
|
Abreve: "Ă",
|
|
46
|
-
Acir: "Â",
|
|
47
50
|
Acirc: "Â",
|
|
48
51
|
Acy: "А",
|
|
49
52
|
Afr: "𝔄",
|
|
50
|
-
Agrav: "À",
|
|
51
53
|
Agrave: "À",
|
|
52
54
|
Alpha: "Α",
|
|
53
55
|
Amacr: "Ā",
|
|
@@ -55,13 +57,10 @@ const entities = {
|
|
|
55
57
|
Aogon: "Ą",
|
|
56
58
|
Aopf: "𝔸",
|
|
57
59
|
ApplyFunction: "",
|
|
58
|
-
Arin: "Å",
|
|
59
60
|
Aring: "Å",
|
|
60
61
|
Ascr: "𝒜",
|
|
61
62
|
Assign: "≔",
|
|
62
|
-
Atild: "Ã",
|
|
63
63
|
Atilde: "Ã",
|
|
64
|
-
Aum: "Ä",
|
|
65
64
|
Auml: "Ä",
|
|
66
65
|
Backslash: "∖",
|
|
67
66
|
Barv: "⫧",
|
|
@@ -76,14 +75,12 @@ const entities = {
|
|
|
76
75
|
Bscr: "ℬ",
|
|
77
76
|
Bumpeq: "≎",
|
|
78
77
|
CHcy: "Ч",
|
|
79
|
-
COP: "©",
|
|
80
78
|
COPY: "©",
|
|
81
79
|
Cacute: "Ć",
|
|
82
80
|
Cap: "⋒",
|
|
83
81
|
CapitalDifferentialD: "ⅅ",
|
|
84
82
|
Cayleys: "ℭ",
|
|
85
83
|
Ccaron: "Č",
|
|
86
|
-
Ccedi: "Ç",
|
|
87
84
|
Ccedil: "Ç",
|
|
88
85
|
Ccirc: "Ĉ",
|
|
89
86
|
Cconint: "∰",
|
|
@@ -166,17 +163,13 @@ const entities = {
|
|
|
166
163
|
Dscr: "𝒟",
|
|
167
164
|
Dstrok: "Đ",
|
|
168
165
|
ENG: "Ŋ",
|
|
169
|
-
ET: "Ð",
|
|
170
166
|
ETH: "Ð",
|
|
171
|
-
Eacut: "É",
|
|
172
167
|
Eacute: "É",
|
|
173
168
|
Ecaron: "Ě",
|
|
174
|
-
Ecir: "Ê",
|
|
175
169
|
Ecirc: "Ê",
|
|
176
170
|
Ecy: "Э",
|
|
177
171
|
Edot: "Ė",
|
|
178
172
|
Efr: "𝔈",
|
|
179
|
-
Egrav: "È",
|
|
180
173
|
Egrave: "È",
|
|
181
174
|
Element: "∈",
|
|
182
175
|
Emacr: "Ē",
|
|
@@ -191,7 +184,6 @@ const entities = {
|
|
|
191
184
|
Escr: "ℰ",
|
|
192
185
|
Esim: "⩳",
|
|
193
186
|
Eta: "Η",
|
|
194
|
-
Eum: "Ë",
|
|
195
187
|
Euml: "Ë",
|
|
196
188
|
Exists: "∃",
|
|
197
189
|
ExponentialE: "ⅇ",
|
|
@@ -204,7 +196,6 @@ const entities = {
|
|
|
204
196
|
Fouriertrf: "ℱ",
|
|
205
197
|
Fscr: "ℱ",
|
|
206
198
|
GJcy: "Ѓ",
|
|
207
|
-
G: ">",
|
|
208
199
|
GT: ">",
|
|
209
200
|
Gamma: "Γ",
|
|
210
201
|
Gammad: "Ϝ",
|
|
@@ -240,14 +231,11 @@ const entities = {
|
|
|
240
231
|
IEcy: "Е",
|
|
241
232
|
IJlig: "IJ",
|
|
242
233
|
IOcy: "Ё",
|
|
243
|
-
Iacut: "Í",
|
|
244
234
|
Iacute: "Í",
|
|
245
|
-
Icir: "Î",
|
|
246
235
|
Icirc: "Î",
|
|
247
236
|
Icy: "И",
|
|
248
237
|
Idot: "İ",
|
|
249
238
|
Ifr: "ℑ",
|
|
250
|
-
Igrav: "Ì",
|
|
251
239
|
Igrave: "Ì",
|
|
252
240
|
Im: "ℑ",
|
|
253
241
|
Imacr: "Ī",
|
|
@@ -264,7 +252,6 @@ const entities = {
|
|
|
264
252
|
Iscr: "ℐ",
|
|
265
253
|
Itilde: "Ĩ",
|
|
266
254
|
Iukcy: "І",
|
|
267
|
-
Ium: "Ï",
|
|
268
255
|
Iuml: "Ï",
|
|
269
256
|
Jcirc: "Ĵ",
|
|
270
257
|
Jcy: "Й",
|
|
@@ -282,7 +269,6 @@ const entities = {
|
|
|
282
269
|
Kopf: "𝕂",
|
|
283
270
|
Kscr: "𝒦",
|
|
284
271
|
LJcy: "Љ",
|
|
285
|
-
L: "<",
|
|
286
272
|
LT: "<",
|
|
287
273
|
Lacute: "Ĺ",
|
|
288
274
|
Lambda: "Λ",
|
|
@@ -419,18 +405,14 @@ const entities = {
|
|
|
419
405
|
NotTildeTilde: "≉",
|
|
420
406
|
NotVerticalBar: "∤",
|
|
421
407
|
Nscr: "𝒩",
|
|
422
|
-
Ntild: "Ñ",
|
|
423
408
|
Ntilde: "Ñ",
|
|
424
409
|
Nu: "Ν",
|
|
425
410
|
OElig: "Œ",
|
|
426
|
-
Oacut: "Ó",
|
|
427
411
|
Oacute: "Ó",
|
|
428
|
-
Ocir: "Ô",
|
|
429
412
|
Ocirc: "Ô",
|
|
430
413
|
Ocy: "О",
|
|
431
414
|
Odblac: "Ő",
|
|
432
415
|
Ofr: "𝔒",
|
|
433
|
-
Ograv: "Ò",
|
|
434
416
|
Ograve: "Ò",
|
|
435
417
|
Omacr: "Ō",
|
|
436
418
|
Omega: "Ω",
|
|
@@ -440,12 +422,9 @@ const entities = {
|
|
|
440
422
|
OpenCurlyQuote: "‘",
|
|
441
423
|
Or: "⩔",
|
|
442
424
|
Oscr: "𝒪",
|
|
443
|
-
Oslas: "Ø",
|
|
444
425
|
Oslash: "Ø",
|
|
445
|
-
Otild: "Õ",
|
|
446
426
|
Otilde: "Õ",
|
|
447
427
|
Otimes: "⨷",
|
|
448
|
-
Oum: "Ö",
|
|
449
428
|
Ouml: "Ö",
|
|
450
429
|
OverBar: "‾",
|
|
451
430
|
OverBrace: "⏞",
|
|
@@ -470,13 +449,11 @@ const entities = {
|
|
|
470
449
|
Proportional: "∝",
|
|
471
450
|
Pscr: "𝒫",
|
|
472
451
|
Psi: "Ψ",
|
|
473
|
-
QUO: "\"",
|
|
474
452
|
QUOT: "\"",
|
|
475
453
|
Qfr: "𝔔",
|
|
476
454
|
Qopf: "ℚ",
|
|
477
455
|
Qscr: "𝒬",
|
|
478
456
|
RBarr: "⤐",
|
|
479
|
-
RE: "®",
|
|
480
457
|
REG: "®",
|
|
481
458
|
Racute: "Ŕ",
|
|
482
459
|
Rang: "⟫",
|
|
@@ -560,7 +537,6 @@ const entities = {
|
|
|
560
537
|
Superset: "⊃",
|
|
561
538
|
SupersetEqual: "⊇",
|
|
562
539
|
Supset: "⋑",
|
|
563
|
-
THOR: "Þ",
|
|
564
540
|
THORN: "Þ",
|
|
565
541
|
TRADE: "™",
|
|
566
542
|
TSHcy: "Ћ",
|
|
@@ -583,18 +559,15 @@ const entities = {
|
|
|
583
559
|
TripleDot: "⃛",
|
|
584
560
|
Tscr: "𝒯",
|
|
585
561
|
Tstrok: "Ŧ",
|
|
586
|
-
Uacut: "Ú",
|
|
587
562
|
Uacute: "Ú",
|
|
588
563
|
Uarr: "↟",
|
|
589
564
|
Uarrocir: "⥉",
|
|
590
565
|
Ubrcy: "Ў",
|
|
591
566
|
Ubreve: "Ŭ",
|
|
592
|
-
Ucir: "Û",
|
|
593
567
|
Ucirc: "Û",
|
|
594
568
|
Ucy: "У",
|
|
595
569
|
Udblac: "Ű",
|
|
596
570
|
Ufr: "𝔘",
|
|
597
|
-
Ugrav: "Ù",
|
|
598
571
|
Ugrave: "Ù",
|
|
599
572
|
Umacr: "Ū",
|
|
600
573
|
UnderBar: "_",
|
|
@@ -621,7 +594,6 @@ const entities = {
|
|
|
621
594
|
Uring: "Ů",
|
|
622
595
|
Uscr: "𝒰",
|
|
623
596
|
Utilde: "Ũ",
|
|
624
|
-
Uum: "Ü",
|
|
625
597
|
Uuml: "Ü",
|
|
626
598
|
VDash: "⊫",
|
|
627
599
|
Vbar: "⫫",
|
|
@@ -652,7 +624,6 @@ const entities = {
|
|
|
652
624
|
YAcy: "Я",
|
|
653
625
|
YIcy: "Ї",
|
|
654
626
|
YUcy: "Ю",
|
|
655
|
-
Yacut: "Ý",
|
|
656
627
|
Yacute: "Ý",
|
|
657
628
|
Ycirc: "Ŷ",
|
|
658
629
|
Ycy: "Ы",
|
|
@@ -670,29 +641,23 @@ const entities = {
|
|
|
670
641
|
Zfr: "ℨ",
|
|
671
642
|
Zopf: "ℤ",
|
|
672
643
|
Zscr: "𝒵",
|
|
673
|
-
aacut: "á",
|
|
674
644
|
aacute: "á",
|
|
675
645
|
abreve: "ă",
|
|
676
646
|
ac: "∾",
|
|
677
647
|
acE: "∾̳",
|
|
678
648
|
acd: "∿",
|
|
679
|
-
acir: "â",
|
|
680
649
|
acirc: "â",
|
|
681
|
-
acut: "´",
|
|
682
650
|
acute: "´",
|
|
683
651
|
acy: "а",
|
|
684
|
-
aeli: "æ",
|
|
685
652
|
aelig: "æ",
|
|
686
653
|
af: "",
|
|
687
654
|
afr: "𝔞",
|
|
688
|
-
agrav: "à",
|
|
689
655
|
agrave: "à",
|
|
690
656
|
alefsym: "ℵ",
|
|
691
657
|
aleph: "ℵ",
|
|
692
658
|
alpha: "α",
|
|
693
659
|
amacr: "ā",
|
|
694
660
|
amalg: "⨿",
|
|
695
|
-
am: "&",
|
|
696
661
|
amp: "&",
|
|
697
662
|
and: "∧",
|
|
698
663
|
andand: "⩕",
|
|
@@ -727,15 +692,12 @@ const entities = {
|
|
|
727
692
|
apos: "'",
|
|
728
693
|
approx: "≈",
|
|
729
694
|
approxeq: "≊",
|
|
730
|
-
arin: "å",
|
|
731
695
|
aring: "å",
|
|
732
696
|
ascr: "𝒶",
|
|
733
697
|
ast: "*",
|
|
734
698
|
asymp: "≈",
|
|
735
699
|
asympeq: "≍",
|
|
736
|
-
atild: "ã",
|
|
737
700
|
atilde: "ã",
|
|
738
|
-
aum: "ä",
|
|
739
701
|
auml: "ä",
|
|
740
702
|
awconint: "∳",
|
|
741
703
|
awint: "⨑",
|
|
@@ -840,7 +802,6 @@ const entities = {
|
|
|
840
802
|
boxvr: "├",
|
|
841
803
|
bprime: "‵",
|
|
842
804
|
breve: "˘",
|
|
843
|
-
brvba: "¦",
|
|
844
805
|
brvbar: "¦",
|
|
845
806
|
bscr: "𝒷",
|
|
846
807
|
bsemi: "⁏",
|
|
@@ -867,16 +828,13 @@ const entities = {
|
|
|
867
828
|
caron: "ˇ",
|
|
868
829
|
ccaps: "⩍",
|
|
869
830
|
ccaron: "č",
|
|
870
|
-
ccedi: "ç",
|
|
871
831
|
ccedil: "ç",
|
|
872
832
|
ccirc: "ĉ",
|
|
873
833
|
ccups: "⩌",
|
|
874
834
|
ccupssm: "⩐",
|
|
875
835
|
cdot: "ċ",
|
|
876
|
-
cedi: "¸",
|
|
877
836
|
cedil: "¸",
|
|
878
837
|
cemptyv: "⦲",
|
|
879
|
-
cen: "¢",
|
|
880
838
|
cent: "¢",
|
|
881
839
|
centerdot: "·",
|
|
882
840
|
cfr: "𝔠",
|
|
@@ -915,7 +873,6 @@ const entities = {
|
|
|
915
873
|
conint: "∮",
|
|
916
874
|
copf: "𝕔",
|
|
917
875
|
coprod: "∐",
|
|
918
|
-
cop: "©",
|
|
919
876
|
copy: "©",
|
|
920
877
|
copysr: "℗",
|
|
921
878
|
crarr: "↵",
|
|
@@ -945,7 +902,6 @@ const entities = {
|
|
|
945
902
|
curlyeqsucc: "⋟",
|
|
946
903
|
curlyvee: "⋎",
|
|
947
904
|
curlywedge: "⋏",
|
|
948
|
-
curre: "¤",
|
|
949
905
|
curren: "¤",
|
|
950
906
|
curvearrowleft: "↶",
|
|
951
907
|
curvearrowright: "↷",
|
|
@@ -969,7 +925,6 @@ const entities = {
|
|
|
969
925
|
ddagger: "‡",
|
|
970
926
|
ddarr: "⇊",
|
|
971
927
|
ddotseq: "⩷",
|
|
972
|
-
de: "°",
|
|
973
928
|
deg: "°",
|
|
974
929
|
delta: "δ",
|
|
975
930
|
demptyv: "⦱",
|
|
@@ -985,7 +940,6 @@ const entities = {
|
|
|
985
940
|
digamma: "ϝ",
|
|
986
941
|
disin: "⋲",
|
|
987
942
|
div: "÷",
|
|
988
|
-
divid: "÷",
|
|
989
943
|
divide: "÷",
|
|
990
944
|
divideontimes: "⋇",
|
|
991
945
|
divonx: "⋇",
|
|
@@ -1022,11 +976,10 @@ const entities = {
|
|
|
1022
976
|
dzigrarr: "⟿",
|
|
1023
977
|
eDDot: "⩷",
|
|
1024
978
|
eDot: "≑",
|
|
1025
|
-
eacut: "é",
|
|
1026
979
|
eacute: "é",
|
|
1027
980
|
easter: "⩮",
|
|
1028
981
|
ecaron: "ě",
|
|
1029
|
-
ecir: "
|
|
982
|
+
ecir: "≖",
|
|
1030
983
|
ecirc: "ê",
|
|
1031
984
|
ecolon: "≕",
|
|
1032
985
|
ecy: "э",
|
|
@@ -1035,7 +988,6 @@ const entities = {
|
|
|
1035
988
|
efDot: "≒",
|
|
1036
989
|
efr: "𝔢",
|
|
1037
990
|
eg: "⪚",
|
|
1038
|
-
egrav: "è",
|
|
1039
991
|
egrave: "è",
|
|
1040
992
|
egs: "⪖",
|
|
1041
993
|
egsdot: "⪘",
|
|
@@ -1077,9 +1029,7 @@ const entities = {
|
|
|
1077
1029
|
esdot: "≐",
|
|
1078
1030
|
esim: "≂",
|
|
1079
1031
|
eta: "η",
|
|
1080
|
-
et: "ð",
|
|
1081
1032
|
eth: "ð",
|
|
1082
|
-
eum: "ë",
|
|
1083
1033
|
euml: "ë",
|
|
1084
1034
|
euro: "€",
|
|
1085
1035
|
excl: "!",
|
|
@@ -1104,7 +1054,6 @@ const entities = {
|
|
|
1104
1054
|
fork: "⋔",
|
|
1105
1055
|
forkv: "⫙",
|
|
1106
1056
|
fpartint: "⨍",
|
|
1107
|
-
frac1: "¼",
|
|
1108
1057
|
frac12: "½",
|
|
1109
1058
|
frac13: "⅓",
|
|
1110
1059
|
frac14: "¼",
|
|
@@ -1113,7 +1062,6 @@ const entities = {
|
|
|
1113
1062
|
frac18: "⅛",
|
|
1114
1063
|
frac23: "⅔",
|
|
1115
1064
|
frac25: "⅖",
|
|
1116
|
-
frac3: "¾",
|
|
1117
1065
|
frac34: "¾",
|
|
1118
1066
|
frac35: "⅗",
|
|
1119
1067
|
frac38: "⅜",
|
|
@@ -1168,7 +1116,6 @@ const entities = {
|
|
|
1168
1116
|
gsim: "≳",
|
|
1169
1117
|
gsime: "⪎",
|
|
1170
1118
|
gsiml: "⪐",
|
|
1171
|
-
g: ">",
|
|
1172
1119
|
gt: ">",
|
|
1173
1120
|
gtcc: "⪧",
|
|
1174
1121
|
gtcir: "⩺",
|
|
@@ -1212,18 +1159,14 @@ const entities = {
|
|
|
1212
1159
|
hstrok: "ħ",
|
|
1213
1160
|
hybull: "⁃",
|
|
1214
1161
|
hyphen: "‐",
|
|
1215
|
-
iacut: "í",
|
|
1216
1162
|
iacute: "í",
|
|
1217
1163
|
ic: "",
|
|
1218
|
-
icir: "î",
|
|
1219
1164
|
icirc: "î",
|
|
1220
1165
|
icy: "и",
|
|
1221
1166
|
iecy: "е",
|
|
1222
|
-
iexc: "¡",
|
|
1223
1167
|
iexcl: "¡",
|
|
1224
1168
|
iff: "⇔",
|
|
1225
1169
|
ifr: "𝔦",
|
|
1226
|
-
igrav: "ì",
|
|
1227
1170
|
igrave: "ì",
|
|
1228
1171
|
ii: "ⅈ",
|
|
1229
1172
|
iiiint: "⨌",
|
|
@@ -1254,7 +1197,6 @@ const entities = {
|
|
|
1254
1197
|
iopf: "𝕚",
|
|
1255
1198
|
iota: "ι",
|
|
1256
1199
|
iprod: "⨼",
|
|
1257
|
-
iques: "¿",
|
|
1258
1200
|
iquest: "¿",
|
|
1259
1201
|
iscr: "𝒾",
|
|
1260
1202
|
isin: "∈",
|
|
@@ -1266,7 +1208,6 @@ const entities = {
|
|
|
1266
1208
|
it: "",
|
|
1267
1209
|
itilde: "ĩ",
|
|
1268
1210
|
iukcy: "і",
|
|
1269
|
-
ium: "ï",
|
|
1270
1211
|
iuml: "ï",
|
|
1271
1212
|
jcirc: "ĵ",
|
|
1272
1213
|
jcy: "й",
|
|
@@ -1301,7 +1242,6 @@ const entities = {
|
|
|
1301
1242
|
langd: "⦑",
|
|
1302
1243
|
langle: "⟨",
|
|
1303
1244
|
lap: "⪅",
|
|
1304
|
-
laqu: "«",
|
|
1305
1245
|
laquo: "«",
|
|
1306
1246
|
larr: "←",
|
|
1307
1247
|
larrb: "⇤",
|
|
@@ -1423,7 +1363,6 @@ const entities = {
|
|
|
1423
1363
|
lsquo: "‘",
|
|
1424
1364
|
lsquor: "‚",
|
|
1425
1365
|
lstrok: "ł",
|
|
1426
|
-
l: "<",
|
|
1427
1366
|
lt: "<",
|
|
1428
1367
|
ltcc: "⪦",
|
|
1429
1368
|
ltcir: "⩹",
|
|
@@ -1441,7 +1380,6 @@ const entities = {
|
|
|
1441
1380
|
lvertneqq: "≨︀",
|
|
1442
1381
|
lvnE: "≨︀",
|
|
1443
1382
|
mDDot: "∺",
|
|
1444
|
-
mac: "¯",
|
|
1445
1383
|
macr: "¯",
|
|
1446
1384
|
male: "♂",
|
|
1447
1385
|
malt: "✠",
|
|
@@ -1458,12 +1396,10 @@ const entities = {
|
|
|
1458
1396
|
measuredangle: "∡",
|
|
1459
1397
|
mfr: "𝔪",
|
|
1460
1398
|
mho: "℧",
|
|
1461
|
-
micr: "µ",
|
|
1462
1399
|
micro: "µ",
|
|
1463
1400
|
mid: "∣",
|
|
1464
1401
|
midast: "*",
|
|
1465
1402
|
midcir: "⫰",
|
|
1466
|
-
middo: "·",
|
|
1467
1403
|
middot: "·",
|
|
1468
1404
|
minus: "−",
|
|
1469
1405
|
minusb: "⊟",
|
|
@@ -1502,7 +1438,6 @@ const entities = {
|
|
|
1502
1438
|
natur: "♮",
|
|
1503
1439
|
natural: "♮",
|
|
1504
1440
|
naturals: "ℕ",
|
|
1505
|
-
nbs: "\xA0",
|
|
1506
1441
|
nbsp: "\xA0",
|
|
1507
1442
|
nbump: "≎̸",
|
|
1508
1443
|
nbumpe: "≏̸",
|
|
@@ -1561,7 +1496,6 @@ const entities = {
|
|
|
1561
1496
|
nltrie: "⋬",
|
|
1562
1497
|
nmid: "∤",
|
|
1563
1498
|
nopf: "𝕟",
|
|
1564
|
-
no: "¬",
|
|
1565
1499
|
not: "¬",
|
|
1566
1500
|
notin: "∉",
|
|
1567
1501
|
notinE: "⋹̸",
|
|
@@ -1618,7 +1552,6 @@ const entities = {
|
|
|
1618
1552
|
nsupseteq: "⊉",
|
|
1619
1553
|
nsupseteqq: "⫆̸",
|
|
1620
1554
|
ntgl: "≹",
|
|
1621
|
-
ntild: "ñ",
|
|
1622
1555
|
ntilde: "ñ",
|
|
1623
1556
|
ntlg: "≸",
|
|
1624
1557
|
ntriangleleft: "⋪",
|
|
@@ -1649,10 +1582,9 @@ const entities = {
|
|
|
1649
1582
|
nwarrow: "↖",
|
|
1650
1583
|
nwnear: "⤧",
|
|
1651
1584
|
oS: "Ⓢ",
|
|
1652
|
-
oacut: "ó",
|
|
1653
1585
|
oacute: "ó",
|
|
1654
1586
|
oast: "⊛",
|
|
1655
|
-
ocir: "
|
|
1587
|
+
ocir: "⊚",
|
|
1656
1588
|
ocirc: "ô",
|
|
1657
1589
|
ocy: "о",
|
|
1658
1590
|
odash: "⊝",
|
|
@@ -1664,7 +1596,6 @@ const entities = {
|
|
|
1664
1596
|
ofcir: "⦿",
|
|
1665
1597
|
ofr: "𝔬",
|
|
1666
1598
|
ogon: "˛",
|
|
1667
|
-
ograv: "ò",
|
|
1668
1599
|
ograve: "ò",
|
|
1669
1600
|
ogt: "⧁",
|
|
1670
1601
|
ohbar: "⦵",
|
|
@@ -1686,7 +1617,7 @@ const entities = {
|
|
|
1686
1617
|
oplus: "⊕",
|
|
1687
1618
|
or: "∨",
|
|
1688
1619
|
orarr: "↻",
|
|
1689
|
-
ord: "
|
|
1620
|
+
ord: "⩝",
|
|
1690
1621
|
order: "ℴ",
|
|
1691
1622
|
orderof: "ℴ",
|
|
1692
1623
|
ordf: "ª",
|
|
@@ -1696,17 +1627,14 @@ const entities = {
|
|
|
1696
1627
|
orslope: "⩗",
|
|
1697
1628
|
orv: "⩛",
|
|
1698
1629
|
oscr: "ℴ",
|
|
1699
|
-
oslas: "ø",
|
|
1700
1630
|
oslash: "ø",
|
|
1701
1631
|
osol: "⊘",
|
|
1702
|
-
otild: "õ",
|
|
1703
1632
|
otilde: "õ",
|
|
1704
1633
|
otimes: "⊗",
|
|
1705
1634
|
otimesas: "⨶",
|
|
1706
|
-
oum: "ö",
|
|
1707
1635
|
ouml: "ö",
|
|
1708
1636
|
ovbar: "⌽",
|
|
1709
|
-
par: "
|
|
1637
|
+
par: "∥",
|
|
1710
1638
|
para: "¶",
|
|
1711
1639
|
parallel: "∥",
|
|
1712
1640
|
parsim: "⫳",
|
|
@@ -1736,14 +1664,12 @@ const entities = {
|
|
|
1736
1664
|
plusdo: "∔",
|
|
1737
1665
|
plusdu: "⨥",
|
|
1738
1666
|
pluse: "⩲",
|
|
1739
|
-
plusm: "±",
|
|
1740
1667
|
plusmn: "±",
|
|
1741
1668
|
plussim: "⨦",
|
|
1742
1669
|
plustwo: "⨧",
|
|
1743
1670
|
pm: "±",
|
|
1744
1671
|
pointint: "⨕",
|
|
1745
1672
|
popf: "𝕡",
|
|
1746
|
-
poun: "£",
|
|
1747
1673
|
pound: "£",
|
|
1748
1674
|
pr: "≺",
|
|
1749
1675
|
prE: "⪳",
|
|
@@ -1783,7 +1709,6 @@ const entities = {
|
|
|
1783
1709
|
quatint: "⨖",
|
|
1784
1710
|
quest: "?",
|
|
1785
1711
|
questeq: "≟",
|
|
1786
|
-
quo: "\"",
|
|
1787
1712
|
quot: "\"",
|
|
1788
1713
|
rAarr: "⇛",
|
|
1789
1714
|
rArr: "⇒",
|
|
@@ -1798,7 +1723,6 @@ const entities = {
|
|
|
1798
1723
|
rangd: "⦒",
|
|
1799
1724
|
range: "⦥",
|
|
1800
1725
|
rangle: "⟩",
|
|
1801
|
-
raqu: "»",
|
|
1802
1726
|
raquo: "»",
|
|
1803
1727
|
rarr: "→",
|
|
1804
1728
|
rarrap: "⥵",
|
|
@@ -1837,7 +1761,6 @@ const entities = {
|
|
|
1837
1761
|
realpart: "ℜ",
|
|
1838
1762
|
reals: "ℝ",
|
|
1839
1763
|
rect: "▭",
|
|
1840
|
-
re: "®",
|
|
1841
1764
|
reg: "®",
|
|
1842
1765
|
rfisht: "⥽",
|
|
1843
1766
|
rfloor: "⌋",
|
|
@@ -1912,7 +1835,6 @@ const entities = {
|
|
|
1912
1835
|
searhk: "⤥",
|
|
1913
1836
|
searr: "↘",
|
|
1914
1837
|
searrow: "↘",
|
|
1915
|
-
sec: "§",
|
|
1916
1838
|
sect: "§",
|
|
1917
1839
|
semi: ";",
|
|
1918
1840
|
seswar: "⤩",
|
|
@@ -1926,7 +1848,6 @@ const entities = {
|
|
|
1926
1848
|
shcy: "ш",
|
|
1927
1849
|
shortmid: "∣",
|
|
1928
1850
|
shortparallel: "∥",
|
|
1929
|
-
sh: "",
|
|
1930
1851
|
shy: "",
|
|
1931
1852
|
sigma: "σ",
|
|
1932
1853
|
sigmaf: "ς",
|
|
@@ -2013,10 +1934,10 @@ const entities = {
|
|
|
2013
1934
|
succsim: "≿",
|
|
2014
1935
|
sum: "∑",
|
|
2015
1936
|
sung: "♪",
|
|
2016
|
-
sup: "⊃",
|
|
2017
1937
|
sup1: "¹",
|
|
2018
1938
|
sup2: "²",
|
|
2019
1939
|
sup3: "³",
|
|
1940
|
+
sup: "⊃",
|
|
2020
1941
|
supE: "⫆",
|
|
2021
1942
|
supdot: "⪾",
|
|
2022
1943
|
supdsub: "⫘",
|
|
@@ -2042,7 +1963,6 @@ const entities = {
|
|
|
2042
1963
|
swarr: "↙",
|
|
2043
1964
|
swarrow: "↙",
|
|
2044
1965
|
swnwar: "⤪",
|
|
2045
|
-
szli: "ß",
|
|
2046
1966
|
szlig: "ß",
|
|
2047
1967
|
target: "⌖",
|
|
2048
1968
|
tau: "τ",
|
|
@@ -2063,10 +1983,8 @@ const entities = {
|
|
|
2063
1983
|
thinsp: " ",
|
|
2064
1984
|
thkap: "≈",
|
|
2065
1985
|
thksim: "∼",
|
|
2066
|
-
thor: "þ",
|
|
2067
1986
|
thorn: "þ",
|
|
2068
1987
|
tilde: "˜",
|
|
2069
|
-
time: "×",
|
|
2070
1988
|
times: "×",
|
|
2071
1989
|
timesb: "⊠",
|
|
2072
1990
|
timesbar: "⨱",
|
|
@@ -2104,12 +2022,10 @@ const entities = {
|
|
|
2104
2022
|
twoheadrightarrow: "↠",
|
|
2105
2023
|
uArr: "⇑",
|
|
2106
2024
|
uHar: "⥣",
|
|
2107
|
-
uacut: "ú",
|
|
2108
2025
|
uacute: "ú",
|
|
2109
2026
|
uarr: "↑",
|
|
2110
2027
|
ubrcy: "ў",
|
|
2111
2028
|
ubreve: "ŭ",
|
|
2112
|
-
ucir: "û",
|
|
2113
2029
|
ucirc: "û",
|
|
2114
2030
|
ucy: "у",
|
|
2115
2031
|
udarr: "⇅",
|
|
@@ -2117,7 +2033,6 @@ const entities = {
|
|
|
2117
2033
|
udhar: "⥮",
|
|
2118
2034
|
ufisht: "⥾",
|
|
2119
2035
|
ufr: "𝔲",
|
|
2120
|
-
ugrav: "ù",
|
|
2121
2036
|
ugrave: "ù",
|
|
2122
2037
|
uharl: "↿",
|
|
2123
2038
|
uharr: "↾",
|
|
@@ -2127,7 +2042,6 @@ const entities = {
|
|
|
2127
2042
|
ulcrop: "⌏",
|
|
2128
2043
|
ultri: "◸",
|
|
2129
2044
|
umacr: "ū",
|
|
2130
|
-
um: "¨",
|
|
2131
2045
|
uml: "¨",
|
|
2132
2046
|
uogon: "ų",
|
|
2133
2047
|
uopf: "𝕦",
|
|
@@ -2151,7 +2065,6 @@ const entities = {
|
|
|
2151
2065
|
utri: "▵",
|
|
2152
2066
|
utrif: "▴",
|
|
2153
2067
|
uuarr: "⇈",
|
|
2154
|
-
uum: "ü",
|
|
2155
2068
|
uuml: "ü",
|
|
2156
2069
|
uwangle: "⦧",
|
|
2157
2070
|
vArr: "⇕",
|
|
@@ -2231,19 +2144,16 @@ const entities = {
|
|
|
2231
2144
|
xutri: "△",
|
|
2232
2145
|
xvee: "⋁",
|
|
2233
2146
|
xwedge: "⋀",
|
|
2234
|
-
yacut: "ý",
|
|
2235
2147
|
yacute: "ý",
|
|
2236
2148
|
yacy: "я",
|
|
2237
2149
|
ycirc: "ŷ",
|
|
2238
2150
|
ycy: "ы",
|
|
2239
|
-
ye: "¥",
|
|
2240
2151
|
yen: "¥",
|
|
2241
2152
|
yfr: "𝔶",
|
|
2242
2153
|
yicy: "ї",
|
|
2243
2154
|
yopf: "𝕪",
|
|
2244
2155
|
yscr: "𝓎",
|
|
2245
2156
|
yucy: "ю",
|
|
2246
|
-
yum: "ÿ",
|
|
2247
2157
|
yuml: "ÿ",
|
|
2248
2158
|
zacute: "ź",
|
|
2249
2159
|
zcaron: "ž",
|
|
@@ -2281,14 +2191,12 @@ function decodeReference(source, start, end) {
|
|
|
2281
2191
|
let point = 0;
|
|
2282
2192
|
for (let offset = start + (hex ? 3 : 2); offset < end - 1; offset++) {
|
|
2283
2193
|
const digit = source.charCodeAt(offset);
|
|
2284
|
-
point = point * radix + (digit <= 57 ? digit - 48 : (digit | 32) -
|
|
2194
|
+
point = point * radix + (digit <= 57 ? digit - 48 : (digit | 32) - 87);
|
|
2285
2195
|
}
|
|
2286
2196
|
if (point < 9 || point === 11 || point > 13 && point < 32 || point >= 127 && point <= 159 || point >= 55296 && point <= 57343 || point >= 64976 && point <= 65007 || (point & 65535) >= 65534 || point > 1114111) point = 65533;
|
|
2287
2197
|
return String.fromCodePoint(point);
|
|
2288
2198
|
}
|
|
2289
|
-
function
|
|
2290
|
-
let ampersand = source.indexOf("&");
|
|
2291
|
-
let backslash = source.indexOf("\\");
|
|
2199
|
+
function decodeFrom(source, ampersand, backslash) {
|
|
2292
2200
|
let copied;
|
|
2293
2201
|
let result = "";
|
|
2294
2202
|
while (ampersand >= 0 || backslash >= 0) {
|
|
@@ -2317,8 +2225,17 @@ function decodeString(source) {
|
|
|
2317
2225
|
}
|
|
2318
2226
|
return copied ? result + source.slice(copied) : source;
|
|
2319
2227
|
}
|
|
2228
|
+
function decodeEntities(source) {
|
|
2229
|
+
const ampersand = source.indexOf("&");
|
|
2230
|
+
return ampersand < 0 ? source : decodeFrom(source, ampersand, -1);
|
|
2231
|
+
}
|
|
2232
|
+
function decodeString(source) {
|
|
2233
|
+
const ampersand = source.indexOf("&");
|
|
2234
|
+
const backslash = source.indexOf("\\");
|
|
2235
|
+
return ampersand < 0 && backslash < 0 ? source : decodeFrom(source, ampersand, backslash);
|
|
2236
|
+
}
|
|
2320
2237
|
// src/constants/block.ts
|
|
2321
|
-
const
|
|
2238
|
+
const paddedLineFeed = Symbol();
|
|
2322
2239
|
// src/primitives.ts
|
|
2323
2240
|
const emptyArray = [];
|
|
2324
2241
|
const emptySet = new Set();
|
|
@@ -2352,17 +2269,14 @@ function containingSegment(mappings, offset) {
|
|
|
2352
2269
|
return low * 2;
|
|
2353
2270
|
}
|
|
2354
2271
|
var SourceView = class {
|
|
2355
|
-
|
|
2356
|
-
#withBoundaryBreak = false;
|
|
2272
|
+
mappings = 0;
|
|
2357
2273
|
text = "";
|
|
2358
2274
|
reset(source, tokens, tokenStart, nodeLength) {
|
|
2359
|
-
this.#withBoundaryBreak = tokens.value(tokenStart) === boundaryBreak;
|
|
2360
2275
|
const first = tokenStart + 1;
|
|
2361
|
-
|
|
2362
|
-
if (count > 1 && tokens.kind(first + count - 1) === 0) count--;
|
|
2276
|
+
const count = nodeLength - 1;
|
|
2363
2277
|
if (count === 1) {
|
|
2364
2278
|
const start = tokens.start(first);
|
|
2365
|
-
this
|
|
2279
|
+
this.mappings = start;
|
|
2366
2280
|
this.text = source.slice(start, tokens.end(first));
|
|
2367
2281
|
return;
|
|
2368
2282
|
}
|
|
@@ -2375,26 +2289,23 @@ var SourceView = class {
|
|
|
2375
2289
|
mappings[index * 2] = start - viewEnd;
|
|
2376
2290
|
mappings[index * 2 + 1] = viewEnd += end - start;
|
|
2377
2291
|
}
|
|
2378
|
-
this
|
|
2292
|
+
this.mappings = mappings;
|
|
2379
2293
|
this.text = parts.join("");
|
|
2380
2294
|
}
|
|
2381
|
-
tokenize(tokenize, scratch = false) {
|
|
2382
|
-
return tokenize(this.text, this.#withBoundaryBreak, !scratch || this.#withBoundaryBreak ? void 0 : this.#mappings);
|
|
2383
|
-
}
|
|
2384
2295
|
mapOffset(offset) {
|
|
2385
|
-
const mappings = this
|
|
2296
|
+
const mappings = this.mappings;
|
|
2386
2297
|
if (typeof mappings === "number") return mappings + offset;
|
|
2387
2298
|
return mappings[containingSegment(mappings, offset)] + offset;
|
|
2388
2299
|
}
|
|
2389
2300
|
mapEnd(offset) {
|
|
2390
|
-
const mappings = this
|
|
2301
|
+
const mappings = this.mappings;
|
|
2391
2302
|
if (typeof mappings === "number") return mappings + offset;
|
|
2392
2303
|
return mappings[containingSegment(mappings, Math.max(0, offset - 1))] + offset;
|
|
2393
2304
|
}
|
|
2394
2305
|
shift(delta) {
|
|
2395
|
-
const mappings = this
|
|
2306
|
+
const mappings = this.mappings;
|
|
2396
2307
|
if (typeof mappings === "number") {
|
|
2397
|
-
this
|
|
2308
|
+
this.mappings = mappings + delta;
|
|
2398
2309
|
return;
|
|
2399
2310
|
}
|
|
2400
2311
|
for (let index = 0; index < mappings.length; index += 2) mappings[index] += delta;
|
|
@@ -2487,14 +2398,14 @@ var Latin1 = class {
|
|
|
2487
2398
|
const word5 = words[offset | 5];
|
|
2488
2399
|
const word6 = words[offset | 6];
|
|
2489
2400
|
const word7 = words[offset | 7];
|
|
2490
|
-
const hits0 = word0 - 269488144 & ~word0 &
|
|
2491
|
-
const hits1 = word1 - 269488144 & ~word1 &
|
|
2492
|
-
const hits2 = word2 - 269488144 & ~word2 &
|
|
2493
|
-
const hits3 = word3 - 269488144 & ~word3 &
|
|
2494
|
-
const hits4 = word4 - 269488144 & ~word4 &
|
|
2495
|
-
const hits5 = word5 - 269488144 & ~word5 &
|
|
2496
|
-
const hits6 = word6 - 269488144 & ~word6 &
|
|
2497
|
-
const hits7 = word7 - 269488144 & ~word7 &
|
|
2401
|
+
const hits0 = word0 - 269488144 & ~word0 & 0x80808080;
|
|
2402
|
+
const hits1 = word1 - 269488144 & ~word1 & 0x80808080;
|
|
2403
|
+
const hits2 = word2 - 269488144 & ~word2 & 0x80808080;
|
|
2404
|
+
const hits3 = word3 - 269488144 & ~word3 & 0x80808080;
|
|
2405
|
+
const hits4 = word4 - 269488144 & ~word4 & 0x80808080;
|
|
2406
|
+
const hits5 = word5 - 269488144 & ~word5 & 0x80808080;
|
|
2407
|
+
const hits6 = word6 - 269488144 & ~word6 & 0x80808080;
|
|
2408
|
+
const hits7 = word7 - 269488144 & ~word7 & 0x80808080;
|
|
2498
2409
|
if (hits0 | hits1 | hits2 | hits3 | hits4 | hits5 | hits6 | hits7) {
|
|
2499
2410
|
let events = Math.imul(hits0 >>> 4 | hits1, 2113665) >>> 24 | Math.imul(hits2 >>> 4 | hits3, 2113665) >>> 24 << 8 | Math.imul(hits4 >>> 4 | hits5, 2113665) >>> 24 << 16 | Math.imul(hits6 >>> 4 | hits7, 2113665) >>> 24 << 24;
|
|
2500
2411
|
const last = cursor + 31;
|
|
@@ -2540,14 +2451,14 @@ var Latin1 = class {
|
|
|
2540
2451
|
}
|
|
2541
2452
|
};
|
|
2542
2453
|
var Index0 = class {
|
|
2543
|
-
static scan(source, fields, sourceOffset) {
|
|
2454
|
+
static scan(source, fields, sourceOffset, start = sourceOffset) {
|
|
2544
2455
|
let field = 0;
|
|
2545
|
-
let start = 0;
|
|
2546
2456
|
let lf = source.indexOf("\n");
|
|
2547
2457
|
let cr = source.indexOf("\r");
|
|
2548
2458
|
const normalized = cr < 0;
|
|
2549
2459
|
const limit = source.length;
|
|
2550
|
-
|
|
2460
|
+
const sourceEnd = sourceOffset + limit;
|
|
2461
|
+
while (start < sourceEnd) {
|
|
2551
2462
|
let end = lf;
|
|
2552
2463
|
let next = end + 1;
|
|
2553
2464
|
if (cr !== -1 && (end < 0 || cr < end)) {
|
|
@@ -2557,12 +2468,15 @@ var Index0 = class {
|
|
|
2557
2468
|
if (lf !== -1 && lf < next) lf = source.indexOf("\n", next);
|
|
2558
2469
|
} else if (lf < 0) end = next = limit;
|
|
2559
2470
|
else lf = source.indexOf("\n", next);
|
|
2560
|
-
if (field >= fields.length)
|
|
2561
|
-
|
|
2471
|
+
if (field >= fields.length) {
|
|
2472
|
+
const capacity = Math.max(field / 4 + 1, getLineCapacity(limit));
|
|
2473
|
+
fields = growLineFields(fields, capacity * 4);
|
|
2474
|
+
}
|
|
2475
|
+
fields[field | 0] = start;
|
|
2562
2476
|
fields[field | 1] = sourceOffset + end;
|
|
2563
2477
|
fields[field | 2] = sourceOffset + next;
|
|
2564
2478
|
field += 4;
|
|
2565
|
-
start = next;
|
|
2479
|
+
start = sourceOffset + next;
|
|
2566
2480
|
}
|
|
2567
2481
|
return {
|
|
2568
2482
|
fields,
|
|
@@ -2572,6 +2486,7 @@ var Index0 = class {
|
|
|
2572
2486
|
}
|
|
2573
2487
|
};
|
|
2574
2488
|
var BlockLines = class BlockLines {
|
|
2489
|
+
#child;
|
|
2575
2490
|
#fields;
|
|
2576
2491
|
#length = 0;
|
|
2577
2492
|
#locatorLine = 1;
|
|
@@ -2579,12 +2494,11 @@ var BlockLines = class BlockLines {
|
|
|
2579
2494
|
#locatorStart = 0;
|
|
2580
2495
|
#normalized = true;
|
|
2581
2496
|
#sourceLength;
|
|
2582
|
-
constructor(sourceLength = 0,
|
|
2497
|
+
constructor(sourceLength = 0, fields = new Int32Array(16)) {
|
|
2583
2498
|
this.#sourceLength = sourceLength;
|
|
2584
|
-
this.#fields =
|
|
2499
|
+
this.#fields = fields;
|
|
2585
2500
|
}
|
|
2586
2501
|
scan(source) {
|
|
2587
|
-
this.#locatorLine = 1;
|
|
2588
2502
|
this.#sourceLength = source.length;
|
|
2589
2503
|
const fields = growLineFields(this.#fields, getLineCapacity(source.length) * 4);
|
|
2590
2504
|
const result = ScratchView.supports ? Latin1.scan(source, fields) : Index0.scan(source, fields, 0);
|
|
@@ -2705,7 +2619,7 @@ var BlockLines = class BlockLines {
|
|
|
2705
2619
|
fields[field | 3] = state;
|
|
2706
2620
|
this.#length++;
|
|
2707
2621
|
}
|
|
2708
|
-
pushFrom(lines, index, start = lines.start(index), prefixColumns = lines.prefixColumns(index), lazy =
|
|
2622
|
+
pushFrom(lines, index, start = lines.start(index), prefixColumns = lines.prefixColumns(index), lazy = false) {
|
|
2709
2623
|
this.push(start, lines.end(index), lines.next(index), prefixColumns, lazy);
|
|
2710
2624
|
}
|
|
2711
2625
|
pushAfterColumns(source, lines, index, columns) {
|
|
@@ -2715,33 +2629,30 @@ var BlockLines = class BlockLines {
|
|
|
2715
2629
|
while (offset < end && consumed < columns) {
|
|
2716
2630
|
const code = source.charCodeAt(offset);
|
|
2717
2631
|
if (code === 32) consumed++;
|
|
2718
|
-
else if (code === 9) consumed +=
|
|
2632
|
+
else if (code === 9) consumed += tabWidthAt(source, offset);
|
|
2719
2633
|
else break;
|
|
2720
2634
|
offset++;
|
|
2721
2635
|
}
|
|
2722
2636
|
if (offset === end) return -2;
|
|
2723
2637
|
if (consumed < columns) return consumed <= 3 ? offset : -1;
|
|
2724
2638
|
if (trimLineWhitespaceStart(source, offset, end) < end) {
|
|
2725
|
-
this.push(offset, end, lines.next(index), consumed - columns,
|
|
2639
|
+
this.push(offset, end, lines.next(index), consumed - columns, false);
|
|
2726
2640
|
return -3;
|
|
2727
2641
|
}
|
|
2728
2642
|
return -2;
|
|
2729
2643
|
}
|
|
2730
|
-
pushLazy(lines, index) {
|
|
2731
|
-
this.pushFrom(lines, index, void 0, void 0, true);
|
|
2732
|
-
}
|
|
2733
2644
|
pop() {
|
|
2734
2645
|
if (this.#length > 0) this.#length--;
|
|
2735
2646
|
}
|
|
2736
|
-
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2739
|
-
this
|
|
2740
|
-
|
|
2647
|
+
child(index, start, prefixColumns) {
|
|
2648
|
+
const child = this.#child ??= new BlockLines();
|
|
2649
|
+
child.#length = 0;
|
|
2650
|
+
child.pushFrom(this, index, start, prefixColumns);
|
|
2651
|
+
return child;
|
|
2741
2652
|
}
|
|
2742
|
-
view(start, end
|
|
2743
|
-
const result = new BlockLines(this.#sourceLength,
|
|
2744
|
-
result.#
|
|
2653
|
+
view(start, end) {
|
|
2654
|
+
const result = new BlockLines(this.#sourceLength, this.#fields.subarray(start * 4, end * 4));
|
|
2655
|
+
result.#child = this.#child;
|
|
2745
2656
|
result.#length = end - start;
|
|
2746
2657
|
result.#normalized = this.#normalized;
|
|
2747
2658
|
return result;
|
|
@@ -2751,14 +2662,17 @@ var BlockLines = class BlockLines {
|
|
|
2751
2662
|
const newSuffixOffset = (suffix < this.length ? this.start(suffix) : nextSource.length - delta) + delta;
|
|
2752
2663
|
const prefixEnd = Math.max(0, this.indexAtOrAfter(damageStart) - 1);
|
|
2753
2664
|
const restartOffset = prefixEnd === 0 ? 0 : this.start(prefixEnd);
|
|
2754
|
-
const
|
|
2755
|
-
const
|
|
2756
|
-
const
|
|
2665
|
+
const scanStart = Math.min(damageStart, this.end(prefixEnd));
|
|
2666
|
+
const changedSource = nextSource.slice(scanStart, newSuffixOffset);
|
|
2667
|
+
const firstField = prefixEnd * 4;
|
|
2668
|
+
const suffixField = suffix < this.#length ? suffix * 4 : void 0;
|
|
2669
|
+
const available = this.#fields.subarray(firstField, suffixField);
|
|
2670
|
+
const changed = Index0.scan(changedSource, available, scanStart, restartOffset);
|
|
2757
2671
|
const nextSuffix = prefixEnd + changed.length;
|
|
2758
2672
|
const length = nextSuffix + this.#length - suffix;
|
|
2759
2673
|
const fields = this.#fields = growLineFields(this.#fields, length * 4);
|
|
2760
2674
|
if (nextSuffix !== suffix) fields.copyWithin(nextSuffix * 4, suffix * 4, this.#length * 4);
|
|
2761
|
-
fields.set(changed.fields.subarray(0, changed.length * 4),
|
|
2675
|
+
if (changed.fields !== available) fields.set(changed.fields.subarray(0, changed.length * 4), firstField);
|
|
2762
2676
|
this.#length = length;
|
|
2763
2677
|
this.#sourceLength = nextSource.length;
|
|
2764
2678
|
this.#normalized &&= changed.normalized;
|
|
@@ -2774,14 +2688,40 @@ var BlockLines = class BlockLines {
|
|
|
2774
2688
|
}
|
|
2775
2689
|
}
|
|
2776
2690
|
};
|
|
2777
|
-
function
|
|
2691
|
+
function dedentLine(source, lines, index, indent, end) {
|
|
2692
|
+
const lineEnd = lines.end(index);
|
|
2778
2693
|
let offset = lines.start(index);
|
|
2779
|
-
|
|
2694
|
+
let columns = lines.prefixColumns(index);
|
|
2695
|
+
while (offset < lineEnd && columns < indent) {
|
|
2696
|
+
const code = source.charCodeAt(offset);
|
|
2697
|
+
if (code === 32) columns++;
|
|
2698
|
+
else if (code === 9) columns += tabWidthAt(source, offset);
|
|
2699
|
+
else break;
|
|
2700
|
+
offset++;
|
|
2701
|
+
}
|
|
2702
|
+
return columns > indent ? " ".repeat(columns - indent) + source.slice(offset, end) : source.slice(offset, end);
|
|
2703
|
+
}
|
|
2704
|
+
function lineIndentOffset(source, lines, index) {
|
|
2780
2705
|
const end = lines.end(index);
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2706
|
+
let offset = lines.start(index);
|
|
2707
|
+
let columns = lines.prefixColumns(index);
|
|
2708
|
+
while (offset < end && columns <= 3) {
|
|
2709
|
+
const code = source.charCodeAt(offset);
|
|
2710
|
+
if (code === 32) {
|
|
2711
|
+
columns++;
|
|
2712
|
+
offset++;
|
|
2713
|
+
} else if (code === 9) {
|
|
2714
|
+
columns += tabWidthAt(source, offset);
|
|
2715
|
+
offset++;
|
|
2716
|
+
} else return offset;
|
|
2717
|
+
}
|
|
2718
|
+
return -1;
|
|
2719
|
+
}
|
|
2720
|
+
function lineIndentColumns(source, lines, index, contentOffset) {
|
|
2721
|
+
if (lines.physicallyContiguous()) return contentOffset - lines.start(index);
|
|
2722
|
+
let columns = lines.prefixColumns(index);
|
|
2723
|
+
for (let offset = lines.start(index); offset < contentOffset; offset++) columns += source.charCodeAt(offset) === 32 ? 1 : tabWidthAt(source, offset);
|
|
2724
|
+
return columns;
|
|
2785
2725
|
}
|
|
2786
2726
|
function isBlankLine(source, lines, index) {
|
|
2787
2727
|
const end = lines.end(index);
|
|
@@ -2803,19 +2743,14 @@ function trimLineWhitespaceEnd(source, start, end) {
|
|
|
2803
2743
|
}
|
|
2804
2744
|
return end;
|
|
2805
2745
|
}
|
|
2806
|
-
function
|
|
2746
|
+
function tabWidthAt(source, offset) {
|
|
2807
2747
|
let start = offset;
|
|
2808
2748
|
while (start > 0) {
|
|
2809
2749
|
const code = source.charCodeAt(start - 1);
|
|
2810
|
-
if (code === 10 || code === 13) break;
|
|
2750
|
+
if (code === 9 || code === 10 || code === 13) break;
|
|
2811
2751
|
start--;
|
|
2812
2752
|
}
|
|
2813
|
-
|
|
2814
|
-
while (start < offset) {
|
|
2815
|
-
column += source.charCodeAt(start) === 9 ? 4 - column % 4 : 1;
|
|
2816
|
-
start++;
|
|
2817
|
-
}
|
|
2818
|
-
return column;
|
|
2753
|
+
return 4 - (offset - start & 3);
|
|
2819
2754
|
}
|
|
2820
2755
|
// src/block/tokens.ts
|
|
2821
2756
|
function copyMetadata(target, source, start, end, targetStart) {
|
|
@@ -2827,14 +2762,12 @@ function copyMetadata(target, source, start, end, targetStart) {
|
|
|
2827
2762
|
}
|
|
2828
2763
|
var BlockTokenStream = class {
|
|
2829
2764
|
#definitionCounts;
|
|
2830
|
-
#definitionMembershipChanges;
|
|
2831
2765
|
#fieldLength = 0;
|
|
2832
2766
|
#fields = new Int32Array();
|
|
2833
2767
|
#metadata;
|
|
2834
2768
|
#opens = [];
|
|
2835
2769
|
reset() {
|
|
2836
2770
|
this.#definitionCounts = void 0;
|
|
2837
|
-
this.#definitionMembershipChanges?.clear();
|
|
2838
2771
|
const metadata = this.#metadata;
|
|
2839
2772
|
if (metadata) {
|
|
2840
2773
|
const used = Math.min(metadata.length, this.length);
|
|
@@ -2848,12 +2781,6 @@ var BlockTokenStream = class {
|
|
|
2848
2781
|
get length() {
|
|
2849
2782
|
return this.#fieldLength / 4;
|
|
2850
2783
|
}
|
|
2851
|
-
hasDefinition(key) {
|
|
2852
|
-
return this.#definitionCounts?.has(key) === true;
|
|
2853
|
-
}
|
|
2854
|
-
hasDefinitions() {
|
|
2855
|
-
return !!this.#definitionCounts?.size;
|
|
2856
|
-
}
|
|
2857
2784
|
push(kind, start, end, meta) {
|
|
2858
2785
|
const field = this.#fieldLength;
|
|
2859
2786
|
this.#ensureCapacity(field + 4);
|
|
@@ -2901,9 +2828,6 @@ var BlockTokenStream = class {
|
|
|
2901
2828
|
this.#fields[open | 3] = (field - open) / 4 + 1;
|
|
2902
2829
|
}
|
|
2903
2830
|
}
|
|
2904
|
-
nodeLength(index) {
|
|
2905
|
-
return this.#fields[index * 4 | 3];
|
|
2906
|
-
}
|
|
2907
2831
|
replace(start, end, replacement, damageStart, damageEnd, sourceDelta) {
|
|
2908
2832
|
const previousLength = this.length;
|
|
2909
2833
|
const replacedLength = end - start;
|
|
@@ -2916,34 +2840,48 @@ var BlockTokenStream = class {
|
|
|
2916
2840
|
const oldStart = start + stablePrefixLength;
|
|
2917
2841
|
const oldEnd = end - stableSuffixLength;
|
|
2918
2842
|
const newEnd = start + replacementLength - stableSuffixLength;
|
|
2919
|
-
|
|
2920
|
-
for (let index = oldStart; index < oldEnd; index++)
|
|
2921
|
-
|
|
2843
|
+
let membershipChanges;
|
|
2844
|
+
for (let index = oldStart; index < oldEnd; index++) {
|
|
2845
|
+
const key = this.#metadata?.[index]?.definitionKey;
|
|
2846
|
+
if (key !== void 0 && this.#updateDefinitionCount(key, -1)) {
|
|
2847
|
+
membershipChanges ??= new Set();
|
|
2848
|
+
membershipChanges.add(key);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
for (let index = stablePrefixLength; index < replacementLength - stableSuffixLength; index++) {
|
|
2852
|
+
const key = replacement.#metadata?.[index]?.definitionKey;
|
|
2853
|
+
if (key !== void 0 && this.#updateDefinitionCount(key, 1) && !membershipChanges?.delete(key)) {
|
|
2854
|
+
membershipChanges ??= new Set();
|
|
2855
|
+
membershipChanges.add(key);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2922
2858
|
const change = {
|
|
2923
|
-
definitionMembershipChanges:
|
|
2859
|
+
definitionMembershipChanges: membershipChanges ?? emptySet,
|
|
2924
2860
|
newEnd,
|
|
2925
2861
|
oldEnd,
|
|
2926
2862
|
oldStart
|
|
2927
2863
|
};
|
|
2928
|
-
|
|
2864
|
+
let preservedPrefix = 0;
|
|
2865
|
+
while (preservedPrefix < stablePrefixLength && this.nodeLength(start + preservedPrefix) === replacement.nodeLength(preservedPrefix) && this.end(start + preservedPrefix) < damageStart) preservedPrefix++;
|
|
2866
|
+
const writeStart = start + preservedPrefix;
|
|
2929
2867
|
const indexDelta = replacementLength - replacedLength;
|
|
2930
2868
|
const newSuffixStart = start + replacementLength;
|
|
2931
2869
|
const fieldLength = this.#fieldLength + indexDelta * 4;
|
|
2932
2870
|
this.#ensureCapacity(fieldLength);
|
|
2933
2871
|
if (indexDelta !== 0 && end < previousLength) this.#fields.copyWithin(newSuffixStart * 4, end * 4, this.#fieldLength);
|
|
2934
|
-
this.#fields.set(replacement.#fields.subarray(
|
|
2872
|
+
this.#fields.set(replacement.#fields.subarray(preservedPrefix * 4, replacement.#fieldLength), writeStart * 4);
|
|
2935
2873
|
this.#fieldLength = fieldLength;
|
|
2936
2874
|
const metadata = this.#metadata;
|
|
2937
2875
|
if (metadata) {
|
|
2938
|
-
if (end === previousLength || end >= metadata.length) metadata.length = Math.min(
|
|
2939
|
-
else if (indexDelta === 0) metadata.fill(void 0,
|
|
2876
|
+
if (end === previousLength || end >= metadata.length) metadata.length = Math.min(writeStart, metadata.length);
|
|
2877
|
+
else if (indexDelta === 0) metadata.fill(void 0, writeStart, end);
|
|
2940
2878
|
else {
|
|
2941
2879
|
const shifted = this.#metadata = [];
|
|
2942
|
-
copyMetadata(shifted, metadata, 0,
|
|
2880
|
+
copyMetadata(shifted, metadata, 0, writeStart, 0);
|
|
2943
2881
|
copyMetadata(shifted, metadata, end, previousLength, newSuffixStart);
|
|
2944
2882
|
}
|
|
2945
2883
|
}
|
|
2946
|
-
if (replacement.#metadata) copyMetadata(this.#metadata ??= [], replacement.#metadata,
|
|
2884
|
+
if (replacement.#metadata) copyMetadata(this.#metadata ??= [], replacement.#metadata, preservedPrefix, replacementLength, writeStart);
|
|
2947
2885
|
if (sourceDelta !== 0 && newSuffixStart < this.length) {
|
|
2948
2886
|
const suffixFieldStart = newSuffixStart * 4;
|
|
2949
2887
|
for (let field = suffixFieldStart; field < this.#fieldLength; field += 4) {
|
|
@@ -2953,6 +2891,14 @@ var BlockTokenStream = class {
|
|
|
2953
2891
|
}
|
|
2954
2892
|
return change;
|
|
2955
2893
|
}
|
|
2894
|
+
#ensureCapacity(length) {
|
|
2895
|
+
if (length <= this.#fields.length) return;
|
|
2896
|
+
let capacity = Math.max(64, this.#fields.length * 2);
|
|
2897
|
+
while (capacity < length) capacity *= 2;
|
|
2898
|
+
const fields = new Int32Array(capacity);
|
|
2899
|
+
fields.set(this.#fields.subarray(0, this.#fieldLength));
|
|
2900
|
+
this.#fields = fields;
|
|
2901
|
+
}
|
|
2956
2902
|
#matchesAfterShift(index, next, nextIndex, delta, damageStart, damageEnd) {
|
|
2957
2903
|
const start = this.start(index);
|
|
2958
2904
|
const end = this.end(index);
|
|
@@ -2961,12 +2907,7 @@ var BlockTokenStream = class {
|
|
|
2961
2907
|
if (this.kind(index) !== next.kind(nextIndex) || start + delta !== nextStart || end + delta !== nextEnd) return false;
|
|
2962
2908
|
const metadata = this.#metadata?.[index];
|
|
2963
2909
|
const nextMetadata = next.#metadata?.[nextIndex];
|
|
2964
|
-
if (metadata !== nextMetadata)
|
|
2965
|
-
if (metadata?.definitionKey !== nextMetadata?.definitionKey) return false;
|
|
2966
|
-
const value = metadata?.value;
|
|
2967
|
-
const nextValue = nextMetadata?.value;
|
|
2968
|
-
if (value !== nextValue && (value === null || typeof value !== "object" || nextValue === null || typeof nextValue !== "object")) return false;
|
|
2969
|
-
}
|
|
2910
|
+
if (metadata !== nextMetadata && (metadata?.definitionKey !== nextMetadata?.definitionKey || metadata?.value !== nextMetadata?.value)) return false;
|
|
2970
2911
|
return start === end || end <= damageStart || start >= damageEnd;
|
|
2971
2912
|
}
|
|
2972
2913
|
kind(index) {
|
|
@@ -2984,6 +2925,9 @@ var BlockTokenStream = class {
|
|
|
2984
2925
|
end(index) {
|
|
2985
2926
|
return this.#fields[index * 4 | 2];
|
|
2986
2927
|
}
|
|
2928
|
+
nodeLength(index) {
|
|
2929
|
+
return this.#fields[index * 4 | 3];
|
|
2930
|
+
}
|
|
2987
2931
|
node(index) {
|
|
2988
2932
|
return this.#metadata?.[index]?.node;
|
|
2989
2933
|
}
|
|
@@ -2996,50 +2940,42 @@ var BlockTokenStream = class {
|
|
|
2996
2940
|
this.#metadata[index].value = value;
|
|
2997
2941
|
}
|
|
2998
2942
|
addDefinition(key) {
|
|
2999
|
-
this.#updateDefinitionCount(key, 1
|
|
2943
|
+
this.#updateDefinitionCount(key, 1);
|
|
3000
2944
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
2945
|
+
hasDefinition(key) {
|
|
2946
|
+
return this.#definitionCounts?.has(key) === true;
|
|
2947
|
+
}
|
|
2948
|
+
hasDefinitions() {
|
|
2949
|
+
return !!this.#definitionCounts?.size;
|
|
2950
|
+
}
|
|
2951
|
+
#updateDefinitionCount(key, delta) {
|
|
3003
2952
|
const counts = this.#definitionCounts ??= new Map();
|
|
3004
2953
|
const previousCount = counts.get(key) ?? 0;
|
|
3005
2954
|
const nextCount = previousCount + delta;
|
|
3006
2955
|
if (nextCount === 0) counts.delete(key);
|
|
3007
2956
|
else counts.set(key, nextCount);
|
|
3008
|
-
|
|
3009
|
-
const changes = this.#definitionMembershipChanges ??= new Set();
|
|
3010
|
-
if (!changes.delete(key)) changes.add(key);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
#ensureCapacity(length) {
|
|
3014
|
-
if (length <= this.#fields.length) return;
|
|
3015
|
-
let capacity = Math.max(64, this.#fields.length * 2);
|
|
3016
|
-
while (capacity < length) capacity *= 2;
|
|
3017
|
-
const fields = new Int32Array(capacity);
|
|
3018
|
-
fields.set(this.#fields.subarray(0, this.#fieldLength));
|
|
3019
|
-
this.#fields = fields;
|
|
2957
|
+
return previousCount === 0 || nextCount === 0;
|
|
3020
2958
|
}
|
|
3021
2959
|
};
|
|
3022
2960
|
// src/block/scanner.ts
|
|
3023
2961
|
var BlockScanContext = class {
|
|
3024
|
-
#lineViews = [];
|
|
3025
|
-
#scanDepth = 0;
|
|
3026
2962
|
#lookaheadEnd = 0;
|
|
3027
2963
|
#profile;
|
|
3028
|
-
#unwrappedLine = new BlockLines();
|
|
3029
2964
|
startsInterruptingBlock;
|
|
3030
2965
|
constructor(profile) {
|
|
3031
2966
|
this.#profile = profile;
|
|
3032
2967
|
this.startsInterruptingBlock = profile.interrupt;
|
|
3033
2968
|
}
|
|
3034
2969
|
endsWithParagraphLeaf(source, lines, index) {
|
|
2970
|
+
if (lines.lazy(index)) return true;
|
|
3035
2971
|
let contentLines = lines;
|
|
3036
2972
|
let contentIndex = index;
|
|
3037
2973
|
while (true) {
|
|
3038
2974
|
const contentOffset = lineIndentOffset(source, contentLines, contentIndex);
|
|
3039
2975
|
if (contentOffset < 0) return false;
|
|
3040
|
-
const
|
|
3041
|
-
if (
|
|
3042
|
-
contentLines =
|
|
2976
|
+
const child = (0, this.#profile.unwraps[source.charCodeAt(contentOffset)])?.(source, contentLines, contentIndex, contentOffset);
|
|
2977
|
+
if (child) {
|
|
2978
|
+
contentLines = child;
|
|
3043
2979
|
contentIndex = 0;
|
|
3044
2980
|
continue;
|
|
3045
2981
|
}
|
|
@@ -3049,81 +2985,70 @@ var BlockScanContext = class {
|
|
|
3049
2985
|
retainLookahead(end) {
|
|
3050
2986
|
this.#lookaheadEnd = Math.max(this.#lookaheadEnd, end);
|
|
3051
2987
|
}
|
|
3052
|
-
|
|
3053
|
-
const depth = this.#scanDepth - 1;
|
|
3054
|
-
const view = this.#lineViews[depth] ??= new BlockLines();
|
|
3055
|
-
view.resetFrom(lines, index, start, prefixColumns);
|
|
3056
|
-
return view;
|
|
3057
|
-
}
|
|
3058
|
-
scanBlockLines(source, lines, tokens, visit, stopsBefore, sequence) {
|
|
2988
|
+
scanBlockLines(source, lines, tokens, index = 0, visit, stopsBefore, sequence) {
|
|
3059
2989
|
const { starts, fallback } = this.#profile;
|
|
3060
2990
|
const physicallyContiguous = lines.physicallyContiguous();
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
start = lines.start(index);
|
|
3069
|
-
lineEnd = lines.end(index);
|
|
3070
|
-
}
|
|
3071
|
-
let contentOffset = start;
|
|
3072
|
-
let columns = physicallyContiguous ? 0 : lines.prefixColumns(index);
|
|
3073
|
-
let code = -1;
|
|
3074
|
-
while (contentOffset < lineEnd) {
|
|
3075
|
-
code = source.charCodeAt(contentOffset);
|
|
3076
|
-
if (code !== 32 && code !== 9) break;
|
|
3077
|
-
columns += code === 32 ? 1 : 4 - columns % 4;
|
|
3078
|
-
contentOffset++;
|
|
3079
|
-
}
|
|
3080
|
-
if (contentOffset === lineEnd) {
|
|
3081
|
-
index++;
|
|
3082
|
-
continue;
|
|
3083
|
-
}
|
|
3084
|
-
if (stopsBefore?.(start)) return;
|
|
3085
|
-
if (columns > 3) {
|
|
3086
|
-
contentOffset = -1;
|
|
3087
|
-
code = -1;
|
|
3088
|
-
}
|
|
3089
|
-
const lineStart = index;
|
|
3090
|
-
const tokenStart = tokens.length;
|
|
3091
|
-
const result = starts[code + 1]?.(source, lines, tokens, index, contentOffset, this) ?? fallback?.(source, lines, tokens, index, contentOffset, this);
|
|
3092
|
-
if (result === void 0) throw new Error("No block fallback");
|
|
3093
|
-
if (typeof result === "number") {
|
|
3094
|
-
index = result;
|
|
3095
|
-
sequence?.push(lineStart);
|
|
3096
|
-
} else {
|
|
3097
|
-
index = result.nextLine;
|
|
3098
|
-
if (sequence) {
|
|
3099
|
-
const last = index - 1;
|
|
3100
|
-
const afterEnding = result.end > lines.end(last) && result.end === lines.next(last);
|
|
3101
|
-
result.node.position = {
|
|
3102
|
-
start: {
|
|
3103
|
-
line: lineStart + 1,
|
|
3104
|
-
column: result.start - start + 1,
|
|
3105
|
-
offset: result.start
|
|
3106
|
-
},
|
|
3107
|
-
end: {
|
|
3108
|
-
line: last + (afterEnding ? 2 : 1),
|
|
3109
|
-
column: afterEnding ? 1 : result.end - lines.start(last) + 1,
|
|
3110
|
-
offset: result.end
|
|
3111
|
-
}
|
|
3112
|
-
};
|
|
3113
|
-
if (result.definitionKey !== void 0) tokens.addDefinition(result.definitionKey);
|
|
3114
|
-
sequence.push(result.node);
|
|
3115
|
-
} else tokens.push(256, result.start, result.end, result);
|
|
3116
|
-
}
|
|
3117
|
-
visit?.(lineStart, index, tokenStart);
|
|
2991
|
+
while (index < lines.length) {
|
|
2992
|
+
let start = lines.start(index);
|
|
2993
|
+
let lineEnd = lines.end(index);
|
|
2994
|
+
while (start === lineEnd) {
|
|
2995
|
+
if (++index === lines.length) return;
|
|
2996
|
+
start = lines.start(index);
|
|
2997
|
+
lineEnd = lines.end(index);
|
|
3118
2998
|
}
|
|
3119
|
-
|
|
3120
|
-
|
|
2999
|
+
let contentOffset = start;
|
|
3000
|
+
let columns = physicallyContiguous ? 0 : lines.prefixColumns(index);
|
|
3001
|
+
let code = -1;
|
|
3002
|
+
while (contentOffset < lineEnd) {
|
|
3003
|
+
code = source.charCodeAt(contentOffset);
|
|
3004
|
+
if (code !== 32 && code !== 9) break;
|
|
3005
|
+
columns += code === 32 ? 1 : tabWidthAt(source, contentOffset);
|
|
3006
|
+
contentOffset++;
|
|
3007
|
+
}
|
|
3008
|
+
if (contentOffset === lineEnd) {
|
|
3009
|
+
index++;
|
|
3010
|
+
continue;
|
|
3011
|
+
}
|
|
3012
|
+
if (stopsBefore?.(start)) return;
|
|
3013
|
+
if (columns > 3) {
|
|
3014
|
+
contentOffset = -1;
|
|
3015
|
+
code = -1;
|
|
3016
|
+
}
|
|
3017
|
+
const lineStart = index;
|
|
3018
|
+
const tokenStart = tokens.length;
|
|
3019
|
+
const result = starts[code + 1]?.(source, lines, tokens, index, contentOffset, this) ?? fallback?.(source, lines, tokens, index, contentOffset, this);
|
|
3020
|
+
if (result === void 0) throw new Error("No block fallback");
|
|
3021
|
+
if (typeof result === "number") {
|
|
3022
|
+
index = result;
|
|
3023
|
+
sequence?.push(lineStart);
|
|
3024
|
+
} else {
|
|
3025
|
+
index = result.nextLine;
|
|
3026
|
+
if (sequence) {
|
|
3027
|
+
const last = index - 1;
|
|
3028
|
+
const afterEnding = result.end > lines.end(last) && result.end === lines.next(last);
|
|
3029
|
+
result.node.position = {
|
|
3030
|
+
start: {
|
|
3031
|
+
line: lineStart + 1,
|
|
3032
|
+
column: result.start - start + 1,
|
|
3033
|
+
offset: result.start
|
|
3034
|
+
},
|
|
3035
|
+
end: {
|
|
3036
|
+
line: last + (afterEnding ? 2 : 1),
|
|
3037
|
+
column: afterEnding ? 1 : result.end - lines.start(last) + 1,
|
|
3038
|
+
offset: result.end
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
if (result.definitionKey !== void 0) tokens.addDefinition(result.definitionKey);
|
|
3042
|
+
sequence.push(result.node);
|
|
3043
|
+
} else tokens.push(256, result.start, result.end, result);
|
|
3044
|
+
}
|
|
3045
|
+
visit?.(lineStart, index, tokenStart);
|
|
3121
3046
|
}
|
|
3122
3047
|
}
|
|
3123
|
-
scanRecords(source, lines, tokens, tokenOffset = 0, stopsBefore) {
|
|
3048
|
+
scanRecords(source, lines, tokens, firstLine = 0, tokenOffset = 0, stopsBefore) {
|
|
3124
3049
|
const records = [];
|
|
3125
3050
|
this.#lookaheadEnd = 0;
|
|
3126
|
-
this.scanBlockLines(source, lines, tokens, (lineStart, lineEnd, tokenStart) => {
|
|
3051
|
+
this.scanBlockLines(source, lines, tokens, firstLine, (lineStart, lineEnd, tokenStart) => {
|
|
3127
3052
|
const end = lines.next(lineEnd - 1);
|
|
3128
3053
|
records.push({
|
|
3129
3054
|
start: lines.start(lineStart),
|
|
@@ -3131,12 +3056,12 @@ var BlockScanContext = class {
|
|
|
3131
3056
|
dependencyEnd: Math.max(end, this.#lookaheadEnd),
|
|
3132
3057
|
tokenStart: tokenOffset + tokenStart
|
|
3133
3058
|
});
|
|
3134
|
-
this.#lookaheadEnd = 0;
|
|
3135
3059
|
}, stopsBefore);
|
|
3136
3060
|
return records;
|
|
3137
3061
|
}
|
|
3138
3062
|
};
|
|
3139
|
-
var BlockScanner = class {
|
|
3063
|
+
var BlockScanner = class BlockScanner {
|
|
3064
|
+
static #replacement;
|
|
3140
3065
|
#context;
|
|
3141
3066
|
#lines = new BlockLines();
|
|
3142
3067
|
#records = [];
|
|
@@ -3147,41 +3072,42 @@ var BlockScanner = class {
|
|
|
3147
3072
|
this.builds = profile.builds;
|
|
3148
3073
|
}
|
|
3149
3074
|
parse(source, profile) {
|
|
3150
|
-
this.#reset(source);
|
|
3151
|
-
const children = [];
|
|
3152
|
-
this.#context.scanBlockLines(source, this.#lines, this.tokens, void 0, void 0, children);
|
|
3153
3075
|
const lines = this.#lines;
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
const
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3076
|
+
lines.scan(source);
|
|
3077
|
+
try {
|
|
3078
|
+
const children = [];
|
|
3079
|
+
this.#context.scanBlockLines(source, lines, this.tokens, 0, void 0, void 0, children);
|
|
3080
|
+
const locator = lines.locator();
|
|
3081
|
+
const context = createBuildContext(source, this, profile, locator);
|
|
3082
|
+
let token = 0;
|
|
3083
|
+
for (let index = 0; index < children.length; index++) {
|
|
3084
|
+
const entry = children[index];
|
|
3085
|
+
if (typeof entry === "number") {
|
|
3086
|
+
lines.advanceToLine(entry);
|
|
3087
|
+
children[index] = buildBlockNode(token, context);
|
|
3088
|
+
token += this.tokens.nodeLength(token);
|
|
3089
|
+
}
|
|
3163
3090
|
}
|
|
3091
|
+
return {
|
|
3092
|
+
type: "root",
|
|
3093
|
+
children,
|
|
3094
|
+
position: {
|
|
3095
|
+
start: {
|
|
3096
|
+
line: 1,
|
|
3097
|
+
column: 1,
|
|
3098
|
+
offset: 0
|
|
3099
|
+
},
|
|
3100
|
+
end: locator.locationEnd()
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
} finally {
|
|
3104
|
+
this.tokens.reset();
|
|
3164
3105
|
}
|
|
3165
|
-
return {
|
|
3166
|
-
type: "root",
|
|
3167
|
-
children,
|
|
3168
|
-
position: {
|
|
3169
|
-
start: {
|
|
3170
|
-
line: 1,
|
|
3171
|
-
column: 1,
|
|
3172
|
-
offset: 0
|
|
3173
|
-
},
|
|
3174
|
-
end: locator.locationEnd()
|
|
3175
|
-
}
|
|
3176
|
-
};
|
|
3177
3106
|
}
|
|
3178
3107
|
scan(source) {
|
|
3179
|
-
this.#reset(source);
|
|
3180
|
-
this.#records = this.#context.scanRecords(source, this.#lines, this.tokens);
|
|
3181
|
-
}
|
|
3182
|
-
#reset(source) {
|
|
3183
3108
|
this.#lines.scan(source);
|
|
3184
3109
|
this.tokens.reset();
|
|
3110
|
+
this.#records = this.#context.scanRecords(source, this.#lines, this.tokens);
|
|
3185
3111
|
}
|
|
3186
3112
|
get records() {
|
|
3187
3113
|
return this.#records;
|
|
@@ -3195,8 +3121,7 @@ var BlockScanner = class {
|
|
|
3195
3121
|
const lines = this.#lines;
|
|
3196
3122
|
const oldChangedEnd = changedSpan.end - offsetDelta;
|
|
3197
3123
|
const records = this.#records;
|
|
3198
|
-
|
|
3199
|
-
if (affectedIndex < 0) affectedIndex = Math.max(0, records.length - 1);
|
|
3124
|
+
const affectedIndex = findAffectedRecord(records, changedSpan.start);
|
|
3200
3125
|
const affectedRecord = records[affectedIndex];
|
|
3201
3126
|
const restartIndex = affectedIndex === 0 && affectedRecord?.start > changedSpan.start ? -1 : affectedRecord && affectedRecord.end < changedSpan.start ? affectedIndex : Math.max(0, affectedIndex - 1);
|
|
3202
3127
|
const restartRecord = records[restartIndex];
|
|
@@ -3205,11 +3130,11 @@ var BlockScanner = class {
|
|
|
3205
3130
|
const scanLineStart = lines.indexAtOrAfter(restartOffset);
|
|
3206
3131
|
const stableBlockCount = Math.max(0, restartIndex);
|
|
3207
3132
|
const oldTokenStart = restartRecord?.tokenStart ?? 0;
|
|
3208
|
-
const replacement = new BlockTokenStream();
|
|
3209
|
-
|
|
3133
|
+
const replacement = BlockScanner.#replacement ?? new BlockTokenStream();
|
|
3134
|
+
BlockScanner.#replacement = void 0;
|
|
3210
3135
|
let oldRecordEnd = records.length;
|
|
3211
3136
|
let candidate = affectedIndex;
|
|
3212
|
-
const rescannedRecords = context.scanRecords(nextSource,
|
|
3137
|
+
const rescannedRecords = context.scanRecords(nextSource, lines, replacement, scanLineStart, oldTokenStart, (start) => {
|
|
3213
3138
|
if (start < changedSpan.end) return false;
|
|
3214
3139
|
const oldStart = start - offsetDelta;
|
|
3215
3140
|
if (offsetDelta && (start === 0 || oldStart === 0) && this.builds[257]) return false;
|
|
@@ -3221,6 +3146,8 @@ var BlockScanner = class {
|
|
|
3221
3146
|
const oldTokenLength = this.tokens.length;
|
|
3222
3147
|
const oldTokenEnd = records[oldRecordEnd]?.tokenStart ?? oldTokenLength;
|
|
3223
3148
|
const tokenChange = this.tokens.replace(oldTokenStart, oldTokenEnd, replacement, changedSpan.start, oldChangedEnd, offsetDelta);
|
|
3149
|
+
replacement.reset();
|
|
3150
|
+
BlockScanner.#replacement = replacement;
|
|
3224
3151
|
const tokenDelta = tokenChange.newEnd - tokenChange.oldEnd;
|
|
3225
3152
|
let oldRecordStart = stableBlockCount;
|
|
3226
3153
|
while (oldRecordStart < records.length && (records[oldRecordStart + 1]?.tokenStart ?? oldTokenLength) <= tokenChange.oldStart) oldRecordStart++;
|
|
@@ -3234,6 +3161,8 @@ var BlockScanner = class {
|
|
|
3234
3161
|
record.dependencyEnd += offsetDelta;
|
|
3235
3162
|
record.tokenStart += tokenDelta;
|
|
3236
3163
|
}
|
|
3164
|
+
joinRecordDependencies(records, stableBlockCount, newRecordEnd);
|
|
3165
|
+
joinRecordDependencies(records, newRecordEnd, records.length);
|
|
3237
3166
|
return {
|
|
3238
3167
|
newRecordEnd,
|
|
3239
3168
|
offsetDelta,
|
|
@@ -3244,8 +3173,33 @@ var BlockScanner = class {
|
|
|
3244
3173
|
};
|
|
3245
3174
|
}
|
|
3246
3175
|
};
|
|
3176
|
+
function findAffectedRecord(records, offset) {
|
|
3177
|
+
let low = 0;
|
|
3178
|
+
let high = records.length - 1;
|
|
3179
|
+
while (low < high) {
|
|
3180
|
+
const middle = low + high >>> 1;
|
|
3181
|
+
if (records[middle].dependencyEnd < offset) low = middle + 1;
|
|
3182
|
+
else high = middle;
|
|
3183
|
+
}
|
|
3184
|
+
return low;
|
|
3185
|
+
}
|
|
3186
|
+
function joinRecordDependencies(records, start, end) {
|
|
3187
|
+
if (start > 0) {
|
|
3188
|
+
const dependencyEnd = records[start - 1].dependencyEnd;
|
|
3189
|
+
for (let index = start; index < end && records[index].dependencyEnd < dependencyEnd; index++) records[index].dependencyEnd = dependencyEnd;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3247
3192
|
// src/inline/region.ts
|
|
3248
3193
|
const definitionAny = Symbol();
|
|
3194
|
+
var InlineRegion = class extends SourceView {
|
|
3195
|
+
tokenStart = 0;
|
|
3196
|
+
tokens = emptyArray;
|
|
3197
|
+
rawTokens = emptyArray;
|
|
3198
|
+
dependencies;
|
|
3199
|
+
depends(changes) {
|
|
3200
|
+
return this.dependencies === definitionAny || (typeof this.dependencies === "string" ? changes.has(this.dependencies) : this.dependencies !== void 0 && isDefinitionShared(this.dependencies, changes));
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3249
3203
|
function isDefinitionShared(left, right) {
|
|
3250
3204
|
const smaller = left.size < right.size ? left : right;
|
|
3251
3205
|
const larger = smaller === left ? right : left;
|
|
@@ -3254,51 +3208,44 @@ function isDefinitionShared(left, right) {
|
|
|
3254
3208
|
}
|
|
3255
3209
|
var InlineRegionResolver = class {
|
|
3256
3210
|
#profile;
|
|
3257
|
-
#
|
|
3211
|
+
#blockTokens;
|
|
3258
3212
|
#dependencies;
|
|
3259
|
-
constructor(profile,
|
|
3213
|
+
constructor(profile, blockTokens) {
|
|
3260
3214
|
this.#profile = profile;
|
|
3261
|
-
this.#
|
|
3215
|
+
this.#blockTokens = blockTokens;
|
|
3262
3216
|
}
|
|
3263
3217
|
hasDefinition(key) {
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3218
|
+
const dependencies = this.#dependencies;
|
|
3219
|
+
if (dependencies === void 0) this.#dependencies = key;
|
|
3220
|
+
else if (typeof dependencies === "string") {
|
|
3221
|
+
if (dependencies !== key) this.#dependencies = new Set([dependencies, key]);
|
|
3222
|
+
} else if (dependencies !== definitionAny) dependencies.add(key);
|
|
3223
|
+
return this.#blockTokens.hasDefinition(key);
|
|
3269
3224
|
}
|
|
3270
3225
|
hasDefinitions() {
|
|
3271
|
-
const hasAny = this.#
|
|
3226
|
+
const hasAny = this.#blockTokens.hasDefinitions();
|
|
3272
3227
|
if (!hasAny) this.#dependencies = definitionAny;
|
|
3273
3228
|
return hasAny;
|
|
3274
3229
|
}
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
this.updateDefinitions(previous, changes);
|
|
3280
|
-
return previous;
|
|
3281
|
-
}
|
|
3282
|
-
const rawTokens = view.tokenize(this.#profile.tokenize);
|
|
3283
|
-
return {
|
|
3284
|
-
tokenStart,
|
|
3285
|
-
view,
|
|
3286
|
-
tokens: this.#resolve(view, rawTokens),
|
|
3287
|
-
rawTokens,
|
|
3288
|
-
dependencies: this.#dependencies
|
|
3289
|
-
};
|
|
3230
|
+
updateTokens(region, initial) {
|
|
3231
|
+
const hasPaddedLineFeed = this.#blockTokens.value(region.tokenStart) === paddedLineFeed;
|
|
3232
|
+
const rawTokens = this.#profile.tokenize(region.text, hasPaddedLineFeed, hasPaddedLineFeed || !initial ? void 0 : region.mappings);
|
|
3233
|
+
this.#resolve(region, rawTokens);
|
|
3290
3234
|
}
|
|
3291
3235
|
updateDefinitions(region, changes) {
|
|
3292
3236
|
const dependencies = region.dependencies;
|
|
3293
|
-
if (
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
region.dependencies = this.#dependencies;
|
|
3297
|
-
return true;
|
|
3237
|
+
if (changes.size === 0 || !region.depends(changes)) return false;
|
|
3238
|
+
this.#resolve(region, region.rawTokens);
|
|
3239
|
+
return dependencies !== definitionAny || region.depends(changes);
|
|
3298
3240
|
}
|
|
3299
|
-
#resolve(
|
|
3300
|
-
|
|
3301
|
-
|
|
3241
|
+
#resolve(region, rawTokens) {
|
|
3242
|
+
try {
|
|
3243
|
+
region.tokens = rawTokens.length ? this.#profile.resolve(region.text, rawTokens, this) : rawTokens;
|
|
3244
|
+
region.dependencies = this.#dependencies;
|
|
3245
|
+
region.rawTokens = this.#dependencies ? rawTokens : emptyArray;
|
|
3246
|
+
} finally {
|
|
3247
|
+
this.#dependencies = void 0;
|
|
3248
|
+
}
|
|
3302
3249
|
}
|
|
3303
3250
|
};
|
|
3304
3251
|
var InlineRegionState = class {
|
|
@@ -3316,7 +3263,6 @@ var InlineRegionState = class {
|
|
|
3316
3263
|
const structure = this.#structure;
|
|
3317
3264
|
const tokens = structure.tokens;
|
|
3318
3265
|
const regionsByBlock = this.#regionsByBlock;
|
|
3319
|
-
const stableBlockCount = change?.stableBlockCount ?? 0;
|
|
3320
3266
|
const oldRecordStart = change?.oldRecordStart ?? 0;
|
|
3321
3267
|
const oldRecordEnd = change?.oldRecordEnd ?? 0;
|
|
3322
3268
|
const newRecordEnd = change?.newRecordEnd ?? structure.records.length;
|
|
@@ -3329,36 +3275,37 @@ var InlineRegionState = class {
|
|
|
3329
3275
|
for (let index = oldRecordStart; index < oldRecordEnd; index++) for (const region of regionsByBlock[index]) displacedRegions.push(region);
|
|
3330
3276
|
let displacedIndex = 0;
|
|
3331
3277
|
shiftTail(regionsByBlock, oldRecordEnd, newRecordEnd);
|
|
3332
|
-
for (let blockIndex =
|
|
3333
|
-
const previousRegions = blockIndex < oldRecordStart ? regionsByBlock[blockIndex] : void 0;
|
|
3278
|
+
for (let blockIndex = oldRecordStart; blockIndex < newRecordEnd; blockIndex++) {
|
|
3334
3279
|
const tokenStart = structure.records[blockIndex].tokenStart;
|
|
3335
3280
|
const blockLength = tokens.nodeLength(tokenStart);
|
|
3336
3281
|
if (blockLength === 1) {
|
|
3337
3282
|
regionsByBlock[blockIndex] = emptyArray;
|
|
3338
3283
|
continue;
|
|
3339
3284
|
}
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
for (let token = tokenStart; token < tokenEnd; token++) {
|
|
3285
|
+
let regions;
|
|
3286
|
+
for (let token = tokenStart; token < tokenStart + blockLength; token++) {
|
|
3343
3287
|
const nodeLength = tokens.nodeLength(token);
|
|
3344
3288
|
if (nodeLength <= 1 || tokens.kind(token + 1) !== 1) continue;
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
if (!candidate && tokenChange && blockIndex >= oldRecordStart) {
|
|
3289
|
+
let candidate;
|
|
3290
|
+
if (tokenChange) {
|
|
3348
3291
|
const previousTokenStart = token < tokenChange.oldStart ? token : token >= tokenChange.newEnd ? token - suffixTokenDelta : -1;
|
|
3349
3292
|
while (displacedIndex < displacedRegions.length && displacedRegions[displacedIndex].tokenStart < previousTokenStart) displacedIndex++;
|
|
3350
3293
|
if (displacedRegions[displacedIndex]?.tokenStart === previousTokenStart) candidate = displacedRegions[displacedIndex++];
|
|
3351
3294
|
}
|
|
3352
|
-
const
|
|
3353
|
-
|
|
3354
|
-
|
|
3295
|
+
const region = candidate ?? new InlineRegion();
|
|
3296
|
+
const previousText = candidate?.text;
|
|
3297
|
+
region.reset(source, tokens, token, nodeLength);
|
|
3298
|
+
region.tokenStart = token;
|
|
3299
|
+
if (previousText === region.text) this.#resolver.updateDefinitions(region, definitionMembershipChanges);
|
|
3300
|
+
else this.#resolver.updateTokens(region, change === void 0);
|
|
3301
|
+
regions?.push(region) ?? (regions = [region]);
|
|
3355
3302
|
token += nodeLength - 1;
|
|
3356
3303
|
}
|
|
3357
|
-
regionsByBlock[blockIndex] = regions;
|
|
3304
|
+
regionsByBlock[blockIndex] = regions ?? emptyArray;
|
|
3358
3305
|
}
|
|
3359
3306
|
if (offsetDelta !== 0 || suffixTokenDelta !== 0) for (let index = newRecordEnd; index < regionsByBlock.length; index++) for (const region of regionsByBlock[index]) {
|
|
3360
3307
|
region.tokenStart += suffixTokenDelta;
|
|
3361
|
-
region.
|
|
3308
|
+
region.shift(offsetDelta);
|
|
3362
3309
|
}
|
|
3363
3310
|
if (definitionMembershipChanges.size > 0) {
|
|
3364
3311
|
const refreshDefinitions = (start, end) => {
|
|
@@ -3366,10 +3313,13 @@ var InlineRegionState = class {
|
|
|
3366
3313
|
const regions = regionsByBlock[index];
|
|
3367
3314
|
let changed = false;
|
|
3368
3315
|
for (const region of regions) if (this.#resolver.updateDefinitions(region, definitionMembershipChanges)) changed = true;
|
|
3369
|
-
if (changed)
|
|
3316
|
+
if (changed) {
|
|
3317
|
+
invalidatedBlocks ??= [];
|
|
3318
|
+
invalidatedBlocks.push(index);
|
|
3319
|
+
}
|
|
3370
3320
|
}
|
|
3371
3321
|
};
|
|
3372
|
-
refreshDefinitions(0,
|
|
3322
|
+
refreshDefinitions(0, oldRecordStart);
|
|
3373
3323
|
refreshDefinitions(newRecordEnd, regionsByBlock.length);
|
|
3374
3324
|
}
|
|
3375
3325
|
return invalidatedBlocks ?? emptyArray;
|
|
@@ -3457,26 +3407,28 @@ var DocumentImpl = class {
|
|
|
3457
3407
|
const blockChange = this.#blockScanner.edit(change);
|
|
3458
3408
|
const invalidatedBlocks = this.#regionState.update(change.nextSource, blockChange);
|
|
3459
3409
|
this.#source = change.nextSource;
|
|
3460
|
-
this.#updateTree(invalidatedBlocks, blockChange);
|
|
3410
|
+
this.#updateTree(invalidatedBlocks, blockChange, change.changedSpan.start);
|
|
3461
3411
|
return { changedSpan: change.changedSpan };
|
|
3462
3412
|
}
|
|
3463
|
-
#updateTree(invalidatedBlocks, change) {
|
|
3413
|
+
#updateTree(invalidatedBlocks, change, damageStart = 0) {
|
|
3464
3414
|
const records = this.#blockScanner.records;
|
|
3465
3415
|
const regionsByBlock = this.#regionState.regionsByBlock;
|
|
3466
3416
|
const root = this.#tree;
|
|
3467
3417
|
const children = root.children;
|
|
3468
|
-
|
|
3469
|
-
const
|
|
3470
|
-
|
|
3418
|
+
let rebuildStart = change?.stableBlockCount ?? 0;
|
|
3419
|
+
const matchedEnd = change?.oldRecordStart ?? 0;
|
|
3420
|
+
while (rebuildStart < matchedEnd && records[rebuildStart].dependencyEnd < damageStart) rebuildStart++;
|
|
3421
|
+
const startLine = children[Math.min(rebuildStart, invalidatedBlocks[0] ?? rebuildStart) - 1]?.position?.end.line ?? 1;
|
|
3422
|
+
const locator = this.#blockScanner.locator(startLine - 1);
|
|
3471
3423
|
const context = createBuildContext(this.#source, this.#blockScanner, this.#profile.inline, locator, new InlineRegionCursor());
|
|
3472
3424
|
const oldRebuildEnd = change?.oldRecordEnd ?? 0;
|
|
3473
3425
|
const newRebuildEnd = change?.newRecordEnd ?? records.length;
|
|
3474
3426
|
const suffixOffsetDelta = change?.offsetDelta ?? 0;
|
|
3475
3427
|
shiftTail(children, oldRebuildEnd, newRebuildEnd);
|
|
3476
3428
|
let invalidatedIndex = 0;
|
|
3477
|
-
while (invalidatedIndex < invalidatedBlocks.length && invalidatedBlocks[invalidatedIndex] <
|
|
3429
|
+
while (invalidatedIndex < invalidatedBlocks.length && invalidatedBlocks[invalidatedIndex] < newRebuildEnd) {
|
|
3478
3430
|
const index = invalidatedBlocks[invalidatedIndex++];
|
|
3479
|
-
children[index] = buildTreeBlock(records[index], regionsByBlock[index], context);
|
|
3431
|
+
if (index < rebuildStart) children[index] = buildTreeBlock(records[index], regionsByBlock[index], context);
|
|
3480
3432
|
}
|
|
3481
3433
|
for (let index = rebuildStart; index < newRebuildEnd; index++) children[index] = buildTreeBlock(records[index], regionsByBlock[index], context);
|
|
3482
3434
|
const end = locator.locationEnd();
|
|
@@ -3515,7 +3467,7 @@ function composeUnwraps(unwraps) {
|
|
|
3515
3467
|
for (let index = unwraps.length - 1; index >= 0; index--) {
|
|
3516
3468
|
const unwrap = unwraps[index];
|
|
3517
3469
|
const next = chain;
|
|
3518
|
-
chain = next ? (source, lines,
|
|
3470
|
+
chain = next ? (source, lines, index, offset) => unwrap(source, lines, index, offset) ?? next(source, lines, index, offset) : unwrap;
|
|
3519
3471
|
}
|
|
3520
3472
|
return chain;
|
|
3521
3473
|
}
|
|
@@ -3580,6 +3532,115 @@ function createBlockProfile(features) {
|
|
|
3580
3532
|
interrupt: composeInterrupts(interrupts)
|
|
3581
3533
|
};
|
|
3582
3534
|
}
|
|
3535
|
+
// src/inline/boundary.ts
|
|
3536
|
+
const punctuation = /\p{P}/uy;
|
|
3537
|
+
const symbol = /\p{S}/uy;
|
|
3538
|
+
const characters = [
|
|
3539
|
+
String.raw`\u1100-\u11FF\u20A9\u2329\u232A\u2630-\u2637\u268A-\u268F\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5`,
|
|
3540
|
+
String.raw`\u2FF0-\u303E\u3041-\u3096\u309B-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\u31E5\u31EF-\u321E`,
|
|
3541
|
+
String.raw`\u3220-\u3247\u3250-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB`,
|
|
3542
|
+
String.raw`\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFFBE\uFFC2-\uFFC7`,
|
|
3543
|
+
String.raw`\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\uFFE0-\uFFE6\uFFE8-\uFFEE`,
|
|
3544
|
+
String.raw`\u{16FE0}-\u{16FE4}\u{16FF0}-\u{16FF6}\u{17000}-\u{18CDA}\u{18CFF}-\u{18D20}\u{18D80}-\u{18DF2}`,
|
|
3545
|
+
String.raw`\u{18E00}-\u{19191}\u{191A0}-\u{191D2}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}`,
|
|
3546
|
+
String.raw`\u{1B000}-\u{1B128}\u{1B132}\u{1B150}-\u{1B152}\u{1B155}\u{1B164}-\u{1B168}\u{1B170}-\u{1B2FB}`,
|
|
3547
|
+
String.raw`\u{1D300}-\u{1D356}\u{1D360}-\u{1D376}\u{1F1AE}\u{1F200}\u{1F202}\u{1F210}-\u{1F219}`,
|
|
3548
|
+
String.raw`\u{1F21B}-\u{1F22E}\u{1F230}\u{1F231}\u{1F237}\u{1F23B}`,
|
|
3549
|
+
String.raw`\u{1F240}-\u{1F248}\u{1F260}-\u{1F265}\u{1F7DA}\u{20000}-\u{3FFFD}`
|
|
3550
|
+
].join("");
|
|
3551
|
+
const eastAsians = new RegExp(`[${characters}]`, "uy");
|
|
3552
|
+
const boundaryAscii = Uint8Array.from({ length: 128 }, (item, code) => {
|
|
3553
|
+
if (isAsciiWhitespace(code)) return 1;
|
|
3554
|
+
if (!isAsciiPunctuation(code)) return 0;
|
|
3555
|
+
switch (code) {
|
|
3556
|
+
case 36:
|
|
3557
|
+
case 43:
|
|
3558
|
+
case 60:
|
|
3559
|
+
case 61:
|
|
3560
|
+
case 62:
|
|
3561
|
+
case 94:
|
|
3562
|
+
case 96:
|
|
3563
|
+
case 124:
|
|
3564
|
+
case 126: return 4;
|
|
3565
|
+
default: return 2;
|
|
3566
|
+
}
|
|
3567
|
+
});
|
|
3568
|
+
function isNonAsciiWhitespace(code) {
|
|
3569
|
+
if (code >= 8192 && code <= 8202) return true;
|
|
3570
|
+
switch (code) {
|
|
3571
|
+
case 160:
|
|
3572
|
+
case 5760:
|
|
3573
|
+
case 8232:
|
|
3574
|
+
case 8233:
|
|
3575
|
+
case 8239:
|
|
3576
|
+
case 8287:
|
|
3577
|
+
case 12288:
|
|
3578
|
+
case 65279: return true;
|
|
3579
|
+
default: return false;
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
function isNonEmojiGeneralUseVs(code) {
|
|
3583
|
+
return code >= 65024 && code <= 65038;
|
|
3584
|
+
}
|
|
3585
|
+
function isIdeoVs(code) {
|
|
3586
|
+
return code >= 917760 && code <= 917999;
|
|
3587
|
+
}
|
|
3588
|
+
function isCJKAmbiguousPunctuation(base, vs) {
|
|
3589
|
+
return vs === 65025 && (base === 8216 || base === 8217 || base === 8220 || base === 8221);
|
|
3590
|
+
}
|
|
3591
|
+
function classifyNonAscii(source, index, code, checkCJK) {
|
|
3592
|
+
if (checkCJK && (code >= 19968 && code <= 40959 || code >= 44032 && code <= 55203 || code >= 12353 && code <= 12438 || code >= 12449 && code <= 12538 || code >= 131072 && code <= 262141)) return 8;
|
|
3593
|
+
if (isNonAsciiWhitespace(code)) return 1;
|
|
3594
|
+
if (checkCJK && isIdeoVs(code)) return 16;
|
|
3595
|
+
let flags = 0;
|
|
3596
|
+
if (punctuation.lastIndex = index, punctuation.test(source)) flags = 2;
|
|
3597
|
+
else if (symbol.lastIndex = index, symbol.test(source)) flags = 4;
|
|
3598
|
+
if (checkCJK && code >= 4352 && (code === 12441 || code === 12442 || code >= 12272 && code <= 12350 || code >= 65281 && code <= 65470 || (eastAsians.lastIndex = index, eastAsians.test(source)))) flags |= 8;
|
|
3599
|
+
return flags;
|
|
3600
|
+
}
|
|
3601
|
+
function codePointBefore(source, end) {
|
|
3602
|
+
let index = end - 1;
|
|
3603
|
+
let code = source.charCodeAt(index);
|
|
3604
|
+
if (code >= 56320 && code <= 57343 && index > 0) {
|
|
3605
|
+
const leading = source.charCodeAt(index - 1);
|
|
3606
|
+
if (leading >= 55296 && leading <= 56319) {
|
|
3607
|
+
index--;
|
|
3608
|
+
code = (leading - 55296 << 10) + code - 56320 + 65536;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
return [index, code];
|
|
3612
|
+
}
|
|
3613
|
+
function boundaryBefore(source, end, checkCJK) {
|
|
3614
|
+
if (end <= 0) return 1;
|
|
3615
|
+
const unit = source.charCodeAt(end - 1);
|
|
3616
|
+
if (unit < 128) return boundaryAscii[unit];
|
|
3617
|
+
const [index, code] = codePointBefore(source, end);
|
|
3618
|
+
if (checkCJK && isNonEmojiGeneralUseVs(code)) {
|
|
3619
|
+
if (index <= 0) return 0;
|
|
3620
|
+
const [baseIndex, baseCode] = codePointBefore(source, index);
|
|
3621
|
+
let baseFlags = baseCode < 128 ? boundaryAscii[baseCode] : classifyNonAscii(source, baseIndex, baseCode, true);
|
|
3622
|
+
if (baseFlags & 1) return 0;
|
|
3623
|
+
baseFlags &= -17;
|
|
3624
|
+
if (isCJKAmbiguousPunctuation(baseCode, code)) baseFlags |= 8;
|
|
3625
|
+
return baseFlags;
|
|
3626
|
+
}
|
|
3627
|
+
return classifyNonAscii(source, index, code, checkCJK);
|
|
3628
|
+
}
|
|
3629
|
+
function boundaryAfter(source, start, checkCJK) {
|
|
3630
|
+
if (start >= source.length) return 1;
|
|
3631
|
+
let code = source.charCodeAt(start);
|
|
3632
|
+
if (code < 128) return boundaryAscii[code];
|
|
3633
|
+
if (code >= 55296 && code <= 56319 && start + 1 < source.length) {
|
|
3634
|
+
const trailing = source.charCodeAt(start + 1);
|
|
3635
|
+
if (trailing >= 56320 && trailing <= 57343) code = (code - 55296 << 10) + trailing - 56320 + 65536;
|
|
3636
|
+
}
|
|
3637
|
+
return classifyNonAscii(source, start, code, checkCJK);
|
|
3638
|
+
}
|
|
3639
|
+
function hasInlineColonBoundary(source, start) {
|
|
3640
|
+
if (start <= 0) return true;
|
|
3641
|
+
if (source.charCodeAt(start - 1) === 58) return false;
|
|
3642
|
+
return Boolean(boundaryBefore(source, start, true) & 27);
|
|
3643
|
+
}
|
|
3583
3644
|
// src/inline/tokens.ts
|
|
3584
3645
|
function inlineTokenCount(tokens) {
|
|
3585
3646
|
return tokens.length / 4;
|
|
@@ -3606,26 +3667,19 @@ function appendInlineToken(target, kind, start, end, data = 0) {
|
|
|
3606
3667
|
target.push(kind, start, end, data);
|
|
3607
3668
|
}
|
|
3608
3669
|
// src/inline/delimiter.ts
|
|
3609
|
-
const
|
|
3610
|
-
const punctuation = /[\p{P}\p{S}]/uy;
|
|
3611
|
-
const delimiterClasses = Uint8Array.from({ length: 128 }, (value, code) => isAsciiWhitespace(code) ? 0 : isAsciiPunctuation(code) ? 1 : 2);
|
|
3612
|
-
function delimiterCharacterClass(source, index) {
|
|
3613
|
-
if (index < 0 || index >= source.length) return 0;
|
|
3614
|
-
const code = source.charCodeAt(index);
|
|
3615
|
-
if (code <= 127) return delimiterClasses[code];
|
|
3616
|
-
if (code >= 56320 && code <= 57343) {
|
|
3617
|
-
const leading = source.charCodeAt(index - 1);
|
|
3618
|
-
if (leading >= 55296 && leading <= 56319) index--;
|
|
3619
|
-
}
|
|
3620
|
-
if (whitespace.lastIndex = index, whitespace.test(source)) return 0;
|
|
3621
|
-
if (punctuation.lastIndex = index, punctuation.test(source)) return 1;
|
|
3622
|
-
return 2;
|
|
3623
|
-
}
|
|
3670
|
+
const delimiterPunctuationMask = 6;
|
|
3624
3671
|
function flanking(source, start, end, config) {
|
|
3625
|
-
const
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3628
|
-
|
|
3672
|
+
const cjk = (config.bits & 8) !== 0;
|
|
3673
|
+
const before = boundaryBefore(source, start, cjk);
|
|
3674
|
+
const after = boundaryAfter(source, end, cjk);
|
|
3675
|
+
const beforeSpace = before & 1;
|
|
3676
|
+
const afterSpace = after & 1;
|
|
3677
|
+
if (beforeSpace || afterSpace) return (afterSpace ? 0 : 1) | (beforeSpace ? 0 : 2);
|
|
3678
|
+
const beforePunctuation = before & delimiterPunctuationMask;
|
|
3679
|
+
const afterPunctuation = after & delimiterPunctuationMask;
|
|
3680
|
+
if (!(config.bits & 1)) return (beforePunctuation ? 1 : 0) | (afterPunctuation ? 2 : 0);
|
|
3681
|
+
const adjacentCJK = cjk && before & 24 | after & 8;
|
|
3682
|
+
return (!afterPunctuation || beforePunctuation || adjacentCJK ? 1 : 0) | (!beforePunctuation || afterPunctuation || adjacentCJK ? 2 : 0);
|
|
3629
3683
|
}
|
|
3630
3684
|
function canPair(opener, closer) {
|
|
3631
3685
|
if (closer.config.bits & 2 && (opener.state & 12) !== (closer.state & 12)) return false;
|
|
@@ -3633,7 +3687,7 @@ function canPair(opener, closer) {
|
|
|
3633
3687
|
return true;
|
|
3634
3688
|
}
|
|
3635
3689
|
var DelimiterStack = class {
|
|
3636
|
-
#replacements
|
|
3690
|
+
#replacements;
|
|
3637
3691
|
#runs = [];
|
|
3638
3692
|
add(source, tokens, tokenIndex, config) {
|
|
3639
3693
|
const offset = inlineTokenStart(tokens, tokenIndex);
|
|
@@ -3666,7 +3720,7 @@ var DelimiterStack = class {
|
|
|
3666
3720
|
runs[top++] = closer;
|
|
3667
3721
|
continue;
|
|
3668
3722
|
}
|
|
3669
|
-
const bottomSlot = (closer.config.bits >>>
|
|
3723
|
+
const bottomSlot = (closer.config.bits >>> 4) + (closer.state & 1 ? 3 : 0) + (closer.state >> 2);
|
|
3670
3724
|
const bottom = openersBottom[bottomSlot] ?? 0;
|
|
3671
3725
|
while (closer.remaining) {
|
|
3672
3726
|
let candidate = top - 1;
|
|
@@ -3686,9 +3740,9 @@ var DelimiterStack = class {
|
|
|
3686
3740
|
const openStart = openEnd - use;
|
|
3687
3741
|
const closeStart = closer.start;
|
|
3688
3742
|
const closeEnd = closeStart + use;
|
|
3689
|
-
const
|
|
3690
|
-
this.#record(tokens, opener.tokenIndex, openStart, openEnd,
|
|
3691
|
-
this.#record(tokens, closer.tokenIndex, closeStart, closeEnd,
|
|
3743
|
+
const openKind = use === 2 ? closer.config.double : closer.config.single;
|
|
3744
|
+
this.#record(tokens, opener.tokenIndex, openStart, openEnd, openKind);
|
|
3745
|
+
this.#record(tokens, closer.tokenIndex, closeStart, closeEnd, openKind + 1);
|
|
3692
3746
|
opener.remaining -= use;
|
|
3693
3747
|
closer.start += use;
|
|
3694
3748
|
closer.remaining -= use;
|
|
@@ -3702,8 +3756,9 @@ var DelimiterStack = class {
|
|
|
3702
3756
|
tokens[index * 4 | 0] = kind;
|
|
3703
3757
|
return;
|
|
3704
3758
|
}
|
|
3705
|
-
this.#replacements
|
|
3706
|
-
|
|
3759
|
+
const replacements = this.#replacements ??= [];
|
|
3760
|
+
replacements[index] ??= [];
|
|
3761
|
+
replacements[index].push({
|
|
3707
3762
|
start,
|
|
3708
3763
|
end,
|
|
3709
3764
|
kind
|
|
@@ -3747,16 +3802,17 @@ function emitResolvedTokens(tokens, replacements = emptyArray) {
|
|
|
3747
3802
|
}
|
|
3748
3803
|
return result;
|
|
3749
3804
|
}
|
|
3750
|
-
function resolveDelimiterConfigs(configs) {
|
|
3751
|
-
const
|
|
3752
|
-
configs.
|
|
3753
|
-
|
|
3805
|
+
function resolveDelimiterConfigs(configs, cjk) {
|
|
3806
|
+
const delimiters = [];
|
|
3807
|
+
for (let i = 0; i < configs.length; i++) {
|
|
3808
|
+
const config = configs[i];
|
|
3809
|
+
delimiters[config.token] = {
|
|
3754
3810
|
single: config.single,
|
|
3755
3811
|
double: config.double,
|
|
3756
|
-
bits:
|
|
3812
|
+
bits: i * 6 << 4 | (config.allowIntraword !== false ? 1 : 0) | (config.pairing.kind === "whole" ? 2 : 0) | (config.pairing.kind === "partial" && config.pairing.ruleOfThree ? 4 : 0) | (cjk ? 8 : 0)
|
|
3757
3813
|
};
|
|
3758
|
-
}
|
|
3759
|
-
return
|
|
3814
|
+
}
|
|
3815
|
+
return delimiters;
|
|
3760
3816
|
}
|
|
3761
3817
|
// src/profile/features/attributes/shared.ts
|
|
3762
3818
|
const brackets = {
|
|
@@ -3764,21 +3820,14 @@ const brackets = {
|
|
|
3764
3820
|
[123]: 125,
|
|
3765
3821
|
[40]: 41
|
|
3766
3822
|
};
|
|
3767
|
-
const stops1 = new Set([
|
|
3768
|
-
32,
|
|
3769
|
-
35,
|
|
3770
|
-
46,
|
|
3771
|
-
125
|
|
3772
|
-
]);
|
|
3773
|
-
const stops2 = new Set([32, 125]);
|
|
3774
3823
|
function assignAttribute(attributes, name, value) {
|
|
3775
3824
|
if (name === "class" && typeof value === "string" && typeof attributes.class === "string") attributes.class += ` ${value}`;
|
|
3776
3825
|
else attributes[name] = value;
|
|
3777
3826
|
}
|
|
3778
|
-
function scanUntil(source, offset, limit,
|
|
3827
|
+
function scanUntil(source, offset, limit, shorthand) {
|
|
3779
3828
|
while (offset < limit) {
|
|
3780
3829
|
const code = source.charCodeAt(offset);
|
|
3781
|
-
if (code ===
|
|
3830
|
+
if (isSpaceTabOrLineEnding(code) || code === 125 || shorthand && (code === 35 || code === 46)) break;
|
|
3782
3831
|
offset += code === 92 && offset + 1 < limit ? 2 : 1;
|
|
3783
3832
|
}
|
|
3784
3833
|
return offset;
|
|
@@ -3818,23 +3867,23 @@ function scanBracketed(source, offset, limit) {
|
|
|
3818
3867
|
return -1;
|
|
3819
3868
|
}
|
|
3820
3869
|
function scanAttributes(source, start, attributes, limit = source.length) {
|
|
3821
|
-
if (source.charCodeAt(start) !== 123
|
|
3870
|
+
if (source.charCodeAt(start) !== 123) return;
|
|
3822
3871
|
let offset = start + 1;
|
|
3823
3872
|
while (offset < limit) {
|
|
3824
3873
|
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
3825
|
-
if (source.charCodeAt(offset) === 125) return offset + 1;
|
|
3826
3874
|
const marker = source.charCodeAt(offset);
|
|
3875
|
+
if (marker === 125) return offset + 1;
|
|
3827
3876
|
if (marker === 46 || marker === 35) {
|
|
3828
3877
|
offset++;
|
|
3829
3878
|
const valueStart = offset;
|
|
3830
|
-
offset = scanUntil(source, offset, limit,
|
|
3879
|
+
offset = scanUntil(source, offset, limit, true);
|
|
3831
3880
|
if (offset === valueStart) return;
|
|
3832
3881
|
if (attributes) assignAttribute(attributes, marker === 46 ? "class" : "id", source.slice(valueStart, offset));
|
|
3833
3882
|
continue;
|
|
3834
3883
|
}
|
|
3835
3884
|
const nameStart = offset;
|
|
3836
|
-
if (source.charCodeAt(offset) === 58) offset++;
|
|
3837
3885
|
let code = source.charCodeAt(offset);
|
|
3886
|
+
if (code === 58) code = source.charCodeAt(++offset);
|
|
3838
3887
|
if (!isAsciiLetter(code) && code !== 95) return;
|
|
3839
3888
|
offset++;
|
|
3840
3889
|
while (true) {
|
|
@@ -3847,7 +3896,7 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
3847
3896
|
if (source.charCodeAt(offset) !== 61) {
|
|
3848
3897
|
if (attributes) {
|
|
3849
3898
|
const name = source.slice(nameStart, nameEnd);
|
|
3850
|
-
assignAttribute(attributes,
|
|
3899
|
+
assignAttribute(attributes, code === 58 ? name : `:${name}`, "true");
|
|
3851
3900
|
}
|
|
3852
3901
|
continue;
|
|
3853
3902
|
}
|
|
@@ -3866,7 +3915,7 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
3866
3915
|
if (offset < 0) return;
|
|
3867
3916
|
valueEnd = offset;
|
|
3868
3917
|
} else {
|
|
3869
|
-
offset = scanUntil(source, offset, limit,
|
|
3918
|
+
offset = scanUntil(source, offset, limit, false);
|
|
3870
3919
|
valueEnd = offset;
|
|
3871
3920
|
if (valueEnd === valueStart) return;
|
|
3872
3921
|
}
|
|
@@ -3880,8 +3929,8 @@ function parseAttributes(source, start, attributes = {}) {
|
|
|
3880
3929
|
scanAttributes(source, start, attributes);
|
|
3881
3930
|
return attributes;
|
|
3882
3931
|
}
|
|
3883
|
-
// src/profile/features/footnote
|
|
3884
|
-
const
|
|
3932
|
+
// src/profile/features/footnote.ts
|
|
3933
|
+
const footnoteDefinitionHead = "FOOTNOTE\0";
|
|
3885
3934
|
function footnoteLabelEnd(source, start, limit) {
|
|
3886
3935
|
if (source.charCodeAt(start) !== 91 || source.charCodeAt(start + 1) !== 94) return;
|
|
3887
3936
|
const labelStart = start + 2;
|
|
@@ -3906,45 +3955,156 @@ function footnoteLabelAt(source, start, limit) {
|
|
|
3906
3955
|
const label = source.slice(start + 2, end - 1);
|
|
3907
3956
|
return {
|
|
3908
3957
|
end,
|
|
3909
|
-
definitionKey:
|
|
3958
|
+
definitionKey: footnoteDefinitionHead + normalizeIdentifier(label)
|
|
3910
3959
|
};
|
|
3911
3960
|
}
|
|
3912
3961
|
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
if (source.charCodeAt(
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3962
|
+
function definitionMarkerEnd(source, start, lineEnd) {
|
|
3963
|
+
const end = footnoteLabelEnd(source, start, lineEnd);
|
|
3964
|
+
if (end !== void 0 && source.charCodeAt(end) === 58) return end + 1;
|
|
3965
|
+
}
|
|
3966
|
+
const feature$18 = {
|
|
3967
|
+
block: {
|
|
3968
|
+
builds: [{
|
|
3969
|
+
token: 76,
|
|
3970
|
+
build(tokenStart, context) {
|
|
3971
|
+
const tokens = context.structure.tokens;
|
|
3972
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3973
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3974
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
3975
|
+
const label = context.source.slice(tokens.start(tokenStart) + 2, tokens.end(tokenStart) - 2);
|
|
3976
|
+
return {
|
|
3977
|
+
type: "footnoteDefinition",
|
|
3978
|
+
identifier: tokens.value(tokenStart),
|
|
3979
|
+
label: decodeString(label),
|
|
3980
|
+
children,
|
|
3981
|
+
position: {
|
|
3982
|
+
start,
|
|
3983
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
3986
|
+
}
|
|
3987
|
+
}],
|
|
3988
|
+
starts: [{
|
|
3989
|
+
codes: [91],
|
|
3990
|
+
unwrap(source, lines, index, contentOffset) {
|
|
3991
|
+
const lineEnd = lines.end(index);
|
|
3992
|
+
const markerEnd = definitionMarkerEnd(source, contentOffset, lineEnd);
|
|
3993
|
+
if (markerEnd !== void 0) return lines.child(index, trimLineWhitespaceStart(source, markerEnd, lineEnd), 0);
|
|
3994
|
+
},
|
|
3995
|
+
interrupt(source, lines, index, contentOffset) {
|
|
3996
|
+
return definitionMarkerEnd(source, contentOffset, lines.end(index)) !== void 0;
|
|
3997
|
+
},
|
|
3998
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
3999
|
+
const lineEnd = lines.end(start);
|
|
4000
|
+
const markerEnd = definitionMarkerEnd(source, contentOffset, lineEnd);
|
|
4001
|
+
if (markerEnd === void 0) return;
|
|
4002
|
+
const bodyStart = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
4003
|
+
const definitionLines = lines.child(start, bodyStart, 0);
|
|
4004
|
+
let index = start + 1;
|
|
4005
|
+
for (; index < lines.length; index++) {
|
|
4006
|
+
if (!lines.lazy(index)) {
|
|
4007
|
+
const line = definitionLines.pushAfterColumns(source, lines, index, 4);
|
|
4008
|
+
if (line === -2) {
|
|
4009
|
+
definitionLines.pushFrom(lines, index);
|
|
4010
|
+
continue;
|
|
4011
|
+
}
|
|
4012
|
+
if (line === -3) continue;
|
|
4013
|
+
if (context.startsInterruptingBlock(source, lines, index, line) || !context.endsWithParagraphLeaf(source, definitionLines, definitionLines.length - 1)) break;
|
|
4014
|
+
}
|
|
4015
|
+
definitionLines.pushFrom(lines, index, void 0, void 0, true);
|
|
4016
|
+
}
|
|
4017
|
+
while (definitionLines.length > 0 && isBlankLine(source, definitionLines, definitionLines.length - 1)) definitionLines.pop();
|
|
4018
|
+
const identifier = normalizeIdentifier(source.slice(contentOffset + 2, markerEnd - 2));
|
|
4019
|
+
tokens.push(76, contentOffset, markerEnd, {
|
|
4020
|
+
definitionKey: footnoteDefinitionHead + identifier,
|
|
4021
|
+
value: identifier
|
|
4022
|
+
});
|
|
4023
|
+
context.scanBlockLines(source, definitionLines, tokens);
|
|
4024
|
+
const end = definitionLines.length > 0 ? definitionLines.next(definitionLines.length - 1) : markerEnd;
|
|
4025
|
+
tokens.push(197, end, end);
|
|
4026
|
+
return index;
|
|
4027
|
+
}
|
|
4028
|
+
}]
|
|
4029
|
+
},
|
|
4030
|
+
inline: { builds: [{
|
|
4031
|
+
kind: "leaf",
|
|
4032
|
+
token: 132,
|
|
4033
|
+
build(tokenIndex, position, context) {
|
|
4034
|
+
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 2, 1);
|
|
4035
|
+
return {
|
|
4036
|
+
type: "footnoteReference",
|
|
4037
|
+
identifier: normalizeIdentifier(label),
|
|
4038
|
+
label: decodeString(label),
|
|
4039
|
+
position
|
|
4040
|
+
};
|
|
3931
4041
|
}
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
4042
|
+
}] }
|
|
4043
|
+
};
|
|
4044
|
+
// src/profile/resolve.ts
|
|
4045
|
+
const referenceTail = /\[(?:[^[\]\\]|\\[\s\S])*\]/y;
|
|
4046
|
+
function hasDirectTail(tokens, close) {
|
|
4047
|
+
return inlineTokenKind(tokens, close) === 68 || inlineTokenData(tokens, close) !== 0;
|
|
4048
|
+
}
|
|
4049
|
+
function setBoundary(tokens, index, kind, end) {
|
|
4050
|
+
const field = index * 4;
|
|
4051
|
+
tokens[field | 0] = kind;
|
|
4052
|
+
tokens[field | 2] = end;
|
|
3935
4053
|
}
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4054
|
+
function matchFootnote(source, tokens, definitions, open, close) {
|
|
4055
|
+
if (hasDirectTail(tokens, close)) return -1;
|
|
4056
|
+
const label = footnoteLabelAt(source, inlineTokenEnd(tokens, open) - 1, source.length);
|
|
4057
|
+
if (!label || label.end !== inlineTokenEnd(tokens, close) || !definitions.hasDefinition(label.definitionKey)) return -1;
|
|
4058
|
+
const field = open * 4;
|
|
4059
|
+
if (tokens[field | 0] === 4) tokens[field | 1]++;
|
|
4060
|
+
setBoundary(tokens, open, 132, label.end);
|
|
4061
|
+
return label.end;
|
|
3940
4062
|
}
|
|
3941
4063
|
function opensComponentLabel(tokens, open) {
|
|
3942
4064
|
return open > 0 && inlineTokenKind(tokens, open - 1) === 136 && inlineTokenEnd(tokens, open - 1) === inlineTokenStart(tokens, open);
|
|
3943
4065
|
}
|
|
4066
|
+
function componentOpening(source, tokens, open, close, insideLink) {
|
|
4067
|
+
if (opensComponentLabel(tokens, open)) return 208;
|
|
4068
|
+
const suffix = inlineTokenStart(tokens, close) + 1;
|
|
4069
|
+
const trailing = source.charCodeAt(suffix);
|
|
4070
|
+
if (trailing === 40 || trailing === 91) return 0;
|
|
4071
|
+
if (insideLink && (trailing !== 123 || attributesEnd(source, suffix) === void 0)) return 0;
|
|
4072
|
+
return 206;
|
|
4073
|
+
}
|
|
4074
|
+
function closeComponent(tokens, open, close, claim) {
|
|
4075
|
+
const at = inlineTokenStart(tokens, close);
|
|
4076
|
+
if (claim === 208) {
|
|
4077
|
+
const openingEnd = inlineTokenEnd(tokens, open);
|
|
4078
|
+
tokens[open * 4 | 0] = 0;
|
|
4079
|
+
if (openingEnd >= at) {
|
|
4080
|
+
tokens[close * 4 | 0] = 0;
|
|
4081
|
+
return;
|
|
4082
|
+
}
|
|
4083
|
+
setBoundary(tokens, open - 1, claim, openingEnd);
|
|
4084
|
+
}
|
|
4085
|
+
setBoundary(tokens, close, claim + 1, at + 1);
|
|
4086
|
+
}
|
|
4087
|
+
function matchedReferenceEnd(source, tokens, definitions, open, close, lastVisibleOpener) {
|
|
4088
|
+
if (!definitions.hasDefinitions()) return -1;
|
|
4089
|
+
const end = inlineTokenEnd(tokens, close);
|
|
4090
|
+
referenceTail.lastIndex = end;
|
|
4091
|
+
let suffixEnd = referenceTail.test(source) ? referenceTail.lastIndex : -1;
|
|
4092
|
+
let identifier = suffixEnd > end + 2 ? referenceIdentifier(source.slice(end + 1, suffixEnd - 1)) : "";
|
|
4093
|
+
if (!identifier) {
|
|
4094
|
+
if (suffixEnd !== end + 2) {
|
|
4095
|
+
if (lastVisibleOpener > open) return -1;
|
|
4096
|
+
suffixEnd = end;
|
|
4097
|
+
}
|
|
4098
|
+
identifier = referenceIdentifier(source.slice(inlineTokenEnd(tokens, open), inlineTokenStart(tokens, close)));
|
|
4099
|
+
}
|
|
4100
|
+
return definitions.hasDefinition(identifier) ? suffixEnd : -1;
|
|
4101
|
+
}
|
|
3944
4102
|
function pairBrackets(tokens, start, end) {
|
|
3945
4103
|
const mates = new Array(end);
|
|
3946
4104
|
const openers = [];
|
|
4105
|
+
let consumedEnd = -1;
|
|
3947
4106
|
for (let index = start; index < end; index++) {
|
|
4107
|
+
if (consumedEnd >= 0 && inlineTokenStart(tokens, index) < consumedEnd) continue;
|
|
3948
4108
|
const kind = inlineTokenKind(tokens, index);
|
|
3949
4109
|
if (kind === 5 || kind === 4) openers.push(index);
|
|
3950
4110
|
else if (kind === 6 || kind === 68) {
|
|
@@ -3952,39 +4112,15 @@ function pairBrackets(tokens, start, end) {
|
|
|
3952
4112
|
if (open !== void 0) {
|
|
3953
4113
|
mates[open] = index;
|
|
3954
4114
|
mates[index] = open;
|
|
4115
|
+
if (kind === 6 && !opensComponentLabel(tokens, open)) {
|
|
4116
|
+
const tailEnd = inlineTokenData(tokens, index);
|
|
4117
|
+
if (tailEnd > 0) consumedEnd = tailEnd;
|
|
4118
|
+
}
|
|
3955
4119
|
}
|
|
3956
4120
|
}
|
|
3957
4121
|
}
|
|
3958
4122
|
return mates;
|
|
3959
4123
|
}
|
|
3960
|
-
function componentOpening(source, tokens, open, close, insideLink) {
|
|
3961
|
-
if (opensComponentLabel(tokens, open)) return 208;
|
|
3962
|
-
const suffix = inlineTokenStart(tokens, close) + 1;
|
|
3963
|
-
const trailing = source.charCodeAt(suffix);
|
|
3964
|
-
if (trailing === 40 || trailing === 91) return 0;
|
|
3965
|
-
if (insideLink && (trailing !== 123 || attributesEnd(source, suffix) === void 0)) return 0;
|
|
3966
|
-
return 206;
|
|
3967
|
-
}
|
|
3968
|
-
function matchedLinkEnd(source, tokens, definitions, open, close, lastVisibleOpener) {
|
|
3969
|
-
const end = inlineTokenEnd(tokens, close);
|
|
3970
|
-
if (inlineTokenKind(tokens, close) === 68) return end;
|
|
3971
|
-
if (!definitions.hasDefinitions()) return -1;
|
|
3972
|
-
const contentStart = inlineTokenEnd(tokens, open);
|
|
3973
|
-
const contentEnd = inlineTokenStart(tokens, close);
|
|
3974
|
-
const labelEnd = referenceLabelEnd(source, end);
|
|
3975
|
-
if (labelEnd > 0) {
|
|
3976
|
-
const label = labelEnd === end + 2 ? source.slice(contentStart, contentEnd) : source.slice(end + 1, labelEnd - 1);
|
|
3977
|
-
return definitions.hasDefinition(normalizeIdentifier(label)) ? labelEnd : -1;
|
|
3978
|
-
}
|
|
3979
|
-
if (lastVisibleOpener > open) return -1;
|
|
3980
|
-
const label = source.slice(contentStart, contentEnd);
|
|
3981
|
-
return acceptsShortcutLabel(label) && definitions.hasDefinition(normalizeIdentifier(label)) ? end : -1;
|
|
3982
|
-
}
|
|
3983
|
-
function setBoundary(tokens, index, kind, end) {
|
|
3984
|
-
const field = index * 4;
|
|
3985
|
-
tokens[field | 0] = kind;
|
|
3986
|
-
tokens[field | 2] = end;
|
|
3987
|
-
}
|
|
3988
4124
|
function resolvePairs(source, tokens, definitions, options, delimiters, start) {
|
|
3989
4125
|
const end = inlineTokenCount(tokens);
|
|
3990
4126
|
const openers = [];
|
|
@@ -3996,15 +4132,15 @@ function resolvePairs(source, tokens, definitions, options, delimiters, start) {
|
|
|
3996
4132
|
let resourceLabelEnd = -1;
|
|
3997
4133
|
let consumedEnd = -1;
|
|
3998
4134
|
for (let index = start; index < end; index++) {
|
|
3999
|
-
const
|
|
4000
|
-
const
|
|
4001
|
-
if (
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
tokens[
|
|
4135
|
+
const field = index * 4;
|
|
4136
|
+
const kind = tokens[field | 0];
|
|
4137
|
+
if (consumedEnd >= 0 && tokens[field | 1] < consumedEnd) {
|
|
4138
|
+
if (options.component && kind === 5) {
|
|
4139
|
+
mates ??= pairBrackets(tokens, index, end);
|
|
4140
|
+
const close = mates[index];
|
|
4141
|
+
if (close !== void 0 && hasDirectTail(tokens, close)) resourceLabelEnd = Math.max(resourceLabelEnd, close);
|
|
4142
|
+
}
|
|
4143
|
+
tokens[field | 0] = 0;
|
|
4008
4144
|
continue;
|
|
4009
4145
|
}
|
|
4010
4146
|
const delimiter = delimiters[kind];
|
|
@@ -4013,26 +4149,29 @@ function resolvePairs(source, tokens, definitions, options, delimiters, start) {
|
|
|
4013
4149
|
scopes.add(source, tokens, index, delimiter);
|
|
4014
4150
|
continue;
|
|
4015
4151
|
}
|
|
4016
|
-
if (
|
|
4017
|
-
if (options.footnote &&
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4152
|
+
if (kind === 5 || kind === 4) {
|
|
4153
|
+
if (options.component || options.footnote && source.charCodeAt(tokens[field | 2]) === 94) mates ??= pairBrackets(tokens, index, end);
|
|
4154
|
+
const close = mates?.[index];
|
|
4155
|
+
const component = options.component && kind === 5 && close !== void 0;
|
|
4156
|
+
const insideLink = index < resourceLabelEnd;
|
|
4157
|
+
if (component && hasDirectTail(tokens, close)) resourceLabelEnd = Math.max(resourceLabelEnd, close);
|
|
4158
|
+
if (options.footnote && close !== void 0) {
|
|
4159
|
+
const footnoteEnd = matchFootnote(source, tokens, definitions, index, close);
|
|
4160
|
+
if (footnoteEnd >= 0) {
|
|
4161
|
+
consumedEnd = footnoteEnd;
|
|
4023
4162
|
continue;
|
|
4024
4163
|
}
|
|
4025
4164
|
}
|
|
4026
4165
|
if (component) {
|
|
4027
4166
|
const opening = componentOpening(source, tokens, index, close, insideLink);
|
|
4028
4167
|
if (opening !== 0) {
|
|
4029
|
-
tokens[
|
|
4168
|
+
tokens[field | 0] = opening;
|
|
4030
4169
|
if (insideLink) literalLabelEnd = Math.max(literalLabelEnd, close);
|
|
4031
4170
|
continue;
|
|
4032
4171
|
}
|
|
4033
4172
|
}
|
|
4034
4173
|
if (index < literalLabelEnd && kind !== 4) {
|
|
4035
|
-
tokens[
|
|
4174
|
+
tokens[field | 0] = 0;
|
|
4036
4175
|
if (close !== void 0) tokens[close * 4 | 0] = 0;
|
|
4037
4176
|
continue;
|
|
4038
4177
|
}
|
|
@@ -4046,27 +4185,20 @@ function resolvePairs(source, tokens, definitions, options, delimiters, start) {
|
|
|
4046
4185
|
let open;
|
|
4047
4186
|
if (claim === 208 || claim === 206) {
|
|
4048
4187
|
open = mate;
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
tokens[open * 4 | 0] = 0;
|
|
4053
|
-
if (openingEnd >= at) tokens[index * 4 | 0] = 0;
|
|
4054
|
-
else {
|
|
4055
|
-
setBoundary(tokens, open - 1, claim, openingEnd);
|
|
4056
|
-
setBoundary(tokens, index, claim + 1, at + 1);
|
|
4057
|
-
}
|
|
4058
|
-
} else setBoundary(tokens, index, claim + 1, at + 1);
|
|
4059
|
-
} else {
|
|
4060
|
-
if (index < literalLabelEnd && mate !== void 0 && inlineTokenKind(tokens, mate) !== 4) continue;
|
|
4188
|
+
closeComponent(tokens, open, index, claim);
|
|
4189
|
+
} else if (index < literalLabelEnd && claim !== 4) continue;
|
|
4190
|
+
else {
|
|
4061
4191
|
const label = openers.pop();
|
|
4062
4192
|
if (label === void 0) continue;
|
|
4063
4193
|
const image = inlineTokenKind(tokens, label) === 4;
|
|
4064
4194
|
if (!image && label < lastLinkOpener) continue;
|
|
4065
|
-
const
|
|
4195
|
+
const tokenEnd = tokens[field | 2];
|
|
4196
|
+
const directEnd = kind === 68 ? tokenEnd : tokens[field | 3];
|
|
4197
|
+
const direct = directEnd > 0;
|
|
4198
|
+
const closeEnd = direct ? directEnd : matchedReferenceEnd(source, tokens, definitions, label, index, lastVisibleOpener);
|
|
4066
4199
|
if (closeEnd < 0) continue;
|
|
4067
4200
|
open = label;
|
|
4068
|
-
const opening = (
|
|
4069
|
-
const tokenEnd = inlineTokenEnd(tokens, index);
|
|
4201
|
+
const opening = (direct ? 198 : 202) + (image ? 2 : 0);
|
|
4070
4202
|
tokens[open * 4 | 0] = opening;
|
|
4071
4203
|
setBoundary(tokens, index, opening + 1, closeEnd);
|
|
4072
4204
|
if (!image) lastLinkOpener = open;
|
|
@@ -4076,8 +4208,8 @@ function resolvePairs(source, tokens, definitions, options, delimiters, start) {
|
|
|
4076
4208
|
}
|
|
4077
4209
|
return scopes?.finish(tokens) ?? emitResolvedTokens(tokens);
|
|
4078
4210
|
}
|
|
4079
|
-
function createInlineResolver(options,
|
|
4080
|
-
const
|
|
4211
|
+
function createInlineResolver(options, delimiterConfigs) {
|
|
4212
|
+
const delimiters = resolveDelimiterConfigs(delimiterConfigs, options.cjk);
|
|
4081
4213
|
return (source, tokens, definitions, consume) => {
|
|
4082
4214
|
let start = 0;
|
|
4083
4215
|
let resolved = consume ? tokens : void 0;
|
|
@@ -4099,7 +4231,7 @@ function createInlineResolver(options, delimiters) {
|
|
|
4099
4231
|
}
|
|
4100
4232
|
const closing = close === end ? 0 : inlineTokenKind(tokens, close);
|
|
4101
4233
|
const resource = closing === 68;
|
|
4102
|
-
if (closing !== 0 && !resource && (closing !== 6 || options.component || options.footnote && source.charCodeAt(inlineTokenEnd(tokens, start)) === 94 || definitions.hasDefinitions())) break;
|
|
4234
|
+
if (closing !== 0 && !resource && (closing !== 6 || options.component || options.footnote && source.charCodeAt(inlineTokenEnd(tokens, start)) === 94 || inlineTokenData(tokens, close) !== 0 || definitions.hasDefinitions())) break;
|
|
4103
4235
|
if (!resource) {
|
|
4104
4236
|
literalBrackets += close < end ? 2 : 1;
|
|
4105
4237
|
start = close < end ? close + 1 : end;
|
|
@@ -4119,7 +4251,7 @@ function createInlineResolver(options, delimiters) {
|
|
|
4119
4251
|
default: return emitResolvedTokens(settled);
|
|
4120
4252
|
}
|
|
4121
4253
|
}
|
|
4122
|
-
return resolvePairs(source, resolved ?? tokens.slice(), definitions, options,
|
|
4254
|
+
return resolvePairs(source, resolved ?? tokens.slice(), definitions, options, delimiters, start);
|
|
4123
4255
|
};
|
|
4124
4256
|
}
|
|
4125
4257
|
// src/inline/tokenizer.ts
|
|
@@ -4131,8 +4263,8 @@ function createMasks(chars) {
|
|
|
4131
4263
|
for (let i = 0; i < chars.length; i++) {
|
|
4132
4264
|
const marker = chars.charCodeAt(i);
|
|
4133
4265
|
for (let byte = 0; byte < 256; byte++) {
|
|
4134
|
-
masks[byte << 8 | marker] |=
|
|
4135
|
-
masks[marker << 8 | byte] |=
|
|
4266
|
+
masks[byte << 8 | marker] |= 2;
|
|
4267
|
+
masks[marker << 8 | byte] |= 1;
|
|
4136
4268
|
}
|
|
4137
4269
|
}
|
|
4138
4270
|
cacheMasks.set(chars, masks);
|
|
@@ -4156,16 +4288,10 @@ function findClosingRunEnd(source, start, width, marker, code) {
|
|
|
4156
4288
|
}
|
|
4157
4289
|
return -1;
|
|
4158
4290
|
}
|
|
4159
|
-
function
|
|
4291
|
+
function findLineEndingEnd(source, start) {
|
|
4160
4292
|
let next = start + 1;
|
|
4161
4293
|
if (source.charCodeAt(start) === 13 && source.charCodeAt(next) === 10) next++;
|
|
4162
|
-
const lineStart = next;
|
|
4163
4294
|
while (source.charCodeAt(next) === 32) next++;
|
|
4164
|
-
if (source.charCodeAt(start - 1) === 32 && source.charCodeAt(start - 2) === 32) {
|
|
4165
|
-
let spaces = start - 2;
|
|
4166
|
-
while (source.charCodeAt(spaces - 1) === 32) spaces--;
|
|
4167
|
-
tokens.push(128, spaces, next, lineStart);
|
|
4168
|
-
} else tokens.push(67, start, next, 0);
|
|
4169
4295
|
return next;
|
|
4170
4296
|
}
|
|
4171
4297
|
function createBitmap(words, masks, group) {
|
|
@@ -4174,7 +4300,7 @@ function createBitmap(words, masks, group) {
|
|
|
4174
4300
|
const word1 = words[i | 1];
|
|
4175
4301
|
const word2 = words[i | 2];
|
|
4176
4302
|
const word3 = words[i | 3];
|
|
4177
|
-
return masks[word0 & 65535] | masks[word0 >>> 16] <<
|
|
4303
|
+
return (masks[word0 & 65535] << 2 | masks[word0 >>> 16]) << 28 | (masks[word1 & 65535] << 2 | masks[word1 >>> 16]) << 24 | (masks[word2 & 65535] << 2 | masks[word2 >>> 16]) << 20 | (masks[word3 & 65535] << 2 | masks[word3 >>> 16]) << 16;
|
|
4178
4304
|
}
|
|
4179
4305
|
function tokenizeLatin1(scanners, masks, source, mapping) {
|
|
4180
4306
|
const words = ScratchView.words;
|
|
@@ -4188,7 +4314,7 @@ function tokenizeLatin1(scanners, masks, source, mapping) {
|
|
|
4188
4314
|
let cursor = base + offset;
|
|
4189
4315
|
groups: for (let group = cursor & -16; cursor < limit;) {
|
|
4190
4316
|
let bits;
|
|
4191
|
-
let mask = -1
|
|
4317
|
+
let mask = -1 >>> (cursor & 15);
|
|
4192
4318
|
do {
|
|
4193
4319
|
bits = createBitmap(words, masks, group) & mask;
|
|
4194
4320
|
mask = -1;
|
|
@@ -4196,14 +4322,13 @@ function tokenizeLatin1(scanners, masks, source, mapping) {
|
|
|
4196
4322
|
if (!bits) break;
|
|
4197
4323
|
const groupEnd = group + 16;
|
|
4198
4324
|
do {
|
|
4199
|
-
const markerOffset = group +
|
|
4325
|
+
const markerOffset = group + Math.clz32(bits) - base;
|
|
4200
4326
|
if (markerOffset >= end) break groups;
|
|
4201
|
-
const
|
|
4202
|
-
const next = scan?.(source, markerOffset, tokens ??= []) ?? markerOffset;
|
|
4327
|
+
const next = (0, scanners[source.charCodeAt(markerOffset)])?.(source, markerOffset, tokens ??= []) ?? markerOffset;
|
|
4203
4328
|
offset = next > markerOffset ? next : markerOffset + 1;
|
|
4204
4329
|
cursor = base + offset;
|
|
4205
4330
|
if (cursor >= groupEnd) break;
|
|
4206
|
-
bits &= -1
|
|
4331
|
+
bits &= -1 >>> (cursor & 15);
|
|
4207
4332
|
} while (bits);
|
|
4208
4333
|
cursor = Math.max(cursor, groupEnd);
|
|
4209
4334
|
group = cursor & -16;
|
|
@@ -4215,15 +4340,14 @@ function tokenizeLatin1(scanners, masks, source, mapping) {
|
|
|
4215
4340
|
}
|
|
4216
4341
|
}
|
|
4217
4342
|
function createInlineTokenizer(boundaryFast, boundarySlow, scanners, masks) {
|
|
4218
|
-
return (source,
|
|
4343
|
+
return (source, hasPaddedLineFeed, mapping) => {
|
|
4219
4344
|
if (masks && mapping !== void 0) return tokenizeLatin1(scanners, masks, source, mapping);
|
|
4220
|
-
const boundary =
|
|
4345
|
+
const boundary = hasPaddedLineFeed ? boundarySlow : boundaryFast;
|
|
4221
4346
|
let tokens;
|
|
4222
4347
|
for (let cursor = 0; cursor < source.length;) {
|
|
4223
4348
|
const offset = findPatternEnd(source, cursor, boundary) - 1;
|
|
4224
4349
|
if (offset < 0) break;
|
|
4225
|
-
const
|
|
4226
|
-
const end = scan?.(source, offset, tokens ??= []) ?? offset;
|
|
4350
|
+
const end = (0, scanners[source.charCodeAt(offset)])?.(source, offset, tokens ??= []) ?? offset;
|
|
4227
4351
|
cursor = end > offset ? end : offset + 1;
|
|
4228
4352
|
}
|
|
4229
4353
|
return tokens ?? emptyArray;
|
|
@@ -4248,12 +4372,12 @@ function generateInlineTokenizer(boundaryFast, boundarySlow, scanners, masks, co
|
|
|
4248
4372
|
const dispatch = `if(t===ea)t=[];let n;switch(s.charCodeAt(mo)){${cases.join("")}default:n=mo}o=n>mo?n:mo+1;`;
|
|
4249
4373
|
const scanBitmap = [
|
|
4250
4374
|
`const l=b+e;let c=b+o;`,
|
|
4251
|
-
`g:for(let g=c&~15;c<l;){let bs,m=-1
|
|
4375
|
+
`g:for(let g=c&~15;c<l;){let bs,m=-1>>>(c&15);`,
|
|
4252
4376
|
`do{bs=cb(w,ms,g)&m;m=-1}while(!bs&&(g+=16)<l);`,
|
|
4253
4377
|
`if(!bs)break;const ge=g+16;`,
|
|
4254
|
-
`do{const mo=g+
|
|
4378
|
+
`do{const mo=g+Math.clz32(bs)-b;if(mo>=e)break g;`,
|
|
4255
4379
|
dispatch,
|
|
4256
|
-
`c=b+o;if(c>=ge)break;bs&=-1
|
|
4380
|
+
`c=b+o;if(c>=ge)break;bs&=-1>>>(c&15)`,
|
|
4257
4381
|
`}while(bs);c=Math.max(c,ge);g=c&~15}`
|
|
4258
4382
|
].join("");
|
|
4259
4383
|
return Function(...Object.keys(bindings), [
|
|
@@ -4265,7 +4389,7 @@ function generateInlineTokenizer(boundaryFast, boundarySlow, scanners, masks, co
|
|
|
4265
4389
|
scanBitmap,
|
|
4266
4390
|
`o=Math.max(o,e)}return t}`
|
|
4267
4391
|
].join(""),
|
|
4268
|
-
`return(s,
|
|
4392
|
+
`return(s,hp,mp)=>{let t=ea,o=0;`,
|
|
4269
4393
|
masks && [
|
|
4270
4394
|
`if(mp!==void 0){`,
|
|
4271
4395
|
`if(typeof mp!=="number")return sg(s,mp);`,
|
|
@@ -4273,14 +4397,14 @@ function generateInlineTokenizer(boundaryFast, boundarySlow, scanners, masks, co
|
|
|
4273
4397
|
scanBitmap,
|
|
4274
4398
|
`return t}`
|
|
4275
4399
|
].join(""),
|
|
4276
|
-
`const b0=
|
|
4400
|
+
`const b0=hp?b2:b1;while(o<s.length){`,
|
|
4277
4401
|
`b0.lastIndex=o;if(!b0.test(s))break;`,
|
|
4278
4402
|
`const mo=b0.lastIndex-1;`,
|
|
4279
4403
|
dispatch,
|
|
4280
4404
|
`}return t}`
|
|
4281
4405
|
].join(""))(...Object.values(bindings));
|
|
4282
4406
|
}
|
|
4283
|
-
function create(rules) {
|
|
4407
|
+
function create(rules, scanAllLineFeeds) {
|
|
4284
4408
|
const scanners = [];
|
|
4285
4409
|
const codes = [];
|
|
4286
4410
|
for (const rule of rules) {
|
|
@@ -4292,14 +4416,12 @@ function create(rules) {
|
|
|
4292
4416
|
};
|
|
4293
4417
|
if (previous === void 0) codes.push(code);
|
|
4294
4418
|
}
|
|
4295
|
-
const markers =
|
|
4296
|
-
const
|
|
4297
|
-
const
|
|
4419
|
+
const markers = scanAllLineFeeds ? codes.slice() : codes.filter((code) => code !== 10);
|
|
4420
|
+
const chars = String.fromCharCode(...markers.sort((a, b) => a - b));
|
|
4421
|
+
const masks = ScratchView.supports && codes.every((code) => code >= 0 && code <= 255) ? createMasks(chars) : void 0;
|
|
4422
|
+
const boundaries = chars.replaceAll(/[\\\]-]/g, "\\$&");
|
|
4298
4423
|
const boundaryFast = new RegExp(`[${boundaries}]`, "g");
|
|
4299
|
-
const boundarySlow = new RegExp(`[${boundaries}]|\\n(?:(?<=[ \\t]\\n)|(?= ))`, "g");
|
|
4300
|
-
scanners[10] = scanLineEnding;
|
|
4301
|
-
scanners[13] = scanLineEnding;
|
|
4302
|
-
codes.push(10, 13);
|
|
4424
|
+
const boundarySlow = scanAllLineFeeds ? boundaryFast : new RegExp(`[${boundaries}]|\\n(?:(?<=[ \\t]\\n)|(?= ))`, "g");
|
|
4303
4425
|
try {
|
|
4304
4426
|
return generateInlineTokenizer(boundaryFast, boundarySlow, scanners, masks, codes);
|
|
4305
4427
|
} catch {
|
|
@@ -4328,35 +4450,37 @@ function createInlineProfile(features, resolverOptions) {
|
|
|
4328
4450
|
return {
|
|
4329
4451
|
builders,
|
|
4330
4452
|
resolve: createInlineResolver(resolverOptions, delimiters),
|
|
4331
|
-
tokenize: create(scanRules)
|
|
4453
|
+
tokenize: create(scanRules, resolverOptions.breaks)
|
|
4332
4454
|
};
|
|
4333
4455
|
}
|
|
4334
4456
|
// src/profile/features/attributes/block.ts
|
|
4457
|
+
function promoteParagraphAttributes(owner) {
|
|
4458
|
+
const paragraph = owner.children.length === 1 ? owner.children[0] : void 0;
|
|
4459
|
+
if (paragraph?.type !== "paragraph" || !paragraph.attributes) return;
|
|
4460
|
+
owner.attributes = paragraph.attributes;
|
|
4461
|
+
owner.children[0] = {
|
|
4462
|
+
type: "paragraph",
|
|
4463
|
+
children: paragraph.children,
|
|
4464
|
+
position: paragraph.position
|
|
4465
|
+
};
|
|
4466
|
+
}
|
|
4335
4467
|
const blockDecorators = [{
|
|
4336
|
-
token: [
|
|
4468
|
+
token: [71, 72],
|
|
4337
4469
|
decorate(build) {
|
|
4338
4470
|
return (tokenStart, context) => {
|
|
4339
4471
|
const result = build(tokenStart, context);
|
|
4340
|
-
if (!result.spread)
|
|
4341
|
-
const
|
|
4342
|
-
if (paragraph?.attributes) {
|
|
4343
|
-
item.attributes = paragraph.attributes;
|
|
4344
|
-
delete paragraph.attributes;
|
|
4345
|
-
}
|
|
4472
|
+
if (!result.spread) {
|
|
4473
|
+
for (const item of result.children) if (!item.spread) promoteParagraphAttributes(item);
|
|
4346
4474
|
}
|
|
4347
4475
|
return result;
|
|
4348
4476
|
};
|
|
4349
4477
|
}
|
|
4350
4478
|
}, {
|
|
4351
|
-
token:
|
|
4479
|
+
token: 70,
|
|
4352
4480
|
decorate(build) {
|
|
4353
4481
|
return (tokenStart, context) => {
|
|
4354
4482
|
const result = build(tokenStart, context);
|
|
4355
|
-
|
|
4356
|
-
if (paragraph?.attributes) {
|
|
4357
|
-
result.attributes = paragraph.attributes;
|
|
4358
|
-
delete paragraph.attributes;
|
|
4359
|
-
}
|
|
4483
|
+
promoteParagraphAttributes(result);
|
|
4360
4484
|
return result;
|
|
4361
4485
|
};
|
|
4362
4486
|
}
|
|
@@ -4373,7 +4497,7 @@ function attributeEndAt(source, start) {
|
|
|
4373
4497
|
}
|
|
4374
4498
|
}
|
|
4375
4499
|
// src/profile/features/attributes/index.ts
|
|
4376
|
-
const feature$
|
|
4500
|
+
const feature$17 = {
|
|
4377
4501
|
block: { decorators: blockDecorators },
|
|
4378
4502
|
inline: {
|
|
4379
4503
|
scans: [{
|
|
@@ -4395,9 +4519,7 @@ const feature$18 = {
|
|
|
4395
4519
|
const previousEnd = previous >= 0 ? inlineTokenEnd(tokens, previous) : 0;
|
|
4396
4520
|
if (previousEnd < start && (previous >= 0 && inlineTokenKind(tokens, previous) === 256 || hasVisibleText(source, previousEnd, start))) appendInlineToken(tokens, 64, previousEnd, start);
|
|
4397
4521
|
appendInlineToken(tokens, 256, start, end, start > 0 && isSpaceTabOrLineEnding(source.charCodeAt(start - 1)) ? 1 : 0);
|
|
4398
|
-
let
|
|
4399
|
-
while (isSpaceTabOrLineEnding(source.charCodeAt(next))) next++;
|
|
4400
|
-
if (next === source.length) for (let index = inlineTokenCount(tokens) - 1; index >= 0; index--) {
|
|
4522
|
+
if (!hasVisibleText(source, end, source.length)) for (let index = inlineTokenCount(tokens) - 1; index >= 0; index--) {
|
|
4401
4523
|
const kind = inlineTokenKind(tokens, index);
|
|
4402
4524
|
if (kind === 64 && !hasVisibleText(source, inlineTokenStart(tokens, index), inlineTokenEnd(tokens, index))) continue;
|
|
4403
4525
|
if (kind !== 256) break;
|
|
@@ -4425,7 +4547,7 @@ const feature$18 = {
|
|
|
4425
4547
|
};
|
|
4426
4548
|
// src/profile/features/binding.ts
|
|
4427
4549
|
const leadingWhitespace = /\s*/y;
|
|
4428
|
-
const feature$
|
|
4550
|
+
const feature$16 = { inline: {
|
|
4429
4551
|
scans: [{
|
|
4430
4552
|
marker: 123,
|
|
4431
4553
|
scan(source, start, tokens) {
|
|
@@ -4440,7 +4562,7 @@ const feature$17 = { inline: {
|
|
|
4440
4562
|
}
|
|
4441
4563
|
if (valueStart >= valueEnd) return -1;
|
|
4442
4564
|
const end = close + 2;
|
|
4443
|
-
appendInlineToken(tokens, 134, start, end, valueEnd
|
|
4565
|
+
appendInlineToken(tokens, 134, start, end, valueEnd);
|
|
4444
4566
|
return end;
|
|
4445
4567
|
}
|
|
4446
4568
|
}],
|
|
@@ -4449,10 +4571,9 @@ const feature$17 = { inline: {
|
|
|
4449
4571
|
token: 134,
|
|
4450
4572
|
build(tokenIndex, position, context) {
|
|
4451
4573
|
const source = context.view.text;
|
|
4452
|
-
const
|
|
4453
|
-
const start = tokenStart + 2;
|
|
4574
|
+
const start = inlineTokenStart(context.tokens, tokenIndex) + 2;
|
|
4454
4575
|
const end = inlineTokenEnd(context.tokens, tokenIndex) - 2;
|
|
4455
|
-
const separator =
|
|
4576
|
+
const separator = inlineTokenData(context.tokens, tokenIndex);
|
|
4456
4577
|
const value = source.slice(start, separator).trim();
|
|
4457
4578
|
const defaultValue = separator === end ? "" : source.slice(separator + 2, end).trim();
|
|
4458
4579
|
const attributes = { ":value": value };
|
|
@@ -4468,13 +4589,14 @@ const feature$17 = { inline: {
|
|
|
4468
4589
|
}]
|
|
4469
4590
|
} };
|
|
4470
4591
|
// src/profile/features/blockquote.ts
|
|
4471
|
-
function blockQuoteOffset(source,
|
|
4592
|
+
function blockQuoteOffset(source, markerOffset) {
|
|
4472
4593
|
if (markerOffset < 0 || source.charCodeAt(markerOffset) !== 62) return;
|
|
4473
4594
|
let offset = markerOffset + 1;
|
|
4474
|
-
let prefixColumns =
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4595
|
+
let prefixColumns = 0;
|
|
4596
|
+
const code = source.charCodeAt(offset);
|
|
4597
|
+
if (code === 32) offset++;
|
|
4598
|
+
else if (code === 9) {
|
|
4599
|
+
prefixColumns = tabWidthAt(source, offset) - 1;
|
|
4478
4600
|
offset++;
|
|
4479
4601
|
}
|
|
4480
4602
|
return {
|
|
@@ -4482,52 +4604,50 @@ function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
|
4482
4604
|
prefixColumns
|
|
4483
4605
|
};
|
|
4484
4606
|
}
|
|
4485
|
-
const feature$
|
|
4607
|
+
const feature$15 = { block: {
|
|
4486
4608
|
builds: [{
|
|
4487
|
-
token:
|
|
4609
|
+
token: 70,
|
|
4488
4610
|
build(tokenStart, context) {
|
|
4489
4611
|
const tokens = context.structure.tokens;
|
|
4490
4612
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4491
4613
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
4614
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
4492
4615
|
return {
|
|
4493
4616
|
type: "blockquote",
|
|
4494
|
-
children
|
|
4617
|
+
children,
|
|
4495
4618
|
position: {
|
|
4496
4619
|
start,
|
|
4497
|
-
end: context.locator.locationAt(tokens.end(close))
|
|
4620
|
+
end: context.locator.locationAt(Math.max(tokens.end(close), children.at(-1)?.position?.end.offset ?? 0))
|
|
4498
4621
|
}
|
|
4499
4622
|
};
|
|
4500
4623
|
}
|
|
4501
4624
|
}],
|
|
4502
4625
|
starts: [{
|
|
4503
4626
|
codes: [62],
|
|
4504
|
-
unwrap(source, lines, index, contentOffset
|
|
4505
|
-
const marker = blockQuoteOffset(source,
|
|
4506
|
-
if (
|
|
4507
|
-
target.resetFrom(lines, index, marker.offset, marker.prefixColumns);
|
|
4508
|
-
return true;
|
|
4627
|
+
unwrap(source, lines, index, contentOffset) {
|
|
4628
|
+
const marker = blockQuoteOffset(source, contentOffset);
|
|
4629
|
+
if (marker) return lines.child(index, marker.offset, marker.prefixColumns);
|
|
4509
4630
|
},
|
|
4510
4631
|
interrupt() {
|
|
4511
4632
|
return true;
|
|
4512
4633
|
},
|
|
4513
4634
|
start(source, lines, tokens, start, contentOffset, context) {
|
|
4514
|
-
const firstMarker = blockQuoteOffset(source,
|
|
4515
|
-
const quoteLines =
|
|
4635
|
+
const firstMarker = blockQuoteOffset(source, contentOffset);
|
|
4636
|
+
const quoteLines = lines.child(start, firstMarker.offset, firstMarker.prefixColumns);
|
|
4516
4637
|
let index = start + 1;
|
|
4517
|
-
let lazyParagraph;
|
|
4518
4638
|
for (; index < lines.length; index++) {
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4639
|
+
if (!lines.lazy(index)) {
|
|
4640
|
+
const markerOffset = lineIndentOffset(source, lines, index);
|
|
4641
|
+
const marker = blockQuoteOffset(source, markerOffset);
|
|
4642
|
+
if (marker) {
|
|
4643
|
+
quoteLines.pushFrom(lines, index, marker.offset, marker.prefixColumns);
|
|
4644
|
+
continue;
|
|
4645
|
+
}
|
|
4646
|
+
if (markerOffset < 0 && isBlankLine(source, lines, index) || context.startsInterruptingBlock(source, lines, index, markerOffset) || !context.endsWithParagraphLeaf(source, quoteLines, quoteLines.length - 1)) break;
|
|
4525
4647
|
}
|
|
4526
|
-
|
|
4527
|
-
if (!lazyParagraph || markerOffset < 0 && isBlankLine(source, lines, index) || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index, markerOffset)) break;
|
|
4528
|
-
quoteLines.pushLazy(lines, index);
|
|
4648
|
+
quoteLines.pushFrom(lines, index, void 0, void 0, true);
|
|
4529
4649
|
}
|
|
4530
|
-
tokens.push(
|
|
4650
|
+
tokens.push(70, contentOffset, contentOffset + 1);
|
|
4531
4651
|
context.scanBlockLines(source, quoteLines, tokens);
|
|
4532
4652
|
const end = quoteLines.end(quoteLines.length - 1);
|
|
4533
4653
|
tokens.push(192, end, end);
|
|
@@ -4539,60 +4659,91 @@ const feature$16 = { block: {
|
|
|
4539
4659
|
function isThematicBreak(source, lines, index, contentOffset) {
|
|
4540
4660
|
const marker = source.charCodeAt(contentOffset);
|
|
4541
4661
|
if (marker !== 42 && marker !== 45 && marker !== 95) return false;
|
|
4542
|
-
let count =
|
|
4543
|
-
for (let offset = contentOffset, end = lines.end(index); offset < end; offset++) {
|
|
4662
|
+
let count = 1;
|
|
4663
|
+
for (let offset = contentOffset + 1, end = lines.end(index); offset < end; offset++) {
|
|
4544
4664
|
const code = source.charCodeAt(offset);
|
|
4545
4665
|
if (code === marker) count++;
|
|
4546
4666
|
else if (code !== 32 && code !== 9) return false;
|
|
4547
4667
|
}
|
|
4548
4668
|
return count >= 3;
|
|
4549
4669
|
}
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4670
|
+
function scanHardBreak(source, start, tokens) {
|
|
4671
|
+
let from = start;
|
|
4672
|
+
let before = source.charCodeAt(from - 1);
|
|
4673
|
+
while (before === 32) {
|
|
4674
|
+
from--;
|
|
4675
|
+
before = source.charCodeAt(from - 1);
|
|
4676
|
+
}
|
|
4677
|
+
if (before === 9 && start - from < 2) from = trimLineWhitespaceEnd(source, 0, from - 1);
|
|
4678
|
+
const end = findLineEndingEnd(source, start);
|
|
4679
|
+
appendInlineToken(tokens, 128, from, end);
|
|
4680
|
+
return end;
|
|
4681
|
+
}
|
|
4682
|
+
function scanLineEnding(source, start, tokens) {
|
|
4683
|
+
const next = findLineEndingEnd(source, start);
|
|
4684
|
+
if (source.charCodeAt(start - 1) === 32 && source.charCodeAt(start - 2) === 32) {
|
|
4685
|
+
let spaces = start - 2;
|
|
4686
|
+
while (source.charCodeAt(spaces - 1) === 32) spaces--;
|
|
4687
|
+
appendInlineToken(tokens, 128, spaces, next);
|
|
4688
|
+
} else appendInlineToken(tokens, 67, start, next);
|
|
4689
|
+
return next;
|
|
4690
|
+
}
|
|
4691
|
+
const blockStarts$2 = [{
|
|
4692
|
+
codes: [
|
|
4693
|
+
42,
|
|
4694
|
+
45,
|
|
4695
|
+
95
|
|
4696
|
+
],
|
|
4697
|
+
interrupt(source, lines, index, contentOffset) {
|
|
4698
|
+
return isThematicBreak(source, lines, index, contentOffset);
|
|
4699
|
+
},
|
|
4700
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
4701
|
+
if (!isThematicBreak(source, lines, start, contentOffset)) return;
|
|
4702
|
+
return {
|
|
4703
|
+
node: {
|
|
4704
|
+
type: "thematicBreak",
|
|
4705
|
+
position: void 0
|
|
4706
|
+
},
|
|
4707
|
+
nextLine: start + 1,
|
|
4708
|
+
start: contentOffset,
|
|
4709
|
+
end: lines.end(start)
|
|
4710
|
+
};
|
|
4711
|
+
}
|
|
4712
|
+
}];
|
|
4713
|
+
const inlineBuilds$2 = [{
|
|
4714
|
+
kind: "leaf",
|
|
4715
|
+
token: 128,
|
|
4716
|
+
build(tokenIndex, position) {
|
|
4717
|
+
position.end.offset -= position.end.column - 1;
|
|
4718
|
+
position.end.column = 1;
|
|
4719
|
+
return {
|
|
4720
|
+
type: "break",
|
|
4721
|
+
position
|
|
4722
|
+
};
|
|
4723
|
+
}
|
|
4724
|
+
}];
|
|
4725
|
+
const feature$14 = (soft) => ({
|
|
4726
|
+
block: { starts: blockStarts$2 },
|
|
4727
|
+
inline: {
|
|
4728
|
+
scans: [{
|
|
4729
|
+
marker: 10,
|
|
4730
|
+
scan: soft ? scanHardBreak : scanLineEnding
|
|
4731
|
+
}, {
|
|
4732
|
+
marker: 13,
|
|
4733
|
+
scan: soft ? scanHardBreak : scanLineEnding
|
|
4734
|
+
}],
|
|
4735
|
+
builds: inlineBuilds$2
|
|
4736
|
+
}
|
|
4737
|
+
});
|
|
4588
4738
|
// src/block/fence.ts
|
|
4589
4739
|
function createFence(options) {
|
|
4590
4740
|
const { marker, minimumLength, allowMarkerInInfo, normalizeEndings, build } = options;
|
|
4591
4741
|
const escaped = "\\u" + marker.toString(16).padStart(4, "0");
|
|
4592
|
-
const
|
|
4593
|
-
const
|
|
4594
|
-
const
|
|
4595
|
-
const
|
|
4742
|
+
const minimum = escaped.repeat(minimumLength);
|
|
4743
|
+
const remaining = `(?:${minimum})*${escaped}{0,${minimumLength - 1}}`;
|
|
4744
|
+
const checkInfo = allowMarkerInInfo ? "" : `(?=[^${escaped}\\r\\n]*(?:\\r|\\n|$))`;
|
|
4745
|
+
const opening = new RegExp(minimum + remaining + checkInfo, "y");
|
|
4746
|
+
const closing = new RegExp(remaining + "[ ]*", "y");
|
|
4596
4747
|
function openingEnd(source, offset) {
|
|
4597
4748
|
opening.lastIndex = offset;
|
|
4598
4749
|
return opening.test(source) ? opening.lastIndex : -1;
|
|
@@ -4610,10 +4761,9 @@ function createFence(options) {
|
|
|
4610
4761
|
const markerEnd = openingEnd(source, offset);
|
|
4611
4762
|
if (markerEnd < 0) return;
|
|
4612
4763
|
const close = findFenceClose(source, lines, start, lines.length, marker, markerEnd - offset, closing);
|
|
4613
|
-
const indent = lines.prefixColumns(start) + offset - lines.start(start);
|
|
4614
4764
|
const closed = close < lines.length;
|
|
4615
4765
|
const last = closed ? close : close - 1;
|
|
4616
|
-
const content = lines.physicallyContiguous() ? physicalFenceContent(source, lines, start, close - 1,
|
|
4766
|
+
const content = lines.physicallyContiguous() ? physicalFenceContent(source, lines, start, close - 1, offset - lines.start(start), normalizeEndings) : logicalFenceContent(source, lines, start, close - 1, closed, lineIndentColumns(source, lines, start, offset), normalizeEndings);
|
|
4617
4767
|
const lineEnd = lines.end(start);
|
|
4618
4768
|
const infoStart = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
4619
4769
|
return {
|
|
@@ -4635,7 +4785,11 @@ function findFenceClose(source, lines, open, limit, marker, length, closing) {
|
|
|
4635
4785
|
const lastStart = Math.min(end - length, offset + 3 - lines.prefixColumns(line));
|
|
4636
4786
|
while (first === 32 && offset < lastStart) first = source.charCodeAt(++offset);
|
|
4637
4787
|
}
|
|
4638
|
-
if (first !== marker)
|
|
4788
|
+
if (first !== marker) {
|
|
4789
|
+
if (first !== 9 || lines.physicallyContiguous()) continue;
|
|
4790
|
+
offset = lineIndentOffset(source, lines, line);
|
|
4791
|
+
if (offset < 0 || end - offset < length || source.charCodeAt(offset) !== marker) continue;
|
|
4792
|
+
}
|
|
4639
4793
|
if (source.charCodeAt(offset + length - 1) !== marker) continue;
|
|
4640
4794
|
closing.lastIndex = offset + 1;
|
|
4641
4795
|
if (closing.test(source) && closing.lastIndex === end) return line;
|
|
@@ -4664,41 +4818,31 @@ function logicalFenceContent(source, lines, start, last, closed, indent, normali
|
|
|
4664
4818
|
if (!closed && last > start && lines.start(last) === lines.next(last) && !lines.prefixColumns(last)) last--;
|
|
4665
4819
|
const parts = [];
|
|
4666
4820
|
for (let index = start + 1; index <= last; index++) {
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
let columns = lines.prefixColumns(index);
|
|
4670
|
-
while (offset < lineEnd && columns < indent) {
|
|
4671
|
-
const code = source.charCodeAt(offset);
|
|
4672
|
-
if (code === 32) columns++;
|
|
4673
|
-
else if (code === 9) columns += 4 - physicalColumnAt(source, offset) % 4;
|
|
4674
|
-
else break;
|
|
4675
|
-
offset++;
|
|
4676
|
-
}
|
|
4677
|
-
parts.push(" ".repeat(Math.max(0, columns - indent)) + source.slice(offset, normalizeEndings || index >= last ? lineEnd : lines.next(index)));
|
|
4821
|
+
const end = normalizeEndings || index >= last ? lines.end(index) : lines.next(index);
|
|
4822
|
+
parts.push(dedentLine(source, lines, index, indent, end));
|
|
4678
4823
|
}
|
|
4679
4824
|
return parts.join(normalizeEndings ? "\n" : "");
|
|
4680
4825
|
}
|
|
4681
4826
|
// src/profile/features/code.ts
|
|
4682
|
-
const complexInfo = /[\\& \t]
|
|
4683
|
-
const separator = /[ \t]
|
|
4827
|
+
const complexInfo = /[\\& \t]/;
|
|
4828
|
+
const separator = /[ \t]+/;
|
|
4684
4829
|
function buildFencedCode(info, value) {
|
|
4685
|
-
|
|
4686
|
-
let langEnd = complexInfo.test(info) ? complexInfo.lastIndex - 1 : -1;
|
|
4687
|
-
if (langEnd >= 0) {
|
|
4688
|
-
const code = info.charCodeAt(langEnd);
|
|
4689
|
-
info = decodeString(info);
|
|
4690
|
-
if (code !== 32 && code !== 9) {
|
|
4691
|
-
separator.lastIndex = langEnd;
|
|
4692
|
-
langEnd = separator.test(info) ? separator.lastIndex - 1 : -1;
|
|
4693
|
-
}
|
|
4694
|
-
}
|
|
4695
|
-
return {
|
|
4830
|
+
const node = {
|
|
4696
4831
|
type: "code",
|
|
4697
|
-
lang:
|
|
4698
|
-
meta:
|
|
4832
|
+
lang: info || null,
|
|
4833
|
+
meta: null,
|
|
4699
4834
|
value,
|
|
4700
4835
|
position: void 0
|
|
4701
4836
|
};
|
|
4837
|
+
if (info && complexInfo.test(info)) {
|
|
4838
|
+
const match = separator.exec(info);
|
|
4839
|
+
if (match) {
|
|
4840
|
+
node.meta = decodeString(info.slice(match.index + match[0].length)) || null;
|
|
4841
|
+
info = info.slice(0, match.index);
|
|
4842
|
+
}
|
|
4843
|
+
node.lang = decodeString(info) || null;
|
|
4844
|
+
}
|
|
4845
|
+
return node;
|
|
4702
4846
|
}
|
|
4703
4847
|
const backtickFence = createFence({
|
|
4704
4848
|
marker: 96,
|
|
@@ -4719,24 +4863,7 @@ function codeFenceClosingLine(source, lines, open, limit, offset) {
|
|
|
4719
4863
|
if (marker === 96) return backtickFence.closingLineAt(source, lines, open, limit, offset);
|
|
4720
4864
|
if (marker === 126) return tildeFence.closingLineAt(source, lines, open, limit, offset);
|
|
4721
4865
|
}
|
|
4722
|
-
|
|
4723
|
-
const parts = [];
|
|
4724
|
-
for (let index = start; index < end; index++) {
|
|
4725
|
-
let offset = lines.start(index);
|
|
4726
|
-
let columns = lines.prefixColumns(index);
|
|
4727
|
-
const lineEnd = lines.end(index);
|
|
4728
|
-
while (offset < lineEnd && columns < 4) {
|
|
4729
|
-
const code = source.charCodeAt(offset);
|
|
4730
|
-
if (code === 32) columns++;
|
|
4731
|
-
else if (code === 9) columns += Math.max(4 - columns, 4 - physicalColumnAt(source, offset) % 4);
|
|
4732
|
-
else break;
|
|
4733
|
-
offset++;
|
|
4734
|
-
}
|
|
4735
|
-
parts.push(" ".repeat(Math.max(0, columns - 4)) + source.slice(offset, lineEnd));
|
|
4736
|
-
}
|
|
4737
|
-
return parts.join("\n");
|
|
4738
|
-
}
|
|
4739
|
-
const feature$14 = {
|
|
4866
|
+
const feature$13 = {
|
|
4740
4867
|
block: { starts: [
|
|
4741
4868
|
{
|
|
4742
4869
|
codes: [-1],
|
|
@@ -4744,12 +4871,14 @@ const feature$14 = {
|
|
|
4744
4871
|
let end = start + 1;
|
|
4745
4872
|
while (end < lines.length && lineIndentOffset(source, lines, end) < 0) end++;
|
|
4746
4873
|
while (end > start + 1 && isBlankLine(source, lines, end - 1)) end--;
|
|
4874
|
+
const parts = [];
|
|
4875
|
+
for (let index = start; index < end; index++) parts.push(dedentLine(source, lines, index, 4, lines.end(index)));
|
|
4747
4876
|
return {
|
|
4748
4877
|
node: {
|
|
4749
4878
|
type: "code",
|
|
4750
4879
|
lang: null,
|
|
4751
4880
|
meta: null,
|
|
4752
|
-
value:
|
|
4881
|
+
value: parts.join("\n"),
|
|
4753
4882
|
position: void 0
|
|
4754
4883
|
},
|
|
4755
4884
|
nextLine: end,
|
|
@@ -4766,7 +4895,6 @@ const feature$14 = {
|
|
|
4766
4895
|
marker: 96,
|
|
4767
4896
|
scan(source, start, tokens) {
|
|
4768
4897
|
const openEnd = findMarkerRunEnd(source, start, 96);
|
|
4769
|
-
if (source.charCodeAt(start - 1) === 96) return openEnd;
|
|
4770
4898
|
const markerLength = openEnd - start;
|
|
4771
4899
|
const end = findClosingRunEnd(source, openEnd, markerLength, "`", 96);
|
|
4772
4900
|
if (end < 0) return openEnd;
|
|
@@ -4847,8 +4975,7 @@ function appendTextRange(context, output, trimEnd) {
|
|
|
4847
4975
|
appendText(context, output, "\n", childStart, childEnd, false);
|
|
4848
4976
|
} else {
|
|
4849
4977
|
if (childStart > output.end) appendGap(context, output, output.end, childStart);
|
|
4850
|
-
|
|
4851
|
-
appendText(context, output, build(index, context), childStart, childEnd, kind === 64);
|
|
4978
|
+
appendText(context, output, (0, context.profile.builders[kind])(index, context), childStart, childEnd, kind === 64);
|
|
4852
4979
|
}
|
|
4853
4980
|
index++;
|
|
4854
4981
|
continue;
|
|
@@ -4860,8 +4987,7 @@ function appendTextRange(context, output, trimEnd) {
|
|
|
4860
4987
|
start: sourceStart,
|
|
4861
4988
|
end: childStart === childEnd ? sourceStart : context.view.mapEnd(childEnd)
|
|
4862
4989
|
};
|
|
4863
|
-
|
|
4864
|
-
if (decorate(index, sourceSpan, context, output)) {
|
|
4990
|
+
if ((0, context.profile.builders[kind])(index, sourceSpan, context, output)) {
|
|
4865
4991
|
const previous = output.children.at(-1);
|
|
4866
4992
|
output.pendingText = previous?.type === "text" ? previous : void 0;
|
|
4867
4993
|
output.end = childEnd;
|
|
@@ -4886,9 +5012,9 @@ function buildLiteral(context, start, end) {
|
|
|
4886
5012
|
}
|
|
4887
5013
|
function buildFragment(context, cursor, closer) {
|
|
4888
5014
|
const trimEnd = closer === 0;
|
|
4889
|
-
const children = [];
|
|
4890
5015
|
const tokens = context.tokens;
|
|
4891
5016
|
const end = inlineTokenCount(tokens);
|
|
5017
|
+
let children;
|
|
4892
5018
|
let output;
|
|
4893
5019
|
while (context.tokenIndex < end) {
|
|
4894
5020
|
const index = context.tokenIndex;
|
|
@@ -4900,7 +5026,7 @@ function buildFragment(context, cursor, closer) {
|
|
|
4900
5026
|
output.pendingText = void 0;
|
|
4901
5027
|
output.literalStart = 0;
|
|
4902
5028
|
} else output = {
|
|
4903
|
-
children,
|
|
5029
|
+
children: children ??= [],
|
|
4904
5030
|
end: cursor,
|
|
4905
5031
|
pendingText: void 0,
|
|
4906
5032
|
literalStart: 0
|
|
@@ -4910,7 +5036,11 @@ function buildFragment(context, cursor, closer) {
|
|
|
4910
5036
|
continue;
|
|
4911
5037
|
}
|
|
4912
5038
|
const startOffset = inlineTokenStart(tokens, index);
|
|
4913
|
-
if (cursor < startOffset)
|
|
5039
|
+
if (cursor < startOffset) {
|
|
5040
|
+
const node = buildLiteral(context, cursor, startOffset);
|
|
5041
|
+
children ??= [];
|
|
5042
|
+
children.push(node);
|
|
5043
|
+
}
|
|
4914
5044
|
const sourceStart = context.view.mapOffset(startOffset);
|
|
4915
5045
|
const start = context.locator.locationAt(sourceStart);
|
|
4916
5046
|
let nested;
|
|
@@ -4931,32 +5061,55 @@ function buildFragment(context, cursor, closer) {
|
|
|
4931
5061
|
};
|
|
4932
5062
|
const build = context.profile.builders[kind];
|
|
4933
5063
|
const node = nested ? build(index, close, position, nested, context) : build(index, position, context);
|
|
4934
|
-
children
|
|
5064
|
+
children?.push(node) ?? (children = [node]);
|
|
4935
5065
|
cursor = endOffset;
|
|
4936
5066
|
}
|
|
4937
5067
|
let tail = context.tokenIndex < end ? inlineTokenStart(tokens, context.tokenIndex) : context.view.text.length;
|
|
4938
5068
|
if (cursor < tail && trimEnd) tail = trimLineWhitespaceEnd(context.view.text, cursor, tail);
|
|
4939
|
-
if (cursor < tail)
|
|
4940
|
-
|
|
5069
|
+
if (cursor < tail) {
|
|
5070
|
+
const node = buildLiteral(context, cursor, tail);
|
|
5071
|
+
children?.push(node) ?? (children = [node]);
|
|
5072
|
+
}
|
|
5073
|
+
return output ?? { children: children ??= [] };
|
|
5074
|
+
}
|
|
5075
|
+
function buildLiteralChunk(context, chunkStart, chunkEnd, text) {
|
|
5076
|
+
const trimmedEnd = trimLineWhitespaceEnd(context.source, chunkStart, chunkEnd);
|
|
5077
|
+
return { children: trimmedEnd <= chunkStart ? [] : [{
|
|
5078
|
+
type: "text",
|
|
5079
|
+
value: trimmedEnd === chunkEnd ? text : context.source.slice(chunkStart, trimmedEnd),
|
|
5080
|
+
position: context.locator.positionAt(chunkStart, trimmedEnd)
|
|
5081
|
+
}] };
|
|
4941
5082
|
}
|
|
4942
|
-
function buildInlineFragment(tokenStart,
|
|
5083
|
+
function buildInlineFragment(tokenStart, context) {
|
|
4943
5084
|
let tokens;
|
|
4944
5085
|
let view;
|
|
4945
5086
|
if (context.cursor) {
|
|
4946
5087
|
const region = context.cursor.take(tokenStart);
|
|
4947
5088
|
if (!region) return { children: [] };
|
|
4948
5089
|
tokens = region.tokens;
|
|
4949
|
-
view = region
|
|
5090
|
+
view = region;
|
|
5091
|
+
if (tokens.length === 0 && typeof view.mappings === "number") return buildLiteralChunk(context, view.mappings, view.mappings + view.text.length, view.text);
|
|
4950
5092
|
} else {
|
|
4951
5093
|
const blockTokens = context.structure.tokens;
|
|
4952
5094
|
const nodeLength = blockTokens.nodeLength(tokenStart);
|
|
4953
5095
|
if (nodeLength <= 1 || blockTokens.kind(tokenStart + 1) !== 1) return { children: [] };
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
5096
|
+
const hasPaddedLineFeed = blockTokens.value(tokenStart) === paddedLineFeed;
|
|
5097
|
+
if (nodeLength === 2) {
|
|
5098
|
+
const chunkStart = blockTokens.start(tokenStart + 1);
|
|
5099
|
+
const chunkEnd = blockTokens.end(tokenStart + 1);
|
|
5100
|
+
const text = context.source.slice(chunkStart, chunkEnd);
|
|
5101
|
+
tokens = context.profile.tokenize(text, hasPaddedLineFeed, hasPaddedLineFeed ? void 0 : chunkStart);
|
|
5102
|
+
if (tokens.length === 0) return buildLiteralChunk(context, chunkStart, chunkEnd, text);
|
|
5103
|
+
view = context.view;
|
|
5104
|
+
view.mappings = chunkStart;
|
|
5105
|
+
view.text = text;
|
|
5106
|
+
} else {
|
|
5107
|
+
view = context.view;
|
|
5108
|
+
view.reset(context.source, blockTokens, tokenStart, nodeLength);
|
|
5109
|
+
tokens = context.profile.tokenize(view.text, hasPaddedLineFeed, hasPaddedLineFeed ? void 0 : view.mappings);
|
|
5110
|
+
}
|
|
4957
5111
|
if (tokens.length) tokens = context.profile.resolve(view.text, tokens, blockTokens, true);
|
|
4958
5112
|
}
|
|
4959
|
-
context.tableCell = tableCell;
|
|
4960
5113
|
context.tokens = tokens;
|
|
4961
5114
|
context.view = view;
|
|
4962
5115
|
if (tokens.length === 0) {
|
|
@@ -4984,7 +5137,7 @@ const buildYamlBlock = (tokenStart, context) => {
|
|
|
4984
5137
|
position: context.locator.positionAt(tokens.start(tokenStart), tokens.end(tokenStart))
|
|
4985
5138
|
};
|
|
4986
5139
|
};
|
|
4987
|
-
function feature$
|
|
5140
|
+
function feature$12(marker) {
|
|
4988
5141
|
const code = marker.charCodeAt(0);
|
|
4989
5142
|
return { block: {
|
|
4990
5143
|
builds: [{
|
|
@@ -5016,24 +5169,24 @@ function componentNameEnd(source, start, block) {
|
|
|
5016
5169
|
}
|
|
5017
5170
|
return end;
|
|
5018
5171
|
}
|
|
5172
|
+
function isNameSeparator(code) {
|
|
5173
|
+
return code === 45 || code === 95 || code === 46;
|
|
5174
|
+
}
|
|
5019
5175
|
function normalizeComponentName(value) {
|
|
5020
5176
|
let result = "";
|
|
5021
|
-
let
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
const character = value[index];
|
|
5025
|
-
const code = value.charCodeAt(index);
|
|
5026
|
-
if (code === 45 || code === 95 || code === 47 || code === 46) {
|
|
5027
|
-
partLength = 0;
|
|
5028
|
-
previousUpper = void 0;
|
|
5177
|
+
for (let index = 0; index < value.length;) {
|
|
5178
|
+
if (isNameSeparator(value.charCodeAt(index))) {
|
|
5179
|
+
index++;
|
|
5029
5180
|
continue;
|
|
5030
5181
|
}
|
|
5031
|
-
const
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5182
|
+
const start = index++;
|
|
5183
|
+
while (index < value.length) {
|
|
5184
|
+
const code = value.charCodeAt(index);
|
|
5185
|
+
if (isNameSeparator(code) || isUppercaseLetter(code) && (isLowercaseLetter(value.charCodeAt(index - 1)) || isLowercaseLetter(value.charCodeAt(index + 1)))) break;
|
|
5186
|
+
index++;
|
|
5187
|
+
}
|
|
5188
|
+
if (result) result += "-";
|
|
5189
|
+
result += value.slice(start, index);
|
|
5037
5190
|
}
|
|
5038
5191
|
return result.toLowerCase();
|
|
5039
5192
|
}
|
|
@@ -5050,57 +5203,40 @@ function closingBracket(source, start, limit) {
|
|
|
5050
5203
|
}
|
|
5051
5204
|
}
|
|
5052
5205
|
}
|
|
5053
|
-
function lineValue(source, lines, index) {
|
|
5054
|
-
const offset = lineIndentOffset(source, lines, index);
|
|
5055
|
-
return offset < 0 ? void 0 : source.slice(offset, lines.end(index));
|
|
5056
|
-
}
|
|
5057
|
-
function yamlClosingMarker(value) {
|
|
5058
|
-
switch (value) {
|
|
5059
|
-
case "---": return "---";
|
|
5060
|
-
case "```yaml [props]":
|
|
5061
|
-
case "```yml [props]": return "```";
|
|
5062
|
-
case "~~~yaml [props]":
|
|
5063
|
-
case "~~~yml [props]": return "~~~";
|
|
5064
|
-
}
|
|
5065
|
-
}
|
|
5066
5206
|
function yamlPropsEnd(source, lines, start, end) {
|
|
5067
|
-
const
|
|
5207
|
+
const offset = lineIndentOffset(source, lines, start);
|
|
5208
|
+
if (offset < 0) return;
|
|
5209
|
+
const opening = source.slice(offset, lines.end(start));
|
|
5210
|
+
const marker = opening === "---" ? "---" : opening === "```yaml [props]" || opening === "```yml [props]" ? "```" : opening === `~~~yaml [props]` || opening === `~~~yml [props]` ? `~~~` : void 0;
|
|
5068
5211
|
if (!marker) return;
|
|
5069
|
-
for (let index = start + 1; index < end; index++)
|
|
5212
|
+
for (let index = start + 1; index < end; index++) {
|
|
5213
|
+
const lineEnd = lines.end(index);
|
|
5214
|
+
if (source.endsWith(marker, lineEnd) && lineIndentOffset(source, lines, index) === lineEnd - marker.length) return index + 1;
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
function openingAttributesEnd(source, start, lineEnd) {
|
|
5218
|
+
if (start === lineEnd) return start;
|
|
5219
|
+
const end = attributesEnd(source, start, lineEnd);
|
|
5220
|
+
if (end !== void 0 && trimLineWhitespaceStart(source, end, lineEnd) === lineEnd) return end;
|
|
5070
5221
|
}
|
|
5071
5222
|
function slotOpeningAt(source, lines, index, contentOffset) {
|
|
5072
5223
|
if (source.charCodeAt(contentOffset) !== 35) return;
|
|
5073
|
-
const code = source.charCodeAt(contentOffset + 1);
|
|
5074
|
-
if (code === 35 || code === 32 || code === 9) return;
|
|
5075
5224
|
const nameEnd = componentNameEnd(source, contentOffset + 1, true);
|
|
5225
|
+
if (nameEnd === void 0) return;
|
|
5076
5226
|
const lineEnd = lines.end(index);
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
let attributesEndValue;
|
|
5081
|
-
if (source.charCodeAt(offset) === 123) {
|
|
5082
|
-
attributesStart = offset;
|
|
5083
|
-
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
5084
|
-
if (attributesEndValue === void 0) return;
|
|
5085
|
-
offset = attributesEndValue;
|
|
5086
|
-
}
|
|
5087
|
-
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
5227
|
+
const offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
5228
|
+
const end = openingAttributesEnd(source, offset, lineEnd);
|
|
5229
|
+
if (end === void 0) return;
|
|
5088
5230
|
return {
|
|
5089
|
-
attributesEnd:
|
|
5090
|
-
attributesStart,
|
|
5231
|
+
attributesEnd: end,
|
|
5232
|
+
attributesStart: offset,
|
|
5091
5233
|
nameEnd,
|
|
5092
5234
|
offset: contentOffset
|
|
5093
5235
|
};
|
|
5094
5236
|
}
|
|
5095
|
-
function
|
|
5096
|
-
let offset = contentOffset;
|
|
5097
|
-
while (source.charCodeAt(offset) === 58) offset++;
|
|
5098
|
-
const fenceSize = offset - contentOffset;
|
|
5099
|
-
if (shorthand ? fenceSize !== 1 : fenceSize < 2) return;
|
|
5100
|
-
const lineEnd = lines.end(index);
|
|
5101
|
-
if (!shorthand) offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
5237
|
+
function componentHeaderAt(source, offset, lineEnd, fenceSize) {
|
|
5102
5238
|
const nameEnd = componentNameEnd(source, offset, true);
|
|
5103
|
-
if (nameEnd === void 0
|
|
5239
|
+
if (nameEnd === void 0) return;
|
|
5104
5240
|
offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
5105
5241
|
let labelStart;
|
|
5106
5242
|
let labelEnd;
|
|
@@ -5111,45 +5247,48 @@ function blockOpeningAt(source, lines, index, contentOffset, shorthand) {
|
|
|
5111
5247
|
labelEnd = close + 1;
|
|
5112
5248
|
offset = trimLineWhitespaceStart(source, labelEnd, lineEnd);
|
|
5113
5249
|
}
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
if (source.charCodeAt(offset) === 123) {
|
|
5117
|
-
attributesStart = offset;
|
|
5118
|
-
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
5119
|
-
if (attributesEndValue === void 0) return;
|
|
5120
|
-
offset = attributesEndValue;
|
|
5121
|
-
}
|
|
5122
|
-
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
5250
|
+
const end = openingAttributesEnd(source, offset, lineEnd);
|
|
5251
|
+
if (end === void 0) return;
|
|
5123
5252
|
return {
|
|
5124
|
-
attributesEnd:
|
|
5125
|
-
attributesStart,
|
|
5253
|
+
attributesEnd: end,
|
|
5254
|
+
attributesStart: offset,
|
|
5126
5255
|
fenceSize,
|
|
5127
5256
|
labelEnd,
|
|
5128
5257
|
labelStart,
|
|
5129
5258
|
nameEnd
|
|
5130
5259
|
};
|
|
5131
5260
|
}
|
|
5132
|
-
function
|
|
5261
|
+
function blockOpeningAt(source, lines, index, contentOffset, allowShorthand) {
|
|
5262
|
+
let offset = contentOffset;
|
|
5263
|
+
while (source.charCodeAt(offset) === 58) offset++;
|
|
5264
|
+
const fenceSize = offset - contentOffset;
|
|
5265
|
+
if (fenceSize === 0 || !allowShorthand && fenceSize < 2) return;
|
|
5266
|
+
const lineEnd = lines.end(index);
|
|
5267
|
+
if (fenceSize >= 2) offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
5268
|
+
return componentHeaderAt(source, offset, lineEnd, fenceSize);
|
|
5269
|
+
}
|
|
5270
|
+
function blockClose(source, lines, start, end, opening) {
|
|
5133
5271
|
let depth = 0;
|
|
5134
|
-
for (let index = start + 1; index <
|
|
5272
|
+
for (let index = start + 1; index < end; index++) {
|
|
5135
5273
|
const contentOffset = lineIndentOffset(source, lines, index);
|
|
5136
5274
|
if (contentOffset < 0) continue;
|
|
5137
|
-
const close = codeFenceClosingLine(source, lines, index,
|
|
5275
|
+
const close = codeFenceClosingLine(source, lines, index, end, contentOffset);
|
|
5138
5276
|
if (close !== void 0) {
|
|
5139
5277
|
index = close;
|
|
5140
5278
|
continue;
|
|
5141
5279
|
}
|
|
5142
5280
|
let markerEnd = contentOffset;
|
|
5143
5281
|
while (source.charCodeAt(markerEnd) === 58) markerEnd++;
|
|
5144
|
-
if (markerEnd - contentOffset
|
|
5282
|
+
if (markerEnd - contentOffset !== opening.fenceSize) continue;
|
|
5283
|
+
const lineEnd = lines.end(index);
|
|
5284
|
+
const nameStart = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
5285
|
+
if (nameStart === lineEnd) {
|
|
5145
5286
|
if (depth === 0) return {
|
|
5146
5287
|
index,
|
|
5147
5288
|
offset: contentOffset
|
|
5148
5289
|
};
|
|
5149
5290
|
depth--;
|
|
5150
|
-
|
|
5151
|
-
}
|
|
5152
|
-
if (blockOpeningAt(source, lines, index, contentOffset, false)?.fenceSize === opening.fenceSize) depth++;
|
|
5291
|
+
} else if (componentHeaderAt(source, nameStart, lineEnd, opening.fenceSize)) depth++;
|
|
5153
5292
|
}
|
|
5154
5293
|
}
|
|
5155
5294
|
function nextSlot(source, lines, start, end) {
|
|
@@ -5167,9 +5306,12 @@ function nextSlot(source, lines, start, end) {
|
|
|
5167
5306
|
opening: slot
|
|
5168
5307
|
};
|
|
5169
5308
|
const nested = blockOpeningAt(source, lines, index, contentOffset, false);
|
|
5170
|
-
if (nested) index = blockClose(source, lines, index, nested)?.index ?? index;
|
|
5309
|
+
if (nested) index = blockClose(source, lines, index, end, nested)?.index ?? index;
|
|
5171
5310
|
}
|
|
5172
5311
|
}
|
|
5312
|
+
function emitOpeningAttributes(tokens, opening) {
|
|
5313
|
+
if (opening.attributesStart < opening.attributesEnd) tokens.push(2, opening.attributesStart, opening.attributesEnd);
|
|
5314
|
+
}
|
|
5173
5315
|
function emitComponentBody(source, lines, tokens, start, end, closingOffset, context) {
|
|
5174
5316
|
let cursor = start;
|
|
5175
5317
|
const yamlEnd = cursor < end ? yamlPropsEnd(source, lines, cursor, end) : void 0;
|
|
@@ -5187,8 +5329,8 @@ function emitComponentBody(source, lines, tokens, start, end, closingOffset, con
|
|
|
5187
5329
|
const following = nextSlot(source, lines, slot.index + 1, end);
|
|
5188
5330
|
const next = following?.index ?? end;
|
|
5189
5331
|
const opening = slot.opening;
|
|
5190
|
-
tokens.push(
|
|
5191
|
-
|
|
5332
|
+
tokens.push(82, opening.offset, opening.nameEnd);
|
|
5333
|
+
emitOpeningAttributes(tokens, opening);
|
|
5192
5334
|
context.scanBlockLines(source, lines.view(slot.index + 1, next), tokens);
|
|
5193
5335
|
const slotEnd = following ? following.opening.offset : closingOffset;
|
|
5194
5336
|
tokens.push(201, slotEnd, slotEnd);
|
|
@@ -5196,46 +5338,25 @@ function emitComponentBody(source, lines, tokens, start, end, closingOffset, con
|
|
|
5196
5338
|
}
|
|
5197
5339
|
}
|
|
5198
5340
|
function emitOpening(tokens, contentOffset, opening) {
|
|
5199
|
-
tokens.push(
|
|
5200
|
-
if (opening.labelStart !== void 0 && opening.labelEnd !== void 0) tokens.pushInlineFrame(
|
|
5201
|
-
|
|
5341
|
+
tokens.push(81, contentOffset, opening.nameEnd);
|
|
5342
|
+
if (opening.labelStart !== void 0 && opening.labelEnd !== void 0) tokens.pushInlineFrame(83, opening.labelStart, opening.labelEnd, opening.labelStart + 1, opening.labelEnd - 1);
|
|
5343
|
+
emitOpeningAttributes(tokens, opening);
|
|
5202
5344
|
}
|
|
5203
5345
|
const buildBlockLabel = (tokenStart, context) => {
|
|
5204
5346
|
const tokens = context.structure.tokens;
|
|
5205
5347
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5206
5348
|
return {
|
|
5207
5349
|
type: "paragraph",
|
|
5208
|
-
children: buildInlineFragment(tokenStart,
|
|
5350
|
+
children: buildInlineFragment(tokenStart, context).children,
|
|
5209
5351
|
position: {
|
|
5210
5352
|
start,
|
|
5211
5353
|
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
5212
5354
|
}
|
|
5213
5355
|
};
|
|
5214
5356
|
};
|
|
5215
|
-
|
|
5216
|
-
return (source, lines, tokens, start, contentOffset, context) => {
|
|
5217
|
-
const opening = blockOpeningAt(source, lines, start, contentOffset, shorthand);
|
|
5218
|
-
if (!opening) return;
|
|
5219
|
-
if (shorthand) {
|
|
5220
|
-
emitOpening(tokens, contentOffset, opening);
|
|
5221
|
-
const lineEnd = lines.end(start);
|
|
5222
|
-
tokens.push(200, lineEnd, lineEnd);
|
|
5223
|
-
return start + 1;
|
|
5224
|
-
}
|
|
5225
|
-
const closing = blockClose(source, lines, start, opening);
|
|
5226
|
-
if (!closing) {
|
|
5227
|
-
context.retainLookahead(lines.next(lines.length - 1));
|
|
5228
|
-
return;
|
|
5229
|
-
}
|
|
5230
|
-
emitOpening(tokens, contentOffset, opening);
|
|
5231
|
-
emitComponentBody(source, lines, tokens, start + 1, closing.index, closing.offset, context);
|
|
5232
|
-
tokens.push(200, closing.offset, lines.end(closing.index));
|
|
5233
|
-
return closing.index + 1;
|
|
5234
|
-
};
|
|
5235
|
-
}
|
|
5236
|
-
const blockBuilds$1 = [
|
|
5357
|
+
const blockBuilds = [
|
|
5237
5358
|
{
|
|
5238
|
-
token:
|
|
5359
|
+
token: 83,
|
|
5239
5360
|
build: buildBlockLabel
|
|
5240
5361
|
},
|
|
5241
5362
|
{
|
|
@@ -5243,17 +5364,14 @@ const blockBuilds$1 = [
|
|
|
5243
5364
|
build: buildYamlBlock
|
|
5244
5365
|
},
|
|
5245
5366
|
{
|
|
5246
|
-
token:
|
|
5367
|
+
token: 81,
|
|
5247
5368
|
build(tokenStart, context) {
|
|
5248
5369
|
const tokens = context.structure.tokens;
|
|
5249
5370
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
5250
5371
|
let openingToken = tokenStart + 1;
|
|
5251
5372
|
let parsed;
|
|
5252
|
-
if (tokens.kind(openingToken) ===
|
|
5253
|
-
if (tokens.kind(openingToken) === 2)
|
|
5254
|
-
parsed = parseAttributes(context.source, tokens.start(openingToken));
|
|
5255
|
-
openingToken++;
|
|
5256
|
-
}
|
|
5373
|
+
if (tokens.kind(openingToken) === 83) openingToken += tokens.nodeLength(openingToken);
|
|
5374
|
+
if (tokens.kind(openingToken) === 2) parsed = parseAttributes(context.source, tokens.start(openingToken));
|
|
5257
5375
|
const nameEnd = tokens.end(tokenStart);
|
|
5258
5376
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5259
5377
|
const children = buildBlockChildren(tokenStart, context);
|
|
@@ -5261,47 +5379,63 @@ const blockBuilds$1 = [
|
|
|
5261
5379
|
type: "blockComponent",
|
|
5262
5380
|
name: normalizeComponentName(context.source.slice(context.source.lastIndexOf(":", nameEnd) + 1, nameEnd).trim()),
|
|
5263
5381
|
attributes: parsed ?? {},
|
|
5382
|
+
children,
|
|
5264
5383
|
position: {
|
|
5265
5384
|
start,
|
|
5266
5385
|
end: context.locator.locationAt(tokens.end(close))
|
|
5267
|
-
}
|
|
5268
|
-
children
|
|
5386
|
+
}
|
|
5269
5387
|
};
|
|
5270
5388
|
}
|
|
5271
5389
|
},
|
|
5272
5390
|
{
|
|
5273
|
-
token:
|
|
5391
|
+
token: 82,
|
|
5274
5392
|
build(tokenStart, context) {
|
|
5275
5393
|
const tokens = context.structure.tokens;
|
|
5276
5394
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
5277
5395
|
const attributesToken = tokens.kind(tokenStart + 1) === 2 ? tokenStart + 1 : void 0;
|
|
5278
5396
|
const parsed = attributesToken !== void 0 ? parseAttributes(context.source, tokens.start(attributesToken)) : void 0;
|
|
5279
5397
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5398
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
5280
5399
|
return {
|
|
5281
5400
|
type: "blockComponent",
|
|
5282
5401
|
name: "template",
|
|
5283
|
-
|
|
5402
|
+
attributes: {
|
|
5403
|
+
...parsed,
|
|
5404
|
+
name: normalizeComponentName(context.source.slice(tokens.start(tokenStart) + 1, tokens.end(tokenStart)))
|
|
5405
|
+
},
|
|
5406
|
+
children,
|
|
5284
5407
|
position: {
|
|
5285
5408
|
start,
|
|
5286
5409
|
end: context.locator.locationAt(tokens.end(close))
|
|
5287
|
-
},
|
|
5288
|
-
attributes: {
|
|
5289
|
-
...parsed,
|
|
5290
|
-
name: normalizeComponentName(context.source.slice(tokens.start(tokenStart) + 1, tokens.end(tokenStart)).trim())
|
|
5291
5410
|
}
|
|
5292
5411
|
};
|
|
5293
5412
|
}
|
|
5294
5413
|
}
|
|
5295
5414
|
];
|
|
5296
|
-
const blockStarts$
|
|
5415
|
+
const blockStarts$1 = [{
|
|
5297
5416
|
codes: [58],
|
|
5298
5417
|
interrupt(source, lines, index, contentOffset) {
|
|
5299
|
-
return blockOpeningAt(source, lines, index, contentOffset,
|
|
5418
|
+
return blockOpeningAt(source, lines, index, contentOffset, true) !== void 0;
|
|
5300
5419
|
},
|
|
5301
|
-
start
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5420
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
5421
|
+
const opening = blockOpeningAt(source, lines, start, contentOffset, true);
|
|
5422
|
+
if (!opening) return;
|
|
5423
|
+
if (opening.fenceSize === 1) {
|
|
5424
|
+
emitOpening(tokens, contentOffset, opening);
|
|
5425
|
+
const lineEnd = lines.end(start);
|
|
5426
|
+
tokens.push(200, lineEnd, lineEnd);
|
|
5427
|
+
return start + 1;
|
|
5428
|
+
}
|
|
5429
|
+
const closing = blockClose(source, lines, start, lines.length, opening);
|
|
5430
|
+
if (!closing) {
|
|
5431
|
+
context.retainLookahead(lines.next(lines.length - 1));
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5434
|
+
emitOpening(tokens, contentOffset, opening);
|
|
5435
|
+
emitComponentBody(source, lines, tokens, start + 1, closing.index, closing.offset, context);
|
|
5436
|
+
tokens.push(200, closing.offset, lines.end(closing.index));
|
|
5437
|
+
return closing.index + 1;
|
|
5438
|
+
}
|
|
5305
5439
|
}];
|
|
5306
5440
|
// src/profile/features/component/inline.ts
|
|
5307
5441
|
const inlineScans = [{
|
|
@@ -5324,10 +5458,10 @@ const buildInlineComponent = (open, close, position, children, context) => {
|
|
|
5324
5458
|
};
|
|
5325
5459
|
};
|
|
5326
5460
|
// src/profile/features/component/index.ts
|
|
5327
|
-
const feature$
|
|
5461
|
+
const feature$11 = {
|
|
5328
5462
|
block: {
|
|
5329
|
-
builds: blockBuilds
|
|
5330
|
-
starts: blockStarts$
|
|
5463
|
+
builds: blockBuilds,
|
|
5464
|
+
starts: blockStarts$1
|
|
5331
5465
|
},
|
|
5332
5466
|
inline: {
|
|
5333
5467
|
scans: inlineScans,
|
|
@@ -5364,14 +5498,15 @@ const feature$12 = {
|
|
|
5364
5498
|
function isShortcodeCharacter(code) {
|
|
5365
5499
|
return isAsciiLetter(code) || isAsciiDigit(code) || code === 43 || code === 45 || code === 95;
|
|
5366
5500
|
}
|
|
5367
|
-
const feature$
|
|
5501
|
+
const feature$10 = { inline: {
|
|
5368
5502
|
scans: [{
|
|
5369
5503
|
marker: 58,
|
|
5370
5504
|
scan(source, start, tokens) {
|
|
5371
5505
|
if (!hasInlineColonBoundary(source, start)) return -1;
|
|
5372
5506
|
let end = start + 1;
|
|
5373
|
-
|
|
5374
|
-
|
|
5507
|
+
let code = source.charCodeAt(end);
|
|
5508
|
+
while (isShortcodeCharacter(code)) code = source.charCodeAt(++end);
|
|
5509
|
+
if (end === start + 1 || code !== 58) return -1;
|
|
5375
5510
|
end++;
|
|
5376
5511
|
appendInlineToken(tokens, 135, start, end);
|
|
5377
5512
|
return end;
|
|
@@ -5389,103 +5524,6 @@ const feature$11 = { inline: {
|
|
|
5389
5524
|
}
|
|
5390
5525
|
}]
|
|
5391
5526
|
} };
|
|
5392
|
-
// src/profile/features/footnote/block.ts
|
|
5393
|
-
function definitionMarkerEnd(source, start, lineEnd) {
|
|
5394
|
-
const end = footnoteLabelEnd(source, start, lineEnd);
|
|
5395
|
-
if (end !== void 0 && source.charCodeAt(end) === 58) return end + 1;
|
|
5396
|
-
}
|
|
5397
|
-
// src/profile/features/footnote/index.ts
|
|
5398
|
-
const feature$10 = {
|
|
5399
|
-
block: {
|
|
5400
|
-
builds: [{
|
|
5401
|
-
token: 78,
|
|
5402
|
-
build(tokenStart, context) {
|
|
5403
|
-
const tokens = context.structure.tokens;
|
|
5404
|
-
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
5405
|
-
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5406
|
-
const children = buildBlockChildren(tokenStart, context);
|
|
5407
|
-
const fields = tokens.value(tokenStart);
|
|
5408
|
-
return {
|
|
5409
|
-
type: "footnoteDefinition",
|
|
5410
|
-
identifier: fields.normalizedLabel,
|
|
5411
|
-
label: decodeString(fields.label),
|
|
5412
|
-
children,
|
|
5413
|
-
position: {
|
|
5414
|
-
start,
|
|
5415
|
-
end: context.locator.locationAt(tokens.end(close))
|
|
5416
|
-
}
|
|
5417
|
-
};
|
|
5418
|
-
}
|
|
5419
|
-
}],
|
|
5420
|
-
starts: [{
|
|
5421
|
-
codes: [91],
|
|
5422
|
-
unwrap(source, lines, index, contentOffset, target) {
|
|
5423
|
-
const lineEnd = lines.end(index);
|
|
5424
|
-
const markerEnd = definitionMarkerEnd(source, contentOffset, lineEnd);
|
|
5425
|
-
if (markerEnd === void 0) return false;
|
|
5426
|
-
target.resetFrom(lines, index, trimLineWhitespaceStart(source, markerEnd, lineEnd), 0);
|
|
5427
|
-
return true;
|
|
5428
|
-
},
|
|
5429
|
-
interrupt(source, lines, index, contentOffset) {
|
|
5430
|
-
return definitionMarkerEnd(source, contentOffset, lines.end(index)) !== void 0;
|
|
5431
|
-
},
|
|
5432
|
-
start(source, lines, tokens, start, contentOffset, context) {
|
|
5433
|
-
const lineEnd = lines.end(start);
|
|
5434
|
-
const markerEnd = definitionMarkerEnd(source, contentOffset, lineEnd);
|
|
5435
|
-
if (markerEnd === void 0) return;
|
|
5436
|
-
const bodyStart = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
5437
|
-
const definitionLines = context.createLineView(lines, start, bodyStart, 0);
|
|
5438
|
-
let index = start + 1;
|
|
5439
|
-
let lazyParagraph;
|
|
5440
|
-
while (index < lines.length) {
|
|
5441
|
-
const line = definitionLines.pushAfterColumns(source, lines, index, 4);
|
|
5442
|
-
if (line === -2) {
|
|
5443
|
-
definitionLines.pushFrom(lines, index);
|
|
5444
|
-
lazyParagraph = false;
|
|
5445
|
-
index++;
|
|
5446
|
-
continue;
|
|
5447
|
-
}
|
|
5448
|
-
if (line === -3) {
|
|
5449
|
-
lazyParagraph = void 0;
|
|
5450
|
-
index++;
|
|
5451
|
-
continue;
|
|
5452
|
-
}
|
|
5453
|
-
lazyParagraph ??= context.endsWithParagraphLeaf(source, definitionLines, definitionLines.length - 1);
|
|
5454
|
-
if (!lazyParagraph || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index, line)) break;
|
|
5455
|
-
definitionLines.pushLazy(lines, index);
|
|
5456
|
-
index++;
|
|
5457
|
-
}
|
|
5458
|
-
while (definitionLines.length > 0 && isBlankLine(source, definitionLines, definitionLines.length - 1)) definitionLines.pop();
|
|
5459
|
-
const label = source.slice(contentOffset + 2, markerEnd - 2);
|
|
5460
|
-
const normalizedLabel = normalizeIdentifier(label);
|
|
5461
|
-
tokens.push(78, contentOffset, markerEnd, {
|
|
5462
|
-
definitionKey: footnoteDefinitionPrefix + normalizedLabel,
|
|
5463
|
-
value: {
|
|
5464
|
-
label,
|
|
5465
|
-
normalizedLabel
|
|
5466
|
-
}
|
|
5467
|
-
});
|
|
5468
|
-
context.scanBlockLines(source, definitionLines, tokens);
|
|
5469
|
-
const end = definitionLines.length > 0 ? definitionLines.next(definitionLines.length - 1) : markerEnd;
|
|
5470
|
-
tokens.push(197, end, end);
|
|
5471
|
-
return index;
|
|
5472
|
-
}
|
|
5473
|
-
}]
|
|
5474
|
-
},
|
|
5475
|
-
inline: { builds: [{
|
|
5476
|
-
kind: "leaf",
|
|
5477
|
-
token: 132,
|
|
5478
|
-
build(tokenIndex, position, context) {
|
|
5479
|
-
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 2, 1);
|
|
5480
|
-
return {
|
|
5481
|
-
type: "footnoteReference",
|
|
5482
|
-
identifier: normalizeIdentifier(label),
|
|
5483
|
-
label: decodeString(label),
|
|
5484
|
-
position
|
|
5485
|
-
};
|
|
5486
|
-
}
|
|
5487
|
-
}] }
|
|
5488
|
-
};
|
|
5489
5527
|
// src/profile/features/formatting.ts
|
|
5490
5528
|
function createFormatting(type, marker, buildToken, delimiter) {
|
|
5491
5529
|
return {
|
|
@@ -5511,14 +5549,8 @@ function createFormatting(type, marker, buildToken, delimiter) {
|
|
|
5511
5549
|
}
|
|
5512
5550
|
const formattingAsterisk = createFormatting("emphasis", 42, 192, {
|
|
5513
5551
|
token: 1,
|
|
5514
|
-
single:
|
|
5515
|
-
|
|
5516
|
-
close: 193
|
|
5517
|
-
},
|
|
5518
|
-
double: {
|
|
5519
|
-
open: 194,
|
|
5520
|
-
close: 195
|
|
5521
|
-
},
|
|
5552
|
+
single: 192,
|
|
5553
|
+
double: 194,
|
|
5522
5554
|
pairing: {
|
|
5523
5555
|
kind: "partial",
|
|
5524
5556
|
ruleOfThree: true
|
|
@@ -5526,14 +5558,8 @@ const formattingAsterisk = createFormatting("emphasis", 42, 192, {
|
|
|
5526
5558
|
});
|
|
5527
5559
|
const formattingUnderscore = createFormatting("strong", 95, 194, {
|
|
5528
5560
|
token: 2,
|
|
5529
|
-
single:
|
|
5530
|
-
|
|
5531
|
-
close: 193
|
|
5532
|
-
},
|
|
5533
|
-
double: {
|
|
5534
|
-
open: 194,
|
|
5535
|
-
close: 195
|
|
5536
|
-
},
|
|
5561
|
+
single: 192,
|
|
5562
|
+
double: 194,
|
|
5537
5563
|
pairing: {
|
|
5538
5564
|
kind: "partial",
|
|
5539
5565
|
ruleOfThree: true
|
|
@@ -5542,10 +5568,7 @@ const formattingUnderscore = createFormatting("strong", 95, 194, {
|
|
|
5542
5568
|
});
|
|
5543
5569
|
const formattingStrikethrough = createFormatting("delete", 126, 196, {
|
|
5544
5570
|
token: 3,
|
|
5545
|
-
double:
|
|
5546
|
-
open: 196,
|
|
5547
|
-
close: 197
|
|
5548
|
-
},
|
|
5571
|
+
double: 196,
|
|
5549
5572
|
pairing: { kind: "whole" }
|
|
5550
5573
|
});
|
|
5551
5574
|
function feature$9(strikethroughOptions) {
|
|
@@ -5569,39 +5592,18 @@ function feature$9(strikethroughOptions) {
|
|
|
5569
5592
|
// src/profile/features/heading.ts
|
|
5570
5593
|
function atxMarkerEnd(source, markerOffset, lineEnd) {
|
|
5571
5594
|
let markerEnd = markerOffset + 1;
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
if (code !== 32 && code !== 9) return 0;
|
|
5576
|
-
}
|
|
5577
|
-
return markerEnd;
|
|
5595
|
+
let code = source.charCodeAt(markerEnd);
|
|
5596
|
+
while (markerEnd < lineEnd && markerEnd - markerOffset < 6 && code === 35) code = source.charCodeAt(++markerEnd);
|
|
5597
|
+
return markerEnd < lineEnd && code !== 32 && code !== 9 ? 0 : markerEnd;
|
|
5578
5598
|
}
|
|
5579
5599
|
function setextMarkerAt(source, marker, markerOffset, lineEnd) {
|
|
5580
5600
|
if (marker !== 61 && marker !== 45) return;
|
|
5581
5601
|
let offset = markerOffset + 1;
|
|
5582
|
-
|
|
5583
|
-
offset =
|
|
5602
|
+
let code = source.charCodeAt(offset);
|
|
5603
|
+
while (offset < lineEnd && code === marker) code = source.charCodeAt(++offset);
|
|
5604
|
+
if (code === 32 || code === 9) offset = trimLineWhitespaceStart(source, offset + 1, lineEnd);
|
|
5584
5605
|
return offset === lineEnd ? marker : void 0;
|
|
5585
5606
|
}
|
|
5586
|
-
function createBuildHeading(openKind) {
|
|
5587
|
-
return (tokenStart, context) => {
|
|
5588
|
-
const tokens = context.structure.tokens;
|
|
5589
|
-
const kind = tokens.kind(tokenStart);
|
|
5590
|
-
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5591
|
-
const inline = buildInlineFragment(tokenStart, false, context);
|
|
5592
|
-
const result = {
|
|
5593
|
-
type: "heading",
|
|
5594
|
-
depth: kind - openKind + 1,
|
|
5595
|
-
children: inline.children,
|
|
5596
|
-
position: {
|
|
5597
|
-
start,
|
|
5598
|
-
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
5599
|
-
}
|
|
5600
|
-
};
|
|
5601
|
-
if (inline.attributes) result.attributes = inline.attributes;
|
|
5602
|
-
return result;
|
|
5603
|
-
};
|
|
5604
|
-
}
|
|
5605
5607
|
const feature$8 = { block: {
|
|
5606
5608
|
builds: [{
|
|
5607
5609
|
token: [
|
|
@@ -5612,10 +5614,22 @@ const feature$8 = { block: {
|
|
|
5612
5614
|
68,
|
|
5613
5615
|
69
|
|
5614
5616
|
],
|
|
5615
|
-
build
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5617
|
+
build(tokenStart, context) {
|
|
5618
|
+
const tokens = context.structure.tokens;
|
|
5619
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
5620
|
+
const inline = buildInlineFragment(tokenStart, context);
|
|
5621
|
+
const result = {
|
|
5622
|
+
type: "heading",
|
|
5623
|
+
depth: tokens.kind(tokenStart) - 64 + 1,
|
|
5624
|
+
children: inline.children,
|
|
5625
|
+
position: {
|
|
5626
|
+
start,
|
|
5627
|
+
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
5628
|
+
}
|
|
5629
|
+
};
|
|
5630
|
+
if (inline.attributes) result.attributes = inline.attributes;
|
|
5631
|
+
return result;
|
|
5632
|
+
}
|
|
5619
5633
|
}],
|
|
5620
5634
|
starts: [{
|
|
5621
5635
|
codes: [35],
|
|
@@ -5652,8 +5666,11 @@ const htmlAttribute = `\\s+[a-z_:][\\w.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'
|
|
|
5652
5666
|
const htmlTag = /^<\/?([a-z][a-z0-9-]*)(?=[ \t\n\r/>]|$)/i;
|
|
5653
5667
|
const htmlTagDelimiter = /[ \t>]/;
|
|
5654
5668
|
const completeHtmlTag = new RegExp(`^(?:<${htmlTagName}(?:${htmlAttribute})*\\s*/?>|</${htmlTagName}\\s*>)[ \\t]*$`, "i");
|
|
5655
|
-
const htmlComment = /<!--(
|
|
5656
|
-
const
|
|
5669
|
+
const htmlComment = /<!--(?:-?>|.*?-->)/sy;
|
|
5670
|
+
const uriAutolink = /[A-Z][A-Z0-9+.\-]{1,31}:[^\x00-\x20\x7f<>]*/;
|
|
5671
|
+
const emailLocal = /[\w!#$%&'*+\-/=?^`{|}~.]+/;
|
|
5672
|
+
const domainLabel = /[A-Z0-9][A-Z0-9-]{0,62}\b/;
|
|
5673
|
+
const autolink = new RegExp(`<(?:${uriAutolink.source}|${emailLocal.source}@${domainLabel.source}(?:\\.${domainLabel.source})*)>`, "iy");
|
|
5657
5674
|
const inlineHtml = /<[A-Za-z][A-Za-z0-9-]*(?:[ \t\n\r]+[A-Za-z_:][\w.:-]*(?:[ \t\n\r]*=[ \t\n\r]*(?:[^ \t\n\r"'=<>`]+|'[^']*'|"[^"]*"))?)*[ \t\n\r]*\/?>|<\/[A-Za-z][A-Za-z0-9-]*[ \t\n\r]*>|<\?[\s\S]*?\?>|<![A-Za-z][\s\S]*?>|<!\[CDATA\[[\s\S]*?\]\]>/y;
|
|
5658
5675
|
function htmlTerminator(body, allowCompleteTag) {
|
|
5659
5676
|
switch (body.charCodeAt(1)) {
|
|
@@ -5707,12 +5724,14 @@ const feature$7 = {
|
|
|
5707
5724
|
scans: [{
|
|
5708
5725
|
marker: 60,
|
|
5709
5726
|
scan(source, start, tokens) {
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5727
|
+
if (source.startsWith("<!--", start)) {
|
|
5728
|
+
const end = findPatternEnd(source, start, htmlComment);
|
|
5729
|
+
if (end < 0) return start + 1;
|
|
5730
|
+
appendInlineToken(tokens, 130, start, end);
|
|
5731
|
+
return end;
|
|
5715
5732
|
}
|
|
5733
|
+
let end = findPatternEnd(source, start, autolink);
|
|
5734
|
+
let kind = 131;
|
|
5716
5735
|
if (end < 0) {
|
|
5717
5736
|
end = findPatternEnd(source, start, inlineHtml);
|
|
5718
5737
|
kind = 130;
|
|
@@ -5771,46 +5790,40 @@ function linkDestinationEnd(source, start, end) {
|
|
|
5771
5790
|
}
|
|
5772
5791
|
return end > start && depth === 0 ? end : -1;
|
|
5773
5792
|
}
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5793
|
+
const titleLineEnding = /[\r\n]/;
|
|
5794
|
+
const titleIndent = /(?<=[\r\n])[ \t]+/g;
|
|
5795
|
+
const titleTail = /(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\((?:[^()\\]|\\.)*\))[ \t\r\n]*/sy;
|
|
5796
|
+
const destinationBoundary = /.*?[<\\()\t\n\r ]/sy;
|
|
5797
|
+
function decodeLinkTitle(source) {
|
|
5798
|
+
return decodeString(titleLineEnding.test(source) ? source.replace(titleIndent, "") : source);
|
|
5799
|
+
}
|
|
5800
|
+
function resourceTail(source, destinationEnd) {
|
|
5801
|
+
const start = skipWhitespace(source, destinationEnd);
|
|
5802
|
+
if (source.charCodeAt(start) === 41) return start;
|
|
5803
|
+
if (start === destinationEnd) return -1;
|
|
5804
|
+
const tail = findPatternEnd(source, start, titleTail);
|
|
5805
|
+
return source.charCodeAt(tail) === 41 ? tail : -1;
|
|
5786
5806
|
}
|
|
5787
|
-
const destinationTail = /[^<\\()\t\n\r ]*\)?/y;
|
|
5788
5807
|
function scanLinkTail(source, start, tokens) {
|
|
5789
5808
|
if (source.charCodeAt(start + 1) !== 40) return -1;
|
|
5790
5809
|
const contentStart = start + 2;
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
const prefixEnd =
|
|
5794
|
-
if (source.charCodeAt(prefixEnd
|
|
5795
|
-
|
|
5796
|
-
|
|
5810
|
+
destinationBoundary.lastIndex = contentStart;
|
|
5811
|
+
if (!destinationBoundary.test(source)) return -1;
|
|
5812
|
+
const prefixEnd = destinationBoundary.lastIndex - 1;
|
|
5813
|
+
if (source.charCodeAt(prefixEnd) === 41) {
|
|
5814
|
+
const end = prefixEnd + 1;
|
|
5815
|
+
appendInlineToken(tokens, 68, start, end);
|
|
5816
|
+
return end;
|
|
5797
5817
|
}
|
|
5798
5818
|
let offset = skipWhitespace(source, contentStart);
|
|
5799
|
-
let destinationEnd = offset;
|
|
5800
5819
|
if (source.charCodeAt(offset) !== 41) {
|
|
5801
|
-
destinationEnd = linkDestinationEnd(source, offset, Math.max(offset, prefixEnd));
|
|
5820
|
+
const destinationEnd = linkDestinationEnd(source, offset, Math.max(offset, prefixEnd));
|
|
5802
5821
|
if (destinationEnd < 0) return -1;
|
|
5803
|
-
offset = destinationEnd;
|
|
5804
|
-
|
|
5805
|
-
if (whitespaceEnd > offset && source.charCodeAt(whitespaceEnd) !== 41) {
|
|
5806
|
-
const titleEnd = linkTitleEnd(source, whitespaceEnd);
|
|
5807
|
-
if (titleEnd < 0) return -1;
|
|
5808
|
-
offset = skipWhitespace(source, titleEnd);
|
|
5809
|
-
} else offset = whitespaceEnd;
|
|
5810
|
-
if (source.charCodeAt(offset) !== 41) return -1;
|
|
5822
|
+
offset = resourceTail(source, destinationEnd);
|
|
5823
|
+
if (offset < 0) return -1;
|
|
5811
5824
|
}
|
|
5812
|
-
const end =
|
|
5813
|
-
appendInlineToken(tokens,
|
|
5825
|
+
const end = start + 1;
|
|
5826
|
+
appendInlineToken(tokens, 6, start, end, offset + 1);
|
|
5814
5827
|
return end;
|
|
5815
5828
|
}
|
|
5816
5829
|
function phrasingText(children) {
|
|
@@ -5843,23 +5856,22 @@ function createBuildMedia(media, resourceKind) {
|
|
|
5843
5856
|
position
|
|
5844
5857
|
} : {
|
|
5845
5858
|
type: "linkReference",
|
|
5846
|
-
children,
|
|
5847
5859
|
identifier,
|
|
5848
5860
|
label,
|
|
5849
5861
|
referenceType,
|
|
5862
|
+
children,
|
|
5850
5863
|
position
|
|
5851
5864
|
};
|
|
5852
5865
|
} : (openToken, closeToken, position, children, context) => {
|
|
5853
5866
|
const source = context.view.text;
|
|
5854
|
-
const tokenStart = inlineTokenStart(context.tokens, closeToken);
|
|
5855
5867
|
const end = inlineTokenEnd(context.tokens, closeToken) - 1;
|
|
5856
|
-
let start =
|
|
5868
|
+
let start = inlineTokenStart(context.tokens, closeToken) + 2;
|
|
5857
5869
|
let destinationEnd = end;
|
|
5858
5870
|
let title = null;
|
|
5859
|
-
const
|
|
5860
|
-
if (
|
|
5861
|
-
|
|
5862
|
-
|
|
5871
|
+
const general = inlineTokenData(context.tokens, closeToken) !== 0;
|
|
5872
|
+
if (general) {
|
|
5873
|
+
start = skipWhitespace(source, start, end);
|
|
5874
|
+
const resourceEnd = start < end ? linkDestinationEnd(source, start, start) : start;
|
|
5863
5875
|
destinationEnd = resourceEnd;
|
|
5864
5876
|
if (source.charCodeAt(start) === 60) {
|
|
5865
5877
|
start++;
|
|
@@ -5869,10 +5881,11 @@ function createBuildMedia(media, resourceKind) {
|
|
|
5869
5881
|
if (titleStart < end) {
|
|
5870
5882
|
let titleEnd = end;
|
|
5871
5883
|
while (isSpaceTabOrLineEnding(source.charCodeAt(titleEnd - 1))) titleEnd--;
|
|
5872
|
-
title =
|
|
5884
|
+
title = decodeLinkTitle(source.slice(titleStart + 1, titleEnd - 1));
|
|
5873
5885
|
}
|
|
5874
5886
|
}
|
|
5875
|
-
const
|
|
5887
|
+
const destination = source.slice(start, destinationEnd);
|
|
5888
|
+
const url = general ? decodeString(destination) : decodeEntities(destination);
|
|
5876
5889
|
return isImage ? {
|
|
5877
5890
|
type: "image",
|
|
5878
5891
|
alt: phrasingText(children),
|
|
@@ -5881,9 +5894,9 @@ function createBuildMedia(media, resourceKind) {
|
|
|
5881
5894
|
position
|
|
5882
5895
|
} : {
|
|
5883
5896
|
type: "link",
|
|
5884
|
-
children,
|
|
5885
5897
|
url,
|
|
5886
5898
|
title,
|
|
5899
|
+
children,
|
|
5887
5900
|
position
|
|
5888
5901
|
};
|
|
5889
5902
|
};
|
|
@@ -5974,7 +5987,7 @@ const feature$6 = { inline: {
|
|
|
5974
5987
|
{
|
|
5975
5988
|
kind: "text",
|
|
5976
5989
|
token: 68,
|
|
5977
|
-
build: (tokenIndex, context) =>
|
|
5990
|
+
build: (tokenIndex, context) => decodeEntities(inlineTokenText(context.view.text, context.tokens, tokenIndex))
|
|
5978
5991
|
}
|
|
5979
5992
|
]
|
|
5980
5993
|
} };
|
|
@@ -5989,26 +6002,26 @@ function listMarkerAt(source, lines, index, contentOffset) {
|
|
|
5989
6002
|
if (marker === 45 || marker === 43 || marker === 42) delimiter = marker;
|
|
5990
6003
|
else {
|
|
5991
6004
|
if (!isAsciiDigit(marker)) return;
|
|
5992
|
-
while (markerEnd < lineEnd && markerEnd - contentOffset < 9 && isAsciiDigit(source.charCodeAt(markerEnd))) markerEnd++;
|
|
5993
6005
|
delimiter = source.charCodeAt(markerEnd);
|
|
6006
|
+
while (markerEnd < lineEnd && markerEnd - contentOffset < 9 && isAsciiDigit(delimiter)) delimiter = source.charCodeAt(++markerEnd);
|
|
5994
6007
|
if (delimiter !== 46 && delimiter !== 41) return;
|
|
5995
6008
|
markerEnd++;
|
|
5996
6009
|
}
|
|
5997
6010
|
const padding = source.charCodeAt(markerEnd);
|
|
5998
6011
|
if (markerEnd < lineEnd && padding !== 32 && padding !== 9) return;
|
|
5999
|
-
const markerColumn = lines
|
|
6012
|
+
const markerColumn = lineIndentColumns(source, lines, index, contentOffset) + markerEnd - contentOffset;
|
|
6000
6013
|
let contentIndent = markerColumn + 1;
|
|
6001
6014
|
let contentStart = markerEnd;
|
|
6002
6015
|
let hasContent = false;
|
|
6003
6016
|
let prefixColumns = 0;
|
|
6004
6017
|
if (markerEnd < lineEnd) {
|
|
6005
|
-
const firstPaddingColumns = padding === 9 ?
|
|
6018
|
+
const firstPaddingColumns = padding === 9 ? tabWidthAt(source, markerEnd) : 1;
|
|
6006
6019
|
let column = markerColumn + firstPaddingColumns;
|
|
6007
6020
|
contentStart++;
|
|
6008
6021
|
while (contentStart < lineEnd) {
|
|
6009
6022
|
const code = source.charCodeAt(contentStart);
|
|
6010
6023
|
if (code === 32) column++;
|
|
6011
|
-
else if (code === 9) column +=
|
|
6024
|
+
else if (code === 9) column += tabWidthAt(source, contentStart);
|
|
6012
6025
|
else {
|
|
6013
6026
|
if (code === marker && isThematicBreak(source, lines, index, contentOffset)) return;
|
|
6014
6027
|
break;
|
|
@@ -6033,7 +6046,6 @@ function listMarkerAt(source, lines, index, contentOffset) {
|
|
|
6033
6046
|
};
|
|
6034
6047
|
}
|
|
6035
6048
|
function taskListMarkerAt(source, start, end) {
|
|
6036
|
-
while (source.charCodeAt(start) === 32) start++;
|
|
6037
6049
|
if (source.charCodeAt(start++) !== 91) return;
|
|
6038
6050
|
const state = source.charCodeAt(start++);
|
|
6039
6051
|
const checked = state === 88 || state === 120;
|
|
@@ -6065,8 +6077,8 @@ const buildListItem = (tokenStart, context) => {
|
|
|
6065
6077
|
const children = buildBlockChildren(tokenStart, context);
|
|
6066
6078
|
return {
|
|
6067
6079
|
type: "listItem",
|
|
6080
|
+
checked: markerKind === 75 ? true : markerKind === 74 ? false : null,
|
|
6068
6081
|
spread: tokens.kind(close) === 194,
|
|
6069
|
-
checked: markerKind === 77 ? true : markerKind === 76 ? false : null,
|
|
6070
6082
|
children,
|
|
6071
6083
|
position: {
|
|
6072
6084
|
start,
|
|
@@ -6101,60 +6113,59 @@ const listStart = (source, lines, tokens, start, contentOffset, context) => {
|
|
|
6101
6113
|
let marker = listMarkerAt(source, lines, start, contentOffset);
|
|
6102
6114
|
if (!marker) return;
|
|
6103
6115
|
const delimiter = marker.delimiter;
|
|
6104
|
-
const listOpen = delimiter === 46 || delimiter === 41 ?
|
|
6116
|
+
const listOpen = delimiter === 46 || delimiter === 41 ? 72 : 71;
|
|
6105
6117
|
tokens.push(listOpen, marker.offset, marker.end);
|
|
6106
6118
|
let index = start;
|
|
6107
6119
|
let listEnd = marker.end;
|
|
6108
6120
|
let listSpread = false;
|
|
6109
6121
|
let trailingBlank = false;
|
|
6122
|
+
let itemLines;
|
|
6123
|
+
let itemSpread;
|
|
6124
|
+
let previousEnd;
|
|
6125
|
+
const visit = (lineStart, lineEnd) => {
|
|
6126
|
+
itemSpread ||= previousEnd >= 0 && (lineStart > previousEnd || isBlankLine(source, itemLines, previousEnd - 1));
|
|
6127
|
+
previousEnd = lineEnd;
|
|
6128
|
+
};
|
|
6110
6129
|
while (marker?.delimiter === delimiter) {
|
|
6111
6130
|
let sibling;
|
|
6112
6131
|
listSpread ||= trailingBlank;
|
|
6113
6132
|
trailingBlank = false;
|
|
6114
|
-
tokens.push(
|
|
6115
|
-
|
|
6133
|
+
tokens.push(73, marker.offset, marker.end);
|
|
6134
|
+
itemLines = lines.child(index, marker.contentOffset, marker.contentPrefixColumns);
|
|
6116
6135
|
let hasContent = marker.hasContent;
|
|
6117
|
-
let paragraphLeaf = hasContent ? 2 : 0;
|
|
6118
6136
|
index++;
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
if (
|
|
6137
|
+
for (; index < lines.length; index++) {
|
|
6138
|
+
if (!lines.lazy(index)) {
|
|
6139
|
+
const line = itemLines.pushAfterColumns(source, lines, index, marker.contentIndent);
|
|
6140
|
+
if (line === -2) {
|
|
6141
|
+
if (!hasContent) {
|
|
6142
|
+
trailingBlank = true;
|
|
6143
|
+
index++;
|
|
6144
|
+
sibling = index < lines.length ? listMarkerAt(source, lines, index, lineIndentOffset(source, lines, index)) : void 0;
|
|
6145
|
+
break;
|
|
6146
|
+
}
|
|
6147
|
+
itemLines.pushFrom(lines, index);
|
|
6123
6148
|
trailingBlank = true;
|
|
6124
|
-
|
|
6125
|
-
|
|
6149
|
+
continue;
|
|
6150
|
+
}
|
|
6151
|
+
if (line === -3) {
|
|
6152
|
+
trailingBlank = false;
|
|
6153
|
+
hasContent = true;
|
|
6154
|
+
continue;
|
|
6155
|
+
}
|
|
6156
|
+
const candidate = listMarkerAt(source, lines, index, line);
|
|
6157
|
+
if (candidate) {
|
|
6158
|
+
sibling = candidate;
|
|
6126
6159
|
break;
|
|
6127
6160
|
}
|
|
6128
|
-
|
|
6129
|
-
trailingBlank = true;
|
|
6130
|
-
paragraphLeaf = 0;
|
|
6131
|
-
index++;
|
|
6132
|
-
continue;
|
|
6133
|
-
}
|
|
6134
|
-
if (line === -3) {
|
|
6135
|
-
trailingBlank = false;
|
|
6136
|
-
hasContent = true;
|
|
6137
|
-
paragraphLeaf = 2;
|
|
6138
|
-
index++;
|
|
6139
|
-
continue;
|
|
6140
|
-
}
|
|
6141
|
-
const candidate = listMarkerAt(source, lines, index, line);
|
|
6142
|
-
if (candidate) {
|
|
6143
|
-
sibling = candidate;
|
|
6144
|
-
break;
|
|
6161
|
+
if (trailingBlank || !hasContent || context.startsInterruptingBlock(source, lines, index, line) || !context.endsWithParagraphLeaf(source, itemLines, itemLines.length - 1)) break;
|
|
6145
6162
|
}
|
|
6146
|
-
|
|
6147
|
-
if (paragraphLeaf === 0 || context.startsInterruptingBlock(source, lines, index, line)) break;
|
|
6148
|
-
itemLines.pushLazy(lines, index);
|
|
6149
|
-
index++;
|
|
6163
|
+
itemLines.pushFrom(lines, index, void 0, void 0, true);
|
|
6150
6164
|
}
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
context.scanBlockLines(source, itemLines, tokens,
|
|
6154
|
-
|
|
6155
|
-
previousEnd = lineEnd;
|
|
6156
|
-
});
|
|
6157
|
-
const itemEnd = itemLines.length ? itemLines.end(itemLines.length - 1) : marker.end;
|
|
6165
|
+
previousEnd = -1;
|
|
6166
|
+
itemSpread = false;
|
|
6167
|
+
context.scanBlockLines(source, itemLines, tokens, 0, visit);
|
|
6168
|
+
const itemEnd = itemLines.end(itemLines.length - 1);
|
|
6158
6169
|
tokens.push(itemSpread ? 194 : 193, itemEnd, itemEnd);
|
|
6159
6170
|
listEnd = itemEnd;
|
|
6160
6171
|
marker = sibling;
|
|
@@ -6173,11 +6184,11 @@ const taskListStart = (source, lines, tokens, start, contentOffset, context) =>
|
|
|
6173
6184
|
paragraph += tokens.nodeLength(paragraph);
|
|
6174
6185
|
contentKind = tokens.kind(paragraph);
|
|
6175
6186
|
}
|
|
6176
|
-
if (contentKind !==
|
|
6187
|
+
if (contentKind !== 77) continue;
|
|
6177
6188
|
const firstChunk = paragraph + 1;
|
|
6178
6189
|
const marker = taskListMarkerAt(source, tokens.start(firstChunk), tokens.end(firstChunk));
|
|
6179
6190
|
if (!marker || !hasTaskListContent(source, tokens, firstChunk, marker.contentStart)) continue;
|
|
6180
|
-
tokens.setKind(item, marker.checked ?
|
|
6191
|
+
tokens.setKind(item, marker.checked ? 75 : 74);
|
|
6181
6192
|
tokens.setStart(firstChunk, marker.contentStart);
|
|
6182
6193
|
}
|
|
6183
6194
|
return nextLine;
|
|
@@ -6187,18 +6198,18 @@ function feature$5(taskList = false) {
|
|
|
6187
6198
|
builds: [
|
|
6188
6199
|
{
|
|
6189
6200
|
token: [
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6201
|
+
73,
|
|
6202
|
+
74,
|
|
6203
|
+
75
|
|
6193
6204
|
],
|
|
6194
6205
|
build: buildListItem
|
|
6195
6206
|
},
|
|
6196
6207
|
{
|
|
6197
|
-
token:
|
|
6208
|
+
token: 71,
|
|
6198
6209
|
build: createBuildList(false)
|
|
6199
6210
|
},
|
|
6200
6211
|
{
|
|
6201
|
-
token:
|
|
6212
|
+
token: 72,
|
|
6202
6213
|
build: createBuildList(true)
|
|
6203
6214
|
}
|
|
6204
6215
|
],
|
|
@@ -6218,11 +6229,9 @@ function feature$5(taskList = false) {
|
|
|
6218
6229
|
56,
|
|
6219
6230
|
57
|
|
6220
6231
|
],
|
|
6221
|
-
unwrap(source, lines, index, contentOffset
|
|
6232
|
+
unwrap(source, lines, index, contentOffset) {
|
|
6222
6233
|
const marker = listMarkerAt(source, lines, index, contentOffset);
|
|
6223
|
-
if (
|
|
6224
|
-
target.resetFrom(lines, index, marker.contentOffset, marker.contentPrefixColumns);
|
|
6225
|
-
return true;
|
|
6234
|
+
if (marker) return lines.child(index, marker.contentOffset, marker.contentPrefixColumns);
|
|
6226
6235
|
},
|
|
6227
6236
|
interrupt(source, lines, index, contentOffset) {
|
|
6228
6237
|
interruptingMarker.lastIndex = contentOffset;
|
|
@@ -6288,39 +6297,51 @@ function feature$4(options) {
|
|
|
6288
6297
|
const feature$3 = { block: {
|
|
6289
6298
|
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
6290
6299
|
const openToken = tokens.openInlineFrame();
|
|
6291
|
-
let kind =
|
|
6300
|
+
let kind = 77;
|
|
6292
6301
|
let underlineEnd;
|
|
6293
6302
|
let chunkOffset = contentOffset;
|
|
6294
6303
|
let chunkEnd = lines.end(start);
|
|
6295
|
-
let
|
|
6304
|
+
let hasPaddedLineFeed = false;
|
|
6296
6305
|
let index = start + 1;
|
|
6297
6306
|
while (index < lines.length) {
|
|
6298
6307
|
const lineStart = lines.start(index);
|
|
6299
6308
|
const lineEnd = lines.end(index);
|
|
6309
|
+
const prefixColumns = lines.prefixColumns(index);
|
|
6300
6310
|
let spaceEnd = lineStart;
|
|
6301
6311
|
let first = source.charCodeAt(spaceEnd);
|
|
6302
6312
|
while (spaceEnd < lineEnd && first === 32) first = source.charCodeAt(++spaceEnd);
|
|
6303
|
-
|
|
6313
|
+
let contentStart = spaceEnd;
|
|
6314
|
+
let columns = prefixColumns + spaceEnd - lineStart;
|
|
6315
|
+
if (spaceEnd < lineEnd && first === 9) while (contentStart < lineEnd) {
|
|
6316
|
+
const code = source.charCodeAt(contentStart);
|
|
6317
|
+
if (code === 32) columns++;
|
|
6318
|
+
else if (code === 9) columns += tabWidthAt(source, contentStart);
|
|
6319
|
+
else {
|
|
6320
|
+
first = code;
|
|
6321
|
+
break;
|
|
6322
|
+
}
|
|
6323
|
+
contentStart++;
|
|
6324
|
+
}
|
|
6304
6325
|
if (contentStart === lineEnd) break;
|
|
6305
|
-
|
|
6306
|
-
if (!lines.lazy(index) && chunkStart === contentStart) {
|
|
6326
|
+
if (!lines.lazy(index) && columns <= 3) {
|
|
6307
6327
|
const setext = setextMarkerAt(source, first, contentStart, lineEnd);
|
|
6308
6328
|
if (setext) {
|
|
6309
|
-
kind = setext === 61 ?
|
|
6329
|
+
kind = setext === 61 ? 64 : 65;
|
|
6310
6330
|
underlineEnd = lineEnd;
|
|
6311
6331
|
index++;
|
|
6312
6332
|
break;
|
|
6313
6333
|
}
|
|
6314
6334
|
if (context.startsInterruptingBlock(source, lines, index, contentStart)) break;
|
|
6315
6335
|
}
|
|
6336
|
+
const chunkStart = contentStart > spaceEnd ? contentStart : Math.min(spaceEnd, lineStart + Math.max(0, 3 - prefixColumns));
|
|
6316
6337
|
const previousEnd = lines.next(index - 1);
|
|
6317
|
-
if (!
|
|
6338
|
+
if (!hasPaddedLineFeed) {
|
|
6318
6339
|
let padded = chunkStart < spaceEnd;
|
|
6319
6340
|
if (!padded) {
|
|
6320
6341
|
const previous = source.charCodeAt(chunkEnd - 1);
|
|
6321
6342
|
padded = previous === 32 || previous === 9;
|
|
6322
6343
|
}
|
|
6323
|
-
if (padded && source.charCodeAt(chunkEnd) === 10)
|
|
6344
|
+
if (padded && source.charCodeAt(chunkEnd) === 10) hasPaddedLineFeed = true;
|
|
6324
6345
|
}
|
|
6325
6346
|
if (chunkStart !== previousEnd) {
|
|
6326
6347
|
tokens.push(1, chunkOffset, previousEnd);
|
|
@@ -6330,15 +6351,15 @@ const feature$3 = { block: {
|
|
|
6330
6351
|
index++;
|
|
6331
6352
|
}
|
|
6332
6353
|
tokens.closeInlineFrame(openToken, kind, contentOffset, underlineEnd ?? chunkEnd, chunkOffset, chunkEnd);
|
|
6333
|
-
if (
|
|
6354
|
+
if (hasPaddedLineFeed) tokens.setValue(openToken, paddedLineFeed);
|
|
6334
6355
|
return index;
|
|
6335
6356
|
}],
|
|
6336
6357
|
builds: [{
|
|
6337
|
-
token:
|
|
6358
|
+
token: 77,
|
|
6338
6359
|
build(tokenStart, context) {
|
|
6339
6360
|
const tokens = context.structure.tokens;
|
|
6340
6361
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
6341
|
-
const inline = buildInlineFragment(tokenStart,
|
|
6362
|
+
const inline = buildInlineFragment(tokenStart, context);
|
|
6342
6363
|
const result = {
|
|
6343
6364
|
type: "paragraph",
|
|
6344
6365
|
children: inline.children,
|
|
@@ -6360,40 +6381,35 @@ function titleCloser(code) {
|
|
|
6360
6381
|
}
|
|
6361
6382
|
function scanMultilineLabel(source, lines, startIndex, labelStart, offset, context) {
|
|
6362
6383
|
let lineIndex = startIndex;
|
|
6363
|
-
let
|
|
6364
|
-
let
|
|
6365
|
-
if (labelLength > 999) return;
|
|
6366
|
-
let labelHasContent = trimLineWhitespaceStart(source, labelStart, offset) < offset;
|
|
6384
|
+
let lineStart = labelStart;
|
|
6385
|
+
let remaining = maximumLabelUnits;
|
|
6367
6386
|
while (true) {
|
|
6368
6387
|
const lineEnd = lines.end(lineIndex);
|
|
6369
|
-
|
|
6388
|
+
const limit = Math.min(lineEnd, lineStart + remaining + 1);
|
|
6389
|
+
while (offset < limit) {
|
|
6370
6390
|
const code = source.charCodeAt(offset);
|
|
6371
6391
|
if (code === 92 && offset + 1 < lineEnd) {
|
|
6372
|
-
labelHasContent = true;
|
|
6373
|
-
labelLength += 2;
|
|
6374
6392
|
offset += 2;
|
|
6375
6393
|
continue;
|
|
6376
6394
|
}
|
|
6377
6395
|
if (code === 91) return;
|
|
6378
6396
|
if (code === 93) {
|
|
6379
|
-
if (source.charCodeAt(offset + 1) === 58
|
|
6380
|
-
label:
|
|
6397
|
+
if (source.charCodeAt(offset + 1) === 58) return {
|
|
6398
|
+
label: sliceLines(source, lines, startIndex, labelStart, lineIndex, offset),
|
|
6381
6399
|
lineIndex,
|
|
6382
6400
|
offset: offset + 2
|
|
6383
6401
|
};
|
|
6384
6402
|
return;
|
|
6385
6403
|
}
|
|
6386
|
-
if (code !== 32 && code !== 9) labelHasContent = true;
|
|
6387
|
-
if (++labelLength > 999) return;
|
|
6388
6404
|
offset++;
|
|
6389
6405
|
}
|
|
6390
6406
|
const nextLine = lineIndex + 1;
|
|
6391
6407
|
context.retainLookahead(nextLine < lines.length ? lines.end(nextLine) : lines.next(lineIndex));
|
|
6392
|
-
|
|
6393
|
-
|
|
6408
|
+
remaining -= lines.next(lineIndex) - lineStart;
|
|
6409
|
+
if (remaining < 0 || nextLine >= lines.length || isBlankLine(source, lines, nextLine)) return;
|
|
6394
6410
|
lineIndex = nextLine;
|
|
6395
6411
|
offset = lines.start(lineIndex);
|
|
6396
|
-
|
|
6412
|
+
lineStart = offset;
|
|
6397
6413
|
}
|
|
6398
6414
|
}
|
|
6399
6415
|
function scanAngleDestination(source, start, lineEnd) {
|
|
@@ -6412,7 +6428,7 @@ function scanAngleDestination(source, start, lineEnd) {
|
|
|
6412
6428
|
}
|
|
6413
6429
|
return end;
|
|
6414
6430
|
}
|
|
6415
|
-
function scanBalancedDestination(source,
|
|
6431
|
+
function scanBalancedDestination(source, offset, lineEnd) {
|
|
6416
6432
|
let depth = 0;
|
|
6417
6433
|
while (offset < lineEnd) {
|
|
6418
6434
|
const code = source.charCodeAt(offset);
|
|
@@ -6426,19 +6442,20 @@ function scanBalancedDestination(source, start, offset, lineEnd) {
|
|
|
6426
6442
|
} else if (code === 41 && --depth < 0) return -1;
|
|
6427
6443
|
offset++;
|
|
6428
6444
|
}
|
|
6429
|
-
return
|
|
6445
|
+
return depth === 0 ? offset : -1;
|
|
6430
6446
|
}
|
|
6431
|
-
function
|
|
6447
|
+
function sliceLines(source, lines, first, start, last, end) {
|
|
6432
6448
|
if (first === last || lines.physicallyContiguous()) return source.slice(start, end);
|
|
6433
|
-
let
|
|
6449
|
+
let text = "";
|
|
6434
6450
|
for (let line = first; line < last; line++) {
|
|
6435
|
-
|
|
6451
|
+
text += source.slice(start, lines.next(line));
|
|
6436
6452
|
start = lines.start(line + 1);
|
|
6437
6453
|
}
|
|
6438
|
-
return
|
|
6454
|
+
return text + source.slice(start, end);
|
|
6439
6455
|
}
|
|
6440
|
-
function scanTitle(source, lines, destinationLine, lineIndex, offset, closer,
|
|
6456
|
+
function scanTitle(source, lines, destinationLine, lineIndex, offset, closer, context) {
|
|
6441
6457
|
const firstLine = lineIndex;
|
|
6458
|
+
const titleOnNextLine = lineIndex !== destinationLine;
|
|
6442
6459
|
const titleStart = ++offset;
|
|
6443
6460
|
scan: for (;;) {
|
|
6444
6461
|
const lineEnd = lines.end(lineIndex);
|
|
@@ -6450,7 +6467,7 @@ function scanTitle(source, lines, destinationLine, lineIndex, offset, closer, ti
|
|
|
6450
6467
|
}
|
|
6451
6468
|
if (code === closer) {
|
|
6452
6469
|
if (trimLineWhitespaceStart(source, offset + 1, lineEnd) === lineEnd) return {
|
|
6453
|
-
title:
|
|
6470
|
+
title: sliceLines(source, lines, firstLine, titleStart, lineIndex, offset),
|
|
6454
6471
|
endLine: lineIndex + 1
|
|
6455
6472
|
};
|
|
6456
6473
|
break scan;
|
|
@@ -6480,7 +6497,7 @@ const linkDefinitionStart = (source, lines, tokens, start, contentOffset, contex
|
|
|
6480
6497
|
let offset;
|
|
6481
6498
|
const stopCode = stop < firstLineEnd ? source.charCodeAt(stop) : 0;
|
|
6482
6499
|
if (stopCode === 93) {
|
|
6483
|
-
if (source.charCodeAt(stop + 1) !== 58
|
|
6500
|
+
if (source.charCodeAt(stop + 1) !== 58) return;
|
|
6484
6501
|
label = source.slice(labelStart, stop);
|
|
6485
6502
|
offset = stop + 2;
|
|
6486
6503
|
} else {
|
|
@@ -6491,15 +6508,18 @@ const linkDefinitionStart = (source, lines, tokens, start, contentOffset, contex
|
|
|
6491
6508
|
lineIndex = match.lineIndex;
|
|
6492
6509
|
offset = match.offset;
|
|
6493
6510
|
}
|
|
6511
|
+
const identifier = referenceIdentifier(label);
|
|
6512
|
+
if (!identifier) return;
|
|
6494
6513
|
let lineEnd = lines.end(lineIndex);
|
|
6495
6514
|
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
6496
6515
|
if (offset === lineEnd) {
|
|
6497
6516
|
const nextLine = lineIndex + 1;
|
|
6498
|
-
|
|
6499
|
-
|
|
6517
|
+
lineEnd = nextLine < lines.length ? lines.end(nextLine) : lines.next(lineIndex);
|
|
6518
|
+
context.retainLookahead(lineEnd);
|
|
6519
|
+
if (nextLine >= lines.length) return;
|
|
6500
6520
|
lineIndex = nextLine;
|
|
6501
|
-
lineEnd = lines.end(lineIndex);
|
|
6502
6521
|
offset = trimLineWhitespaceStart(source, lines.start(lineIndex), lineEnd);
|
|
6522
|
+
if (offset === lineEnd) return;
|
|
6503
6523
|
}
|
|
6504
6524
|
let destination;
|
|
6505
6525
|
if (source.charCodeAt(offset) === 60) {
|
|
@@ -6512,7 +6532,7 @@ const linkDefinitionStart = (source, lines, tokens, start, contentOffset, contex
|
|
|
6512
6532
|
let end = destinationHead.test(source) ? Math.min(destinationHead.lastIndex, lineEnd) : offset;
|
|
6513
6533
|
if (end < lineEnd) {
|
|
6514
6534
|
const code = source.charCodeAt(end);
|
|
6515
|
-
if (code !== 32 && code !== 9) end = scanBalancedDestination(source,
|
|
6535
|
+
if (code !== 32 && code !== 9) end = scanBalancedDestination(source, end, lineEnd);
|
|
6516
6536
|
}
|
|
6517
6537
|
if (end <= offset) return;
|
|
6518
6538
|
destination = source.slice(offset, end);
|
|
@@ -6520,30 +6540,27 @@ const linkDefinitionStart = (source, lines, tokens, start, contentOffset, contex
|
|
|
6520
6540
|
}
|
|
6521
6541
|
const destinationLine = lineIndex;
|
|
6522
6542
|
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
6523
|
-
let titleOnNextLine = false;
|
|
6524
6543
|
if (offset === lineEnd && lineIndex + 1 < lines.length) {
|
|
6525
6544
|
lineIndex++;
|
|
6526
6545
|
lineEnd = lines.end(lineIndex);
|
|
6527
6546
|
offset = trimLineWhitespaceStart(source, lines.start(lineIndex), lineEnd);
|
|
6528
|
-
titleOnNextLine = true;
|
|
6529
6547
|
}
|
|
6530
6548
|
let title;
|
|
6531
6549
|
let endLine = destinationLine + 1;
|
|
6532
6550
|
const closer = titleCloser(source.charCodeAt(offset));
|
|
6533
6551
|
if (closer) {
|
|
6534
|
-
const match = scanTitle(source, lines, destinationLine, lineIndex, offset, closer,
|
|
6552
|
+
const match = scanTitle(source, lines, destinationLine, lineIndex, offset, closer, context);
|
|
6535
6553
|
if (!match) return;
|
|
6536
6554
|
title = match.title;
|
|
6537
6555
|
endLine = match.endLine;
|
|
6538
6556
|
}
|
|
6539
|
-
const identifier = normalizeIdentifier(label);
|
|
6540
6557
|
return {
|
|
6541
6558
|
node: {
|
|
6542
6559
|
type: "definition",
|
|
6543
6560
|
identifier,
|
|
6544
6561
|
label: decodeString(label),
|
|
6545
6562
|
url: decodeString(destination),
|
|
6546
|
-
title: title === void 0 ? null :
|
|
6563
|
+
title: title === void 0 ? null : decodeLinkTitle(title),
|
|
6547
6564
|
position: void 0
|
|
6548
6565
|
},
|
|
6549
6566
|
nextLine: endLine,
|
|
@@ -6581,8 +6598,7 @@ function delimiterAt(source, lines, index, contentOffset) {
|
|
|
6581
6598
|
const first = source.charCodeAt(contentOffset);
|
|
6582
6599
|
if (first !== 45 && first !== 58 && first !== 124) return;
|
|
6583
6600
|
const lineEnd = lines.end(index);
|
|
6584
|
-
const
|
|
6585
|
-
let spanStart = contentOffset;
|
|
6601
|
+
const alignments = [];
|
|
6586
6602
|
let offset = first === 124 ? contentOffset + 1 : contentOffset;
|
|
6587
6603
|
while (offset < lineEnd) {
|
|
6588
6604
|
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
@@ -6595,24 +6611,21 @@ function delimiterAt(source, lines, index, contentOffset) {
|
|
|
6595
6611
|
const right = offset < lineEnd && source.charCodeAt(offset) === 58;
|
|
6596
6612
|
if (right) offset++;
|
|
6597
6613
|
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
6598
|
-
let nextSpanStart = lineEnd;
|
|
6599
6614
|
if (offset < lineEnd) {
|
|
6600
6615
|
if (source.charCodeAt(offset) !== 124) return;
|
|
6601
|
-
nextSpanStart = offset;
|
|
6602
6616
|
offset++;
|
|
6603
6617
|
}
|
|
6604
|
-
|
|
6605
|
-
spanStart = nextSpanStart;
|
|
6618
|
+
alignments.push(left ? right ? 262 : 260 : right ? 261 : 259);
|
|
6606
6619
|
}
|
|
6607
|
-
return
|
|
6620
|
+
return alignments.length ? alignments : void 0;
|
|
6608
6621
|
}
|
|
6609
6622
|
function emitTableCell(source, tokens, spanStart, contentStart, contentEnd) {
|
|
6610
6623
|
contentStart = trimLineWhitespaceStart(source, contentStart, contentEnd);
|
|
6611
6624
|
contentEnd = trimLineWhitespaceEnd(source, contentStart, contentEnd);
|
|
6612
|
-
tokens.pushInlineFrame(
|
|
6625
|
+
tokens.pushInlineFrame(80, spanStart, spanStart, contentStart, contentEnd);
|
|
6613
6626
|
}
|
|
6614
6627
|
function emitTableRow(source, tokens, contentOffset, lineEnd, visibleEnd, nextPipe) {
|
|
6615
|
-
tokens.push(
|
|
6628
|
+
tokens.push(79, contentOffset, contentOffset);
|
|
6616
6629
|
let contentStart = contentOffset;
|
|
6617
6630
|
let spanStart = contentOffset;
|
|
6618
6631
|
let lastPipe = -1;
|
|
@@ -6637,52 +6650,60 @@ function emitTableRow(source, tokens, contentOffset, lineEnd, visibleEnd, nextPi
|
|
|
6637
6650
|
function buildTableRow(tokenStart, context) {
|
|
6638
6651
|
const tokens = context.structure.tokens;
|
|
6639
6652
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
6640
|
-
const
|
|
6641
|
-
const
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6653
|
+
const offset = tokens.start(tokenStart);
|
|
6654
|
+
const start = context.locator.locationAt(offset);
|
|
6655
|
+
const columnShift = start.column - offset;
|
|
6656
|
+
const children = new Array(close - tokenStart - 1 >>> 1);
|
|
6657
|
+
context.tableCell = true;
|
|
6658
|
+
for (let index = 0; index < children.length; index++) {
|
|
6659
|
+
const cell = tokenStart + 1 + index * 2;
|
|
6660
|
+
const from = tokens.start(cell);
|
|
6661
|
+
const to = tokens.start(cell + 2);
|
|
6662
|
+
children[index] = {
|
|
6646
6663
|
type: "tableCell",
|
|
6647
|
-
children: buildInlineFragment(cell,
|
|
6664
|
+
children: buildInlineFragment(cell, context).children,
|
|
6648
6665
|
position: {
|
|
6649
|
-
start
|
|
6650
|
-
|
|
6666
|
+
start: {
|
|
6667
|
+
line: start.line,
|
|
6668
|
+
column: from + columnShift,
|
|
6669
|
+
offset: from
|
|
6670
|
+
},
|
|
6671
|
+
end: {
|
|
6672
|
+
line: start.line,
|
|
6673
|
+
column: to + columnShift,
|
|
6674
|
+
offset: to
|
|
6675
|
+
}
|
|
6651
6676
|
}
|
|
6652
|
-
}
|
|
6653
|
-
cell = next;
|
|
6677
|
+
};
|
|
6654
6678
|
}
|
|
6679
|
+
context.tableCell = false;
|
|
6680
|
+
const end = tokens.start(close);
|
|
6655
6681
|
return {
|
|
6656
6682
|
type: "tableRow",
|
|
6657
6683
|
children,
|
|
6658
6684
|
position: {
|
|
6659
6685
|
start,
|
|
6660
|
-
end:
|
|
6686
|
+
end: {
|
|
6687
|
+
line: start.line,
|
|
6688
|
+
column: end + columnShift,
|
|
6689
|
+
offset: end
|
|
6690
|
+
}
|
|
6661
6691
|
}
|
|
6662
6692
|
};
|
|
6663
6693
|
}
|
|
6664
|
-
function tableAlignment(tokenStart, context) {
|
|
6665
|
-
const tokens = context.structure.tokens;
|
|
6666
|
-
const result = [];
|
|
6667
|
-
for (let token = tokenStart; tokens.kind(token) !== 81 && tokens.kind(token) !== 198; token++) {
|
|
6668
|
-
const kind = tokens.kind(token);
|
|
6669
|
-
result.push(kind === 260 ? "left" : kind === 261 ? "right" : kind === 262 ? "center" : null);
|
|
6670
|
-
}
|
|
6671
|
-
return result;
|
|
6672
|
-
}
|
|
6673
6694
|
const feature$1 = { block: {
|
|
6674
6695
|
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
6675
6696
|
const delimiterLine = start + 1;
|
|
6676
6697
|
if (delimiterLine >= lines.length) return;
|
|
6677
6698
|
const delimiterOffset = lineIndentOffset(source, lines, delimiterLine);
|
|
6678
6699
|
if (delimiterOffset < 0 || context.startsInterruptingBlock(source, lines, delimiterLine, delimiterOffset)) return;
|
|
6679
|
-
const
|
|
6680
|
-
if (!
|
|
6681
|
-
tokens.push(
|
|
6700
|
+
const alignments = delimiterAt(source, lines, delimiterLine, delimiterOffset);
|
|
6701
|
+
if (!alignments || countHeaderCells(source, lines, start, contentOffset) !== alignments.length) return;
|
|
6702
|
+
tokens.push(78, contentOffset, contentOffset);
|
|
6682
6703
|
const headerEnd = lines.end(start);
|
|
6683
6704
|
let nextPipe = emitTableRow(source, tokens, contentOffset, headerEnd, trimLineWhitespaceEnd(source, contentOffset, headerEnd), source.indexOf("|", contentOffset));
|
|
6684
6705
|
const delimiterEnd = lines.end(delimiterLine);
|
|
6685
|
-
for (
|
|
6706
|
+
for (const alignment of alignments) tokens.push(alignment, delimiterOffset, delimiterEnd);
|
|
6686
6707
|
let end = start + 2;
|
|
6687
6708
|
while (end < lines.length) {
|
|
6688
6709
|
const contentOffset = lineIndentOffset(source, lines, end);
|
|
@@ -6698,16 +6719,30 @@ const feature$1 = { block: {
|
|
|
6698
6719
|
return end;
|
|
6699
6720
|
}],
|
|
6700
6721
|
builds: [{
|
|
6701
|
-
token:
|
|
6722
|
+
token: 78,
|
|
6702
6723
|
build(tokenStart, context) {
|
|
6703
6724
|
const tokens = context.structure.tokens;
|
|
6704
6725
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
6705
6726
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
6706
6727
|
const header = tokenStart + 1;
|
|
6728
|
+
const headerRow = buildTableRow(header, context);
|
|
6729
|
+
const width = headerRow.children.length;
|
|
6707
6730
|
const delimiter = header + tokens.nodeLength(header);
|
|
6708
|
-
const align =
|
|
6709
|
-
|
|
6710
|
-
|
|
6731
|
+
const align = new Array(width);
|
|
6732
|
+
for (let column = 0; column < width; column++) switch (tokens.kind(delimiter + column)) {
|
|
6733
|
+
case 260:
|
|
6734
|
+
align[column] = "left";
|
|
6735
|
+
break;
|
|
6736
|
+
case 261:
|
|
6737
|
+
align[column] = "right";
|
|
6738
|
+
break;
|
|
6739
|
+
case 262:
|
|
6740
|
+
align[column] = "center";
|
|
6741
|
+
break;
|
|
6742
|
+
default: align[column] = null;
|
|
6743
|
+
}
|
|
6744
|
+
const rows = [headerRow];
|
|
6745
|
+
for (let row = delimiter + width; row < close; row += tokens.nodeLength(row)) rows.push(buildTableRow(row, context));
|
|
6711
6746
|
return {
|
|
6712
6747
|
type: "table",
|
|
6713
6748
|
align,
|
|
@@ -6735,11 +6770,8 @@ const feature = { inline: {
|
|
|
6735
6770
|
scan(source, start, tokens) {
|
|
6736
6771
|
const next = source.charCodeAt(start + 1);
|
|
6737
6772
|
if (next === 10 || next === 13) {
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
const lineStart = offset;
|
|
6741
|
-
while (source.charCodeAt(offset) === 32) offset++;
|
|
6742
|
-
appendInlineToken(tokens, 128, start, offset, lineStart);
|
|
6773
|
+
const offset = findLineEndingEnd(source, start + 1);
|
|
6774
|
+
appendInlineToken(tokens, 128, start, offset);
|
|
6743
6775
|
return offset;
|
|
6744
6776
|
}
|
|
6745
6777
|
if (isAsciiPunctuation(next)) {
|
|
@@ -6747,7 +6779,7 @@ const feature = { inline: {
|
|
|
6747
6779
|
appendInlineToken(tokens, 65, start, end);
|
|
6748
6780
|
return end;
|
|
6749
6781
|
}
|
|
6750
|
-
return start +
|
|
6782
|
+
return start + 1;
|
|
6751
6783
|
}
|
|
6752
6784
|
}],
|
|
6753
6785
|
builds: [
|
|
@@ -6781,21 +6813,21 @@ const feature = { inline: {
|
|
|
6781
6813
|
function createProfile(options = {}) {
|
|
6782
6814
|
const features = [
|
|
6783
6815
|
feature$8,
|
|
6816
|
+
feature$14(options.breaks),
|
|
6784
6817
|
feature$15,
|
|
6785
|
-
feature$16,
|
|
6786
6818
|
feature$5(options.taskList),
|
|
6787
|
-
feature$
|
|
6819
|
+
feature$13,
|
|
6788
6820
|
feature$7
|
|
6789
6821
|
];
|
|
6790
|
-
if (options.footnote) features.push(feature$
|
|
6791
|
-
if (options.frontmatter) features.unshift(feature$
|
|
6822
|
+
if (options.footnote) features.push(feature$18);
|
|
6823
|
+
if (options.frontmatter) features.unshift(feature$12(typeof options.frontmatter === "object" ? options.frontmatter.marker : "-"));
|
|
6792
6824
|
if (options.table) features.push(feature$1);
|
|
6793
6825
|
if (options.math) features.push(feature$4(options.math));
|
|
6794
6826
|
features.push(feature$3, feature, feature$9(options.strikethrough), feature$6);
|
|
6795
|
-
if (options.attributes) features.push(feature$
|
|
6796
|
-
if (options.binding) features.push(feature$
|
|
6797
|
-
if (options.emoji) features.push(feature$
|
|
6798
|
-
if (options.component) features.push(feature$
|
|
6827
|
+
if (options.attributes) features.push(feature$17);
|
|
6828
|
+
if (options.binding) features.push(feature$16);
|
|
6829
|
+
if (options.emoji) features.push(feature$10);
|
|
6830
|
+
if (options.component) features.push(feature$11);
|
|
6799
6831
|
features.push(feature$2);
|
|
6800
6832
|
const blockFeatures = [];
|
|
6801
6833
|
const inlineFeatures = [];
|
|
@@ -6806,6 +6838,8 @@ function createProfile(options = {}) {
|
|
|
6806
6838
|
return {
|
|
6807
6839
|
block: createBlockProfile(blockFeatures),
|
|
6808
6840
|
inline: createInlineProfile(inlineFeatures, {
|
|
6841
|
+
breaks: options.breaks === true,
|
|
6842
|
+
cjk: options.cjk === true,
|
|
6809
6843
|
component: options.component === true,
|
|
6810
6844
|
footnote: options.footnote === true
|
|
6811
6845
|
})
|