@likec4/core 1.48.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/RichText.mjs +1 -148
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -379
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +255 -136
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +1 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/{index3.d.mts → theme.d.mts} +15 -13
- package/dist/_chunks/{index7.d.mts → to-text.d.mts} +165 -29
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +2 -8
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +86 -15
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -14
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -8
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +4 -11
- package/dist/utils/index.mjs +1 -17
- package/package.json +13 -12
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/geometry.mjs +0 -335
- package/dist/_chunks/index2.d.mts +0 -937
- package/dist/_chunks/index4.d.mts +0 -62
- package/dist/_chunks/index5.d.mts +0 -42
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +0 -1898
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/_chunks/utils.mjs +0 -483
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -1,2243 +1 @@
|
|
|
1
|
-
import { _ as unicodePunctuation, a as resolveAll, d as asciiAlpha, f as asciiAlphanumeric, g as markdownSpace, h as markdownLineEndingOrSpace, i as factorySpace, l as classifyCharacter, m as markdownLineEnding, o as combineExtensions, p as asciiControl, r as blankLine, s as splice, u as normalizeIdentifier, v as unicodeWhitespace } from "./mdast-util-from-markdown.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-autolink-literal@2.1.0/node_modules/micromark-extension-gfm-autolink-literal/lib/syntax.js
|
|
4
|
-
/**
|
|
5
|
-
* @import {Code, ConstructRecord, Event, Extension, Previous, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
6
|
-
*/
|
|
7
|
-
const wwwPrefix = {
|
|
8
|
-
tokenize: tokenizeWwwPrefix,
|
|
9
|
-
partial: true
|
|
10
|
-
};
|
|
11
|
-
const domain = {
|
|
12
|
-
tokenize: tokenizeDomain,
|
|
13
|
-
partial: true
|
|
14
|
-
};
|
|
15
|
-
const path = {
|
|
16
|
-
tokenize: tokenizePath,
|
|
17
|
-
partial: true
|
|
18
|
-
};
|
|
19
|
-
const trail = {
|
|
20
|
-
tokenize: tokenizeTrail,
|
|
21
|
-
partial: true
|
|
22
|
-
};
|
|
23
|
-
const emailDomainDotTrail = {
|
|
24
|
-
tokenize: tokenizeEmailDomainDotTrail,
|
|
25
|
-
partial: true
|
|
26
|
-
};
|
|
27
|
-
const wwwAutolink = {
|
|
28
|
-
name: "wwwAutolink",
|
|
29
|
-
tokenize: tokenizeWwwAutolink,
|
|
30
|
-
previous: previousWww
|
|
31
|
-
};
|
|
32
|
-
const protocolAutolink = {
|
|
33
|
-
name: "protocolAutolink",
|
|
34
|
-
tokenize: tokenizeProtocolAutolink,
|
|
35
|
-
previous: previousProtocol
|
|
36
|
-
};
|
|
37
|
-
const emailAutolink = {
|
|
38
|
-
name: "emailAutolink",
|
|
39
|
-
tokenize: tokenizeEmailAutolink,
|
|
40
|
-
previous: previousEmail
|
|
41
|
-
};
|
|
42
|
-
/** @type {ConstructRecord} */
|
|
43
|
-
const text = {};
|
|
44
|
-
/**
|
|
45
|
-
* Create an extension for `micromark` to support GitHub autolink literal
|
|
46
|
-
* syntax.
|
|
47
|
-
*
|
|
48
|
-
* @returns {Extension}
|
|
49
|
-
* Extension for `micromark` that can be passed in `extensions` to enable GFM
|
|
50
|
-
* autolink literal syntax.
|
|
51
|
-
*/
|
|
52
|
-
function gfmAutolinkLiteral() {
|
|
53
|
-
return { text };
|
|
54
|
-
}
|
|
55
|
-
/** @type {Code} */
|
|
56
|
-
let code = 48;
|
|
57
|
-
while (code < 123) {
|
|
58
|
-
text[code] = emailAutolink;
|
|
59
|
-
code++;
|
|
60
|
-
if (code === 58) code = 65;
|
|
61
|
-
else if (code === 91) code = 97;
|
|
62
|
-
}
|
|
63
|
-
text[43] = emailAutolink;
|
|
64
|
-
text[45] = emailAutolink;
|
|
65
|
-
text[46] = emailAutolink;
|
|
66
|
-
text[95] = emailAutolink;
|
|
67
|
-
text[72] = [emailAutolink, protocolAutolink];
|
|
68
|
-
text[104] = [emailAutolink, protocolAutolink];
|
|
69
|
-
text[87] = [emailAutolink, wwwAutolink];
|
|
70
|
-
text[119] = [emailAutolink, wwwAutolink];
|
|
71
|
-
/**
|
|
72
|
-
* Email autolink literal.
|
|
73
|
-
*
|
|
74
|
-
* ```markdown
|
|
75
|
-
* > | a contact@example.org b
|
|
76
|
-
* ^^^^^^^^^^^^^^^^^^^
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @this {TokenizeContext}
|
|
80
|
-
* @type {Tokenizer}
|
|
81
|
-
*/
|
|
82
|
-
function tokenizeEmailAutolink(effects, ok, nok) {
|
|
83
|
-
const self = this;
|
|
84
|
-
/** @type {boolean | undefined} */
|
|
85
|
-
let dot;
|
|
86
|
-
/** @type {boolean} */
|
|
87
|
-
let data;
|
|
88
|
-
return start;
|
|
89
|
-
/**
|
|
90
|
-
* Start of email autolink literal.
|
|
91
|
-
*
|
|
92
|
-
* ```markdown
|
|
93
|
-
* > | a contact@example.org b
|
|
94
|
-
* ^
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @type {State}
|
|
98
|
-
*/
|
|
99
|
-
function start(code) {
|
|
100
|
-
if (!gfmAtext(code) || !previousEmail.call(self, self.previous) || previousUnbalanced(self.events)) return nok(code);
|
|
101
|
-
effects.enter("literalAutolink");
|
|
102
|
-
effects.enter("literalAutolinkEmail");
|
|
103
|
-
return atext(code);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* In email atext.
|
|
107
|
-
*
|
|
108
|
-
* ```markdown
|
|
109
|
-
* > | a contact@example.org b
|
|
110
|
-
* ^
|
|
111
|
-
* ```
|
|
112
|
-
*
|
|
113
|
-
* @type {State}
|
|
114
|
-
*/
|
|
115
|
-
function atext(code) {
|
|
116
|
-
if (gfmAtext(code)) {
|
|
117
|
-
effects.consume(code);
|
|
118
|
-
return atext;
|
|
119
|
-
}
|
|
120
|
-
if (code === 64) {
|
|
121
|
-
effects.consume(code);
|
|
122
|
-
return emailDomain;
|
|
123
|
-
}
|
|
124
|
-
return nok(code);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* In email domain.
|
|
128
|
-
*
|
|
129
|
-
* The reference code is a bit overly complex as it handles the `@`, of which
|
|
130
|
-
* there may be just one.
|
|
131
|
-
* Source: <https://github.com/github/cmark-gfm/blob/ef1cfcb/extensions/autolink.c#L318>
|
|
132
|
-
*
|
|
133
|
-
* ```markdown
|
|
134
|
-
* > | a contact@example.org b
|
|
135
|
-
* ^
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @type {State}
|
|
139
|
-
*/
|
|
140
|
-
function emailDomain(code) {
|
|
141
|
-
if (code === 46) return effects.check(emailDomainDotTrail, emailDomainAfter, emailDomainDot)(code);
|
|
142
|
-
if (code === 45 || code === 95 || asciiAlphanumeric(code)) {
|
|
143
|
-
data = true;
|
|
144
|
-
effects.consume(code);
|
|
145
|
-
return emailDomain;
|
|
146
|
-
}
|
|
147
|
-
return emailDomainAfter(code);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* In email domain, on dot that is not a trail.
|
|
151
|
-
*
|
|
152
|
-
* ```markdown
|
|
153
|
-
* > | a contact@example.org b
|
|
154
|
-
* ^
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* @type {State}
|
|
158
|
-
*/
|
|
159
|
-
function emailDomainDot(code) {
|
|
160
|
-
effects.consume(code);
|
|
161
|
-
dot = true;
|
|
162
|
-
return emailDomain;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* After email domain.
|
|
166
|
-
*
|
|
167
|
-
* ```markdown
|
|
168
|
-
* > | a contact@example.org b
|
|
169
|
-
* ^
|
|
170
|
-
* ```
|
|
171
|
-
*
|
|
172
|
-
* @type {State}
|
|
173
|
-
*/
|
|
174
|
-
function emailDomainAfter(code) {
|
|
175
|
-
if (data && dot && asciiAlpha(self.previous)) {
|
|
176
|
-
effects.exit("literalAutolinkEmail");
|
|
177
|
-
effects.exit("literalAutolink");
|
|
178
|
-
return ok(code);
|
|
179
|
-
}
|
|
180
|
-
return nok(code);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* `www` autolink literal.
|
|
185
|
-
*
|
|
186
|
-
* ```markdown
|
|
187
|
-
* > | a www.example.org b
|
|
188
|
-
* ^^^^^^^^^^^^^^^
|
|
189
|
-
* ```
|
|
190
|
-
*
|
|
191
|
-
* @this {TokenizeContext}
|
|
192
|
-
* @type {Tokenizer}
|
|
193
|
-
*/
|
|
194
|
-
function tokenizeWwwAutolink(effects, ok, nok) {
|
|
195
|
-
const self = this;
|
|
196
|
-
return wwwStart;
|
|
197
|
-
/**
|
|
198
|
-
* Start of www autolink literal.
|
|
199
|
-
*
|
|
200
|
-
* ```markdown
|
|
201
|
-
* > | www.example.com/a?b#c
|
|
202
|
-
* ^
|
|
203
|
-
* ```
|
|
204
|
-
*
|
|
205
|
-
* @type {State}
|
|
206
|
-
*/
|
|
207
|
-
function wwwStart(code) {
|
|
208
|
-
if (code !== 87 && code !== 119 || !previousWww.call(self, self.previous) || previousUnbalanced(self.events)) return nok(code);
|
|
209
|
-
effects.enter("literalAutolink");
|
|
210
|
-
effects.enter("literalAutolinkWww");
|
|
211
|
-
return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(path, wwwAfter), nok), nok)(code);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* After a www autolink literal.
|
|
215
|
-
*
|
|
216
|
-
* ```markdown
|
|
217
|
-
* > | www.example.com/a?b#c
|
|
218
|
-
* ^
|
|
219
|
-
* ```
|
|
220
|
-
*
|
|
221
|
-
* @type {State}
|
|
222
|
-
*/
|
|
223
|
-
function wwwAfter(code) {
|
|
224
|
-
effects.exit("literalAutolinkWww");
|
|
225
|
-
effects.exit("literalAutolink");
|
|
226
|
-
return ok(code);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Protocol autolink literal.
|
|
231
|
-
*
|
|
232
|
-
* ```markdown
|
|
233
|
-
* > | a https://example.org b
|
|
234
|
-
* ^^^^^^^^^^^^^^^^^^^
|
|
235
|
-
* ```
|
|
236
|
-
*
|
|
237
|
-
* @this {TokenizeContext}
|
|
238
|
-
* @type {Tokenizer}
|
|
239
|
-
*/
|
|
240
|
-
function tokenizeProtocolAutolink(effects, ok, nok) {
|
|
241
|
-
const self = this;
|
|
242
|
-
let buffer = "";
|
|
243
|
-
let seen = false;
|
|
244
|
-
return protocolStart;
|
|
245
|
-
/**
|
|
246
|
-
* Start of protocol autolink literal.
|
|
247
|
-
*
|
|
248
|
-
* ```markdown
|
|
249
|
-
* > | https://example.com/a?b#c
|
|
250
|
-
* ^
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* @type {State}
|
|
254
|
-
*/
|
|
255
|
-
function protocolStart(code) {
|
|
256
|
-
if ((code === 72 || code === 104) && previousProtocol.call(self, self.previous) && !previousUnbalanced(self.events)) {
|
|
257
|
-
effects.enter("literalAutolink");
|
|
258
|
-
effects.enter("literalAutolinkHttp");
|
|
259
|
-
buffer += String.fromCodePoint(code);
|
|
260
|
-
effects.consume(code);
|
|
261
|
-
return protocolPrefixInside;
|
|
262
|
-
}
|
|
263
|
-
return nok(code);
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* In protocol.
|
|
267
|
-
*
|
|
268
|
-
* ```markdown
|
|
269
|
-
* > | https://example.com/a?b#c
|
|
270
|
-
* ^^^^^
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
* @type {State}
|
|
274
|
-
*/
|
|
275
|
-
function protocolPrefixInside(code) {
|
|
276
|
-
if (asciiAlpha(code) && buffer.length < 5) {
|
|
277
|
-
buffer += String.fromCodePoint(code);
|
|
278
|
-
effects.consume(code);
|
|
279
|
-
return protocolPrefixInside;
|
|
280
|
-
}
|
|
281
|
-
if (code === 58) {
|
|
282
|
-
const protocol = buffer.toLowerCase();
|
|
283
|
-
if (protocol === "http" || protocol === "https") {
|
|
284
|
-
effects.consume(code);
|
|
285
|
-
return protocolSlashesInside;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return nok(code);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* In slashes.
|
|
292
|
-
*
|
|
293
|
-
* ```markdown
|
|
294
|
-
* > | https://example.com/a?b#c
|
|
295
|
-
* ^^
|
|
296
|
-
* ```
|
|
297
|
-
*
|
|
298
|
-
* @type {State}
|
|
299
|
-
*/
|
|
300
|
-
function protocolSlashesInside(code) {
|
|
301
|
-
if (code === 47) {
|
|
302
|
-
effects.consume(code);
|
|
303
|
-
if (seen) return afterProtocol;
|
|
304
|
-
seen = true;
|
|
305
|
-
return protocolSlashesInside;
|
|
306
|
-
}
|
|
307
|
-
return nok(code);
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* After protocol, before domain.
|
|
311
|
-
*
|
|
312
|
-
* ```markdown
|
|
313
|
-
* > | https://example.com/a?b#c
|
|
314
|
-
* ^
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* @type {State}
|
|
318
|
-
*/
|
|
319
|
-
function afterProtocol(code) {
|
|
320
|
-
return code === null || asciiControl(code) || markdownLineEndingOrSpace(code) || unicodeWhitespace(code) || unicodePunctuation(code) ? nok(code) : effects.attempt(domain, effects.attempt(path, protocolAfter), nok)(code);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* After a protocol autolink literal.
|
|
324
|
-
*
|
|
325
|
-
* ```markdown
|
|
326
|
-
* > | https://example.com/a?b#c
|
|
327
|
-
* ^
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* @type {State}
|
|
331
|
-
*/
|
|
332
|
-
function protocolAfter(code) {
|
|
333
|
-
effects.exit("literalAutolinkHttp");
|
|
334
|
-
effects.exit("literalAutolink");
|
|
335
|
-
return ok(code);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* `www` prefix.
|
|
340
|
-
*
|
|
341
|
-
* ```markdown
|
|
342
|
-
* > | a www.example.org b
|
|
343
|
-
* ^^^^
|
|
344
|
-
* ```
|
|
345
|
-
*
|
|
346
|
-
* @this {TokenizeContext}
|
|
347
|
-
* @type {Tokenizer}
|
|
348
|
-
*/
|
|
349
|
-
function tokenizeWwwPrefix(effects, ok, nok) {
|
|
350
|
-
let size = 0;
|
|
351
|
-
return wwwPrefixInside;
|
|
352
|
-
/**
|
|
353
|
-
* In www prefix.
|
|
354
|
-
*
|
|
355
|
-
* ```markdown
|
|
356
|
-
* > | www.example.com
|
|
357
|
-
* ^^^^
|
|
358
|
-
* ```
|
|
359
|
-
*
|
|
360
|
-
* @type {State}
|
|
361
|
-
*/
|
|
362
|
-
function wwwPrefixInside(code) {
|
|
363
|
-
if ((code === 87 || code === 119) && size < 3) {
|
|
364
|
-
size++;
|
|
365
|
-
effects.consume(code);
|
|
366
|
-
return wwwPrefixInside;
|
|
367
|
-
}
|
|
368
|
-
if (code === 46 && size === 3) {
|
|
369
|
-
effects.consume(code);
|
|
370
|
-
return wwwPrefixAfter;
|
|
371
|
-
}
|
|
372
|
-
return nok(code);
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* After www prefix.
|
|
376
|
-
*
|
|
377
|
-
* ```markdown
|
|
378
|
-
* > | www.example.com
|
|
379
|
-
* ^
|
|
380
|
-
* ```
|
|
381
|
-
*
|
|
382
|
-
* @type {State}
|
|
383
|
-
*/
|
|
384
|
-
function wwwPrefixAfter(code) {
|
|
385
|
-
return code === null ? nok(code) : ok(code);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Domain.
|
|
390
|
-
*
|
|
391
|
-
* ```markdown
|
|
392
|
-
* > | a https://example.org b
|
|
393
|
-
* ^^^^^^^^^^^
|
|
394
|
-
* ```
|
|
395
|
-
*
|
|
396
|
-
* @this {TokenizeContext}
|
|
397
|
-
* @type {Tokenizer}
|
|
398
|
-
*/
|
|
399
|
-
function tokenizeDomain(effects, ok, nok) {
|
|
400
|
-
/** @type {boolean | undefined} */
|
|
401
|
-
let underscoreInLastSegment;
|
|
402
|
-
/** @type {boolean | undefined} */
|
|
403
|
-
let underscoreInLastLastSegment;
|
|
404
|
-
/** @type {boolean | undefined} */
|
|
405
|
-
let seen;
|
|
406
|
-
return domainInside;
|
|
407
|
-
/**
|
|
408
|
-
* In domain.
|
|
409
|
-
*
|
|
410
|
-
* ```markdown
|
|
411
|
-
* > | https://example.com/a
|
|
412
|
-
* ^^^^^^^^^^^
|
|
413
|
-
* ```
|
|
414
|
-
*
|
|
415
|
-
* @type {State}
|
|
416
|
-
*/
|
|
417
|
-
function domainInside(code) {
|
|
418
|
-
if (code === 46 || code === 95) return effects.check(trail, domainAfter, domainAtPunctuation)(code);
|
|
419
|
-
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code) || code !== 45 && unicodePunctuation(code)) return domainAfter(code);
|
|
420
|
-
seen = true;
|
|
421
|
-
effects.consume(code);
|
|
422
|
-
return domainInside;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* In domain, at potential trailing punctuation, that was not trailing.
|
|
426
|
-
*
|
|
427
|
-
* ```markdown
|
|
428
|
-
* > | https://example.com
|
|
429
|
-
* ^
|
|
430
|
-
* ```
|
|
431
|
-
*
|
|
432
|
-
* @type {State}
|
|
433
|
-
*/
|
|
434
|
-
function domainAtPunctuation(code) {
|
|
435
|
-
if (code === 95) underscoreInLastSegment = true;
|
|
436
|
-
else {
|
|
437
|
-
underscoreInLastLastSegment = underscoreInLastSegment;
|
|
438
|
-
underscoreInLastSegment = void 0;
|
|
439
|
-
}
|
|
440
|
-
effects.consume(code);
|
|
441
|
-
return domainInside;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* After domain.
|
|
445
|
-
*
|
|
446
|
-
* ```markdown
|
|
447
|
-
* > | https://example.com/a
|
|
448
|
-
* ^
|
|
449
|
-
* ```
|
|
450
|
-
*
|
|
451
|
-
* @type {State} */
|
|
452
|
-
function domainAfter(code) {
|
|
453
|
-
if (underscoreInLastLastSegment || underscoreInLastSegment || !seen) return nok(code);
|
|
454
|
-
return ok(code);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Path.
|
|
459
|
-
*
|
|
460
|
-
* ```markdown
|
|
461
|
-
* > | a https://example.org/stuff b
|
|
462
|
-
* ^^^^^^
|
|
463
|
-
* ```
|
|
464
|
-
*
|
|
465
|
-
* @this {TokenizeContext}
|
|
466
|
-
* @type {Tokenizer}
|
|
467
|
-
*/
|
|
468
|
-
function tokenizePath(effects, ok) {
|
|
469
|
-
let sizeOpen = 0;
|
|
470
|
-
let sizeClose = 0;
|
|
471
|
-
return pathInside;
|
|
472
|
-
/**
|
|
473
|
-
* In path.
|
|
474
|
-
*
|
|
475
|
-
* ```markdown
|
|
476
|
-
* > | https://example.com/a
|
|
477
|
-
* ^^
|
|
478
|
-
* ```
|
|
479
|
-
*
|
|
480
|
-
* @type {State}
|
|
481
|
-
*/
|
|
482
|
-
function pathInside(code) {
|
|
483
|
-
if (code === 40) {
|
|
484
|
-
sizeOpen++;
|
|
485
|
-
effects.consume(code);
|
|
486
|
-
return pathInside;
|
|
487
|
-
}
|
|
488
|
-
if (code === 41 && sizeClose < sizeOpen) return pathAtPunctuation(code);
|
|
489
|
-
if (code === 33 || code === 34 || code === 38 || code === 39 || code === 41 || code === 42 || code === 44 || code === 46 || code === 58 || code === 59 || code === 60 || code === 63 || code === 93 || code === 95 || code === 126) return effects.check(trail, ok, pathAtPunctuation)(code);
|
|
490
|
-
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return ok(code);
|
|
491
|
-
effects.consume(code);
|
|
492
|
-
return pathInside;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* In path, at potential trailing punctuation, that was not trailing.
|
|
496
|
-
*
|
|
497
|
-
* ```markdown
|
|
498
|
-
* > | https://example.com/a"b
|
|
499
|
-
* ^
|
|
500
|
-
* ```
|
|
501
|
-
*
|
|
502
|
-
* @type {State}
|
|
503
|
-
*/
|
|
504
|
-
function pathAtPunctuation(code) {
|
|
505
|
-
if (code === 41) sizeClose++;
|
|
506
|
-
effects.consume(code);
|
|
507
|
-
return pathInside;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Trail.
|
|
512
|
-
*
|
|
513
|
-
* This calls `ok` if this *is* the trail, followed by an end, which means
|
|
514
|
-
* the entire trail is not part of the link.
|
|
515
|
-
* It calls `nok` if this *is* part of the link.
|
|
516
|
-
*
|
|
517
|
-
* ```markdown
|
|
518
|
-
* > | https://example.com").
|
|
519
|
-
* ^^^
|
|
520
|
-
* ```
|
|
521
|
-
*
|
|
522
|
-
* @this {TokenizeContext}
|
|
523
|
-
* @type {Tokenizer}
|
|
524
|
-
*/
|
|
525
|
-
function tokenizeTrail(effects, ok, nok) {
|
|
526
|
-
return trail;
|
|
527
|
-
/**
|
|
528
|
-
* In trail of domain or path.
|
|
529
|
-
*
|
|
530
|
-
* ```markdown
|
|
531
|
-
* > | https://example.com").
|
|
532
|
-
* ^
|
|
533
|
-
* ```
|
|
534
|
-
*
|
|
535
|
-
* @type {State}
|
|
536
|
-
*/
|
|
537
|
-
function trail(code) {
|
|
538
|
-
if (code === 33 || code === 34 || code === 39 || code === 41 || code === 42 || code === 44 || code === 46 || code === 58 || code === 59 || code === 63 || code === 95 || code === 126) {
|
|
539
|
-
effects.consume(code);
|
|
540
|
-
return trail;
|
|
541
|
-
}
|
|
542
|
-
if (code === 38) {
|
|
543
|
-
effects.consume(code);
|
|
544
|
-
return trailCharacterReferenceStart;
|
|
545
|
-
}
|
|
546
|
-
if (code === 93) {
|
|
547
|
-
effects.consume(code);
|
|
548
|
-
return trailBracketAfter;
|
|
549
|
-
}
|
|
550
|
-
if (code === 60 || code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return ok(code);
|
|
551
|
-
return nok(code);
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* In trail, after `]`.
|
|
555
|
-
*
|
|
556
|
-
* > 👉 **Note**: this deviates from `cmark-gfm` to fix a bug.
|
|
557
|
-
* > See end of <https://github.com/github/cmark-gfm/issues/278> for more.
|
|
558
|
-
*
|
|
559
|
-
* ```markdown
|
|
560
|
-
* > | https://example.com](
|
|
561
|
-
* ^
|
|
562
|
-
* ```
|
|
563
|
-
*
|
|
564
|
-
* @type {State}
|
|
565
|
-
*/
|
|
566
|
-
function trailBracketAfter(code) {
|
|
567
|
-
if (code === null || code === 40 || code === 91 || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return ok(code);
|
|
568
|
-
return trail(code);
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* In character-reference like trail, after `&`.
|
|
572
|
-
*
|
|
573
|
-
* ```markdown
|
|
574
|
-
* > | https://example.com&).
|
|
575
|
-
* ^
|
|
576
|
-
* ```
|
|
577
|
-
*
|
|
578
|
-
* @type {State}
|
|
579
|
-
*/
|
|
580
|
-
function trailCharacterReferenceStart(code) {
|
|
581
|
-
return asciiAlpha(code) ? trailCharacterReferenceInside(code) : nok(code);
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* In character-reference like trail.
|
|
585
|
-
*
|
|
586
|
-
* ```markdown
|
|
587
|
-
* > | https://example.com&).
|
|
588
|
-
* ^
|
|
589
|
-
* ```
|
|
590
|
-
*
|
|
591
|
-
* @type {State}
|
|
592
|
-
*/
|
|
593
|
-
function trailCharacterReferenceInside(code) {
|
|
594
|
-
if (code === 59) {
|
|
595
|
-
effects.consume(code);
|
|
596
|
-
return trail;
|
|
597
|
-
}
|
|
598
|
-
if (asciiAlpha(code)) {
|
|
599
|
-
effects.consume(code);
|
|
600
|
-
return trailCharacterReferenceInside;
|
|
601
|
-
}
|
|
602
|
-
return nok(code);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Dot in email domain trail.
|
|
607
|
-
*
|
|
608
|
-
* This calls `ok` if this *is* the trail, followed by an end, which means
|
|
609
|
-
* the trail is not part of the link.
|
|
610
|
-
* It calls `nok` if this *is* part of the link.
|
|
611
|
-
*
|
|
612
|
-
* ```markdown
|
|
613
|
-
* > | contact@example.org.
|
|
614
|
-
* ^
|
|
615
|
-
* ```
|
|
616
|
-
*
|
|
617
|
-
* @this {TokenizeContext}
|
|
618
|
-
* @type {Tokenizer}
|
|
619
|
-
*/
|
|
620
|
-
function tokenizeEmailDomainDotTrail(effects, ok, nok) {
|
|
621
|
-
return start;
|
|
622
|
-
/**
|
|
623
|
-
* Dot.
|
|
624
|
-
*
|
|
625
|
-
* ```markdown
|
|
626
|
-
* > | contact@example.org.
|
|
627
|
-
* ^ ^
|
|
628
|
-
* ```
|
|
629
|
-
*
|
|
630
|
-
* @type {State}
|
|
631
|
-
*/
|
|
632
|
-
function start(code) {
|
|
633
|
-
effects.consume(code);
|
|
634
|
-
return after;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* After dot.
|
|
638
|
-
*
|
|
639
|
-
* ```markdown
|
|
640
|
-
* > | contact@example.org.
|
|
641
|
-
* ^ ^
|
|
642
|
-
* ```
|
|
643
|
-
*
|
|
644
|
-
* @type {State}
|
|
645
|
-
*/
|
|
646
|
-
function after(code) {
|
|
647
|
-
return asciiAlphanumeric(code) ? nok(code) : ok(code);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* See:
|
|
652
|
-
* <https://github.com/github/cmark-gfm/blob/ef1cfcb/extensions/autolink.c#L156>.
|
|
653
|
-
*
|
|
654
|
-
* @type {Previous}
|
|
655
|
-
*/
|
|
656
|
-
function previousWww(code) {
|
|
657
|
-
return code === null || code === 40 || code === 42 || code === 95 || code === 91 || code === 93 || code === 126 || markdownLineEndingOrSpace(code);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* See:
|
|
661
|
-
* <https://github.com/github/cmark-gfm/blob/ef1cfcb/extensions/autolink.c#L214>.
|
|
662
|
-
*
|
|
663
|
-
* @type {Previous}
|
|
664
|
-
*/
|
|
665
|
-
function previousProtocol(code) {
|
|
666
|
-
return !asciiAlpha(code);
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* @this {TokenizeContext}
|
|
670
|
-
* @type {Previous}
|
|
671
|
-
*/
|
|
672
|
-
function previousEmail(code) {
|
|
673
|
-
return !(code === 47 || gfmAtext(code));
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* @param {Code} code
|
|
677
|
-
* @returns {boolean}
|
|
678
|
-
*/
|
|
679
|
-
function gfmAtext(code) {
|
|
680
|
-
return code === 43 || code === 45 || code === 46 || code === 95 || asciiAlphanumeric(code);
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* @param {Array<Event>} events
|
|
684
|
-
* @returns {boolean}
|
|
685
|
-
*/
|
|
686
|
-
function previousUnbalanced(events) {
|
|
687
|
-
let index = events.length;
|
|
688
|
-
let result = false;
|
|
689
|
-
while (index--) {
|
|
690
|
-
const token = events[index][1];
|
|
691
|
-
if ((token.type === "labelLink" || token.type === "labelImage") && !token._balanced) {
|
|
692
|
-
result = true;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
if (token._gfmAutolinkLiteralWalkedInto) {
|
|
696
|
-
result = false;
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
if (events.length > 0 && !result) events[events.length - 1][1]._gfmAutolinkLiteralWalkedInto = true;
|
|
701
|
-
return result;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
//#endregion
|
|
705
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-footnote@2.1.0/node_modules/micromark-extension-gfm-footnote/lib/syntax.js
|
|
706
|
-
/**
|
|
707
|
-
* @import {Event, Exiter, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
708
|
-
*/
|
|
709
|
-
const indent = {
|
|
710
|
-
tokenize: tokenizeIndent,
|
|
711
|
-
partial: true
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* Create an extension for `micromark` to enable GFM footnote syntax.
|
|
715
|
-
*
|
|
716
|
-
* @returns {Extension}
|
|
717
|
-
* Extension for `micromark` that can be passed in `extensions` to
|
|
718
|
-
* enable GFM footnote syntax.
|
|
719
|
-
*/
|
|
720
|
-
function gfmFootnote() {
|
|
721
|
-
/** @type {Extension} */
|
|
722
|
-
return {
|
|
723
|
-
document: { [91]: {
|
|
724
|
-
name: "gfmFootnoteDefinition",
|
|
725
|
-
tokenize: tokenizeDefinitionStart,
|
|
726
|
-
continuation: { tokenize: tokenizeDefinitionContinuation },
|
|
727
|
-
exit: gfmFootnoteDefinitionEnd
|
|
728
|
-
} },
|
|
729
|
-
text: {
|
|
730
|
-
[91]: {
|
|
731
|
-
name: "gfmFootnoteCall",
|
|
732
|
-
tokenize: tokenizeGfmFootnoteCall
|
|
733
|
-
},
|
|
734
|
-
[93]: {
|
|
735
|
-
name: "gfmPotentialFootnoteCall",
|
|
736
|
-
add: "after",
|
|
737
|
-
tokenize: tokenizePotentialGfmFootnoteCall,
|
|
738
|
-
resolveTo: resolveToPotentialGfmFootnoteCall
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* @this {TokenizeContext}
|
|
745
|
-
* @type {Tokenizer}
|
|
746
|
-
*/
|
|
747
|
-
function tokenizePotentialGfmFootnoteCall(effects, ok, nok) {
|
|
748
|
-
const self = this;
|
|
749
|
-
let index = self.events.length;
|
|
750
|
-
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
751
|
-
/** @type {Token} */
|
|
752
|
-
let labelStart;
|
|
753
|
-
while (index--) {
|
|
754
|
-
const token = self.events[index][1];
|
|
755
|
-
if (token.type === "labelImage") {
|
|
756
|
-
labelStart = token;
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
if (token.type === "gfmFootnoteCall" || token.type === "labelLink" || token.type === "label" || token.type === "image" || token.type === "link") break;
|
|
760
|
-
}
|
|
761
|
-
return start;
|
|
762
|
-
/**
|
|
763
|
-
* @type {State}
|
|
764
|
-
*/
|
|
765
|
-
function start(code) {
|
|
766
|
-
if (!labelStart || !labelStart._balanced) return nok(code);
|
|
767
|
-
const id = normalizeIdentifier(self.sliceSerialize({
|
|
768
|
-
start: labelStart.end,
|
|
769
|
-
end: self.now()
|
|
770
|
-
}));
|
|
771
|
-
if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) return nok(code);
|
|
772
|
-
effects.enter("gfmFootnoteCallLabelMarker");
|
|
773
|
-
effects.consume(code);
|
|
774
|
-
effects.exit("gfmFootnoteCallLabelMarker");
|
|
775
|
-
return ok(code);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
/** @type {Resolver} */
|
|
779
|
-
function resolveToPotentialGfmFootnoteCall(events, context) {
|
|
780
|
-
let index = events.length;
|
|
781
|
-
while (index--) if (events[index][1].type === "labelImage" && events[index][0] === "enter") {
|
|
782
|
-
events[index][1];
|
|
783
|
-
break;
|
|
784
|
-
}
|
|
785
|
-
events[index + 1][1].type = "data";
|
|
786
|
-
events[index + 3][1].type = "gfmFootnoteCallLabelMarker";
|
|
787
|
-
/** @type {Token} */
|
|
788
|
-
const call = {
|
|
789
|
-
type: "gfmFootnoteCall",
|
|
790
|
-
start: Object.assign({}, events[index + 3][1].start),
|
|
791
|
-
end: Object.assign({}, events[events.length - 1][1].end)
|
|
792
|
-
};
|
|
793
|
-
/** @type {Token} */
|
|
794
|
-
const marker = {
|
|
795
|
-
type: "gfmFootnoteCallMarker",
|
|
796
|
-
start: Object.assign({}, events[index + 3][1].end),
|
|
797
|
-
end: Object.assign({}, events[index + 3][1].end)
|
|
798
|
-
};
|
|
799
|
-
marker.end.column++;
|
|
800
|
-
marker.end.offset++;
|
|
801
|
-
marker.end._bufferIndex++;
|
|
802
|
-
/** @type {Token} */
|
|
803
|
-
const string = {
|
|
804
|
-
type: "gfmFootnoteCallString",
|
|
805
|
-
start: Object.assign({}, marker.end),
|
|
806
|
-
end: Object.assign({}, events[events.length - 1][1].start)
|
|
807
|
-
};
|
|
808
|
-
/** @type {Token} */
|
|
809
|
-
const chunk = {
|
|
810
|
-
type: "chunkString",
|
|
811
|
-
contentType: "string",
|
|
812
|
-
start: Object.assign({}, string.start),
|
|
813
|
-
end: Object.assign({}, string.end)
|
|
814
|
-
};
|
|
815
|
-
/** @type {Array<Event>} */
|
|
816
|
-
const replacement = [
|
|
817
|
-
events[index + 1],
|
|
818
|
-
events[index + 2],
|
|
819
|
-
[
|
|
820
|
-
"enter",
|
|
821
|
-
call,
|
|
822
|
-
context
|
|
823
|
-
],
|
|
824
|
-
events[index + 3],
|
|
825
|
-
events[index + 4],
|
|
826
|
-
[
|
|
827
|
-
"enter",
|
|
828
|
-
marker,
|
|
829
|
-
context
|
|
830
|
-
],
|
|
831
|
-
[
|
|
832
|
-
"exit",
|
|
833
|
-
marker,
|
|
834
|
-
context
|
|
835
|
-
],
|
|
836
|
-
[
|
|
837
|
-
"enter",
|
|
838
|
-
string,
|
|
839
|
-
context
|
|
840
|
-
],
|
|
841
|
-
[
|
|
842
|
-
"enter",
|
|
843
|
-
chunk,
|
|
844
|
-
context
|
|
845
|
-
],
|
|
846
|
-
[
|
|
847
|
-
"exit",
|
|
848
|
-
chunk,
|
|
849
|
-
context
|
|
850
|
-
],
|
|
851
|
-
[
|
|
852
|
-
"exit",
|
|
853
|
-
string,
|
|
854
|
-
context
|
|
855
|
-
],
|
|
856
|
-
events[events.length - 2],
|
|
857
|
-
events[events.length - 1],
|
|
858
|
-
[
|
|
859
|
-
"exit",
|
|
860
|
-
call,
|
|
861
|
-
context
|
|
862
|
-
]
|
|
863
|
-
];
|
|
864
|
-
events.splice(index, events.length - index + 1, ...replacement);
|
|
865
|
-
return events;
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* @this {TokenizeContext}
|
|
869
|
-
* @type {Tokenizer}
|
|
870
|
-
*/
|
|
871
|
-
function tokenizeGfmFootnoteCall(effects, ok, nok) {
|
|
872
|
-
const self = this;
|
|
873
|
-
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
874
|
-
let size = 0;
|
|
875
|
-
/** @type {boolean} */
|
|
876
|
-
let data;
|
|
877
|
-
return start;
|
|
878
|
-
/**
|
|
879
|
-
* Start of footnote label.
|
|
880
|
-
*
|
|
881
|
-
* ```markdown
|
|
882
|
-
* > | a [^b] c
|
|
883
|
-
* ^
|
|
884
|
-
* ```
|
|
885
|
-
*
|
|
886
|
-
* @type {State}
|
|
887
|
-
*/
|
|
888
|
-
function start(code) {
|
|
889
|
-
effects.enter("gfmFootnoteCall");
|
|
890
|
-
effects.enter("gfmFootnoteCallLabelMarker");
|
|
891
|
-
effects.consume(code);
|
|
892
|
-
effects.exit("gfmFootnoteCallLabelMarker");
|
|
893
|
-
return callStart;
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* After `[`, at `^`.
|
|
897
|
-
*
|
|
898
|
-
* ```markdown
|
|
899
|
-
* > | a [^b] c
|
|
900
|
-
* ^
|
|
901
|
-
* ```
|
|
902
|
-
*
|
|
903
|
-
* @type {State}
|
|
904
|
-
*/
|
|
905
|
-
function callStart(code) {
|
|
906
|
-
if (code !== 94) return nok(code);
|
|
907
|
-
effects.enter("gfmFootnoteCallMarker");
|
|
908
|
-
effects.consume(code);
|
|
909
|
-
effects.exit("gfmFootnoteCallMarker");
|
|
910
|
-
effects.enter("gfmFootnoteCallString");
|
|
911
|
-
effects.enter("chunkString").contentType = "string";
|
|
912
|
-
return callData;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* In label.
|
|
916
|
-
*
|
|
917
|
-
* ```markdown
|
|
918
|
-
* > | a [^b] c
|
|
919
|
-
* ^
|
|
920
|
-
* ```
|
|
921
|
-
*
|
|
922
|
-
* @type {State}
|
|
923
|
-
*/
|
|
924
|
-
function callData(code) {
|
|
925
|
-
if (size > 999 || code === 93 && !data || code === null || code === 91 || markdownLineEndingOrSpace(code)) return nok(code);
|
|
926
|
-
if (code === 93) {
|
|
927
|
-
effects.exit("chunkString");
|
|
928
|
-
const token = effects.exit("gfmFootnoteCallString");
|
|
929
|
-
if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) return nok(code);
|
|
930
|
-
effects.enter("gfmFootnoteCallLabelMarker");
|
|
931
|
-
effects.consume(code);
|
|
932
|
-
effects.exit("gfmFootnoteCallLabelMarker");
|
|
933
|
-
effects.exit("gfmFootnoteCall");
|
|
934
|
-
return ok;
|
|
935
|
-
}
|
|
936
|
-
if (!markdownLineEndingOrSpace(code)) data = true;
|
|
937
|
-
size++;
|
|
938
|
-
effects.consume(code);
|
|
939
|
-
return code === 92 ? callEscape : callData;
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* On character after escape.
|
|
943
|
-
*
|
|
944
|
-
* ```markdown
|
|
945
|
-
* > | a [^b\c] d
|
|
946
|
-
* ^
|
|
947
|
-
* ```
|
|
948
|
-
*
|
|
949
|
-
* @type {State}
|
|
950
|
-
*/
|
|
951
|
-
function callEscape(code) {
|
|
952
|
-
if (code === 91 || code === 92 || code === 93) {
|
|
953
|
-
effects.consume(code);
|
|
954
|
-
size++;
|
|
955
|
-
return callData;
|
|
956
|
-
}
|
|
957
|
-
return callData(code);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* @this {TokenizeContext}
|
|
962
|
-
* @type {Tokenizer}
|
|
963
|
-
*/
|
|
964
|
-
function tokenizeDefinitionStart(effects, ok, nok) {
|
|
965
|
-
const self = this;
|
|
966
|
-
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
967
|
-
/** @type {string} */
|
|
968
|
-
let identifier;
|
|
969
|
-
let size = 0;
|
|
970
|
-
/** @type {boolean | undefined} */
|
|
971
|
-
let data;
|
|
972
|
-
return start;
|
|
973
|
-
/**
|
|
974
|
-
* Start of GFM footnote definition.
|
|
975
|
-
*
|
|
976
|
-
* ```markdown
|
|
977
|
-
* > | [^a]: b
|
|
978
|
-
* ^
|
|
979
|
-
* ```
|
|
980
|
-
*
|
|
981
|
-
* @type {State}
|
|
982
|
-
*/
|
|
983
|
-
function start(code) {
|
|
984
|
-
effects.enter("gfmFootnoteDefinition")._container = true;
|
|
985
|
-
effects.enter("gfmFootnoteDefinitionLabel");
|
|
986
|
-
effects.enter("gfmFootnoteDefinitionLabelMarker");
|
|
987
|
-
effects.consume(code);
|
|
988
|
-
effects.exit("gfmFootnoteDefinitionLabelMarker");
|
|
989
|
-
return labelAtMarker;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* In label, at caret.
|
|
993
|
-
*
|
|
994
|
-
* ```markdown
|
|
995
|
-
* > | [^a]: b
|
|
996
|
-
* ^
|
|
997
|
-
* ```
|
|
998
|
-
*
|
|
999
|
-
* @type {State}
|
|
1000
|
-
*/
|
|
1001
|
-
function labelAtMarker(code) {
|
|
1002
|
-
if (code === 94) {
|
|
1003
|
-
effects.enter("gfmFootnoteDefinitionMarker");
|
|
1004
|
-
effects.consume(code);
|
|
1005
|
-
effects.exit("gfmFootnoteDefinitionMarker");
|
|
1006
|
-
effects.enter("gfmFootnoteDefinitionLabelString");
|
|
1007
|
-
effects.enter("chunkString").contentType = "string";
|
|
1008
|
-
return labelInside;
|
|
1009
|
-
}
|
|
1010
|
-
return nok(code);
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* In label.
|
|
1014
|
-
*
|
|
1015
|
-
* > 👉 **Note**: `cmark-gfm` prevents whitespace from occurring in footnote
|
|
1016
|
-
* > definition labels.
|
|
1017
|
-
*
|
|
1018
|
-
* ```markdown
|
|
1019
|
-
* > | [^a]: b
|
|
1020
|
-
* ^
|
|
1021
|
-
* ```
|
|
1022
|
-
*
|
|
1023
|
-
* @type {State}
|
|
1024
|
-
*/
|
|
1025
|
-
function labelInside(code) {
|
|
1026
|
-
if (size > 999 || code === 93 && !data || code === null || code === 91 || markdownLineEndingOrSpace(code)) return nok(code);
|
|
1027
|
-
if (code === 93) {
|
|
1028
|
-
effects.exit("chunkString");
|
|
1029
|
-
const token = effects.exit("gfmFootnoteDefinitionLabelString");
|
|
1030
|
-
identifier = normalizeIdentifier(self.sliceSerialize(token));
|
|
1031
|
-
effects.enter("gfmFootnoteDefinitionLabelMarker");
|
|
1032
|
-
effects.consume(code);
|
|
1033
|
-
effects.exit("gfmFootnoteDefinitionLabelMarker");
|
|
1034
|
-
effects.exit("gfmFootnoteDefinitionLabel");
|
|
1035
|
-
return labelAfter;
|
|
1036
|
-
}
|
|
1037
|
-
if (!markdownLineEndingOrSpace(code)) data = true;
|
|
1038
|
-
size++;
|
|
1039
|
-
effects.consume(code);
|
|
1040
|
-
return code === 92 ? labelEscape : labelInside;
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* After `\`, at a special character.
|
|
1044
|
-
*
|
|
1045
|
-
* > 👉 **Note**: `cmark-gfm` currently does not support escaped brackets:
|
|
1046
|
-
* > <https://github.com/github/cmark-gfm/issues/240>
|
|
1047
|
-
*
|
|
1048
|
-
* ```markdown
|
|
1049
|
-
* > | [^a\*b]: c
|
|
1050
|
-
* ^
|
|
1051
|
-
* ```
|
|
1052
|
-
*
|
|
1053
|
-
* @type {State}
|
|
1054
|
-
*/
|
|
1055
|
-
function labelEscape(code) {
|
|
1056
|
-
if (code === 91 || code === 92 || code === 93) {
|
|
1057
|
-
effects.consume(code);
|
|
1058
|
-
size++;
|
|
1059
|
-
return labelInside;
|
|
1060
|
-
}
|
|
1061
|
-
return labelInside(code);
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* After definition label.
|
|
1065
|
-
*
|
|
1066
|
-
* ```markdown
|
|
1067
|
-
* > | [^a]: b
|
|
1068
|
-
* ^
|
|
1069
|
-
* ```
|
|
1070
|
-
*
|
|
1071
|
-
* @type {State}
|
|
1072
|
-
*/
|
|
1073
|
-
function labelAfter(code) {
|
|
1074
|
-
if (code === 58) {
|
|
1075
|
-
effects.enter("definitionMarker");
|
|
1076
|
-
effects.consume(code);
|
|
1077
|
-
effects.exit("definitionMarker");
|
|
1078
|
-
if (!defined.includes(identifier)) defined.push(identifier);
|
|
1079
|
-
return factorySpace(effects, whitespaceAfter, "gfmFootnoteDefinitionWhitespace");
|
|
1080
|
-
}
|
|
1081
|
-
return nok(code);
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* After definition prefix.
|
|
1085
|
-
*
|
|
1086
|
-
* ```markdown
|
|
1087
|
-
* > | [^a]: b
|
|
1088
|
-
* ^
|
|
1089
|
-
* ```
|
|
1090
|
-
*
|
|
1091
|
-
* @type {State}
|
|
1092
|
-
*/
|
|
1093
|
-
function whitespaceAfter(code) {
|
|
1094
|
-
return ok(code);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* @this {TokenizeContext}
|
|
1099
|
-
* @type {Tokenizer}
|
|
1100
|
-
*/
|
|
1101
|
-
function tokenizeDefinitionContinuation(effects, ok, nok) {
|
|
1102
|
-
return effects.check(blankLine, ok, effects.attempt(indent, ok, nok));
|
|
1103
|
-
}
|
|
1104
|
-
/** @type {Exiter} */
|
|
1105
|
-
function gfmFootnoteDefinitionEnd(effects) {
|
|
1106
|
-
effects.exit("gfmFootnoteDefinition");
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* @this {TokenizeContext}
|
|
1110
|
-
* @type {Tokenizer}
|
|
1111
|
-
*/
|
|
1112
|
-
function tokenizeIndent(effects, ok, nok) {
|
|
1113
|
-
const self = this;
|
|
1114
|
-
return factorySpace(effects, afterPrefix, "gfmFootnoteDefinitionIndent", 5);
|
|
1115
|
-
/**
|
|
1116
|
-
* @type {State}
|
|
1117
|
-
*/
|
|
1118
|
-
function afterPrefix(code) {
|
|
1119
|
-
const tail = self.events[self.events.length - 1];
|
|
1120
|
-
return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === 4 ? ok(code) : nok(code);
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
//#endregion
|
|
1125
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-strikethrough@2.1.0/node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js
|
|
1126
|
-
/**
|
|
1127
|
-
* @import {Options} from 'micromark-extension-gfm-strikethrough'
|
|
1128
|
-
* @import {Event, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
1129
|
-
*/
|
|
1130
|
-
/**
|
|
1131
|
-
* Create an extension for `micromark` to enable GFM strikethrough syntax.
|
|
1132
|
-
*
|
|
1133
|
-
* @param {Options | null | undefined} [options={}]
|
|
1134
|
-
* Configuration.
|
|
1135
|
-
* @returns {Extension}
|
|
1136
|
-
* Extension for `micromark` that can be passed in `extensions`, to
|
|
1137
|
-
* enable GFM strikethrough syntax.
|
|
1138
|
-
*/
|
|
1139
|
-
function gfmStrikethrough(options) {
|
|
1140
|
-
let single = (options || {}).singleTilde;
|
|
1141
|
-
const tokenizer = {
|
|
1142
|
-
name: "strikethrough",
|
|
1143
|
-
tokenize: tokenizeStrikethrough,
|
|
1144
|
-
resolveAll: resolveAllStrikethrough
|
|
1145
|
-
};
|
|
1146
|
-
if (single === null || single === void 0) single = true;
|
|
1147
|
-
return {
|
|
1148
|
-
text: { [126]: tokenizer },
|
|
1149
|
-
insideSpan: { null: [tokenizer] },
|
|
1150
|
-
attentionMarkers: { null: [126] }
|
|
1151
|
-
};
|
|
1152
|
-
/**
|
|
1153
|
-
* Take events and resolve strikethrough.
|
|
1154
|
-
*
|
|
1155
|
-
* @type {Resolver}
|
|
1156
|
-
*/
|
|
1157
|
-
function resolveAllStrikethrough(events, context) {
|
|
1158
|
-
let index = -1;
|
|
1159
|
-
while (++index < events.length) if (events[index][0] === "enter" && events[index][1].type === "strikethroughSequenceTemporary" && events[index][1]._close) {
|
|
1160
|
-
let open = index;
|
|
1161
|
-
while (open--) if (events[open][0] === "exit" && events[open][1].type === "strikethroughSequenceTemporary" && events[open][1]._open && events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
|
|
1162
|
-
events[index][1].type = "strikethroughSequence";
|
|
1163
|
-
events[open][1].type = "strikethroughSequence";
|
|
1164
|
-
/** @type {Token} */
|
|
1165
|
-
const strikethrough = {
|
|
1166
|
-
type: "strikethrough",
|
|
1167
|
-
start: Object.assign({}, events[open][1].start),
|
|
1168
|
-
end: Object.assign({}, events[index][1].end)
|
|
1169
|
-
};
|
|
1170
|
-
/** @type {Token} */
|
|
1171
|
-
const text = {
|
|
1172
|
-
type: "strikethroughText",
|
|
1173
|
-
start: Object.assign({}, events[open][1].end),
|
|
1174
|
-
end: Object.assign({}, events[index][1].start)
|
|
1175
|
-
};
|
|
1176
|
-
/** @type {Array<Event>} */
|
|
1177
|
-
const nextEvents = [
|
|
1178
|
-
[
|
|
1179
|
-
"enter",
|
|
1180
|
-
strikethrough,
|
|
1181
|
-
context
|
|
1182
|
-
],
|
|
1183
|
-
[
|
|
1184
|
-
"enter",
|
|
1185
|
-
events[open][1],
|
|
1186
|
-
context
|
|
1187
|
-
],
|
|
1188
|
-
[
|
|
1189
|
-
"exit",
|
|
1190
|
-
events[open][1],
|
|
1191
|
-
context
|
|
1192
|
-
],
|
|
1193
|
-
[
|
|
1194
|
-
"enter",
|
|
1195
|
-
text,
|
|
1196
|
-
context
|
|
1197
|
-
]
|
|
1198
|
-
];
|
|
1199
|
-
const insideSpan = context.parser.constructs.insideSpan.null;
|
|
1200
|
-
if (insideSpan) splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));
|
|
1201
|
-
splice(nextEvents, nextEvents.length, 0, [
|
|
1202
|
-
[
|
|
1203
|
-
"exit",
|
|
1204
|
-
text,
|
|
1205
|
-
context
|
|
1206
|
-
],
|
|
1207
|
-
[
|
|
1208
|
-
"enter",
|
|
1209
|
-
events[index][1],
|
|
1210
|
-
context
|
|
1211
|
-
],
|
|
1212
|
-
[
|
|
1213
|
-
"exit",
|
|
1214
|
-
events[index][1],
|
|
1215
|
-
context
|
|
1216
|
-
],
|
|
1217
|
-
[
|
|
1218
|
-
"exit",
|
|
1219
|
-
strikethrough,
|
|
1220
|
-
context
|
|
1221
|
-
]
|
|
1222
|
-
]);
|
|
1223
|
-
splice(events, open - 1, index - open + 3, nextEvents);
|
|
1224
|
-
index = open + nextEvents.length - 2;
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
index = -1;
|
|
1229
|
-
while (++index < events.length) if (events[index][1].type === "strikethroughSequenceTemporary") events[index][1].type = "data";
|
|
1230
|
-
return events;
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* @this {TokenizeContext}
|
|
1234
|
-
* @type {Tokenizer}
|
|
1235
|
-
*/
|
|
1236
|
-
function tokenizeStrikethrough(effects, ok, nok) {
|
|
1237
|
-
const previous = this.previous;
|
|
1238
|
-
const events = this.events;
|
|
1239
|
-
let size = 0;
|
|
1240
|
-
return start;
|
|
1241
|
-
/** @type {State} */
|
|
1242
|
-
function start(code) {
|
|
1243
|
-
if (previous === 126 && events[events.length - 1][1].type !== "characterEscape") return nok(code);
|
|
1244
|
-
effects.enter("strikethroughSequenceTemporary");
|
|
1245
|
-
return more(code);
|
|
1246
|
-
}
|
|
1247
|
-
/** @type {State} */
|
|
1248
|
-
function more(code) {
|
|
1249
|
-
const before = classifyCharacter(previous);
|
|
1250
|
-
if (code === 126) {
|
|
1251
|
-
if (size > 1) return nok(code);
|
|
1252
|
-
effects.consume(code);
|
|
1253
|
-
size++;
|
|
1254
|
-
return more;
|
|
1255
|
-
}
|
|
1256
|
-
if (size < 2 && !single) return nok(code);
|
|
1257
|
-
const token = effects.exit("strikethroughSequenceTemporary");
|
|
1258
|
-
const after = classifyCharacter(code);
|
|
1259
|
-
token._open = !after || after === 2 && Boolean(before);
|
|
1260
|
-
token._close = !before || before === 2 && Boolean(after);
|
|
1261
|
-
return ok(code);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
//#endregion
|
|
1267
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/edit-map.js
|
|
1268
|
-
/**
|
|
1269
|
-
* @import {Event} from 'micromark-util-types'
|
|
1270
|
-
*/
|
|
1271
|
-
/**
|
|
1272
|
-
* @typedef {[number, number, Array<Event>]} Change
|
|
1273
|
-
* @typedef {[number, number, number]} Jump
|
|
1274
|
-
*/
|
|
1275
|
-
/**
|
|
1276
|
-
* Tracks a bunch of edits.
|
|
1277
|
-
*/
|
|
1278
|
-
var EditMap = class {
|
|
1279
|
-
/**
|
|
1280
|
-
* Create a new edit map.
|
|
1281
|
-
*/
|
|
1282
|
-
constructor() {
|
|
1283
|
-
/**
|
|
1284
|
-
* Record of changes.
|
|
1285
|
-
*
|
|
1286
|
-
* @type {Array<Change>}
|
|
1287
|
-
*/
|
|
1288
|
-
this.map = [];
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Create an edit: a remove and/or add at a certain place.
|
|
1292
|
-
*
|
|
1293
|
-
* @param {number} index
|
|
1294
|
-
* @param {number} remove
|
|
1295
|
-
* @param {Array<Event>} add
|
|
1296
|
-
* @returns {undefined}
|
|
1297
|
-
*/
|
|
1298
|
-
add(index, remove, add) {
|
|
1299
|
-
addImplementation(this, index, remove, add);
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* Done, change the events.
|
|
1303
|
-
*
|
|
1304
|
-
* @param {Array<Event>} events
|
|
1305
|
-
* @returns {undefined}
|
|
1306
|
-
*/
|
|
1307
|
-
consume(events) {
|
|
1308
|
-
this.map.sort(function(a, b) {
|
|
1309
|
-
return a[0] - b[0];
|
|
1310
|
-
});
|
|
1311
|
-
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
1312
|
-
if (this.map.length === 0) return;
|
|
1313
|
-
let index = this.map.length;
|
|
1314
|
-
/** @type {Array<Array<Event>>} */
|
|
1315
|
-
const vecs = [];
|
|
1316
|
-
while (index > 0) {
|
|
1317
|
-
index -= 1;
|
|
1318
|
-
vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
|
|
1319
|
-
events.length = this.map[index][0];
|
|
1320
|
-
}
|
|
1321
|
-
vecs.push(events.slice());
|
|
1322
|
-
events.length = 0;
|
|
1323
|
-
let slice = vecs.pop();
|
|
1324
|
-
while (slice) {
|
|
1325
|
-
for (const element of slice) events.push(element);
|
|
1326
|
-
slice = vecs.pop();
|
|
1327
|
-
}
|
|
1328
|
-
this.map.length = 0;
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
/**
|
|
1332
|
-
* Create an edit.
|
|
1333
|
-
*
|
|
1334
|
-
* @param {EditMap} editMap
|
|
1335
|
-
* @param {number} at
|
|
1336
|
-
* @param {number} remove
|
|
1337
|
-
* @param {Array<Event>} add
|
|
1338
|
-
* @returns {undefined}
|
|
1339
|
-
*/
|
|
1340
|
-
function addImplementation(editMap, at, remove, add) {
|
|
1341
|
-
let index = 0;
|
|
1342
|
-
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
1343
|
-
if (remove === 0 && add.length === 0) return;
|
|
1344
|
-
while (index < editMap.map.length) {
|
|
1345
|
-
if (editMap.map[index][0] === at) {
|
|
1346
|
-
editMap.map[index][1] += remove;
|
|
1347
|
-
editMap.map[index][2].push(...add);
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
index += 1;
|
|
1351
|
-
}
|
|
1352
|
-
editMap.map.push([
|
|
1353
|
-
at,
|
|
1354
|
-
remove,
|
|
1355
|
-
add
|
|
1356
|
-
]);
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
//#endregion
|
|
1360
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/infer.js
|
|
1361
|
-
/**
|
|
1362
|
-
* @import {Event} from 'micromark-util-types'
|
|
1363
|
-
*/
|
|
1364
|
-
/**
|
|
1365
|
-
* @typedef {'center' | 'left' | 'none' | 'right'} Align
|
|
1366
|
-
*/
|
|
1367
|
-
/**
|
|
1368
|
-
* Figure out the alignment of a GFM table.
|
|
1369
|
-
*
|
|
1370
|
-
* @param {Readonly<Array<Event>>} events
|
|
1371
|
-
* List of events.
|
|
1372
|
-
* @param {number} index
|
|
1373
|
-
* Table enter event.
|
|
1374
|
-
* @returns {Array<Align>}
|
|
1375
|
-
* List of aligns.
|
|
1376
|
-
*/
|
|
1377
|
-
function gfmTableAlign(events, index) {
|
|
1378
|
-
let inDelimiterRow = false;
|
|
1379
|
-
/** @type {Array<Align>} */
|
|
1380
|
-
const align = [];
|
|
1381
|
-
while (index < events.length) {
|
|
1382
|
-
const event = events[index];
|
|
1383
|
-
if (inDelimiterRow) {
|
|
1384
|
-
if (event[0] === "enter") {
|
|
1385
|
-
if (event[1].type === "tableContent") align.push(events[index + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
|
|
1386
|
-
} else if (event[1].type === "tableContent") {
|
|
1387
|
-
if (events[index - 1][1].type === "tableDelimiterMarker") {
|
|
1388
|
-
const alignIndex = align.length - 1;
|
|
1389
|
-
align[alignIndex] = align[alignIndex] === "left" ? "center" : "right";
|
|
1390
|
-
}
|
|
1391
|
-
} else if (event[1].type === "tableDelimiterRow") break;
|
|
1392
|
-
} else if (event[0] === "enter" && event[1].type === "tableDelimiterRow") inDelimiterRow = true;
|
|
1393
|
-
index += 1;
|
|
1394
|
-
}
|
|
1395
|
-
return align;
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
//#endregion
|
|
1399
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/syntax.js
|
|
1400
|
-
/**
|
|
1401
|
-
* @import {Event, Extension, Point, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
1402
|
-
*/
|
|
1403
|
-
/**
|
|
1404
|
-
* @typedef {[number, number, number, number]} Range
|
|
1405
|
-
* Cell info.
|
|
1406
|
-
*
|
|
1407
|
-
* @typedef {0 | 1 | 2 | 3} RowKind
|
|
1408
|
-
* Where we are: `1` for head row, `2` for delimiter row, `3` for body row.
|
|
1409
|
-
*/
|
|
1410
|
-
/**
|
|
1411
|
-
* Create an HTML extension for `micromark` to support GitHub tables syntax.
|
|
1412
|
-
*
|
|
1413
|
-
* @returns {Extension}
|
|
1414
|
-
* Extension for `micromark` that can be passed in `extensions` to enable GFM
|
|
1415
|
-
* table syntax.
|
|
1416
|
-
*/
|
|
1417
|
-
function gfmTable() {
|
|
1418
|
-
return { flow: { null: {
|
|
1419
|
-
name: "table",
|
|
1420
|
-
tokenize: tokenizeTable,
|
|
1421
|
-
resolveAll: resolveTable
|
|
1422
|
-
} } };
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* @this {TokenizeContext}
|
|
1426
|
-
* @type {Tokenizer}
|
|
1427
|
-
*/
|
|
1428
|
-
function tokenizeTable(effects, ok, nok) {
|
|
1429
|
-
const self = this;
|
|
1430
|
-
let size = 0;
|
|
1431
|
-
let sizeB = 0;
|
|
1432
|
-
/** @type {boolean | undefined} */
|
|
1433
|
-
let seen;
|
|
1434
|
-
return start;
|
|
1435
|
-
/**
|
|
1436
|
-
* Start of a GFM table.
|
|
1437
|
-
*
|
|
1438
|
-
* If there is a valid table row or table head before, then we try to parse
|
|
1439
|
-
* another row.
|
|
1440
|
-
* Otherwise, we try to parse a head.
|
|
1441
|
-
*
|
|
1442
|
-
* ```markdown
|
|
1443
|
-
* > | | a |
|
|
1444
|
-
* ^
|
|
1445
|
-
* | | - |
|
|
1446
|
-
* > | | b |
|
|
1447
|
-
* ^
|
|
1448
|
-
* ```
|
|
1449
|
-
* @type {State}
|
|
1450
|
-
*/
|
|
1451
|
-
function start(code) {
|
|
1452
|
-
let index = self.events.length - 1;
|
|
1453
|
-
while (index > -1) {
|
|
1454
|
-
const type = self.events[index][1].type;
|
|
1455
|
-
if (type === "lineEnding" || type === "linePrefix") index--;
|
|
1456
|
-
else break;
|
|
1457
|
-
}
|
|
1458
|
-
const tail = index > -1 ? self.events[index][1].type : null;
|
|
1459
|
-
const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
|
|
1460
|
-
if (next === bodyRowStart && self.parser.lazy[self.now().line]) return nok(code);
|
|
1461
|
-
return next(code);
|
|
1462
|
-
}
|
|
1463
|
-
/**
|
|
1464
|
-
* Before table head row.
|
|
1465
|
-
*
|
|
1466
|
-
* ```markdown
|
|
1467
|
-
* > | | a |
|
|
1468
|
-
* ^
|
|
1469
|
-
* | | - |
|
|
1470
|
-
* | | b |
|
|
1471
|
-
* ```
|
|
1472
|
-
*
|
|
1473
|
-
* @type {State}
|
|
1474
|
-
*/
|
|
1475
|
-
function headRowBefore(code) {
|
|
1476
|
-
effects.enter("tableHead");
|
|
1477
|
-
effects.enter("tableRow");
|
|
1478
|
-
return headRowStart(code);
|
|
1479
|
-
}
|
|
1480
|
-
/**
|
|
1481
|
-
* Before table head row, after whitespace.
|
|
1482
|
-
*
|
|
1483
|
-
* ```markdown
|
|
1484
|
-
* > | | a |
|
|
1485
|
-
* ^
|
|
1486
|
-
* | | - |
|
|
1487
|
-
* | | b |
|
|
1488
|
-
* ```
|
|
1489
|
-
*
|
|
1490
|
-
* @type {State}
|
|
1491
|
-
*/
|
|
1492
|
-
function headRowStart(code) {
|
|
1493
|
-
if (code === 124) return headRowBreak(code);
|
|
1494
|
-
seen = true;
|
|
1495
|
-
sizeB += 1;
|
|
1496
|
-
return headRowBreak(code);
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* At break in table head row.
|
|
1500
|
-
*
|
|
1501
|
-
* ```markdown
|
|
1502
|
-
* > | | a |
|
|
1503
|
-
* ^
|
|
1504
|
-
* ^
|
|
1505
|
-
* ^
|
|
1506
|
-
* | | - |
|
|
1507
|
-
* | | b |
|
|
1508
|
-
* ```
|
|
1509
|
-
*
|
|
1510
|
-
* @type {State}
|
|
1511
|
-
*/
|
|
1512
|
-
function headRowBreak(code) {
|
|
1513
|
-
if (code === null) return nok(code);
|
|
1514
|
-
if (markdownLineEnding(code)) {
|
|
1515
|
-
if (sizeB > 1) {
|
|
1516
|
-
sizeB = 0;
|
|
1517
|
-
self.interrupt = true;
|
|
1518
|
-
effects.exit("tableRow");
|
|
1519
|
-
effects.enter("lineEnding");
|
|
1520
|
-
effects.consume(code);
|
|
1521
|
-
effects.exit("lineEnding");
|
|
1522
|
-
return headDelimiterStart;
|
|
1523
|
-
}
|
|
1524
|
-
return nok(code);
|
|
1525
|
-
}
|
|
1526
|
-
if (markdownSpace(code)) return factorySpace(effects, headRowBreak, "whitespace")(code);
|
|
1527
|
-
sizeB += 1;
|
|
1528
|
-
if (seen) {
|
|
1529
|
-
seen = false;
|
|
1530
|
-
size += 1;
|
|
1531
|
-
}
|
|
1532
|
-
if (code === 124) {
|
|
1533
|
-
effects.enter("tableCellDivider");
|
|
1534
|
-
effects.consume(code);
|
|
1535
|
-
effects.exit("tableCellDivider");
|
|
1536
|
-
seen = true;
|
|
1537
|
-
return headRowBreak;
|
|
1538
|
-
}
|
|
1539
|
-
effects.enter("data");
|
|
1540
|
-
return headRowData(code);
|
|
1541
|
-
}
|
|
1542
|
-
/**
|
|
1543
|
-
* In table head row data.
|
|
1544
|
-
*
|
|
1545
|
-
* ```markdown
|
|
1546
|
-
* > | | a |
|
|
1547
|
-
* ^
|
|
1548
|
-
* | | - |
|
|
1549
|
-
* | | b |
|
|
1550
|
-
* ```
|
|
1551
|
-
*
|
|
1552
|
-
* @type {State}
|
|
1553
|
-
*/
|
|
1554
|
-
function headRowData(code) {
|
|
1555
|
-
if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {
|
|
1556
|
-
effects.exit("data");
|
|
1557
|
-
return headRowBreak(code);
|
|
1558
|
-
}
|
|
1559
|
-
effects.consume(code);
|
|
1560
|
-
return code === 92 ? headRowEscape : headRowData;
|
|
1561
|
-
}
|
|
1562
|
-
/**
|
|
1563
|
-
* In table head row escape.
|
|
1564
|
-
*
|
|
1565
|
-
* ```markdown
|
|
1566
|
-
* > | | a\-b |
|
|
1567
|
-
* ^
|
|
1568
|
-
* | | ---- |
|
|
1569
|
-
* | | c |
|
|
1570
|
-
* ```
|
|
1571
|
-
*
|
|
1572
|
-
* @type {State}
|
|
1573
|
-
*/
|
|
1574
|
-
function headRowEscape(code) {
|
|
1575
|
-
if (code === 92 || code === 124) {
|
|
1576
|
-
effects.consume(code);
|
|
1577
|
-
return headRowData;
|
|
1578
|
-
}
|
|
1579
|
-
return headRowData(code);
|
|
1580
|
-
}
|
|
1581
|
-
/**
|
|
1582
|
-
* Before delimiter row.
|
|
1583
|
-
*
|
|
1584
|
-
* ```markdown
|
|
1585
|
-
* | | a |
|
|
1586
|
-
* > | | - |
|
|
1587
|
-
* ^
|
|
1588
|
-
* | | b |
|
|
1589
|
-
* ```
|
|
1590
|
-
*
|
|
1591
|
-
* @type {State}
|
|
1592
|
-
*/
|
|
1593
|
-
function headDelimiterStart(code) {
|
|
1594
|
-
self.interrupt = false;
|
|
1595
|
-
if (self.parser.lazy[self.now().line]) return nok(code);
|
|
1596
|
-
effects.enter("tableDelimiterRow");
|
|
1597
|
-
seen = false;
|
|
1598
|
-
if (markdownSpace(code)) return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
|
|
1599
|
-
return headDelimiterBefore(code);
|
|
1600
|
-
}
|
|
1601
|
-
/**
|
|
1602
|
-
* Before delimiter row, after optional whitespace.
|
|
1603
|
-
*
|
|
1604
|
-
* Reused when a `|` is found later, to parse another cell.
|
|
1605
|
-
*
|
|
1606
|
-
* ```markdown
|
|
1607
|
-
* | | a |
|
|
1608
|
-
* > | | - |
|
|
1609
|
-
* ^
|
|
1610
|
-
* | | b |
|
|
1611
|
-
* ```
|
|
1612
|
-
*
|
|
1613
|
-
* @type {State}
|
|
1614
|
-
*/
|
|
1615
|
-
function headDelimiterBefore(code) {
|
|
1616
|
-
if (code === 45 || code === 58) return headDelimiterValueBefore(code);
|
|
1617
|
-
if (code === 124) {
|
|
1618
|
-
seen = true;
|
|
1619
|
-
effects.enter("tableCellDivider");
|
|
1620
|
-
effects.consume(code);
|
|
1621
|
-
effects.exit("tableCellDivider");
|
|
1622
|
-
return headDelimiterCellBefore;
|
|
1623
|
-
}
|
|
1624
|
-
return headDelimiterNok(code);
|
|
1625
|
-
}
|
|
1626
|
-
/**
|
|
1627
|
-
* After `|`, before delimiter cell.
|
|
1628
|
-
*
|
|
1629
|
-
* ```markdown
|
|
1630
|
-
* | | a |
|
|
1631
|
-
* > | | - |
|
|
1632
|
-
* ^
|
|
1633
|
-
* ```
|
|
1634
|
-
*
|
|
1635
|
-
* @type {State}
|
|
1636
|
-
*/
|
|
1637
|
-
function headDelimiterCellBefore(code) {
|
|
1638
|
-
if (markdownSpace(code)) return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code);
|
|
1639
|
-
return headDelimiterValueBefore(code);
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* Before delimiter cell value.
|
|
1643
|
-
*
|
|
1644
|
-
* ```markdown
|
|
1645
|
-
* | | a |
|
|
1646
|
-
* > | | - |
|
|
1647
|
-
* ^
|
|
1648
|
-
* ```
|
|
1649
|
-
*
|
|
1650
|
-
* @type {State}
|
|
1651
|
-
*/
|
|
1652
|
-
function headDelimiterValueBefore(code) {
|
|
1653
|
-
if (code === 58) {
|
|
1654
|
-
sizeB += 1;
|
|
1655
|
-
seen = true;
|
|
1656
|
-
effects.enter("tableDelimiterMarker");
|
|
1657
|
-
effects.consume(code);
|
|
1658
|
-
effects.exit("tableDelimiterMarker");
|
|
1659
|
-
return headDelimiterLeftAlignmentAfter;
|
|
1660
|
-
}
|
|
1661
|
-
if (code === 45) {
|
|
1662
|
-
sizeB += 1;
|
|
1663
|
-
return headDelimiterLeftAlignmentAfter(code);
|
|
1664
|
-
}
|
|
1665
|
-
if (code === null || markdownLineEnding(code)) return headDelimiterCellAfter(code);
|
|
1666
|
-
return headDelimiterNok(code);
|
|
1667
|
-
}
|
|
1668
|
-
/**
|
|
1669
|
-
* After delimiter cell left alignment marker.
|
|
1670
|
-
*
|
|
1671
|
-
* ```markdown
|
|
1672
|
-
* | | a |
|
|
1673
|
-
* > | | :- |
|
|
1674
|
-
* ^
|
|
1675
|
-
* ```
|
|
1676
|
-
*
|
|
1677
|
-
* @type {State}
|
|
1678
|
-
*/
|
|
1679
|
-
function headDelimiterLeftAlignmentAfter(code) {
|
|
1680
|
-
if (code === 45) {
|
|
1681
|
-
effects.enter("tableDelimiterFiller");
|
|
1682
|
-
return headDelimiterFiller(code);
|
|
1683
|
-
}
|
|
1684
|
-
return headDelimiterNok(code);
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* In delimiter cell filler.
|
|
1688
|
-
*
|
|
1689
|
-
* ```markdown
|
|
1690
|
-
* | | a |
|
|
1691
|
-
* > | | - |
|
|
1692
|
-
* ^
|
|
1693
|
-
* ```
|
|
1694
|
-
*
|
|
1695
|
-
* @type {State}
|
|
1696
|
-
*/
|
|
1697
|
-
function headDelimiterFiller(code) {
|
|
1698
|
-
if (code === 45) {
|
|
1699
|
-
effects.consume(code);
|
|
1700
|
-
return headDelimiterFiller;
|
|
1701
|
-
}
|
|
1702
|
-
if (code === 58) {
|
|
1703
|
-
seen = true;
|
|
1704
|
-
effects.exit("tableDelimiterFiller");
|
|
1705
|
-
effects.enter("tableDelimiterMarker");
|
|
1706
|
-
effects.consume(code);
|
|
1707
|
-
effects.exit("tableDelimiterMarker");
|
|
1708
|
-
return headDelimiterRightAlignmentAfter;
|
|
1709
|
-
}
|
|
1710
|
-
effects.exit("tableDelimiterFiller");
|
|
1711
|
-
return headDelimiterRightAlignmentAfter(code);
|
|
1712
|
-
}
|
|
1713
|
-
/**
|
|
1714
|
-
* After delimiter cell right alignment marker.
|
|
1715
|
-
*
|
|
1716
|
-
* ```markdown
|
|
1717
|
-
* | | a |
|
|
1718
|
-
* > | | -: |
|
|
1719
|
-
* ^
|
|
1720
|
-
* ```
|
|
1721
|
-
*
|
|
1722
|
-
* @type {State}
|
|
1723
|
-
*/
|
|
1724
|
-
function headDelimiterRightAlignmentAfter(code) {
|
|
1725
|
-
if (markdownSpace(code)) return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code);
|
|
1726
|
-
return headDelimiterCellAfter(code);
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
* After delimiter cell.
|
|
1730
|
-
*
|
|
1731
|
-
* ```markdown
|
|
1732
|
-
* | | a |
|
|
1733
|
-
* > | | -: |
|
|
1734
|
-
* ^
|
|
1735
|
-
* ```
|
|
1736
|
-
*
|
|
1737
|
-
* @type {State}
|
|
1738
|
-
*/
|
|
1739
|
-
function headDelimiterCellAfter(code) {
|
|
1740
|
-
if (code === 124) return headDelimiterBefore(code);
|
|
1741
|
-
if (code === null || markdownLineEnding(code)) {
|
|
1742
|
-
if (!seen || size !== sizeB) return headDelimiterNok(code);
|
|
1743
|
-
effects.exit("tableDelimiterRow");
|
|
1744
|
-
effects.exit("tableHead");
|
|
1745
|
-
return ok(code);
|
|
1746
|
-
}
|
|
1747
|
-
return headDelimiterNok(code);
|
|
1748
|
-
}
|
|
1749
|
-
/**
|
|
1750
|
-
* In delimiter row, at a disallowed byte.
|
|
1751
|
-
*
|
|
1752
|
-
* ```markdown
|
|
1753
|
-
* | | a |
|
|
1754
|
-
* > | | x |
|
|
1755
|
-
* ^
|
|
1756
|
-
* ```
|
|
1757
|
-
*
|
|
1758
|
-
* @type {State}
|
|
1759
|
-
*/
|
|
1760
|
-
function headDelimiterNok(code) {
|
|
1761
|
-
return nok(code);
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* Before table body row.
|
|
1765
|
-
*
|
|
1766
|
-
* ```markdown
|
|
1767
|
-
* | | a |
|
|
1768
|
-
* | | - |
|
|
1769
|
-
* > | | b |
|
|
1770
|
-
* ^
|
|
1771
|
-
* ```
|
|
1772
|
-
*
|
|
1773
|
-
* @type {State}
|
|
1774
|
-
*/
|
|
1775
|
-
function bodyRowStart(code) {
|
|
1776
|
-
effects.enter("tableRow");
|
|
1777
|
-
return bodyRowBreak(code);
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* At break in table body row.
|
|
1781
|
-
*
|
|
1782
|
-
* ```markdown
|
|
1783
|
-
* | | a |
|
|
1784
|
-
* | | - |
|
|
1785
|
-
* > | | b |
|
|
1786
|
-
* ^
|
|
1787
|
-
* ^
|
|
1788
|
-
* ^
|
|
1789
|
-
* ```
|
|
1790
|
-
*
|
|
1791
|
-
* @type {State}
|
|
1792
|
-
*/
|
|
1793
|
-
function bodyRowBreak(code) {
|
|
1794
|
-
if (code === 124) {
|
|
1795
|
-
effects.enter("tableCellDivider");
|
|
1796
|
-
effects.consume(code);
|
|
1797
|
-
effects.exit("tableCellDivider");
|
|
1798
|
-
return bodyRowBreak;
|
|
1799
|
-
}
|
|
1800
|
-
if (code === null || markdownLineEnding(code)) {
|
|
1801
|
-
effects.exit("tableRow");
|
|
1802
|
-
return ok(code);
|
|
1803
|
-
}
|
|
1804
|
-
if (markdownSpace(code)) return factorySpace(effects, bodyRowBreak, "whitespace")(code);
|
|
1805
|
-
effects.enter("data");
|
|
1806
|
-
return bodyRowData(code);
|
|
1807
|
-
}
|
|
1808
|
-
/**
|
|
1809
|
-
* In table body row data.
|
|
1810
|
-
*
|
|
1811
|
-
* ```markdown
|
|
1812
|
-
* | | a |
|
|
1813
|
-
* | | - |
|
|
1814
|
-
* > | | b |
|
|
1815
|
-
* ^
|
|
1816
|
-
* ```
|
|
1817
|
-
*
|
|
1818
|
-
* @type {State}
|
|
1819
|
-
*/
|
|
1820
|
-
function bodyRowData(code) {
|
|
1821
|
-
if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {
|
|
1822
|
-
effects.exit("data");
|
|
1823
|
-
return bodyRowBreak(code);
|
|
1824
|
-
}
|
|
1825
|
-
effects.consume(code);
|
|
1826
|
-
return code === 92 ? bodyRowEscape : bodyRowData;
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
* In table body row escape.
|
|
1830
|
-
*
|
|
1831
|
-
* ```markdown
|
|
1832
|
-
* | | a |
|
|
1833
|
-
* | | ---- |
|
|
1834
|
-
* > | | b\-c |
|
|
1835
|
-
* ^
|
|
1836
|
-
* ```
|
|
1837
|
-
*
|
|
1838
|
-
* @type {State}
|
|
1839
|
-
*/
|
|
1840
|
-
function bodyRowEscape(code) {
|
|
1841
|
-
if (code === 92 || code === 124) {
|
|
1842
|
-
effects.consume(code);
|
|
1843
|
-
return bodyRowData;
|
|
1844
|
-
}
|
|
1845
|
-
return bodyRowData(code);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
/** @type {Resolver} */
|
|
1849
|
-
function resolveTable(events, context) {
|
|
1850
|
-
let index = -1;
|
|
1851
|
-
let inFirstCellAwaitingPipe = true;
|
|
1852
|
-
/** @type {RowKind} */
|
|
1853
|
-
let rowKind = 0;
|
|
1854
|
-
/** @type {Range} */
|
|
1855
|
-
let lastCell = [
|
|
1856
|
-
0,
|
|
1857
|
-
0,
|
|
1858
|
-
0,
|
|
1859
|
-
0
|
|
1860
|
-
];
|
|
1861
|
-
/** @type {Range} */
|
|
1862
|
-
let cell = [
|
|
1863
|
-
0,
|
|
1864
|
-
0,
|
|
1865
|
-
0,
|
|
1866
|
-
0
|
|
1867
|
-
];
|
|
1868
|
-
let afterHeadAwaitingFirstBodyRow = false;
|
|
1869
|
-
let lastTableEnd = 0;
|
|
1870
|
-
/** @type {Token | undefined} */
|
|
1871
|
-
let currentTable;
|
|
1872
|
-
/** @type {Token | undefined} */
|
|
1873
|
-
let currentBody;
|
|
1874
|
-
/** @type {Token | undefined} */
|
|
1875
|
-
let currentCell;
|
|
1876
|
-
const map = new EditMap();
|
|
1877
|
-
while (++index < events.length) {
|
|
1878
|
-
const event = events[index];
|
|
1879
|
-
const token = event[1];
|
|
1880
|
-
if (event[0] === "enter") {
|
|
1881
|
-
if (token.type === "tableHead") {
|
|
1882
|
-
afterHeadAwaitingFirstBodyRow = false;
|
|
1883
|
-
if (lastTableEnd !== 0) {
|
|
1884
|
-
flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
|
|
1885
|
-
currentBody = void 0;
|
|
1886
|
-
lastTableEnd = 0;
|
|
1887
|
-
}
|
|
1888
|
-
currentTable = {
|
|
1889
|
-
type: "table",
|
|
1890
|
-
start: Object.assign({}, token.start),
|
|
1891
|
-
end: Object.assign({}, token.end)
|
|
1892
|
-
};
|
|
1893
|
-
map.add(index, 0, [[
|
|
1894
|
-
"enter",
|
|
1895
|
-
currentTable,
|
|
1896
|
-
context
|
|
1897
|
-
]]);
|
|
1898
|
-
} else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
|
|
1899
|
-
inFirstCellAwaitingPipe = true;
|
|
1900
|
-
currentCell = void 0;
|
|
1901
|
-
lastCell = [
|
|
1902
|
-
0,
|
|
1903
|
-
0,
|
|
1904
|
-
0,
|
|
1905
|
-
0
|
|
1906
|
-
];
|
|
1907
|
-
cell = [
|
|
1908
|
-
0,
|
|
1909
|
-
index + 1,
|
|
1910
|
-
0,
|
|
1911
|
-
0
|
|
1912
|
-
];
|
|
1913
|
-
if (afterHeadAwaitingFirstBodyRow) {
|
|
1914
|
-
afterHeadAwaitingFirstBodyRow = false;
|
|
1915
|
-
currentBody = {
|
|
1916
|
-
type: "tableBody",
|
|
1917
|
-
start: Object.assign({}, token.start),
|
|
1918
|
-
end: Object.assign({}, token.end)
|
|
1919
|
-
};
|
|
1920
|
-
map.add(index, 0, [[
|
|
1921
|
-
"enter",
|
|
1922
|
-
currentBody,
|
|
1923
|
-
context
|
|
1924
|
-
]]);
|
|
1925
|
-
}
|
|
1926
|
-
rowKind = token.type === "tableDelimiterRow" ? 2 : currentBody ? 3 : 1;
|
|
1927
|
-
} else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
|
|
1928
|
-
inFirstCellAwaitingPipe = false;
|
|
1929
|
-
if (cell[2] === 0) {
|
|
1930
|
-
if (lastCell[1] !== 0) {
|
|
1931
|
-
cell[0] = cell[1];
|
|
1932
|
-
currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
|
|
1933
|
-
lastCell = [
|
|
1934
|
-
0,
|
|
1935
|
-
0,
|
|
1936
|
-
0,
|
|
1937
|
-
0
|
|
1938
|
-
];
|
|
1939
|
-
}
|
|
1940
|
-
cell[2] = index;
|
|
1941
|
-
}
|
|
1942
|
-
} else if (token.type === "tableCellDivider") if (inFirstCellAwaitingPipe) inFirstCellAwaitingPipe = false;
|
|
1943
|
-
else {
|
|
1944
|
-
if (lastCell[1] !== 0) {
|
|
1945
|
-
cell[0] = cell[1];
|
|
1946
|
-
currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
|
|
1947
|
-
}
|
|
1948
|
-
lastCell = cell;
|
|
1949
|
-
cell = [
|
|
1950
|
-
lastCell[1],
|
|
1951
|
-
index,
|
|
1952
|
-
0,
|
|
1953
|
-
0
|
|
1954
|
-
];
|
|
1955
|
-
}
|
|
1956
|
-
} else if (token.type === "tableHead") {
|
|
1957
|
-
afterHeadAwaitingFirstBodyRow = true;
|
|
1958
|
-
lastTableEnd = index;
|
|
1959
|
-
} else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
|
|
1960
|
-
lastTableEnd = index;
|
|
1961
|
-
if (lastCell[1] !== 0) {
|
|
1962
|
-
cell[0] = cell[1];
|
|
1963
|
-
currentCell = flushCell(map, context, lastCell, rowKind, index, currentCell);
|
|
1964
|
-
} else if (cell[1] !== 0) currentCell = flushCell(map, context, cell, rowKind, index, currentCell);
|
|
1965
|
-
rowKind = 0;
|
|
1966
|
-
} else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) cell[3] = index;
|
|
1967
|
-
}
|
|
1968
|
-
if (lastTableEnd !== 0) flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
|
|
1969
|
-
map.consume(context.events);
|
|
1970
|
-
index = -1;
|
|
1971
|
-
while (++index < context.events.length) {
|
|
1972
|
-
const event = context.events[index];
|
|
1973
|
-
if (event[0] === "enter" && event[1].type === "table") event[1]._align = gfmTableAlign(context.events, index);
|
|
1974
|
-
}
|
|
1975
|
-
return events;
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Generate a cell.
|
|
1979
|
-
*
|
|
1980
|
-
* @param {EditMap} map
|
|
1981
|
-
* @param {Readonly<TokenizeContext>} context
|
|
1982
|
-
* @param {Readonly<Range>} range
|
|
1983
|
-
* @param {RowKind} rowKind
|
|
1984
|
-
* @param {number | undefined} rowEnd
|
|
1985
|
-
* @param {Token | undefined} previousCell
|
|
1986
|
-
* @returns {Token | undefined}
|
|
1987
|
-
*/
|
|
1988
|
-
function flushCell(map, context, range, rowKind, rowEnd, previousCell) {
|
|
1989
|
-
const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
|
|
1990
|
-
const valueName = "tableContent";
|
|
1991
|
-
if (range[0] !== 0) {
|
|
1992
|
-
previousCell.end = Object.assign({}, getPoint(context.events, range[0]));
|
|
1993
|
-
map.add(range[0], 0, [[
|
|
1994
|
-
"exit",
|
|
1995
|
-
previousCell,
|
|
1996
|
-
context
|
|
1997
|
-
]]);
|
|
1998
|
-
}
|
|
1999
|
-
const now = getPoint(context.events, range[1]);
|
|
2000
|
-
previousCell = {
|
|
2001
|
-
type: groupName,
|
|
2002
|
-
start: Object.assign({}, now),
|
|
2003
|
-
end: Object.assign({}, now)
|
|
2004
|
-
};
|
|
2005
|
-
map.add(range[1], 0, [[
|
|
2006
|
-
"enter",
|
|
2007
|
-
previousCell,
|
|
2008
|
-
context
|
|
2009
|
-
]]);
|
|
2010
|
-
if (range[2] !== 0) {
|
|
2011
|
-
const relatedStart = getPoint(context.events, range[2]);
|
|
2012
|
-
const relatedEnd = getPoint(context.events, range[3]);
|
|
2013
|
-
/** @type {Token} */
|
|
2014
|
-
const valueToken = {
|
|
2015
|
-
type: valueName,
|
|
2016
|
-
start: Object.assign({}, relatedStart),
|
|
2017
|
-
end: Object.assign({}, relatedEnd)
|
|
2018
|
-
};
|
|
2019
|
-
map.add(range[2], 0, [[
|
|
2020
|
-
"enter",
|
|
2021
|
-
valueToken,
|
|
2022
|
-
context
|
|
2023
|
-
]]);
|
|
2024
|
-
if (rowKind !== 2) {
|
|
2025
|
-
const start = context.events[range[2]];
|
|
2026
|
-
const end = context.events[range[3]];
|
|
2027
|
-
start[1].end = Object.assign({}, end[1].end);
|
|
2028
|
-
start[1].type = "chunkText";
|
|
2029
|
-
start[1].contentType = "text";
|
|
2030
|
-
if (range[3] > range[2] + 1) {
|
|
2031
|
-
const a = range[2] + 1;
|
|
2032
|
-
const b = range[3] - range[2] - 1;
|
|
2033
|
-
map.add(a, b, []);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
map.add(range[3] + 1, 0, [[
|
|
2037
|
-
"exit",
|
|
2038
|
-
valueToken,
|
|
2039
|
-
context
|
|
2040
|
-
]]);
|
|
2041
|
-
}
|
|
2042
|
-
if (rowEnd !== void 0) {
|
|
2043
|
-
previousCell.end = Object.assign({}, getPoint(context.events, rowEnd));
|
|
2044
|
-
map.add(rowEnd, 0, [[
|
|
2045
|
-
"exit",
|
|
2046
|
-
previousCell,
|
|
2047
|
-
context
|
|
2048
|
-
]]);
|
|
2049
|
-
previousCell = void 0;
|
|
2050
|
-
}
|
|
2051
|
-
return previousCell;
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* Generate table end (and table body end).
|
|
2055
|
-
*
|
|
2056
|
-
* @param {Readonly<EditMap>} map
|
|
2057
|
-
* @param {Readonly<TokenizeContext>} context
|
|
2058
|
-
* @param {number} index
|
|
2059
|
-
* @param {Token} table
|
|
2060
|
-
* @param {Token | undefined} tableBody
|
|
2061
|
-
*/
|
|
2062
|
-
function flushTableEnd(map, context, index, table, tableBody) {
|
|
2063
|
-
/** @type {Array<Event>} */
|
|
2064
|
-
const exits = [];
|
|
2065
|
-
const related = getPoint(context.events, index);
|
|
2066
|
-
if (tableBody) {
|
|
2067
|
-
tableBody.end = Object.assign({}, related);
|
|
2068
|
-
exits.push([
|
|
2069
|
-
"exit",
|
|
2070
|
-
tableBody,
|
|
2071
|
-
context
|
|
2072
|
-
]);
|
|
2073
|
-
}
|
|
2074
|
-
table.end = Object.assign({}, related);
|
|
2075
|
-
exits.push([
|
|
2076
|
-
"exit",
|
|
2077
|
-
table,
|
|
2078
|
-
context
|
|
2079
|
-
]);
|
|
2080
|
-
map.add(index + 1, 0, exits);
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* @param {Readonly<Array<Event>>} events
|
|
2084
|
-
* @param {number} index
|
|
2085
|
-
* @returns {Readonly<Point>}
|
|
2086
|
-
*/
|
|
2087
|
-
function getPoint(events, index) {
|
|
2088
|
-
const event = events[index];
|
|
2089
|
-
const side = event[0] === "enter" ? "start" : "end";
|
|
2090
|
-
return event[1][side];
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
//#endregion
|
|
2094
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm-task-list-item@2.1.0/node_modules/micromark-extension-gfm-task-list-item/lib/syntax.js
|
|
2095
|
-
/**
|
|
2096
|
-
* @import {Extension, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
2097
|
-
*/
|
|
2098
|
-
const tasklistCheck = {
|
|
2099
|
-
name: "tasklistCheck",
|
|
2100
|
-
tokenize: tokenizeTasklistCheck
|
|
2101
|
-
};
|
|
2102
|
-
/**
|
|
2103
|
-
* Create an HTML extension for `micromark` to support GFM task list items
|
|
2104
|
-
* syntax.
|
|
2105
|
-
*
|
|
2106
|
-
* @returns {Extension}
|
|
2107
|
-
* Extension for `micromark` that can be passed in `htmlExtensions` to
|
|
2108
|
-
* support GFM task list items when serializing to HTML.
|
|
2109
|
-
*/
|
|
2110
|
-
function gfmTaskListItem() {
|
|
2111
|
-
return { text: { [91]: tasklistCheck } };
|
|
2112
|
-
}
|
|
2113
|
-
/**
|
|
2114
|
-
* @this {TokenizeContext}
|
|
2115
|
-
* @type {Tokenizer}
|
|
2116
|
-
*/
|
|
2117
|
-
function tokenizeTasklistCheck(effects, ok, nok) {
|
|
2118
|
-
const self = this;
|
|
2119
|
-
return open;
|
|
2120
|
-
/**
|
|
2121
|
-
* At start of task list item check.
|
|
2122
|
-
*
|
|
2123
|
-
* ```markdown
|
|
2124
|
-
* > | * [x] y.
|
|
2125
|
-
* ^
|
|
2126
|
-
* ```
|
|
2127
|
-
*
|
|
2128
|
-
* @type {State}
|
|
2129
|
-
*/
|
|
2130
|
-
function open(code) {
|
|
2131
|
-
if (self.previous !== null || !self._gfmTasklistFirstContentOfListItem) return nok(code);
|
|
2132
|
-
effects.enter("taskListCheck");
|
|
2133
|
-
effects.enter("taskListCheckMarker");
|
|
2134
|
-
effects.consume(code);
|
|
2135
|
-
effects.exit("taskListCheckMarker");
|
|
2136
|
-
return inside;
|
|
2137
|
-
}
|
|
2138
|
-
/**
|
|
2139
|
-
* In task list item check.
|
|
2140
|
-
*
|
|
2141
|
-
* ```markdown
|
|
2142
|
-
* > | * [x] y.
|
|
2143
|
-
* ^
|
|
2144
|
-
* ```
|
|
2145
|
-
*
|
|
2146
|
-
* @type {State}
|
|
2147
|
-
*/
|
|
2148
|
-
function inside(code) {
|
|
2149
|
-
if (markdownLineEndingOrSpace(code)) {
|
|
2150
|
-
effects.enter("taskListCheckValueUnchecked");
|
|
2151
|
-
effects.consume(code);
|
|
2152
|
-
effects.exit("taskListCheckValueUnchecked");
|
|
2153
|
-
return close;
|
|
2154
|
-
}
|
|
2155
|
-
if (code === 88 || code === 120) {
|
|
2156
|
-
effects.enter("taskListCheckValueChecked");
|
|
2157
|
-
effects.consume(code);
|
|
2158
|
-
effects.exit("taskListCheckValueChecked");
|
|
2159
|
-
return close;
|
|
2160
|
-
}
|
|
2161
|
-
return nok(code);
|
|
2162
|
-
}
|
|
2163
|
-
/**
|
|
2164
|
-
* At close of task list item check.
|
|
2165
|
-
*
|
|
2166
|
-
* ```markdown
|
|
2167
|
-
* > | * [x] y.
|
|
2168
|
-
* ^
|
|
2169
|
-
* ```
|
|
2170
|
-
*
|
|
2171
|
-
* @type {State}
|
|
2172
|
-
*/
|
|
2173
|
-
function close(code) {
|
|
2174
|
-
if (code === 93) {
|
|
2175
|
-
effects.enter("taskListCheckMarker");
|
|
2176
|
-
effects.consume(code);
|
|
2177
|
-
effects.exit("taskListCheckMarker");
|
|
2178
|
-
effects.exit("taskListCheck");
|
|
2179
|
-
return after;
|
|
2180
|
-
}
|
|
2181
|
-
return nok(code);
|
|
2182
|
-
}
|
|
2183
|
-
/**
|
|
2184
|
-
* @type {State}
|
|
2185
|
-
*/
|
|
2186
|
-
function after(code) {
|
|
2187
|
-
if (markdownLineEnding(code)) return ok(code);
|
|
2188
|
-
if (markdownSpace(code)) return effects.check({ tokenize: spaceThenNonSpace }, ok, nok)(code);
|
|
2189
|
-
return nok(code);
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
/**
|
|
2193
|
-
* @this {TokenizeContext}
|
|
2194
|
-
* @type {Tokenizer}
|
|
2195
|
-
*/
|
|
2196
|
-
function spaceThenNonSpace(effects, ok, nok) {
|
|
2197
|
-
return factorySpace(effects, after, "whitespace");
|
|
2198
|
-
/**
|
|
2199
|
-
* After whitespace, after task list item check.
|
|
2200
|
-
*
|
|
2201
|
-
* ```markdown
|
|
2202
|
-
* > | * [x] y.
|
|
2203
|
-
* ^
|
|
2204
|
-
* ```
|
|
2205
|
-
*
|
|
2206
|
-
* @type {State}
|
|
2207
|
-
*/
|
|
2208
|
-
function after(code) {
|
|
2209
|
-
return code === null ? nok(code) : ok(code);
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
//#endregion
|
|
2214
|
-
//#region ../../node_modules/.pnpm/micromark-extension-gfm@3.0.0/node_modules/micromark-extension-gfm/index.js
|
|
2215
|
-
/**
|
|
2216
|
-
* @typedef {import('micromark-extension-gfm-footnote').HtmlOptions} HtmlOptions
|
|
2217
|
-
* @typedef {import('micromark-extension-gfm-strikethrough').Options} Options
|
|
2218
|
-
* @typedef {import('micromark-util-types').Extension} Extension
|
|
2219
|
-
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
|
|
2220
|
-
*/
|
|
2221
|
-
/**
|
|
2222
|
-
* Create an extension for `micromark` to enable GFM syntax.
|
|
2223
|
-
*
|
|
2224
|
-
* @param {Options | null | undefined} [options]
|
|
2225
|
-
* Configuration (optional).
|
|
2226
|
-
*
|
|
2227
|
-
* Passed to `micromark-extens-gfm-strikethrough`.
|
|
2228
|
-
* @returns {Extension}
|
|
2229
|
-
* Extension for `micromark` that can be passed in `extensions` to enable GFM
|
|
2230
|
-
* syntax.
|
|
2231
|
-
*/
|
|
2232
|
-
function gfm(options) {
|
|
2233
|
-
return combineExtensions([
|
|
2234
|
-
gfmAutolinkLiteral(),
|
|
2235
|
-
gfmFootnote(),
|
|
2236
|
-
gfmStrikethrough(options),
|
|
2237
|
-
gfmTable(),
|
|
2238
|
-
gfmTaskListItem()
|
|
2239
|
-
]);
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
//#endregion
|
|
2243
|
-
export { gfm as t };
|
|
1
|
+
import{_ as unicodePunctuation,a as resolveAll,d as asciiAlpha,f as asciiAlphanumeric,g as markdownSpace,h as markdownLineEndingOrSpace,i as factorySpace,l as classifyCharacter,m as markdownLineEnding,o as combineExtensions,p as asciiControl,r as blankLine,s as splice,u as normalizeIdentifier,v as unicodeWhitespace}from"./mdast-util-from-markdown.mjs";const wwwPrefix={tokenize:tokenizeWwwPrefix,partial:!0},domain={tokenize:tokenizeDomain,partial:!0},path={tokenize:tokenizePath,partial:!0},trail={tokenize:tokenizeTrail,partial:!0},emailDomainDotTrail={tokenize:tokenizeEmailDomainDotTrail,partial:!0},wwwAutolink={name:`wwwAutolink`,tokenize:tokenizeWwwAutolink,previous:previousWww},protocolAutolink={name:`protocolAutolink`,tokenize:tokenizeProtocolAutolink,previous:previousProtocol},emailAutolink={name:`emailAutolink`,tokenize:tokenizeEmailAutolink,previous:previousEmail},text={};function gfmAutolinkLiteral(){return{text}}let code=48;for(;code<123;)text[code]=emailAutolink,code++,code===58?code=65:code===91&&(code=97);text[43]=emailAutolink,text[45]=emailAutolink,text[46]=emailAutolink,text[95]=emailAutolink,text[72]=[emailAutolink,protocolAutolink],text[104]=[emailAutolink,protocolAutolink],text[87]=[emailAutolink,wwwAutolink],text[119]=[emailAutolink,wwwAutolink];function tokenizeEmailAutolink(e,t,i){let a=this,o,s;return c;function c(t){return!gfmAtext(t)||!previousEmail.call(a,a.previous)||previousUnbalanced(a.events)?i(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),l(t))}function l(t){return gfmAtext(t)?(e.consume(t),l):t===64?(e.consume(t),u):i(t)}function u(t){return t===46?e.check(emailDomainDotTrail,f,d)(t):t===45||t===95||asciiAlphanumeric(t)?(s=!0,e.consume(t),u):f(t)}function d(t){return e.consume(t),o=!0,u}function f(r){return s&&o&&asciiAlpha(a.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(r)):i(r)}}function tokenizeWwwAutolink(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!previousWww.call(r,r.previous)||previousUnbalanced(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(wwwPrefix,e.attempt(domain,e.attempt(path,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function tokenizeProtocolAutolink(t,r,i){let o=this,s=``,c=!1;return l;function l(e){return(e===72||e===104)&&previousProtocol.call(o,o.previous)&&!previousUnbalanced(o.events)?(t.enter(`literalAutolink`),t.enter(`literalAutolinkHttp`),s+=String.fromCodePoint(e),t.consume(e),d):i(e)}function d(e){if(asciiAlpha(e)&&s.length<5)return s+=String.fromCodePoint(e),t.consume(e),d;if(e===58){let n=s.toLowerCase();if(n===`http`||n===`https`)return t.consume(e),f}return i(e)}function f(e){return e===47?(t.consume(e),c?p:(c=!0,f)):i(e)}function p(n){return n===null||asciiControl(n)||markdownLineEndingOrSpace(n)||unicodeWhitespace(n)||unicodePunctuation(n)?i(n):t.attempt(domain,t.attempt(path,h),i)(n)}function h(e){return t.exit(`literalAutolinkHttp`),t.exit(`literalAutolink`),r(e)}}function tokenizeWwwPrefix(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function tokenizeDomain(t,n,r){let i,o,s;return c;function c(n){return n===46||n===95?t.check(trail,u,l)(n):n===null||markdownLineEndingOrSpace(n)||unicodeWhitespace(n)||n!==45&&unicodePunctuation(n)?u(n):(s=!0,t.consume(n),c)}function l(e){return e===95?i=!0:(o=i,i=void 0),t.consume(e),c}function u(e){return o||i||!s?r(e):n(e)}}function tokenizePath(e,t){let n=0,r=0;return i;function i(s){return s===40?(n++,e.consume(s),i):s===41&&r<n?o(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?e.check(trail,t,o)(s):s===null||markdownLineEndingOrSpace(s)||unicodeWhitespace(s)?t(s):(e.consume(s),i)}function o(t){return t===41&&r++,e.consume(t),i}}function tokenizeTrail(e,t,r){return i;function i(n){return n===33||n===34||n===39||n===41||n===42||n===44||n===46||n===58||n===59||n===63||n===95||n===126?(e.consume(n),i):n===38?(e.consume(n),s):n===93?(e.consume(n),o):n===60||n===null||markdownLineEndingOrSpace(n)||unicodeWhitespace(n)?t(n):r(n)}function o(e){return e===null||e===40||e===91||markdownLineEndingOrSpace(e)||unicodeWhitespace(e)?t(e):i(e)}function s(e){return asciiAlpha(e)?c(e):r(e)}function c(t){return t===59?(e.consume(t),i):asciiAlpha(t)?(e.consume(t),c):r(t)}}function tokenizeEmailDomainDotTrail(e,t,n){return i;function i(t){return e.consume(t),a}function a(e){return asciiAlphanumeric(e)?n(e):t(e)}}function previousWww(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||markdownLineEndingOrSpace(e)}function previousProtocol(e){return!asciiAlpha(e)}function previousEmail(e){return!(e===47||gfmAtext(e))}function gfmAtext(e){return e===43||e===45||e===46||e===95||asciiAlphanumeric(e)}function previousUnbalanced(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const indent={tokenize:tokenizeIndent,partial:!0};function gfmFootnote(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:tokenizeDefinitionStart,continuation:{tokenize:tokenizeDefinitionContinuation},exit:gfmFootnoteDefinitionEnd}},text:{91:{name:`gfmFootnoteCall`,tokenize:tokenizeGfmFootnoteCall},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:tokenizePotentialGfmFootnoteCall,resolveTo:resolveToPotentialGfmFootnoteCall}}}}function tokenizePotentialGfmFootnoteCall(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=normalizeIdentifier(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function resolveToPotentialGfmFootnoteCall(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function tokenizeGfmFootnoteCall(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o=0,s;return c;function c(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(c){if(o>999||c===93&&!s||c===null||c===91||markdownLineEndingOrSpace(c))return n(c);if(c===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(normalizeIdentifier(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(c),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(c)}return markdownLineEndingOrSpace(c)||(s=!0),o++,e.consume(c),c===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}}function tokenizeDefinitionStart(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),s,c=0,l;return u;function u(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),d}function d(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,f):n(t)}function f(t){if(c>999||t===93&&!l||t===null||t===91||markdownLineEndingOrSpace(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return s=normalizeIdentifier(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),h}return markdownLineEndingOrSpace(t)||(l=!0),c++,e.consume(t),t===92?m:f}function m(t){return t===91||t===92||t===93?(e.consume(t),c++,f):f(t)}function h(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(s)||i.push(s),factorySpace(e,g,`gfmFootnoteDefinitionWhitespace`)):n(t)}function g(e){return t(e)}}function tokenizeDefinitionContinuation(e,t,n){return e.check(blankLine,t,e.attempt(indent,t,n))}function gfmFootnoteDefinitionEnd(e){e.exit(`gfmFootnoteDefinition`)}function tokenizeIndent(e,t,n){let r=this;return factorySpace(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function gfmStrikethrough(e){let n=(e||{}).singleTilde,r={name:`strikethrough`,tokenize:a,resolveAll:i};return n??=!0,{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(e,n){let r=-1;for(;++r<e.length;)if(e[r][0]===`enter`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._close){let i=r;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`strikethroughSequenceTemporary`&&e[i][1]._open&&e[r][1].end.offset-e[r][1].start.offset===e[i][1].end.offset-e[i][1].start.offset){e[r][1].type=`strikethroughSequence`,e[i][1].type=`strikethroughSequence`;let a={type:`strikethrough`,start:Object.assign({},e[i][1].start),end:Object.assign({},e[r][1].end)},o={type:`strikethroughText`,start:Object.assign({},e[i][1].end),end:Object.assign({},e[r][1].start)},s=[[`enter`,a,n],[`enter`,e[i][1],n],[`exit`,e[i][1],n],[`enter`,o,n]],c=n.parser.constructs.insideSpan.null;c&&splice(s,s.length,0,resolveAll(c,e.slice(i+1,r),n)),splice(s,s.length,0,[[`exit`,o,n],[`enter`,e[r][1],n],[`exit`,e[r][1],n],[`exit`,a,n]]),splice(e,i-1,r-i+3,s),r=i+s.length-2;break}}for(r=-1;++r<e.length;)e[r][1].type===`strikethroughSequenceTemporary`&&(e[r][1].type=`data`);return e}function a(e,t,r){let i=this.previous,a=this.events,o=0;return c;function c(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),l(t))}function l(a){let c=classifyCharacter(i);if(a===126)return o>1?r(a):(e.consume(a),o++,l);if(o<2&&!n)return r(a);let u=e.exit(`strikethroughSequenceTemporary`),d=classifyCharacter(a);return u._open=!d||d===2&&!!c,u._close=!c||c===2&&!!d,t(a)}}}var EditMap=class{constructor(){this.map=[]}add(e,t,n){addImplementation(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function addImplementation(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function gfmTableAlign(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function gfmTable(){return{flow:{null:{name:`table`,tokenize:tokenizeTable,resolveAll:resolveTable}}}}function tokenizeTable(e,t,n){let r=this,s=0,l=0,u;return d;function d(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?E:f;return a===E&&r.parser.lazy[r.now().line]?n(e):a(e)}function f(t){return e.enter(`tableHead`),e.enter(`tableRow`),p(t)}function p(e){return e===124?m(e):(u=!0,l+=1,m(e))}function m(t){return t===null?n(t):markdownLineEnding(t)?l>1?(l=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_):n(t):markdownSpace(t)?factorySpace(e,m,`whitespace`)(t):(l+=1,u&&(u=!1,s+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),u=!0,m):(e.enter(`data`),h(t)))}function h(t){return t===null||t===124||markdownLineEndingOrSpace(t)?(e.exit(`data`),m(t)):(e.consume(t),t===92?g:h)}function g(t){return t===92||t===124?(e.consume(t),h):h(t)}function _(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),u=!1,markdownSpace(t)?factorySpace(e,v,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):v(t))}function v(t){return t===45||t===58?b(t):t===124?(u=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),y):T(t)}function y(t){return markdownSpace(t)?factorySpace(e,b,`whitespace`)(t):b(t)}function b(t){return t===58?(l+=1,u=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),x):t===45?(l+=1,x(t)):t===null||markdownLineEnding(t)?w(t):T(t)}function x(t){return t===45?(e.enter(`tableDelimiterFiller`),S(t)):T(t)}function S(t){return t===45?(e.consume(t),S):t===58?(u=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),C):(e.exit(`tableDelimiterFiller`),C(t))}function C(t){return markdownSpace(t)?factorySpace(e,w,`whitespace`)(t):w(t)}function w(n){return n===124?v(n):n===null||markdownLineEnding(n)?!u||s!==l?T(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):T(n)}function T(e){return n(e)}function E(t){return e.enter(`tableRow`),D(t)}function D(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),D):n===null||markdownLineEnding(n)?(e.exit(`tableRow`),t(n)):markdownSpace(n)?factorySpace(e,D,`whitespace`)(n):(e.enter(`data`),O(n))}function O(t){return t===null||t===124||markdownLineEndingOrSpace(t)?(e.exit(`data`),D(t)):(e.consume(t),t===92?k:O)}function k(t){return t===92||t===124?(e.consume(t),O):O(t)}}function resolveTable(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new EditMap;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(flushTableEnd(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=flushCell(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=flushCell(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=flushCell(f,t,o,i,n,d)):(o[0]=o[1],d=flushCell(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&flushTableEnd(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=gfmTableAlign(t.events,n))}return e}function flushCell(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},getPoint(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=getPoint(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=getPoint(t.events,n[2]),a=getPoint(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},getPoint(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function flushTableEnd(e,t,n,r,i){let a=[],o=getPoint(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function getPoint(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}const tasklistCheck={name:`tasklistCheck`,tokenize:tokenizeTasklistCheck};function gfmTaskListItem(){return{text:{91:tasklistCheck}}}function tokenizeTasklistCheck(e,t,n){let r=this;return o;function o(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),s)}function s(t){return markdownLineEndingOrSpace(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),l):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),l):n(t)}function l(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),u):n(t)}function u(r){return markdownLineEnding(r)?t(r):markdownSpace(r)?e.check({tokenize:spaceThenNonSpace},t,n)(r):n(r)}}function spaceThenNonSpace(e,t,n){return factorySpace(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function gfm(e){return combineExtensions([gfmAutolinkLiteral(),gfmFootnote(),gfmStrikethrough(e),gfmTable(),gfmTaskListItem()])}export{gfm as t};
|