@harbour-enterprises/superdoc 0.28.0-next.9 → 0.28.1
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/chunks/{PdfViewer-B13bR8VJ.cjs → PdfViewer-Can0yoW4.cjs} +1 -1
- package/dist/chunks/{PdfViewer-DRCcOt2t.es.js → PdfViewer-DJkdA-8o.es.js} +1 -1
- package/dist/chunks/default-BS6z0SoE-BS6z0SoE.es.js +5 -0
- package/dist/chunks/default-BS6z0SoE-Gl4f7Y7J.cjs +4 -0
- package/dist/chunks/{index-DcpSDyC4.cjs → index-BY-vlgKe.cjs} +3 -3
- package/dist/chunks/index-CHAKf7mX-C5aFF6Zl.es.js +2213 -0
- package/dist/chunks/index-CHAKf7mX-Dx-DOGGJ.cjs +2213 -0
- package/dist/chunks/index-CSaZZzfe-BzemjgYL.cjs +264 -0
- package/dist/chunks/index-CSaZZzfe-CSaZZzfe.es.js +265 -0
- package/dist/chunks/index-C_x_N6Uh-DJn8hIEt.es.js +2200 -0
- package/dist/chunks/index-C_x_N6Uh-Db3CUJMX.cjs +2200 -0
- package/dist/chunks/index-Cd3D_8gF-CFhMnajQ.es.js +862 -0
- package/dist/chunks/index-Cd3D_8gF-DKJ_wTu_.cjs +861 -0
- package/dist/chunks/index-CvBqQJbG-CvBqQJbG.es.js +878 -0
- package/dist/chunks/index-CvBqQJbG-Dwm0THD7.cjs +877 -0
- package/dist/chunks/index-DRCvimau-Cw339678.es.js +9876 -0
- package/dist/chunks/index-DRCvimau-H4Ck3S9a.cjs +9876 -0
- package/dist/chunks/index-D_sWOSiG-BtDZzJ6I.cjs +588 -0
- package/dist/chunks/index-D_sWOSiG-DE96TaT5.es.js +588 -0
- package/dist/chunks/{index-KRsMbx-o.es.js → index-DidXsI6u.es.js} +3 -3
- package/dist/chunks/index-njnq8umX-DU2xcaHZ.es.js +845 -0
- package/dist/chunks/index-njnq8umX-_TfP84XP.cjs +845 -0
- package/dist/chunks/{super-editor.es-DKQa7RQl.es.js → super-editor.es-Br566URP.es.js} +6462 -24112
- package/dist/chunks/{super-editor.es-BnJV-Q-L.cjs → super-editor.es-ksiTgGLm.cjs} +6371 -24021
- package/dist/core/types/index.d.ts +6 -6
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-kpd0gAZh.js → converter-D6Z6OmA3.js} +53 -50
- package/dist/super-editor/chunks/default-BS6z0SoE.js +5 -0
- package/dist/super-editor/chunks/{docx-zipper-1SfZh-7P.js → docx-zipper-Dni97kMT.js} +1 -1
- package/dist/super-editor/chunks/{editor-DdEaVosL.js → editor-D3TKfdXs.js} +3762 -21427
- package/dist/super-editor/chunks/index-CHAKf7mX.js +2213 -0
- package/dist/super-editor/chunks/index-CSaZZzfe.js +265 -0
- package/dist/super-editor/chunks/index-C_x_N6Uh.js +2200 -0
- package/dist/super-editor/chunks/index-Cd3D_8gF.js +862 -0
- package/dist/super-editor/chunks/index-CvBqQJbG.js +878 -0
- package/dist/super-editor/chunks/index-DRCvimau.js +9876 -0
- package/dist/super-editor/chunks/index-D_sWOSiG.js +588 -0
- package/dist/super-editor/chunks/index-njnq8umX.js +845 -0
- package/dist/super-editor/chunks/{toolbar-CTt4vWNb.js → toolbar-fNE3luLB.js} +2 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor/src/core/Editor.d.ts +2 -2
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-block.d.ts +8 -6
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content.d.ts +8 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +11 -4
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +11 -4
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTablesById.d.ts +8 -4
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +11 -4
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +12 -5
- package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts +6 -6
- package/dist/super-editor/super-editor.es.js +15 -15
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +74034 -73990
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const indexCd3D_8gF = require("./index-Cd3D_8gF-DKJ_wTu_.cjs");
|
|
4
|
+
const defaultBS6z0SoE = require("./default-BS6z0SoE-Gl4f7Y7J.cjs");
|
|
5
|
+
const indexCSaZZzfe = require("./index-CSaZZzfe-BzemjgYL.cjs");
|
|
6
|
+
function ccount(value, character) {
|
|
7
|
+
const source = String(value);
|
|
8
|
+
if (typeof character !== "string") {
|
|
9
|
+
throw new TypeError("Expected character");
|
|
10
|
+
}
|
|
11
|
+
let count = 0;
|
|
12
|
+
let index = source.indexOf(character);
|
|
13
|
+
while (index !== -1) {
|
|
14
|
+
count++;
|
|
15
|
+
index = source.indexOf(character, index + character.length);
|
|
16
|
+
}
|
|
17
|
+
return count;
|
|
18
|
+
}
|
|
19
|
+
function escapeStringRegexp(string) {
|
|
20
|
+
if (typeof string !== "string") {
|
|
21
|
+
throw new TypeError("Expected a string");
|
|
22
|
+
}
|
|
23
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
24
|
+
}
|
|
25
|
+
function findAndReplace(tree, list, options) {
|
|
26
|
+
const settings = options || {};
|
|
27
|
+
const ignored = indexCSaZZzfe.convert(settings.ignore || []);
|
|
28
|
+
const pairs = toPairs(list);
|
|
29
|
+
let pairIndex = -1;
|
|
30
|
+
while (++pairIndex < pairs.length) {
|
|
31
|
+
indexCSaZZzfe.visitParents(tree, "text", visitor);
|
|
32
|
+
}
|
|
33
|
+
function visitor(node, parents) {
|
|
34
|
+
let index = -1;
|
|
35
|
+
let grandparent;
|
|
36
|
+
while (++index < parents.length) {
|
|
37
|
+
const parent = parents[index];
|
|
38
|
+
const siblings = grandparent ? grandparent.children : void 0;
|
|
39
|
+
if (ignored(
|
|
40
|
+
parent,
|
|
41
|
+
siblings ? siblings.indexOf(parent) : void 0,
|
|
42
|
+
grandparent
|
|
43
|
+
)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
grandparent = parent;
|
|
47
|
+
}
|
|
48
|
+
if (grandparent) {
|
|
49
|
+
return handler(node, parents);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function handler(node, parents) {
|
|
53
|
+
const parent = parents[parents.length - 1];
|
|
54
|
+
const find = pairs[pairIndex][0];
|
|
55
|
+
const replace2 = pairs[pairIndex][1];
|
|
56
|
+
let start = 0;
|
|
57
|
+
const siblings = parent.children;
|
|
58
|
+
const index = siblings.indexOf(node);
|
|
59
|
+
let change = false;
|
|
60
|
+
let nodes = [];
|
|
61
|
+
find.lastIndex = 0;
|
|
62
|
+
let match = find.exec(node.value);
|
|
63
|
+
while (match) {
|
|
64
|
+
const position = match.index;
|
|
65
|
+
const matchObject = {
|
|
66
|
+
index: match.index,
|
|
67
|
+
input: match.input,
|
|
68
|
+
stack: [...parents, node]
|
|
69
|
+
};
|
|
70
|
+
let value = replace2(...match, matchObject);
|
|
71
|
+
if (typeof value === "string") {
|
|
72
|
+
value = value.length > 0 ? { type: "text", value } : void 0;
|
|
73
|
+
}
|
|
74
|
+
if (value === false) {
|
|
75
|
+
find.lastIndex = position + 1;
|
|
76
|
+
} else {
|
|
77
|
+
if (start !== position) {
|
|
78
|
+
nodes.push({
|
|
79
|
+
type: "text",
|
|
80
|
+
value: node.value.slice(start, position)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
nodes.push(...value);
|
|
85
|
+
} else if (value) {
|
|
86
|
+
nodes.push(value);
|
|
87
|
+
}
|
|
88
|
+
start = position + match[0].length;
|
|
89
|
+
change = true;
|
|
90
|
+
}
|
|
91
|
+
if (!find.global) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
match = find.exec(node.value);
|
|
95
|
+
}
|
|
96
|
+
if (change) {
|
|
97
|
+
if (start < node.value.length) {
|
|
98
|
+
nodes.push({ type: "text", value: node.value.slice(start) });
|
|
99
|
+
}
|
|
100
|
+
parent.children.splice(index, 1, ...nodes);
|
|
101
|
+
} else {
|
|
102
|
+
nodes = [node];
|
|
103
|
+
}
|
|
104
|
+
return index + nodes.length;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function toPairs(tupleOrList) {
|
|
108
|
+
const result = [];
|
|
109
|
+
if (!Array.isArray(tupleOrList)) {
|
|
110
|
+
throw new TypeError("Expected find and replace tuple or list of tuples");
|
|
111
|
+
}
|
|
112
|
+
const list = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? tupleOrList : [tupleOrList];
|
|
113
|
+
let index = -1;
|
|
114
|
+
while (++index < list.length) {
|
|
115
|
+
const tuple = list[index];
|
|
116
|
+
result.push([toExpression(tuple[0]), toFunction(tuple[1])]);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
function toExpression(find) {
|
|
121
|
+
return typeof find === "string" ? new RegExp(escapeStringRegexp(find), "g") : find;
|
|
122
|
+
}
|
|
123
|
+
function toFunction(replace2) {
|
|
124
|
+
return typeof replace2 === "function" ? replace2 : function() {
|
|
125
|
+
return replace2;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const inConstruct = "phrasing";
|
|
129
|
+
const notInConstruct = ["autolink", "link", "image", "label"];
|
|
130
|
+
function gfmAutolinkLiteralFromMarkdown() {
|
|
131
|
+
return {
|
|
132
|
+
transforms: [transformGfmAutolinkLiterals],
|
|
133
|
+
enter: {
|
|
134
|
+
literalAutolink: enterLiteralAutolink,
|
|
135
|
+
literalAutolinkEmail: enterLiteralAutolinkValue,
|
|
136
|
+
literalAutolinkHttp: enterLiteralAutolinkValue,
|
|
137
|
+
literalAutolinkWww: enterLiteralAutolinkValue
|
|
138
|
+
},
|
|
139
|
+
exit: {
|
|
140
|
+
literalAutolink: exitLiteralAutolink,
|
|
141
|
+
literalAutolinkEmail: exitLiteralAutolinkEmail,
|
|
142
|
+
literalAutolinkHttp: exitLiteralAutolinkHttp,
|
|
143
|
+
literalAutolinkWww: exitLiteralAutolinkWww
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function gfmAutolinkLiteralToMarkdown() {
|
|
148
|
+
return {
|
|
149
|
+
unsafe: [
|
|
150
|
+
{
|
|
151
|
+
character: "@",
|
|
152
|
+
before: "[+\\-.\\w]",
|
|
153
|
+
after: "[\\-.\\w]",
|
|
154
|
+
inConstruct,
|
|
155
|
+
notInConstruct
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
character: ".",
|
|
159
|
+
before: "[Ww]",
|
|
160
|
+
after: "[\\-.\\w]",
|
|
161
|
+
inConstruct,
|
|
162
|
+
notInConstruct
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
character: ":",
|
|
166
|
+
before: "[ps]",
|
|
167
|
+
after: "\\/",
|
|
168
|
+
inConstruct,
|
|
169
|
+
notInConstruct
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function enterLiteralAutolink(token) {
|
|
175
|
+
this.enter({ type: "link", title: null, url: "", children: [] }, token);
|
|
176
|
+
}
|
|
177
|
+
function enterLiteralAutolinkValue(token) {
|
|
178
|
+
this.config.enter.autolinkProtocol.call(this, token);
|
|
179
|
+
}
|
|
180
|
+
function exitLiteralAutolinkHttp(token) {
|
|
181
|
+
this.config.exit.autolinkProtocol.call(this, token);
|
|
182
|
+
}
|
|
183
|
+
function exitLiteralAutolinkWww(token) {
|
|
184
|
+
this.config.exit.data.call(this, token);
|
|
185
|
+
const node = this.stack[this.stack.length - 1];
|
|
186
|
+
defaultBS6z0SoE.ok(node.type === "link");
|
|
187
|
+
node.url = "http://" + this.sliceSerialize(token);
|
|
188
|
+
}
|
|
189
|
+
function exitLiteralAutolinkEmail(token) {
|
|
190
|
+
this.config.exit.autolinkEmail.call(this, token);
|
|
191
|
+
}
|
|
192
|
+
function exitLiteralAutolink(token) {
|
|
193
|
+
this.exit(token);
|
|
194
|
+
}
|
|
195
|
+
function transformGfmAutolinkLiterals(tree) {
|
|
196
|
+
findAndReplace(
|
|
197
|
+
tree,
|
|
198
|
+
[
|
|
199
|
+
[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
|
|
200
|
+
[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
|
|
201
|
+
],
|
|
202
|
+
{ ignore: ["link", "linkReference"] }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
function findUrl(_, protocol, domain2, path2, match) {
|
|
206
|
+
let prefix = "";
|
|
207
|
+
if (!previous(match)) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (/^w/i.test(protocol)) {
|
|
211
|
+
domain2 = protocol + domain2;
|
|
212
|
+
protocol = "";
|
|
213
|
+
prefix = "http://";
|
|
214
|
+
}
|
|
215
|
+
if (!isCorrectDomain(domain2)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const parts = splitUrl(domain2 + path2);
|
|
219
|
+
if (!parts[0]) return false;
|
|
220
|
+
const result = {
|
|
221
|
+
type: "link",
|
|
222
|
+
title: null,
|
|
223
|
+
url: prefix + protocol + parts[0],
|
|
224
|
+
children: [{ type: "text", value: protocol + parts[0] }]
|
|
225
|
+
};
|
|
226
|
+
if (parts[1]) {
|
|
227
|
+
return [result, { type: "text", value: parts[1] }];
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
function findEmail(_, atext, label, match) {
|
|
232
|
+
if (
|
|
233
|
+
// Not an expected previous character.
|
|
234
|
+
!previous(match, true) || // Label ends in not allowed character.
|
|
235
|
+
/[-\d_]$/.test(label)
|
|
236
|
+
) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
type: "link",
|
|
241
|
+
title: null,
|
|
242
|
+
url: "mailto:" + atext + "@" + label,
|
|
243
|
+
children: [{ type: "text", value: atext + "@" + label }]
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function isCorrectDomain(domain2) {
|
|
247
|
+
const parts = domain2.split(".");
|
|
248
|
+
if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[a-zA-Z\d]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
function splitUrl(url) {
|
|
254
|
+
const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url);
|
|
255
|
+
if (!trailExec) {
|
|
256
|
+
return [url, void 0];
|
|
257
|
+
}
|
|
258
|
+
url = url.slice(0, trailExec.index);
|
|
259
|
+
let trail2 = trailExec[0];
|
|
260
|
+
let closingParenIndex = trail2.indexOf(")");
|
|
261
|
+
const openingParens = ccount(url, "(");
|
|
262
|
+
let closingParens = ccount(url, ")");
|
|
263
|
+
while (closingParenIndex !== -1 && openingParens > closingParens) {
|
|
264
|
+
url += trail2.slice(0, closingParenIndex + 1);
|
|
265
|
+
trail2 = trail2.slice(closingParenIndex + 1);
|
|
266
|
+
closingParenIndex = trail2.indexOf(")");
|
|
267
|
+
closingParens++;
|
|
268
|
+
}
|
|
269
|
+
return [url, trail2];
|
|
270
|
+
}
|
|
271
|
+
function previous(match, email) {
|
|
272
|
+
const code2 = match.input.charCodeAt(match.index - 1);
|
|
273
|
+
return (match.index === 0 || indexCd3D_8gF.unicodeWhitespace(code2) || indexCd3D_8gF.unicodePunctuation(code2)) && // If it’s an email, the previous character should not be a slash.
|
|
274
|
+
(!email || code2 !== 47);
|
|
275
|
+
}
|
|
276
|
+
function normalizeIdentifier(value) {
|
|
277
|
+
return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
|
|
278
|
+
}
|
|
279
|
+
footnoteReference.peek = footnoteReferencePeek;
|
|
280
|
+
function enterFootnoteCallString() {
|
|
281
|
+
this.buffer();
|
|
282
|
+
}
|
|
283
|
+
function enterFootnoteCall(token) {
|
|
284
|
+
this.enter({ type: "footnoteReference", identifier: "", label: "" }, token);
|
|
285
|
+
}
|
|
286
|
+
function enterFootnoteDefinitionLabelString() {
|
|
287
|
+
this.buffer();
|
|
288
|
+
}
|
|
289
|
+
function enterFootnoteDefinition(token) {
|
|
290
|
+
this.enter(
|
|
291
|
+
{ type: "footnoteDefinition", identifier: "", label: "", children: [] },
|
|
292
|
+
token
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
function exitFootnoteCallString(token) {
|
|
296
|
+
const label = this.resume();
|
|
297
|
+
const node = this.stack[this.stack.length - 1];
|
|
298
|
+
defaultBS6z0SoE.ok(node.type === "footnoteReference");
|
|
299
|
+
node.identifier = normalizeIdentifier(
|
|
300
|
+
this.sliceSerialize(token)
|
|
301
|
+
).toLowerCase();
|
|
302
|
+
node.label = label;
|
|
303
|
+
}
|
|
304
|
+
function exitFootnoteCall(token) {
|
|
305
|
+
this.exit(token);
|
|
306
|
+
}
|
|
307
|
+
function exitFootnoteDefinitionLabelString(token) {
|
|
308
|
+
const label = this.resume();
|
|
309
|
+
const node = this.stack[this.stack.length - 1];
|
|
310
|
+
defaultBS6z0SoE.ok(node.type === "footnoteDefinition");
|
|
311
|
+
node.identifier = normalizeIdentifier(
|
|
312
|
+
this.sliceSerialize(token)
|
|
313
|
+
).toLowerCase();
|
|
314
|
+
node.label = label;
|
|
315
|
+
}
|
|
316
|
+
function exitFootnoteDefinition(token) {
|
|
317
|
+
this.exit(token);
|
|
318
|
+
}
|
|
319
|
+
function footnoteReferencePeek() {
|
|
320
|
+
return "[";
|
|
321
|
+
}
|
|
322
|
+
function footnoteReference(node, _, state, info) {
|
|
323
|
+
const tracker = state.createTracker(info);
|
|
324
|
+
let value = tracker.move("[^");
|
|
325
|
+
const exit2 = state.enter("footnoteReference");
|
|
326
|
+
const subexit = state.enter("reference");
|
|
327
|
+
value += tracker.move(
|
|
328
|
+
state.safe(state.associationId(node), { after: "]", before: value })
|
|
329
|
+
);
|
|
330
|
+
subexit();
|
|
331
|
+
exit2();
|
|
332
|
+
value += tracker.move("]");
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
335
|
+
function gfmFootnoteFromMarkdown() {
|
|
336
|
+
return {
|
|
337
|
+
enter: {
|
|
338
|
+
gfmFootnoteCallString: enterFootnoteCallString,
|
|
339
|
+
gfmFootnoteCall: enterFootnoteCall,
|
|
340
|
+
gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
|
|
341
|
+
gfmFootnoteDefinition: enterFootnoteDefinition
|
|
342
|
+
},
|
|
343
|
+
exit: {
|
|
344
|
+
gfmFootnoteCallString: exitFootnoteCallString,
|
|
345
|
+
gfmFootnoteCall: exitFootnoteCall,
|
|
346
|
+
gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
|
|
347
|
+
gfmFootnoteDefinition: exitFootnoteDefinition
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function gfmFootnoteToMarkdown(options) {
|
|
352
|
+
let firstLineBlank = false;
|
|
353
|
+
if (options && options.firstLineBlank) {
|
|
354
|
+
firstLineBlank = true;
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
handlers: { footnoteDefinition, footnoteReference },
|
|
358
|
+
// This is on by default already.
|
|
359
|
+
unsafe: [{ character: "[", inConstruct: ["label", "phrasing", "reference"] }]
|
|
360
|
+
};
|
|
361
|
+
function footnoteDefinition(node, _, state, info) {
|
|
362
|
+
const tracker = state.createTracker(info);
|
|
363
|
+
let value = tracker.move("[^");
|
|
364
|
+
const exit2 = state.enter("footnoteDefinition");
|
|
365
|
+
const subexit = state.enter("label");
|
|
366
|
+
value += tracker.move(
|
|
367
|
+
state.safe(state.associationId(node), { before: value, after: "]" })
|
|
368
|
+
);
|
|
369
|
+
subexit();
|
|
370
|
+
value += tracker.move("]:");
|
|
371
|
+
if (node.children && node.children.length > 0) {
|
|
372
|
+
tracker.shift(4);
|
|
373
|
+
value += tracker.move(
|
|
374
|
+
(firstLineBlank ? "\n" : " ") + state.indentLines(
|
|
375
|
+
state.containerFlow(node, tracker.current()),
|
|
376
|
+
firstLineBlank ? mapAll : mapExceptFirst
|
|
377
|
+
)
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
exit2();
|
|
381
|
+
return value;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function mapExceptFirst(line, index, blank) {
|
|
385
|
+
return index === 0 ? line : mapAll(line, index, blank);
|
|
386
|
+
}
|
|
387
|
+
function mapAll(line, index, blank) {
|
|
388
|
+
return (blank ? "" : " ") + line;
|
|
389
|
+
}
|
|
390
|
+
const constructsWithoutStrikethrough = [
|
|
391
|
+
"autolink",
|
|
392
|
+
"destinationLiteral",
|
|
393
|
+
"destinationRaw",
|
|
394
|
+
"reference",
|
|
395
|
+
"titleQuote",
|
|
396
|
+
"titleApostrophe"
|
|
397
|
+
];
|
|
398
|
+
handleDelete.peek = peekDelete;
|
|
399
|
+
function gfmStrikethroughFromMarkdown() {
|
|
400
|
+
return {
|
|
401
|
+
canContainEols: ["delete"],
|
|
402
|
+
enter: { strikethrough: enterStrikethrough },
|
|
403
|
+
exit: { strikethrough: exitStrikethrough }
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function gfmStrikethroughToMarkdown() {
|
|
407
|
+
return {
|
|
408
|
+
unsafe: [
|
|
409
|
+
{
|
|
410
|
+
character: "~",
|
|
411
|
+
inConstruct: "phrasing",
|
|
412
|
+
notInConstruct: constructsWithoutStrikethrough
|
|
413
|
+
}
|
|
414
|
+
],
|
|
415
|
+
handlers: { delete: handleDelete }
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function enterStrikethrough(token) {
|
|
419
|
+
this.enter({ type: "delete", children: [] }, token);
|
|
420
|
+
}
|
|
421
|
+
function exitStrikethrough(token) {
|
|
422
|
+
this.exit(token);
|
|
423
|
+
}
|
|
424
|
+
function handleDelete(node, _, state, info) {
|
|
425
|
+
const tracker = state.createTracker(info);
|
|
426
|
+
const exit2 = state.enter("strikethrough");
|
|
427
|
+
let value = tracker.move("~~");
|
|
428
|
+
value += state.containerPhrasing(node, {
|
|
429
|
+
...tracker.current(),
|
|
430
|
+
before: value,
|
|
431
|
+
after: "~"
|
|
432
|
+
});
|
|
433
|
+
value += tracker.move("~~");
|
|
434
|
+
exit2();
|
|
435
|
+
return value;
|
|
436
|
+
}
|
|
437
|
+
function peekDelete() {
|
|
438
|
+
return "~";
|
|
439
|
+
}
|
|
440
|
+
function defaultStringLength(value) {
|
|
441
|
+
return value.length;
|
|
442
|
+
}
|
|
443
|
+
function markdownTable(table, options) {
|
|
444
|
+
const settings = options || {};
|
|
445
|
+
const align = (settings.align || []).concat();
|
|
446
|
+
const stringLength = settings.stringLength || defaultStringLength;
|
|
447
|
+
const alignments = [];
|
|
448
|
+
const cellMatrix = [];
|
|
449
|
+
const sizeMatrix = [];
|
|
450
|
+
const longestCellByColumn = [];
|
|
451
|
+
let mostCellsPerRow = 0;
|
|
452
|
+
let rowIndex = -1;
|
|
453
|
+
while (++rowIndex < table.length) {
|
|
454
|
+
const row2 = [];
|
|
455
|
+
const sizes2 = [];
|
|
456
|
+
let columnIndex2 = -1;
|
|
457
|
+
if (table[rowIndex].length > mostCellsPerRow) {
|
|
458
|
+
mostCellsPerRow = table[rowIndex].length;
|
|
459
|
+
}
|
|
460
|
+
while (++columnIndex2 < table[rowIndex].length) {
|
|
461
|
+
const cell = serialize(table[rowIndex][columnIndex2]);
|
|
462
|
+
if (settings.alignDelimiters !== false) {
|
|
463
|
+
const size = stringLength(cell);
|
|
464
|
+
sizes2[columnIndex2] = size;
|
|
465
|
+
if (longestCellByColumn[columnIndex2] === void 0 || size > longestCellByColumn[columnIndex2]) {
|
|
466
|
+
longestCellByColumn[columnIndex2] = size;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
row2.push(cell);
|
|
470
|
+
}
|
|
471
|
+
cellMatrix[rowIndex] = row2;
|
|
472
|
+
sizeMatrix[rowIndex] = sizes2;
|
|
473
|
+
}
|
|
474
|
+
let columnIndex = -1;
|
|
475
|
+
if (typeof align === "object" && "length" in align) {
|
|
476
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
477
|
+
alignments[columnIndex] = toAlignment(align[columnIndex]);
|
|
478
|
+
}
|
|
479
|
+
} else {
|
|
480
|
+
const code2 = toAlignment(align);
|
|
481
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
482
|
+
alignments[columnIndex] = code2;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
columnIndex = -1;
|
|
486
|
+
const row = [];
|
|
487
|
+
const sizes = [];
|
|
488
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
489
|
+
const code2 = alignments[columnIndex];
|
|
490
|
+
let before = "";
|
|
491
|
+
let after = "";
|
|
492
|
+
if (code2 === 99) {
|
|
493
|
+
before = ":";
|
|
494
|
+
after = ":";
|
|
495
|
+
} else if (code2 === 108) {
|
|
496
|
+
before = ":";
|
|
497
|
+
} else if (code2 === 114) {
|
|
498
|
+
after = ":";
|
|
499
|
+
}
|
|
500
|
+
let size = settings.alignDelimiters === false ? 1 : Math.max(
|
|
501
|
+
1,
|
|
502
|
+
longestCellByColumn[columnIndex] - before.length - after.length
|
|
503
|
+
);
|
|
504
|
+
const cell = before + "-".repeat(size) + after;
|
|
505
|
+
if (settings.alignDelimiters !== false) {
|
|
506
|
+
size = before.length + size + after.length;
|
|
507
|
+
if (size > longestCellByColumn[columnIndex]) {
|
|
508
|
+
longestCellByColumn[columnIndex] = size;
|
|
509
|
+
}
|
|
510
|
+
sizes[columnIndex] = size;
|
|
511
|
+
}
|
|
512
|
+
row[columnIndex] = cell;
|
|
513
|
+
}
|
|
514
|
+
cellMatrix.splice(1, 0, row);
|
|
515
|
+
sizeMatrix.splice(1, 0, sizes);
|
|
516
|
+
rowIndex = -1;
|
|
517
|
+
const lines = [];
|
|
518
|
+
while (++rowIndex < cellMatrix.length) {
|
|
519
|
+
const row2 = cellMatrix[rowIndex];
|
|
520
|
+
const sizes2 = sizeMatrix[rowIndex];
|
|
521
|
+
columnIndex = -1;
|
|
522
|
+
const line = [];
|
|
523
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
524
|
+
const cell = row2[columnIndex] || "";
|
|
525
|
+
let before = "";
|
|
526
|
+
let after = "";
|
|
527
|
+
if (settings.alignDelimiters !== false) {
|
|
528
|
+
const size = longestCellByColumn[columnIndex] - (sizes2[columnIndex] || 0);
|
|
529
|
+
const code2 = alignments[columnIndex];
|
|
530
|
+
if (code2 === 114) {
|
|
531
|
+
before = " ".repeat(size);
|
|
532
|
+
} else if (code2 === 99) {
|
|
533
|
+
if (size % 2) {
|
|
534
|
+
before = " ".repeat(size / 2 + 0.5);
|
|
535
|
+
after = " ".repeat(size / 2 - 0.5);
|
|
536
|
+
} else {
|
|
537
|
+
before = " ".repeat(size / 2);
|
|
538
|
+
after = before;
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
after = " ".repeat(size);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (settings.delimiterStart !== false && !columnIndex) {
|
|
545
|
+
line.push("|");
|
|
546
|
+
}
|
|
547
|
+
if (settings.padding !== false && // Don’t add the opening space if we’re not aligning and the cell is
|
|
548
|
+
// empty: there will be a closing space.
|
|
549
|
+
!(settings.alignDelimiters === false && cell === "") && (settings.delimiterStart !== false || columnIndex)) {
|
|
550
|
+
line.push(" ");
|
|
551
|
+
}
|
|
552
|
+
if (settings.alignDelimiters !== false) {
|
|
553
|
+
line.push(before);
|
|
554
|
+
}
|
|
555
|
+
line.push(cell);
|
|
556
|
+
if (settings.alignDelimiters !== false) {
|
|
557
|
+
line.push(after);
|
|
558
|
+
}
|
|
559
|
+
if (settings.padding !== false) {
|
|
560
|
+
line.push(" ");
|
|
561
|
+
}
|
|
562
|
+
if (settings.delimiterEnd !== false || columnIndex !== mostCellsPerRow - 1) {
|
|
563
|
+
line.push("|");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
lines.push(
|
|
567
|
+
settings.delimiterEnd === false ? line.join("").replace(/ +$/, "") : line.join("")
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
return lines.join("\n");
|
|
571
|
+
}
|
|
572
|
+
function serialize(value) {
|
|
573
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
574
|
+
}
|
|
575
|
+
function toAlignment(value) {
|
|
576
|
+
const code2 = typeof value === "string" ? value.codePointAt(0) : 0;
|
|
577
|
+
return code2 === 67 || code2 === 99 ? 99 : code2 === 76 || code2 === 108 ? 108 : code2 === 82 || code2 === 114 ? 114 : 0;
|
|
578
|
+
}
|
|
579
|
+
function gfmTableFromMarkdown() {
|
|
580
|
+
return {
|
|
581
|
+
enter: {
|
|
582
|
+
table: enterTable,
|
|
583
|
+
tableData: enterCell,
|
|
584
|
+
tableHeader: enterCell,
|
|
585
|
+
tableRow: enterRow
|
|
586
|
+
},
|
|
587
|
+
exit: {
|
|
588
|
+
codeText: exitCodeText,
|
|
589
|
+
table: exitTable,
|
|
590
|
+
tableData: exit,
|
|
591
|
+
tableHeader: exit,
|
|
592
|
+
tableRow: exit
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function enterTable(token) {
|
|
597
|
+
const align = token._align;
|
|
598
|
+
this.enter(
|
|
599
|
+
{
|
|
600
|
+
type: "table",
|
|
601
|
+
align: align.map(function(d) {
|
|
602
|
+
return d === "none" ? null : d;
|
|
603
|
+
}),
|
|
604
|
+
children: []
|
|
605
|
+
},
|
|
606
|
+
token
|
|
607
|
+
);
|
|
608
|
+
this.data.inTable = true;
|
|
609
|
+
}
|
|
610
|
+
function exitTable(token) {
|
|
611
|
+
this.exit(token);
|
|
612
|
+
this.data.inTable = void 0;
|
|
613
|
+
}
|
|
614
|
+
function enterRow(token) {
|
|
615
|
+
this.enter({ type: "tableRow", children: [] }, token);
|
|
616
|
+
}
|
|
617
|
+
function exit(token) {
|
|
618
|
+
this.exit(token);
|
|
619
|
+
}
|
|
620
|
+
function enterCell(token) {
|
|
621
|
+
this.enter({ type: "tableCell", children: [] }, token);
|
|
622
|
+
}
|
|
623
|
+
function exitCodeText(token) {
|
|
624
|
+
let value = this.resume();
|
|
625
|
+
if (this.data.inTable) {
|
|
626
|
+
value = value.replace(/\\([\\|])/g, replace);
|
|
627
|
+
}
|
|
628
|
+
const node = this.stack[this.stack.length - 1];
|
|
629
|
+
defaultBS6z0SoE.ok(node.type === "inlineCode");
|
|
630
|
+
node.value = value;
|
|
631
|
+
this.exit(token);
|
|
632
|
+
}
|
|
633
|
+
function replace($0, $1) {
|
|
634
|
+
return $1 === "|" ? $1 : $0;
|
|
635
|
+
}
|
|
636
|
+
function gfmTableToMarkdown(options) {
|
|
637
|
+
const settings = options || {};
|
|
638
|
+
const padding = settings.tableCellPadding;
|
|
639
|
+
const alignDelimiters = settings.tablePipeAlign;
|
|
640
|
+
const stringLength = settings.stringLength;
|
|
641
|
+
const around = padding ? " " : "|";
|
|
642
|
+
return {
|
|
643
|
+
unsafe: [
|
|
644
|
+
{ character: "\r", inConstruct: "tableCell" },
|
|
645
|
+
{ character: "\n", inConstruct: "tableCell" },
|
|
646
|
+
// A pipe, when followed by a tab or space (padding), or a dash or colon
|
|
647
|
+
// (unpadded delimiter row), could result in a table.
|
|
648
|
+
{ atBreak: true, character: "|", after: "[ :-]" },
|
|
649
|
+
// A pipe in a cell must be encoded.
|
|
650
|
+
{ character: "|", inConstruct: "tableCell" },
|
|
651
|
+
// A colon must be followed by a dash, in which case it could start a
|
|
652
|
+
// delimiter row.
|
|
653
|
+
{ atBreak: true, character: ":", after: "-" },
|
|
654
|
+
// A delimiter row can also start with a dash, when followed by more
|
|
655
|
+
// dashes, a colon, or a pipe.
|
|
656
|
+
// This is a stricter version than the built in check for lists, thematic
|
|
657
|
+
// breaks, and setex heading underlines though:
|
|
658
|
+
// <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
|
|
659
|
+
{ atBreak: true, character: "-", after: "[:|-]" }
|
|
660
|
+
],
|
|
661
|
+
handlers: {
|
|
662
|
+
inlineCode: inlineCodeWithTable,
|
|
663
|
+
table: handleTable,
|
|
664
|
+
tableCell: handleTableCell,
|
|
665
|
+
tableRow: handleTableRow
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
function handleTable(node, _, state, info) {
|
|
669
|
+
return serializeData(handleTableAsData(node, state, info), node.align);
|
|
670
|
+
}
|
|
671
|
+
function handleTableRow(node, _, state, info) {
|
|
672
|
+
const row = handleTableRowAsData(node, state, info);
|
|
673
|
+
const value = serializeData([row]);
|
|
674
|
+
return value.slice(0, value.indexOf("\n"));
|
|
675
|
+
}
|
|
676
|
+
function handleTableCell(node, _, state, info) {
|
|
677
|
+
const exit2 = state.enter("tableCell");
|
|
678
|
+
const subexit = state.enter("phrasing");
|
|
679
|
+
const value = state.containerPhrasing(node, {
|
|
680
|
+
...info,
|
|
681
|
+
before: around,
|
|
682
|
+
after: around
|
|
683
|
+
});
|
|
684
|
+
subexit();
|
|
685
|
+
exit2();
|
|
686
|
+
return value;
|
|
687
|
+
}
|
|
688
|
+
function serializeData(matrix, align) {
|
|
689
|
+
return markdownTable(matrix, {
|
|
690
|
+
align,
|
|
691
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
692
|
+
alignDelimiters,
|
|
693
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
694
|
+
padding,
|
|
695
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
696
|
+
stringLength
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function handleTableAsData(node, state, info) {
|
|
700
|
+
const children = node.children;
|
|
701
|
+
let index = -1;
|
|
702
|
+
const result = [];
|
|
703
|
+
const subexit = state.enter("table");
|
|
704
|
+
while (++index < children.length) {
|
|
705
|
+
result[index] = handleTableRowAsData(children[index], state, info);
|
|
706
|
+
}
|
|
707
|
+
subexit();
|
|
708
|
+
return result;
|
|
709
|
+
}
|
|
710
|
+
function handleTableRowAsData(node, state, info) {
|
|
711
|
+
const children = node.children;
|
|
712
|
+
let index = -1;
|
|
713
|
+
const result = [];
|
|
714
|
+
const subexit = state.enter("tableRow");
|
|
715
|
+
while (++index < children.length) {
|
|
716
|
+
result[index] = handleTableCell(children[index], node, state, info);
|
|
717
|
+
}
|
|
718
|
+
subexit();
|
|
719
|
+
return result;
|
|
720
|
+
}
|
|
721
|
+
function inlineCodeWithTable(node, parent, state) {
|
|
722
|
+
let value = indexCd3D_8gF.handle.inlineCode(node, parent, state);
|
|
723
|
+
if (state.stack.includes("tableCell")) {
|
|
724
|
+
value = value.replace(/\|/g, "\\$&");
|
|
725
|
+
}
|
|
726
|
+
return value;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function gfmTaskListItemFromMarkdown() {
|
|
730
|
+
return {
|
|
731
|
+
exit: {
|
|
732
|
+
taskListCheckValueChecked: exitCheck,
|
|
733
|
+
taskListCheckValueUnchecked: exitCheck,
|
|
734
|
+
paragraph: exitParagraphWithTaskListItem
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function gfmTaskListItemToMarkdown() {
|
|
739
|
+
return {
|
|
740
|
+
unsafe: [{ atBreak: true, character: "-", after: "[:|-]" }],
|
|
741
|
+
handlers: { listItem: listItemWithTaskListItem }
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function exitCheck(token) {
|
|
745
|
+
const node = this.stack[this.stack.length - 2];
|
|
746
|
+
defaultBS6z0SoE.ok(node.type === "listItem");
|
|
747
|
+
node.checked = token.type === "taskListCheckValueChecked";
|
|
748
|
+
}
|
|
749
|
+
function exitParagraphWithTaskListItem(token) {
|
|
750
|
+
const parent = this.stack[this.stack.length - 2];
|
|
751
|
+
if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
|
|
752
|
+
const node = this.stack[this.stack.length - 1];
|
|
753
|
+
defaultBS6z0SoE.ok(node.type === "paragraph");
|
|
754
|
+
const head = node.children[0];
|
|
755
|
+
if (head && head.type === "text") {
|
|
756
|
+
const siblings = parent.children;
|
|
757
|
+
let index = -1;
|
|
758
|
+
let firstParaghraph;
|
|
759
|
+
while (++index < siblings.length) {
|
|
760
|
+
const sibling = siblings[index];
|
|
761
|
+
if (sibling.type === "paragraph") {
|
|
762
|
+
firstParaghraph = sibling;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (firstParaghraph === node) {
|
|
767
|
+
head.value = head.value.slice(1);
|
|
768
|
+
if (head.value.length === 0) {
|
|
769
|
+
node.children.shift();
|
|
770
|
+
} else if (node.position && head.position && typeof head.position.start.offset === "number") {
|
|
771
|
+
head.position.start.column++;
|
|
772
|
+
head.position.start.offset++;
|
|
773
|
+
node.position.start = Object.assign({}, head.position.start);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
this.exit(token);
|
|
779
|
+
}
|
|
780
|
+
function listItemWithTaskListItem(node, parent, state, info) {
|
|
781
|
+
const head = node.children[0];
|
|
782
|
+
const checkable = typeof node.checked === "boolean" && head && head.type === "paragraph";
|
|
783
|
+
const checkbox = "[" + (node.checked ? "x" : " ") + "] ";
|
|
784
|
+
const tracker = state.createTracker(info);
|
|
785
|
+
if (checkable) {
|
|
786
|
+
tracker.move(checkbox);
|
|
787
|
+
}
|
|
788
|
+
let value = indexCd3D_8gF.handle.listItem(node, parent, state, {
|
|
789
|
+
...info,
|
|
790
|
+
...tracker.current()
|
|
791
|
+
});
|
|
792
|
+
if (checkable) {
|
|
793
|
+
value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check);
|
|
794
|
+
}
|
|
795
|
+
return value;
|
|
796
|
+
function check($0) {
|
|
797
|
+
return $0 + checkbox;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
function gfmFromMarkdown() {
|
|
801
|
+
return [
|
|
802
|
+
gfmAutolinkLiteralFromMarkdown(),
|
|
803
|
+
gfmFootnoteFromMarkdown(),
|
|
804
|
+
gfmStrikethroughFromMarkdown(),
|
|
805
|
+
gfmTableFromMarkdown(),
|
|
806
|
+
gfmTaskListItemFromMarkdown()
|
|
807
|
+
];
|
|
808
|
+
}
|
|
809
|
+
function gfmToMarkdown(options) {
|
|
810
|
+
return {
|
|
811
|
+
extensions: [
|
|
812
|
+
gfmAutolinkLiteralToMarkdown(),
|
|
813
|
+
gfmFootnoteToMarkdown(options),
|
|
814
|
+
gfmStrikethroughToMarkdown(),
|
|
815
|
+
gfmTableToMarkdown(options),
|
|
816
|
+
gfmTaskListItemToMarkdown()
|
|
817
|
+
]
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function splice(list, start, remove, items) {
|
|
821
|
+
const end = list.length;
|
|
822
|
+
let chunkStart = 0;
|
|
823
|
+
let parameters;
|
|
824
|
+
if (start < 0) {
|
|
825
|
+
start = -start > end ? 0 : end + start;
|
|
826
|
+
} else {
|
|
827
|
+
start = start > end ? end : start;
|
|
828
|
+
}
|
|
829
|
+
remove = remove > 0 ? remove : 0;
|
|
830
|
+
if (items.length < 1e4) {
|
|
831
|
+
parameters = Array.from(items);
|
|
832
|
+
parameters.unshift(start, remove);
|
|
833
|
+
list.splice(...parameters);
|
|
834
|
+
} else {
|
|
835
|
+
if (remove) list.splice(start, remove);
|
|
836
|
+
while (chunkStart < items.length) {
|
|
837
|
+
parameters = items.slice(chunkStart, chunkStart + 1e4);
|
|
838
|
+
parameters.unshift(start, 0);
|
|
839
|
+
list.splice(...parameters);
|
|
840
|
+
chunkStart += 1e4;
|
|
841
|
+
start += 1e4;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const hasOwnProperty = {}.hasOwnProperty;
|
|
846
|
+
function combineExtensions(extensions) {
|
|
847
|
+
const all = {};
|
|
848
|
+
let index = -1;
|
|
849
|
+
while (++index < extensions.length) {
|
|
850
|
+
syntaxExtension(all, extensions[index]);
|
|
851
|
+
}
|
|
852
|
+
return all;
|
|
853
|
+
}
|
|
854
|
+
function syntaxExtension(all, extension) {
|
|
855
|
+
let hook;
|
|
856
|
+
for (hook in extension) {
|
|
857
|
+
const maybe = hasOwnProperty.call(all, hook) ? all[hook] : void 0;
|
|
858
|
+
const left = maybe || (all[hook] = {});
|
|
859
|
+
const right = extension[hook];
|
|
860
|
+
let code2;
|
|
861
|
+
if (right) {
|
|
862
|
+
for (code2 in right) {
|
|
863
|
+
if (!hasOwnProperty.call(left, code2)) left[code2] = [];
|
|
864
|
+
const value = right[code2];
|
|
865
|
+
constructs(
|
|
866
|
+
// @ts-expect-error Looks like a list.
|
|
867
|
+
left[code2],
|
|
868
|
+
Array.isArray(value) ? value : value ? [value] : []
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function constructs(existing, list) {
|
|
875
|
+
let index = -1;
|
|
876
|
+
const before = [];
|
|
877
|
+
while (++index < list.length) {
|
|
878
|
+
(list[index].add === "after" ? existing : before).push(list[index]);
|
|
879
|
+
}
|
|
880
|
+
splice(existing, 0, 0, before);
|
|
881
|
+
}
|
|
882
|
+
const wwwPrefix = {
|
|
883
|
+
tokenize: tokenizeWwwPrefix,
|
|
884
|
+
partial: true
|
|
885
|
+
};
|
|
886
|
+
const domain = {
|
|
887
|
+
tokenize: tokenizeDomain,
|
|
888
|
+
partial: true
|
|
889
|
+
};
|
|
890
|
+
const path = {
|
|
891
|
+
tokenize: tokenizePath,
|
|
892
|
+
partial: true
|
|
893
|
+
};
|
|
894
|
+
const trail = {
|
|
895
|
+
tokenize: tokenizeTrail,
|
|
896
|
+
partial: true
|
|
897
|
+
};
|
|
898
|
+
const emailDomainDotTrail = {
|
|
899
|
+
tokenize: tokenizeEmailDomainDotTrail,
|
|
900
|
+
partial: true
|
|
901
|
+
};
|
|
902
|
+
const wwwAutolink = {
|
|
903
|
+
name: "wwwAutolink",
|
|
904
|
+
tokenize: tokenizeWwwAutolink,
|
|
905
|
+
previous: previousWww
|
|
906
|
+
};
|
|
907
|
+
const protocolAutolink = {
|
|
908
|
+
name: "protocolAutolink",
|
|
909
|
+
tokenize: tokenizeProtocolAutolink,
|
|
910
|
+
previous: previousProtocol
|
|
911
|
+
};
|
|
912
|
+
const emailAutolink = {
|
|
913
|
+
name: "emailAutolink",
|
|
914
|
+
tokenize: tokenizeEmailAutolink,
|
|
915
|
+
previous: previousEmail
|
|
916
|
+
};
|
|
917
|
+
const text = {};
|
|
918
|
+
function gfmAutolinkLiteral() {
|
|
919
|
+
return {
|
|
920
|
+
text
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
let code = 48;
|
|
924
|
+
while (code < 123) {
|
|
925
|
+
text[code] = emailAutolink;
|
|
926
|
+
code++;
|
|
927
|
+
if (code === 58) code = 65;
|
|
928
|
+
else if (code === 91) code = 97;
|
|
929
|
+
}
|
|
930
|
+
text[43] = emailAutolink;
|
|
931
|
+
text[45] = emailAutolink;
|
|
932
|
+
text[46] = emailAutolink;
|
|
933
|
+
text[95] = emailAutolink;
|
|
934
|
+
text[72] = [emailAutolink, protocolAutolink];
|
|
935
|
+
text[104] = [emailAutolink, protocolAutolink];
|
|
936
|
+
text[87] = [emailAutolink, wwwAutolink];
|
|
937
|
+
text[119] = [emailAutolink, wwwAutolink];
|
|
938
|
+
function tokenizeEmailAutolink(effects, ok2, nok) {
|
|
939
|
+
const self = this;
|
|
940
|
+
let dot;
|
|
941
|
+
let data;
|
|
942
|
+
return start;
|
|
943
|
+
function start(code2) {
|
|
944
|
+
if (!gfmAtext(code2) || !previousEmail.call(self, self.previous) || previousUnbalanced(self.events)) {
|
|
945
|
+
return nok(code2);
|
|
946
|
+
}
|
|
947
|
+
effects.enter("literalAutolink");
|
|
948
|
+
effects.enter("literalAutolinkEmail");
|
|
949
|
+
return atext(code2);
|
|
950
|
+
}
|
|
951
|
+
function atext(code2) {
|
|
952
|
+
if (gfmAtext(code2)) {
|
|
953
|
+
effects.consume(code2);
|
|
954
|
+
return atext;
|
|
955
|
+
}
|
|
956
|
+
if (code2 === 64) {
|
|
957
|
+
effects.consume(code2);
|
|
958
|
+
return emailDomain;
|
|
959
|
+
}
|
|
960
|
+
return nok(code2);
|
|
961
|
+
}
|
|
962
|
+
function emailDomain(code2) {
|
|
963
|
+
if (code2 === 46) {
|
|
964
|
+
return effects.check(emailDomainDotTrail, emailDomainAfter, emailDomainDot)(code2);
|
|
965
|
+
}
|
|
966
|
+
if (code2 === 45 || code2 === 95 || indexCd3D_8gF.asciiAlphanumeric(code2)) {
|
|
967
|
+
data = true;
|
|
968
|
+
effects.consume(code2);
|
|
969
|
+
return emailDomain;
|
|
970
|
+
}
|
|
971
|
+
return emailDomainAfter(code2);
|
|
972
|
+
}
|
|
973
|
+
function emailDomainDot(code2) {
|
|
974
|
+
effects.consume(code2);
|
|
975
|
+
dot = true;
|
|
976
|
+
return emailDomain;
|
|
977
|
+
}
|
|
978
|
+
function emailDomainAfter(code2) {
|
|
979
|
+
if (data && dot && indexCd3D_8gF.asciiAlpha(self.previous)) {
|
|
980
|
+
effects.exit("literalAutolinkEmail");
|
|
981
|
+
effects.exit("literalAutolink");
|
|
982
|
+
return ok2(code2);
|
|
983
|
+
}
|
|
984
|
+
return nok(code2);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
function tokenizeWwwAutolink(effects, ok2, nok) {
|
|
988
|
+
const self = this;
|
|
989
|
+
return wwwStart;
|
|
990
|
+
function wwwStart(code2) {
|
|
991
|
+
if (code2 !== 87 && code2 !== 119 || !previousWww.call(self, self.previous) || previousUnbalanced(self.events)) {
|
|
992
|
+
return nok(code2);
|
|
993
|
+
}
|
|
994
|
+
effects.enter("literalAutolink");
|
|
995
|
+
effects.enter("literalAutolinkWww");
|
|
996
|
+
return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(path, wwwAfter), nok), nok)(code2);
|
|
997
|
+
}
|
|
998
|
+
function wwwAfter(code2) {
|
|
999
|
+
effects.exit("literalAutolinkWww");
|
|
1000
|
+
effects.exit("literalAutolink");
|
|
1001
|
+
return ok2(code2);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function tokenizeProtocolAutolink(effects, ok2, nok) {
|
|
1005
|
+
const self = this;
|
|
1006
|
+
let buffer = "";
|
|
1007
|
+
let seen = false;
|
|
1008
|
+
return protocolStart;
|
|
1009
|
+
function protocolStart(code2) {
|
|
1010
|
+
if ((code2 === 72 || code2 === 104) && previousProtocol.call(self, self.previous) && !previousUnbalanced(self.events)) {
|
|
1011
|
+
effects.enter("literalAutolink");
|
|
1012
|
+
effects.enter("literalAutolinkHttp");
|
|
1013
|
+
buffer += String.fromCodePoint(code2);
|
|
1014
|
+
effects.consume(code2);
|
|
1015
|
+
return protocolPrefixInside;
|
|
1016
|
+
}
|
|
1017
|
+
return nok(code2);
|
|
1018
|
+
}
|
|
1019
|
+
function protocolPrefixInside(code2) {
|
|
1020
|
+
if (indexCd3D_8gF.asciiAlpha(code2) && buffer.length < 5) {
|
|
1021
|
+
buffer += String.fromCodePoint(code2);
|
|
1022
|
+
effects.consume(code2);
|
|
1023
|
+
return protocolPrefixInside;
|
|
1024
|
+
}
|
|
1025
|
+
if (code2 === 58) {
|
|
1026
|
+
const protocol = buffer.toLowerCase();
|
|
1027
|
+
if (protocol === "http" || protocol === "https") {
|
|
1028
|
+
effects.consume(code2);
|
|
1029
|
+
return protocolSlashesInside;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return nok(code2);
|
|
1033
|
+
}
|
|
1034
|
+
function protocolSlashesInside(code2) {
|
|
1035
|
+
if (code2 === 47) {
|
|
1036
|
+
effects.consume(code2);
|
|
1037
|
+
if (seen) {
|
|
1038
|
+
return afterProtocol;
|
|
1039
|
+
}
|
|
1040
|
+
seen = true;
|
|
1041
|
+
return protocolSlashesInside;
|
|
1042
|
+
}
|
|
1043
|
+
return nok(code2);
|
|
1044
|
+
}
|
|
1045
|
+
function afterProtocol(code2) {
|
|
1046
|
+
return code2 === null || indexCd3D_8gF.asciiControl(code2) || indexCd3D_8gF.markdownLineEndingOrSpace(code2) || indexCd3D_8gF.unicodeWhitespace(code2) || indexCd3D_8gF.unicodePunctuation(code2) ? nok(code2) : effects.attempt(domain, effects.attempt(path, protocolAfter), nok)(code2);
|
|
1047
|
+
}
|
|
1048
|
+
function protocolAfter(code2) {
|
|
1049
|
+
effects.exit("literalAutolinkHttp");
|
|
1050
|
+
effects.exit("literalAutolink");
|
|
1051
|
+
return ok2(code2);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
function tokenizeWwwPrefix(effects, ok2, nok) {
|
|
1055
|
+
let size = 0;
|
|
1056
|
+
return wwwPrefixInside;
|
|
1057
|
+
function wwwPrefixInside(code2) {
|
|
1058
|
+
if ((code2 === 87 || code2 === 119) && size < 3) {
|
|
1059
|
+
size++;
|
|
1060
|
+
effects.consume(code2);
|
|
1061
|
+
return wwwPrefixInside;
|
|
1062
|
+
}
|
|
1063
|
+
if (code2 === 46 && size === 3) {
|
|
1064
|
+
effects.consume(code2);
|
|
1065
|
+
return wwwPrefixAfter;
|
|
1066
|
+
}
|
|
1067
|
+
return nok(code2);
|
|
1068
|
+
}
|
|
1069
|
+
function wwwPrefixAfter(code2) {
|
|
1070
|
+
return code2 === null ? nok(code2) : ok2(code2);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
function tokenizeDomain(effects, ok2, nok) {
|
|
1074
|
+
let underscoreInLastSegment;
|
|
1075
|
+
let underscoreInLastLastSegment;
|
|
1076
|
+
let seen;
|
|
1077
|
+
return domainInside;
|
|
1078
|
+
function domainInside(code2) {
|
|
1079
|
+
if (code2 === 46 || code2 === 95) {
|
|
1080
|
+
return effects.check(trail, domainAfter, domainAtPunctuation)(code2);
|
|
1081
|
+
}
|
|
1082
|
+
if (code2 === null || indexCd3D_8gF.markdownLineEndingOrSpace(code2) || indexCd3D_8gF.unicodeWhitespace(code2) || code2 !== 45 && indexCd3D_8gF.unicodePunctuation(code2)) {
|
|
1083
|
+
return domainAfter(code2);
|
|
1084
|
+
}
|
|
1085
|
+
seen = true;
|
|
1086
|
+
effects.consume(code2);
|
|
1087
|
+
return domainInside;
|
|
1088
|
+
}
|
|
1089
|
+
function domainAtPunctuation(code2) {
|
|
1090
|
+
if (code2 === 95) {
|
|
1091
|
+
underscoreInLastSegment = true;
|
|
1092
|
+
} else {
|
|
1093
|
+
underscoreInLastLastSegment = underscoreInLastSegment;
|
|
1094
|
+
underscoreInLastSegment = void 0;
|
|
1095
|
+
}
|
|
1096
|
+
effects.consume(code2);
|
|
1097
|
+
return domainInside;
|
|
1098
|
+
}
|
|
1099
|
+
function domainAfter(code2) {
|
|
1100
|
+
if (underscoreInLastLastSegment || underscoreInLastSegment || !seen) {
|
|
1101
|
+
return nok(code2);
|
|
1102
|
+
}
|
|
1103
|
+
return ok2(code2);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function tokenizePath(effects, ok2) {
|
|
1107
|
+
let sizeOpen = 0;
|
|
1108
|
+
let sizeClose = 0;
|
|
1109
|
+
return pathInside;
|
|
1110
|
+
function pathInside(code2) {
|
|
1111
|
+
if (code2 === 40) {
|
|
1112
|
+
sizeOpen++;
|
|
1113
|
+
effects.consume(code2);
|
|
1114
|
+
return pathInside;
|
|
1115
|
+
}
|
|
1116
|
+
if (code2 === 41 && sizeClose < sizeOpen) {
|
|
1117
|
+
return pathAtPunctuation(code2);
|
|
1118
|
+
}
|
|
1119
|
+
if (code2 === 33 || code2 === 34 || code2 === 38 || code2 === 39 || code2 === 41 || code2 === 42 || code2 === 44 || code2 === 46 || code2 === 58 || code2 === 59 || code2 === 60 || code2 === 63 || code2 === 93 || code2 === 95 || code2 === 126) {
|
|
1120
|
+
return effects.check(trail, ok2, pathAtPunctuation)(code2);
|
|
1121
|
+
}
|
|
1122
|
+
if (code2 === null || indexCd3D_8gF.markdownLineEndingOrSpace(code2) || indexCd3D_8gF.unicodeWhitespace(code2)) {
|
|
1123
|
+
return ok2(code2);
|
|
1124
|
+
}
|
|
1125
|
+
effects.consume(code2);
|
|
1126
|
+
return pathInside;
|
|
1127
|
+
}
|
|
1128
|
+
function pathAtPunctuation(code2) {
|
|
1129
|
+
if (code2 === 41) {
|
|
1130
|
+
sizeClose++;
|
|
1131
|
+
}
|
|
1132
|
+
effects.consume(code2);
|
|
1133
|
+
return pathInside;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
function tokenizeTrail(effects, ok2, nok) {
|
|
1137
|
+
return trail2;
|
|
1138
|
+
function trail2(code2) {
|
|
1139
|
+
if (code2 === 33 || code2 === 34 || code2 === 39 || code2 === 41 || code2 === 42 || code2 === 44 || code2 === 46 || code2 === 58 || code2 === 59 || code2 === 63 || code2 === 95 || code2 === 126) {
|
|
1140
|
+
effects.consume(code2);
|
|
1141
|
+
return trail2;
|
|
1142
|
+
}
|
|
1143
|
+
if (code2 === 38) {
|
|
1144
|
+
effects.consume(code2);
|
|
1145
|
+
return trailCharacterReferenceStart;
|
|
1146
|
+
}
|
|
1147
|
+
if (code2 === 93) {
|
|
1148
|
+
effects.consume(code2);
|
|
1149
|
+
return trailBracketAfter;
|
|
1150
|
+
}
|
|
1151
|
+
if (
|
|
1152
|
+
// `<` is an end.
|
|
1153
|
+
code2 === 60 || // So is whitespace.
|
|
1154
|
+
code2 === null || indexCd3D_8gF.markdownLineEndingOrSpace(code2) || indexCd3D_8gF.unicodeWhitespace(code2)
|
|
1155
|
+
) {
|
|
1156
|
+
return ok2(code2);
|
|
1157
|
+
}
|
|
1158
|
+
return nok(code2);
|
|
1159
|
+
}
|
|
1160
|
+
function trailBracketAfter(code2) {
|
|
1161
|
+
if (code2 === null || code2 === 40 || code2 === 91 || indexCd3D_8gF.markdownLineEndingOrSpace(code2) || indexCd3D_8gF.unicodeWhitespace(code2)) {
|
|
1162
|
+
return ok2(code2);
|
|
1163
|
+
}
|
|
1164
|
+
return trail2(code2);
|
|
1165
|
+
}
|
|
1166
|
+
function trailCharacterReferenceStart(code2) {
|
|
1167
|
+
return indexCd3D_8gF.asciiAlpha(code2) ? trailCharacterReferenceInside(code2) : nok(code2);
|
|
1168
|
+
}
|
|
1169
|
+
function trailCharacterReferenceInside(code2) {
|
|
1170
|
+
if (code2 === 59) {
|
|
1171
|
+
effects.consume(code2);
|
|
1172
|
+
return trail2;
|
|
1173
|
+
}
|
|
1174
|
+
if (indexCd3D_8gF.asciiAlpha(code2)) {
|
|
1175
|
+
effects.consume(code2);
|
|
1176
|
+
return trailCharacterReferenceInside;
|
|
1177
|
+
}
|
|
1178
|
+
return nok(code2);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
function tokenizeEmailDomainDotTrail(effects, ok2, nok) {
|
|
1182
|
+
return start;
|
|
1183
|
+
function start(code2) {
|
|
1184
|
+
effects.consume(code2);
|
|
1185
|
+
return after;
|
|
1186
|
+
}
|
|
1187
|
+
function after(code2) {
|
|
1188
|
+
return indexCd3D_8gF.asciiAlphanumeric(code2) ? nok(code2) : ok2(code2);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
function previousWww(code2) {
|
|
1192
|
+
return code2 === null || code2 === 40 || code2 === 42 || code2 === 95 || code2 === 91 || code2 === 93 || code2 === 126 || indexCd3D_8gF.markdownLineEndingOrSpace(code2);
|
|
1193
|
+
}
|
|
1194
|
+
function previousProtocol(code2) {
|
|
1195
|
+
return !indexCd3D_8gF.asciiAlpha(code2);
|
|
1196
|
+
}
|
|
1197
|
+
function previousEmail(code2) {
|
|
1198
|
+
return !(code2 === 47 || gfmAtext(code2));
|
|
1199
|
+
}
|
|
1200
|
+
function gfmAtext(code2) {
|
|
1201
|
+
return code2 === 43 || code2 === 45 || code2 === 46 || code2 === 95 || indexCd3D_8gF.asciiAlphanumeric(code2);
|
|
1202
|
+
}
|
|
1203
|
+
function previousUnbalanced(events) {
|
|
1204
|
+
let index = events.length;
|
|
1205
|
+
let result = false;
|
|
1206
|
+
while (index--) {
|
|
1207
|
+
const token = events[index][1];
|
|
1208
|
+
if ((token.type === "labelLink" || token.type === "labelImage") && !token._balanced) {
|
|
1209
|
+
result = true;
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
if (token._gfmAutolinkLiteralWalkedInto) {
|
|
1213
|
+
result = false;
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (events.length > 0 && !result) {
|
|
1218
|
+
events[events.length - 1][1]._gfmAutolinkLiteralWalkedInto = true;
|
|
1219
|
+
}
|
|
1220
|
+
return result;
|
|
1221
|
+
}
|
|
1222
|
+
function resolveAll(constructs2, events, context) {
|
|
1223
|
+
const called = [];
|
|
1224
|
+
let index = -1;
|
|
1225
|
+
while (++index < constructs2.length) {
|
|
1226
|
+
const resolve = constructs2[index].resolveAll;
|
|
1227
|
+
if (resolve && !called.includes(resolve)) {
|
|
1228
|
+
events = resolve(events, context);
|
|
1229
|
+
called.push(resolve);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return events;
|
|
1233
|
+
}
|
|
1234
|
+
function factorySpace(effects, ok2, type, max) {
|
|
1235
|
+
const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
|
|
1236
|
+
let size = 0;
|
|
1237
|
+
return start;
|
|
1238
|
+
function start(code2) {
|
|
1239
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1240
|
+
effects.enter(type);
|
|
1241
|
+
return prefix(code2);
|
|
1242
|
+
}
|
|
1243
|
+
return ok2(code2);
|
|
1244
|
+
}
|
|
1245
|
+
function prefix(code2) {
|
|
1246
|
+
if (indexCd3D_8gF.markdownSpace(code2) && size++ < limit) {
|
|
1247
|
+
effects.consume(code2);
|
|
1248
|
+
return prefix;
|
|
1249
|
+
}
|
|
1250
|
+
effects.exit(type);
|
|
1251
|
+
return ok2(code2);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const blankLine = {
|
|
1255
|
+
partial: true,
|
|
1256
|
+
tokenize: tokenizeBlankLine
|
|
1257
|
+
};
|
|
1258
|
+
function tokenizeBlankLine(effects, ok2, nok) {
|
|
1259
|
+
return start;
|
|
1260
|
+
function start(code2) {
|
|
1261
|
+
return indexCd3D_8gF.markdownSpace(code2) ? factorySpace(effects, after, "linePrefix")(code2) : after(code2);
|
|
1262
|
+
}
|
|
1263
|
+
function after(code2) {
|
|
1264
|
+
return code2 === null || indexCd3D_8gF.markdownLineEnding(code2) ? ok2(code2) : nok(code2);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
const indent = {
|
|
1268
|
+
tokenize: tokenizeIndent,
|
|
1269
|
+
partial: true
|
|
1270
|
+
};
|
|
1271
|
+
function gfmFootnote() {
|
|
1272
|
+
return {
|
|
1273
|
+
document: {
|
|
1274
|
+
[91]: {
|
|
1275
|
+
name: "gfmFootnoteDefinition",
|
|
1276
|
+
tokenize: tokenizeDefinitionStart,
|
|
1277
|
+
continuation: {
|
|
1278
|
+
tokenize: tokenizeDefinitionContinuation
|
|
1279
|
+
},
|
|
1280
|
+
exit: gfmFootnoteDefinitionEnd
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
text: {
|
|
1284
|
+
[91]: {
|
|
1285
|
+
name: "gfmFootnoteCall",
|
|
1286
|
+
tokenize: tokenizeGfmFootnoteCall
|
|
1287
|
+
},
|
|
1288
|
+
[93]: {
|
|
1289
|
+
name: "gfmPotentialFootnoteCall",
|
|
1290
|
+
add: "after",
|
|
1291
|
+
tokenize: tokenizePotentialGfmFootnoteCall,
|
|
1292
|
+
resolveTo: resolveToPotentialGfmFootnoteCall
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function tokenizePotentialGfmFootnoteCall(effects, ok2, nok) {
|
|
1298
|
+
const self = this;
|
|
1299
|
+
let index = self.events.length;
|
|
1300
|
+
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
1301
|
+
let labelStart;
|
|
1302
|
+
while (index--) {
|
|
1303
|
+
const token = self.events[index][1];
|
|
1304
|
+
if (token.type === "labelImage") {
|
|
1305
|
+
labelStart = token;
|
|
1306
|
+
break;
|
|
1307
|
+
}
|
|
1308
|
+
if (token.type === "gfmFootnoteCall" || token.type === "labelLink" || token.type === "label" || token.type === "image" || token.type === "link") {
|
|
1309
|
+
break;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return start;
|
|
1313
|
+
function start(code2) {
|
|
1314
|
+
if (!labelStart || !labelStart._balanced) {
|
|
1315
|
+
return nok(code2);
|
|
1316
|
+
}
|
|
1317
|
+
const id = normalizeIdentifier(self.sliceSerialize({
|
|
1318
|
+
start: labelStart.end,
|
|
1319
|
+
end: self.now()
|
|
1320
|
+
}));
|
|
1321
|
+
if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) {
|
|
1322
|
+
return nok(code2);
|
|
1323
|
+
}
|
|
1324
|
+
effects.enter("gfmFootnoteCallLabelMarker");
|
|
1325
|
+
effects.consume(code2);
|
|
1326
|
+
effects.exit("gfmFootnoteCallLabelMarker");
|
|
1327
|
+
return ok2(code2);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function resolveToPotentialGfmFootnoteCall(events, context) {
|
|
1331
|
+
let index = events.length;
|
|
1332
|
+
while (index--) {
|
|
1333
|
+
if (events[index][1].type === "labelImage" && events[index][0] === "enter") {
|
|
1334
|
+
events[index][1];
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
events[index + 1][1].type = "data";
|
|
1339
|
+
events[index + 3][1].type = "gfmFootnoteCallLabelMarker";
|
|
1340
|
+
const call = {
|
|
1341
|
+
type: "gfmFootnoteCall",
|
|
1342
|
+
start: Object.assign({}, events[index + 3][1].start),
|
|
1343
|
+
end: Object.assign({}, events[events.length - 1][1].end)
|
|
1344
|
+
};
|
|
1345
|
+
const marker = {
|
|
1346
|
+
type: "gfmFootnoteCallMarker",
|
|
1347
|
+
start: Object.assign({}, events[index + 3][1].end),
|
|
1348
|
+
end: Object.assign({}, events[index + 3][1].end)
|
|
1349
|
+
};
|
|
1350
|
+
marker.end.column++;
|
|
1351
|
+
marker.end.offset++;
|
|
1352
|
+
marker.end._bufferIndex++;
|
|
1353
|
+
const string = {
|
|
1354
|
+
type: "gfmFootnoteCallString",
|
|
1355
|
+
start: Object.assign({}, marker.end),
|
|
1356
|
+
end: Object.assign({}, events[events.length - 1][1].start)
|
|
1357
|
+
};
|
|
1358
|
+
const chunk = {
|
|
1359
|
+
type: "chunkString",
|
|
1360
|
+
contentType: "string",
|
|
1361
|
+
start: Object.assign({}, string.start),
|
|
1362
|
+
end: Object.assign({}, string.end)
|
|
1363
|
+
};
|
|
1364
|
+
const replacement = [
|
|
1365
|
+
// Take the `labelImageMarker` (now `data`, the `!`)
|
|
1366
|
+
events[index + 1],
|
|
1367
|
+
events[index + 2],
|
|
1368
|
+
["enter", call, context],
|
|
1369
|
+
// The `[`
|
|
1370
|
+
events[index + 3],
|
|
1371
|
+
events[index + 4],
|
|
1372
|
+
// The `^`.
|
|
1373
|
+
["enter", marker, context],
|
|
1374
|
+
["exit", marker, context],
|
|
1375
|
+
// Everything in between.
|
|
1376
|
+
["enter", string, context],
|
|
1377
|
+
["enter", chunk, context],
|
|
1378
|
+
["exit", chunk, context],
|
|
1379
|
+
["exit", string, context],
|
|
1380
|
+
// The ending (`]`, properly parsed and labelled).
|
|
1381
|
+
events[events.length - 2],
|
|
1382
|
+
events[events.length - 1],
|
|
1383
|
+
["exit", call, context]
|
|
1384
|
+
];
|
|
1385
|
+
events.splice(index, events.length - index + 1, ...replacement);
|
|
1386
|
+
return events;
|
|
1387
|
+
}
|
|
1388
|
+
function tokenizeGfmFootnoteCall(effects, ok2, nok) {
|
|
1389
|
+
const self = this;
|
|
1390
|
+
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
1391
|
+
let size = 0;
|
|
1392
|
+
let data;
|
|
1393
|
+
return start;
|
|
1394
|
+
function start(code2) {
|
|
1395
|
+
effects.enter("gfmFootnoteCall");
|
|
1396
|
+
effects.enter("gfmFootnoteCallLabelMarker");
|
|
1397
|
+
effects.consume(code2);
|
|
1398
|
+
effects.exit("gfmFootnoteCallLabelMarker");
|
|
1399
|
+
return callStart;
|
|
1400
|
+
}
|
|
1401
|
+
function callStart(code2) {
|
|
1402
|
+
if (code2 !== 94) return nok(code2);
|
|
1403
|
+
effects.enter("gfmFootnoteCallMarker");
|
|
1404
|
+
effects.consume(code2);
|
|
1405
|
+
effects.exit("gfmFootnoteCallMarker");
|
|
1406
|
+
effects.enter("gfmFootnoteCallString");
|
|
1407
|
+
effects.enter("chunkString").contentType = "string";
|
|
1408
|
+
return callData;
|
|
1409
|
+
}
|
|
1410
|
+
function callData(code2) {
|
|
1411
|
+
if (
|
|
1412
|
+
// Too long.
|
|
1413
|
+
size > 999 || // Closing brace with nothing.
|
|
1414
|
+
code2 === 93 && !data || // Space or tab is not supported by GFM for some reason.
|
|
1415
|
+
// `\n` and `[` not being supported makes sense.
|
|
1416
|
+
code2 === null || code2 === 91 || indexCd3D_8gF.markdownLineEndingOrSpace(code2)
|
|
1417
|
+
) {
|
|
1418
|
+
return nok(code2);
|
|
1419
|
+
}
|
|
1420
|
+
if (code2 === 93) {
|
|
1421
|
+
effects.exit("chunkString");
|
|
1422
|
+
const token = effects.exit("gfmFootnoteCallString");
|
|
1423
|
+
if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) {
|
|
1424
|
+
return nok(code2);
|
|
1425
|
+
}
|
|
1426
|
+
effects.enter("gfmFootnoteCallLabelMarker");
|
|
1427
|
+
effects.consume(code2);
|
|
1428
|
+
effects.exit("gfmFootnoteCallLabelMarker");
|
|
1429
|
+
effects.exit("gfmFootnoteCall");
|
|
1430
|
+
return ok2;
|
|
1431
|
+
}
|
|
1432
|
+
if (!indexCd3D_8gF.markdownLineEndingOrSpace(code2)) {
|
|
1433
|
+
data = true;
|
|
1434
|
+
}
|
|
1435
|
+
size++;
|
|
1436
|
+
effects.consume(code2);
|
|
1437
|
+
return code2 === 92 ? callEscape : callData;
|
|
1438
|
+
}
|
|
1439
|
+
function callEscape(code2) {
|
|
1440
|
+
if (code2 === 91 || code2 === 92 || code2 === 93) {
|
|
1441
|
+
effects.consume(code2);
|
|
1442
|
+
size++;
|
|
1443
|
+
return callData;
|
|
1444
|
+
}
|
|
1445
|
+
return callData(code2);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
function tokenizeDefinitionStart(effects, ok2, nok) {
|
|
1449
|
+
const self = this;
|
|
1450
|
+
const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
|
|
1451
|
+
let identifier;
|
|
1452
|
+
let size = 0;
|
|
1453
|
+
let data;
|
|
1454
|
+
return start;
|
|
1455
|
+
function start(code2) {
|
|
1456
|
+
effects.enter("gfmFootnoteDefinition")._container = true;
|
|
1457
|
+
effects.enter("gfmFootnoteDefinitionLabel");
|
|
1458
|
+
effects.enter("gfmFootnoteDefinitionLabelMarker");
|
|
1459
|
+
effects.consume(code2);
|
|
1460
|
+
effects.exit("gfmFootnoteDefinitionLabelMarker");
|
|
1461
|
+
return labelAtMarker;
|
|
1462
|
+
}
|
|
1463
|
+
function labelAtMarker(code2) {
|
|
1464
|
+
if (code2 === 94) {
|
|
1465
|
+
effects.enter("gfmFootnoteDefinitionMarker");
|
|
1466
|
+
effects.consume(code2);
|
|
1467
|
+
effects.exit("gfmFootnoteDefinitionMarker");
|
|
1468
|
+
effects.enter("gfmFootnoteDefinitionLabelString");
|
|
1469
|
+
effects.enter("chunkString").contentType = "string";
|
|
1470
|
+
return labelInside;
|
|
1471
|
+
}
|
|
1472
|
+
return nok(code2);
|
|
1473
|
+
}
|
|
1474
|
+
function labelInside(code2) {
|
|
1475
|
+
if (
|
|
1476
|
+
// Too long.
|
|
1477
|
+
size > 999 || // Closing brace with nothing.
|
|
1478
|
+
code2 === 93 && !data || // Space or tab is not supported by GFM for some reason.
|
|
1479
|
+
// `\n` and `[` not being supported makes sense.
|
|
1480
|
+
code2 === null || code2 === 91 || indexCd3D_8gF.markdownLineEndingOrSpace(code2)
|
|
1481
|
+
) {
|
|
1482
|
+
return nok(code2);
|
|
1483
|
+
}
|
|
1484
|
+
if (code2 === 93) {
|
|
1485
|
+
effects.exit("chunkString");
|
|
1486
|
+
const token = effects.exit("gfmFootnoteDefinitionLabelString");
|
|
1487
|
+
identifier = normalizeIdentifier(self.sliceSerialize(token));
|
|
1488
|
+
effects.enter("gfmFootnoteDefinitionLabelMarker");
|
|
1489
|
+
effects.consume(code2);
|
|
1490
|
+
effects.exit("gfmFootnoteDefinitionLabelMarker");
|
|
1491
|
+
effects.exit("gfmFootnoteDefinitionLabel");
|
|
1492
|
+
return labelAfter;
|
|
1493
|
+
}
|
|
1494
|
+
if (!indexCd3D_8gF.markdownLineEndingOrSpace(code2)) {
|
|
1495
|
+
data = true;
|
|
1496
|
+
}
|
|
1497
|
+
size++;
|
|
1498
|
+
effects.consume(code2);
|
|
1499
|
+
return code2 === 92 ? labelEscape : labelInside;
|
|
1500
|
+
}
|
|
1501
|
+
function labelEscape(code2) {
|
|
1502
|
+
if (code2 === 91 || code2 === 92 || code2 === 93) {
|
|
1503
|
+
effects.consume(code2);
|
|
1504
|
+
size++;
|
|
1505
|
+
return labelInside;
|
|
1506
|
+
}
|
|
1507
|
+
return labelInside(code2);
|
|
1508
|
+
}
|
|
1509
|
+
function labelAfter(code2) {
|
|
1510
|
+
if (code2 === 58) {
|
|
1511
|
+
effects.enter("definitionMarker");
|
|
1512
|
+
effects.consume(code2);
|
|
1513
|
+
effects.exit("definitionMarker");
|
|
1514
|
+
if (!defined.includes(identifier)) {
|
|
1515
|
+
defined.push(identifier);
|
|
1516
|
+
}
|
|
1517
|
+
return factorySpace(effects, whitespaceAfter, "gfmFootnoteDefinitionWhitespace");
|
|
1518
|
+
}
|
|
1519
|
+
return nok(code2);
|
|
1520
|
+
}
|
|
1521
|
+
function whitespaceAfter(code2) {
|
|
1522
|
+
return ok2(code2);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
function tokenizeDefinitionContinuation(effects, ok2, nok) {
|
|
1526
|
+
return effects.check(blankLine, ok2, effects.attempt(indent, ok2, nok));
|
|
1527
|
+
}
|
|
1528
|
+
function gfmFootnoteDefinitionEnd(effects) {
|
|
1529
|
+
effects.exit("gfmFootnoteDefinition");
|
|
1530
|
+
}
|
|
1531
|
+
function tokenizeIndent(effects, ok2, nok) {
|
|
1532
|
+
const self = this;
|
|
1533
|
+
return factorySpace(effects, afterPrefix, "gfmFootnoteDefinitionIndent", 4 + 1);
|
|
1534
|
+
function afterPrefix(code2) {
|
|
1535
|
+
const tail = self.events[self.events.length - 1];
|
|
1536
|
+
return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === 4 ? ok2(code2) : nok(code2);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
function gfmStrikethrough(options) {
|
|
1540
|
+
const options_ = options || {};
|
|
1541
|
+
let single = options_.singleTilde;
|
|
1542
|
+
const tokenizer = {
|
|
1543
|
+
name: "strikethrough",
|
|
1544
|
+
tokenize: tokenizeStrikethrough,
|
|
1545
|
+
resolveAll: resolveAllStrikethrough
|
|
1546
|
+
};
|
|
1547
|
+
if (single === null || single === void 0) {
|
|
1548
|
+
single = true;
|
|
1549
|
+
}
|
|
1550
|
+
return {
|
|
1551
|
+
text: {
|
|
1552
|
+
[126]: tokenizer
|
|
1553
|
+
},
|
|
1554
|
+
insideSpan: {
|
|
1555
|
+
null: [tokenizer]
|
|
1556
|
+
},
|
|
1557
|
+
attentionMarkers: {
|
|
1558
|
+
null: [126]
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
function resolveAllStrikethrough(events, context) {
|
|
1562
|
+
let index = -1;
|
|
1563
|
+
while (++index < events.length) {
|
|
1564
|
+
if (events[index][0] === "enter" && events[index][1].type === "strikethroughSequenceTemporary" && events[index][1]._close) {
|
|
1565
|
+
let open = index;
|
|
1566
|
+
while (open--) {
|
|
1567
|
+
if (events[open][0] === "exit" && events[open][1].type === "strikethroughSequenceTemporary" && events[open][1]._open && // If the sizes are the same:
|
|
1568
|
+
events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
|
|
1569
|
+
events[index][1].type = "strikethroughSequence";
|
|
1570
|
+
events[open][1].type = "strikethroughSequence";
|
|
1571
|
+
const strikethrough = {
|
|
1572
|
+
type: "strikethrough",
|
|
1573
|
+
start: Object.assign({}, events[open][1].start),
|
|
1574
|
+
end: Object.assign({}, events[index][1].end)
|
|
1575
|
+
};
|
|
1576
|
+
const text2 = {
|
|
1577
|
+
type: "strikethroughText",
|
|
1578
|
+
start: Object.assign({}, events[open][1].end),
|
|
1579
|
+
end: Object.assign({}, events[index][1].start)
|
|
1580
|
+
};
|
|
1581
|
+
const nextEvents = [["enter", strikethrough, context], ["enter", events[open][1], context], ["exit", events[open][1], context], ["enter", text2, context]];
|
|
1582
|
+
const insideSpan = context.parser.constructs.insideSpan.null;
|
|
1583
|
+
if (insideSpan) {
|
|
1584
|
+
splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));
|
|
1585
|
+
}
|
|
1586
|
+
splice(nextEvents, nextEvents.length, 0, [["exit", text2, context], ["enter", events[index][1], context], ["exit", events[index][1], context], ["exit", strikethrough, context]]);
|
|
1587
|
+
splice(events, open - 1, index - open + 3, nextEvents);
|
|
1588
|
+
index = open + nextEvents.length - 2;
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
index = -1;
|
|
1595
|
+
while (++index < events.length) {
|
|
1596
|
+
if (events[index][1].type === "strikethroughSequenceTemporary") {
|
|
1597
|
+
events[index][1].type = "data";
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
return events;
|
|
1601
|
+
}
|
|
1602
|
+
function tokenizeStrikethrough(effects, ok2, nok) {
|
|
1603
|
+
const previous2 = this.previous;
|
|
1604
|
+
const events = this.events;
|
|
1605
|
+
let size = 0;
|
|
1606
|
+
return start;
|
|
1607
|
+
function start(code2) {
|
|
1608
|
+
if (previous2 === 126 && events[events.length - 1][1].type !== "characterEscape") {
|
|
1609
|
+
return nok(code2);
|
|
1610
|
+
}
|
|
1611
|
+
effects.enter("strikethroughSequenceTemporary");
|
|
1612
|
+
return more(code2);
|
|
1613
|
+
}
|
|
1614
|
+
function more(code2) {
|
|
1615
|
+
const before = indexCd3D_8gF.classifyCharacter(previous2);
|
|
1616
|
+
if (code2 === 126) {
|
|
1617
|
+
if (size > 1) return nok(code2);
|
|
1618
|
+
effects.consume(code2);
|
|
1619
|
+
size++;
|
|
1620
|
+
return more;
|
|
1621
|
+
}
|
|
1622
|
+
if (size < 2 && !single) return nok(code2);
|
|
1623
|
+
const token = effects.exit("strikethroughSequenceTemporary");
|
|
1624
|
+
const after = indexCd3D_8gF.classifyCharacter(code2);
|
|
1625
|
+
token._open = !after || after === 2 && Boolean(before);
|
|
1626
|
+
token._close = !before || before === 2 && Boolean(after);
|
|
1627
|
+
return ok2(code2);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
class EditMap {
|
|
1632
|
+
/**
|
|
1633
|
+
* Create a new edit map.
|
|
1634
|
+
*/
|
|
1635
|
+
constructor() {
|
|
1636
|
+
this.map = [];
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Create an edit: a remove and/or add at a certain place.
|
|
1640
|
+
*
|
|
1641
|
+
* @param {number} index
|
|
1642
|
+
* @param {number} remove
|
|
1643
|
+
* @param {Array<Event>} add
|
|
1644
|
+
* @returns {undefined}
|
|
1645
|
+
*/
|
|
1646
|
+
add(index, remove, add) {
|
|
1647
|
+
addImplementation(this, index, remove, add);
|
|
1648
|
+
}
|
|
1649
|
+
// To do: add this when moving to `micromark`.
|
|
1650
|
+
// /**
|
|
1651
|
+
// * Create an edit: but insert `add` before existing additions.
|
|
1652
|
+
// *
|
|
1653
|
+
// * @param {number} index
|
|
1654
|
+
// * @param {number} remove
|
|
1655
|
+
// * @param {Array<Event>} add
|
|
1656
|
+
// * @returns {undefined}
|
|
1657
|
+
// */
|
|
1658
|
+
// addBefore(index, remove, add) {
|
|
1659
|
+
// addImplementation(this, index, remove, add, true)
|
|
1660
|
+
// }
|
|
1661
|
+
/**
|
|
1662
|
+
* Done, change the events.
|
|
1663
|
+
*
|
|
1664
|
+
* @param {Array<Event>} events
|
|
1665
|
+
* @returns {undefined}
|
|
1666
|
+
*/
|
|
1667
|
+
consume(events) {
|
|
1668
|
+
this.map.sort(function(a, b) {
|
|
1669
|
+
return a[0] - b[0];
|
|
1670
|
+
});
|
|
1671
|
+
if (this.map.length === 0) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
let index = this.map.length;
|
|
1675
|
+
const vecs = [];
|
|
1676
|
+
while (index > 0) {
|
|
1677
|
+
index -= 1;
|
|
1678
|
+
vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
|
|
1679
|
+
events.length = this.map[index][0];
|
|
1680
|
+
}
|
|
1681
|
+
vecs.push(events.slice());
|
|
1682
|
+
events.length = 0;
|
|
1683
|
+
let slice = vecs.pop();
|
|
1684
|
+
while (slice) {
|
|
1685
|
+
for (const element of slice) {
|
|
1686
|
+
events.push(element);
|
|
1687
|
+
}
|
|
1688
|
+
slice = vecs.pop();
|
|
1689
|
+
}
|
|
1690
|
+
this.map.length = 0;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
function addImplementation(editMap, at, remove, add) {
|
|
1694
|
+
let index = 0;
|
|
1695
|
+
if (remove === 0 && add.length === 0) {
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
while (index < editMap.map.length) {
|
|
1699
|
+
if (editMap.map[index][0] === at) {
|
|
1700
|
+
editMap.map[index][1] += remove;
|
|
1701
|
+
editMap.map[index][2].push(...add);
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
index += 1;
|
|
1705
|
+
}
|
|
1706
|
+
editMap.map.push([at, remove, add]);
|
|
1707
|
+
}
|
|
1708
|
+
function gfmTableAlign(events, index) {
|
|
1709
|
+
let inDelimiterRow = false;
|
|
1710
|
+
const align = [];
|
|
1711
|
+
while (index < events.length) {
|
|
1712
|
+
const event = events[index];
|
|
1713
|
+
if (inDelimiterRow) {
|
|
1714
|
+
if (event[0] === "enter") {
|
|
1715
|
+
if (event[1].type === "tableContent") {
|
|
1716
|
+
align.push(events[index + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
|
|
1717
|
+
}
|
|
1718
|
+
} else if (event[1].type === "tableContent") {
|
|
1719
|
+
if (events[index - 1][1].type === "tableDelimiterMarker") {
|
|
1720
|
+
const alignIndex = align.length - 1;
|
|
1721
|
+
align[alignIndex] = align[alignIndex] === "left" ? "center" : "right";
|
|
1722
|
+
}
|
|
1723
|
+
} else if (event[1].type === "tableDelimiterRow") {
|
|
1724
|
+
break;
|
|
1725
|
+
}
|
|
1726
|
+
} else if (event[0] === "enter" && event[1].type === "tableDelimiterRow") {
|
|
1727
|
+
inDelimiterRow = true;
|
|
1728
|
+
}
|
|
1729
|
+
index += 1;
|
|
1730
|
+
}
|
|
1731
|
+
return align;
|
|
1732
|
+
}
|
|
1733
|
+
function gfmTable() {
|
|
1734
|
+
return {
|
|
1735
|
+
flow: {
|
|
1736
|
+
null: {
|
|
1737
|
+
name: "table",
|
|
1738
|
+
tokenize: tokenizeTable,
|
|
1739
|
+
resolveAll: resolveTable
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
function tokenizeTable(effects, ok2, nok) {
|
|
1745
|
+
const self = this;
|
|
1746
|
+
let size = 0;
|
|
1747
|
+
let sizeB = 0;
|
|
1748
|
+
let seen;
|
|
1749
|
+
return start;
|
|
1750
|
+
function start(code2) {
|
|
1751
|
+
let index = self.events.length - 1;
|
|
1752
|
+
while (index > -1) {
|
|
1753
|
+
const type = self.events[index][1].type;
|
|
1754
|
+
if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
|
|
1755
|
+
type === "linePrefix") index--;
|
|
1756
|
+
else break;
|
|
1757
|
+
}
|
|
1758
|
+
const tail = index > -1 ? self.events[index][1].type : null;
|
|
1759
|
+
const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
|
|
1760
|
+
if (next === bodyRowStart && self.parser.lazy[self.now().line]) {
|
|
1761
|
+
return nok(code2);
|
|
1762
|
+
}
|
|
1763
|
+
return next(code2);
|
|
1764
|
+
}
|
|
1765
|
+
function headRowBefore(code2) {
|
|
1766
|
+
effects.enter("tableHead");
|
|
1767
|
+
effects.enter("tableRow");
|
|
1768
|
+
return headRowStart(code2);
|
|
1769
|
+
}
|
|
1770
|
+
function headRowStart(code2) {
|
|
1771
|
+
if (code2 === 124) {
|
|
1772
|
+
return headRowBreak(code2);
|
|
1773
|
+
}
|
|
1774
|
+
seen = true;
|
|
1775
|
+
sizeB += 1;
|
|
1776
|
+
return headRowBreak(code2);
|
|
1777
|
+
}
|
|
1778
|
+
function headRowBreak(code2) {
|
|
1779
|
+
if (code2 === null) {
|
|
1780
|
+
return nok(code2);
|
|
1781
|
+
}
|
|
1782
|
+
if (indexCd3D_8gF.markdownLineEnding(code2)) {
|
|
1783
|
+
if (sizeB > 1) {
|
|
1784
|
+
sizeB = 0;
|
|
1785
|
+
self.interrupt = true;
|
|
1786
|
+
effects.exit("tableRow");
|
|
1787
|
+
effects.enter("lineEnding");
|
|
1788
|
+
effects.consume(code2);
|
|
1789
|
+
effects.exit("lineEnding");
|
|
1790
|
+
return headDelimiterStart;
|
|
1791
|
+
}
|
|
1792
|
+
return nok(code2);
|
|
1793
|
+
}
|
|
1794
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1795
|
+
return factorySpace(effects, headRowBreak, "whitespace")(code2);
|
|
1796
|
+
}
|
|
1797
|
+
sizeB += 1;
|
|
1798
|
+
if (seen) {
|
|
1799
|
+
seen = false;
|
|
1800
|
+
size += 1;
|
|
1801
|
+
}
|
|
1802
|
+
if (code2 === 124) {
|
|
1803
|
+
effects.enter("tableCellDivider");
|
|
1804
|
+
effects.consume(code2);
|
|
1805
|
+
effects.exit("tableCellDivider");
|
|
1806
|
+
seen = true;
|
|
1807
|
+
return headRowBreak;
|
|
1808
|
+
}
|
|
1809
|
+
effects.enter("data");
|
|
1810
|
+
return headRowData(code2);
|
|
1811
|
+
}
|
|
1812
|
+
function headRowData(code2) {
|
|
1813
|
+
if (code2 === null || code2 === 124 || indexCd3D_8gF.markdownLineEndingOrSpace(code2)) {
|
|
1814
|
+
effects.exit("data");
|
|
1815
|
+
return headRowBreak(code2);
|
|
1816
|
+
}
|
|
1817
|
+
effects.consume(code2);
|
|
1818
|
+
return code2 === 92 ? headRowEscape : headRowData;
|
|
1819
|
+
}
|
|
1820
|
+
function headRowEscape(code2) {
|
|
1821
|
+
if (code2 === 92 || code2 === 124) {
|
|
1822
|
+
effects.consume(code2);
|
|
1823
|
+
return headRowData;
|
|
1824
|
+
}
|
|
1825
|
+
return headRowData(code2);
|
|
1826
|
+
}
|
|
1827
|
+
function headDelimiterStart(code2) {
|
|
1828
|
+
self.interrupt = false;
|
|
1829
|
+
if (self.parser.lazy[self.now().line]) {
|
|
1830
|
+
return nok(code2);
|
|
1831
|
+
}
|
|
1832
|
+
effects.enter("tableDelimiterRow");
|
|
1833
|
+
seen = false;
|
|
1834
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1835
|
+
return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code2);
|
|
1836
|
+
}
|
|
1837
|
+
return headDelimiterBefore(code2);
|
|
1838
|
+
}
|
|
1839
|
+
function headDelimiterBefore(code2) {
|
|
1840
|
+
if (code2 === 45 || code2 === 58) {
|
|
1841
|
+
return headDelimiterValueBefore(code2);
|
|
1842
|
+
}
|
|
1843
|
+
if (code2 === 124) {
|
|
1844
|
+
seen = true;
|
|
1845
|
+
effects.enter("tableCellDivider");
|
|
1846
|
+
effects.consume(code2);
|
|
1847
|
+
effects.exit("tableCellDivider");
|
|
1848
|
+
return headDelimiterCellBefore;
|
|
1849
|
+
}
|
|
1850
|
+
return headDelimiterNok(code2);
|
|
1851
|
+
}
|
|
1852
|
+
function headDelimiterCellBefore(code2) {
|
|
1853
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1854
|
+
return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code2);
|
|
1855
|
+
}
|
|
1856
|
+
return headDelimiterValueBefore(code2);
|
|
1857
|
+
}
|
|
1858
|
+
function headDelimiterValueBefore(code2) {
|
|
1859
|
+
if (code2 === 58) {
|
|
1860
|
+
sizeB += 1;
|
|
1861
|
+
seen = true;
|
|
1862
|
+
effects.enter("tableDelimiterMarker");
|
|
1863
|
+
effects.consume(code2);
|
|
1864
|
+
effects.exit("tableDelimiterMarker");
|
|
1865
|
+
return headDelimiterLeftAlignmentAfter;
|
|
1866
|
+
}
|
|
1867
|
+
if (code2 === 45) {
|
|
1868
|
+
sizeB += 1;
|
|
1869
|
+
return headDelimiterLeftAlignmentAfter(code2);
|
|
1870
|
+
}
|
|
1871
|
+
if (code2 === null || indexCd3D_8gF.markdownLineEnding(code2)) {
|
|
1872
|
+
return headDelimiterCellAfter(code2);
|
|
1873
|
+
}
|
|
1874
|
+
return headDelimiterNok(code2);
|
|
1875
|
+
}
|
|
1876
|
+
function headDelimiterLeftAlignmentAfter(code2) {
|
|
1877
|
+
if (code2 === 45) {
|
|
1878
|
+
effects.enter("tableDelimiterFiller");
|
|
1879
|
+
return headDelimiterFiller(code2);
|
|
1880
|
+
}
|
|
1881
|
+
return headDelimiterNok(code2);
|
|
1882
|
+
}
|
|
1883
|
+
function headDelimiterFiller(code2) {
|
|
1884
|
+
if (code2 === 45) {
|
|
1885
|
+
effects.consume(code2);
|
|
1886
|
+
return headDelimiterFiller;
|
|
1887
|
+
}
|
|
1888
|
+
if (code2 === 58) {
|
|
1889
|
+
seen = true;
|
|
1890
|
+
effects.exit("tableDelimiterFiller");
|
|
1891
|
+
effects.enter("tableDelimiterMarker");
|
|
1892
|
+
effects.consume(code2);
|
|
1893
|
+
effects.exit("tableDelimiterMarker");
|
|
1894
|
+
return headDelimiterRightAlignmentAfter;
|
|
1895
|
+
}
|
|
1896
|
+
effects.exit("tableDelimiterFiller");
|
|
1897
|
+
return headDelimiterRightAlignmentAfter(code2);
|
|
1898
|
+
}
|
|
1899
|
+
function headDelimiterRightAlignmentAfter(code2) {
|
|
1900
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1901
|
+
return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code2);
|
|
1902
|
+
}
|
|
1903
|
+
return headDelimiterCellAfter(code2);
|
|
1904
|
+
}
|
|
1905
|
+
function headDelimiterCellAfter(code2) {
|
|
1906
|
+
if (code2 === 124) {
|
|
1907
|
+
return headDelimiterBefore(code2);
|
|
1908
|
+
}
|
|
1909
|
+
if (code2 === null || indexCd3D_8gF.markdownLineEnding(code2)) {
|
|
1910
|
+
if (!seen || size !== sizeB) {
|
|
1911
|
+
return headDelimiterNok(code2);
|
|
1912
|
+
}
|
|
1913
|
+
effects.exit("tableDelimiterRow");
|
|
1914
|
+
effects.exit("tableHead");
|
|
1915
|
+
return ok2(code2);
|
|
1916
|
+
}
|
|
1917
|
+
return headDelimiterNok(code2);
|
|
1918
|
+
}
|
|
1919
|
+
function headDelimiterNok(code2) {
|
|
1920
|
+
return nok(code2);
|
|
1921
|
+
}
|
|
1922
|
+
function bodyRowStart(code2) {
|
|
1923
|
+
effects.enter("tableRow");
|
|
1924
|
+
return bodyRowBreak(code2);
|
|
1925
|
+
}
|
|
1926
|
+
function bodyRowBreak(code2) {
|
|
1927
|
+
if (code2 === 124) {
|
|
1928
|
+
effects.enter("tableCellDivider");
|
|
1929
|
+
effects.consume(code2);
|
|
1930
|
+
effects.exit("tableCellDivider");
|
|
1931
|
+
return bodyRowBreak;
|
|
1932
|
+
}
|
|
1933
|
+
if (code2 === null || indexCd3D_8gF.markdownLineEnding(code2)) {
|
|
1934
|
+
effects.exit("tableRow");
|
|
1935
|
+
return ok2(code2);
|
|
1936
|
+
}
|
|
1937
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
1938
|
+
return factorySpace(effects, bodyRowBreak, "whitespace")(code2);
|
|
1939
|
+
}
|
|
1940
|
+
effects.enter("data");
|
|
1941
|
+
return bodyRowData(code2);
|
|
1942
|
+
}
|
|
1943
|
+
function bodyRowData(code2) {
|
|
1944
|
+
if (code2 === null || code2 === 124 || indexCd3D_8gF.markdownLineEndingOrSpace(code2)) {
|
|
1945
|
+
effects.exit("data");
|
|
1946
|
+
return bodyRowBreak(code2);
|
|
1947
|
+
}
|
|
1948
|
+
effects.consume(code2);
|
|
1949
|
+
return code2 === 92 ? bodyRowEscape : bodyRowData;
|
|
1950
|
+
}
|
|
1951
|
+
function bodyRowEscape(code2) {
|
|
1952
|
+
if (code2 === 92 || code2 === 124) {
|
|
1953
|
+
effects.consume(code2);
|
|
1954
|
+
return bodyRowData;
|
|
1955
|
+
}
|
|
1956
|
+
return bodyRowData(code2);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
function resolveTable(events, context) {
|
|
1960
|
+
let index = -1;
|
|
1961
|
+
let inFirstCellAwaitingPipe = true;
|
|
1962
|
+
let rowKind = 0;
|
|
1963
|
+
let lastCell = [0, 0, 0, 0];
|
|
1964
|
+
let cell = [0, 0, 0, 0];
|
|
1965
|
+
let afterHeadAwaitingFirstBodyRow = false;
|
|
1966
|
+
let lastTableEnd = 0;
|
|
1967
|
+
let currentTable;
|
|
1968
|
+
let currentBody;
|
|
1969
|
+
let currentCell;
|
|
1970
|
+
const map = new EditMap();
|
|
1971
|
+
while (++index < events.length) {
|
|
1972
|
+
const event = events[index];
|
|
1973
|
+
const token = event[1];
|
|
1974
|
+
if (event[0] === "enter") {
|
|
1975
|
+
if (token.type === "tableHead") {
|
|
1976
|
+
afterHeadAwaitingFirstBodyRow = false;
|
|
1977
|
+
if (lastTableEnd !== 0) {
|
|
1978
|
+
flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
|
|
1979
|
+
currentBody = void 0;
|
|
1980
|
+
lastTableEnd = 0;
|
|
1981
|
+
}
|
|
1982
|
+
currentTable = {
|
|
1983
|
+
type: "table",
|
|
1984
|
+
start: Object.assign({}, token.start),
|
|
1985
|
+
// Note: correct end is set later.
|
|
1986
|
+
end: Object.assign({}, token.end)
|
|
1987
|
+
};
|
|
1988
|
+
map.add(index, 0, [["enter", currentTable, context]]);
|
|
1989
|
+
} else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
|
|
1990
|
+
inFirstCellAwaitingPipe = true;
|
|
1991
|
+
currentCell = void 0;
|
|
1992
|
+
lastCell = [0, 0, 0, 0];
|
|
1993
|
+
cell = [0, index + 1, 0, 0];
|
|
1994
|
+
if (afterHeadAwaitingFirstBodyRow) {
|
|
1995
|
+
afterHeadAwaitingFirstBodyRow = false;
|
|
1996
|
+
currentBody = {
|
|
1997
|
+
type: "tableBody",
|
|
1998
|
+
start: Object.assign({}, token.start),
|
|
1999
|
+
// Note: correct end is set later.
|
|
2000
|
+
end: Object.assign({}, token.end)
|
|
2001
|
+
};
|
|
2002
|
+
map.add(index, 0, [["enter", currentBody, context]]);
|
|
2003
|
+
}
|
|
2004
|
+
rowKind = token.type === "tableDelimiterRow" ? 2 : currentBody ? 3 : 1;
|
|
2005
|
+
} else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
|
|
2006
|
+
inFirstCellAwaitingPipe = false;
|
|
2007
|
+
if (cell[2] === 0) {
|
|
2008
|
+
if (lastCell[1] !== 0) {
|
|
2009
|
+
cell[0] = cell[1];
|
|
2010
|
+
currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
|
|
2011
|
+
lastCell = [0, 0, 0, 0];
|
|
2012
|
+
}
|
|
2013
|
+
cell[2] = index;
|
|
2014
|
+
}
|
|
2015
|
+
} else if (token.type === "tableCellDivider") {
|
|
2016
|
+
if (inFirstCellAwaitingPipe) {
|
|
2017
|
+
inFirstCellAwaitingPipe = false;
|
|
2018
|
+
} else {
|
|
2019
|
+
if (lastCell[1] !== 0) {
|
|
2020
|
+
cell[0] = cell[1];
|
|
2021
|
+
currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
|
|
2022
|
+
}
|
|
2023
|
+
lastCell = cell;
|
|
2024
|
+
cell = [lastCell[1], index, 0, 0];
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
} else if (token.type === "tableHead") {
|
|
2028
|
+
afterHeadAwaitingFirstBodyRow = true;
|
|
2029
|
+
lastTableEnd = index;
|
|
2030
|
+
} else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
|
|
2031
|
+
lastTableEnd = index;
|
|
2032
|
+
if (lastCell[1] !== 0) {
|
|
2033
|
+
cell[0] = cell[1];
|
|
2034
|
+
currentCell = flushCell(map, context, lastCell, rowKind, index, currentCell);
|
|
2035
|
+
} else if (cell[1] !== 0) {
|
|
2036
|
+
currentCell = flushCell(map, context, cell, rowKind, index, currentCell);
|
|
2037
|
+
}
|
|
2038
|
+
rowKind = 0;
|
|
2039
|
+
} else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
|
|
2040
|
+
cell[3] = index;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
if (lastTableEnd !== 0) {
|
|
2044
|
+
flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
|
|
2045
|
+
}
|
|
2046
|
+
map.consume(context.events);
|
|
2047
|
+
index = -1;
|
|
2048
|
+
while (++index < context.events.length) {
|
|
2049
|
+
const event = context.events[index];
|
|
2050
|
+
if (event[0] === "enter" && event[1].type === "table") {
|
|
2051
|
+
event[1]._align = gfmTableAlign(context.events, index);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
return events;
|
|
2055
|
+
}
|
|
2056
|
+
function flushCell(map, context, range, rowKind, rowEnd, previousCell) {
|
|
2057
|
+
const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
|
|
2058
|
+
const valueName = "tableContent";
|
|
2059
|
+
if (range[0] !== 0) {
|
|
2060
|
+
previousCell.end = Object.assign({}, getPoint(context.events, range[0]));
|
|
2061
|
+
map.add(range[0], 0, [["exit", previousCell, context]]);
|
|
2062
|
+
}
|
|
2063
|
+
const now = getPoint(context.events, range[1]);
|
|
2064
|
+
previousCell = {
|
|
2065
|
+
type: groupName,
|
|
2066
|
+
start: Object.assign({}, now),
|
|
2067
|
+
// Note: correct end is set later.
|
|
2068
|
+
end: Object.assign({}, now)
|
|
2069
|
+
};
|
|
2070
|
+
map.add(range[1], 0, [["enter", previousCell, context]]);
|
|
2071
|
+
if (range[2] !== 0) {
|
|
2072
|
+
const relatedStart = getPoint(context.events, range[2]);
|
|
2073
|
+
const relatedEnd = getPoint(context.events, range[3]);
|
|
2074
|
+
const valueToken = {
|
|
2075
|
+
type: valueName,
|
|
2076
|
+
start: Object.assign({}, relatedStart),
|
|
2077
|
+
end: Object.assign({}, relatedEnd)
|
|
2078
|
+
};
|
|
2079
|
+
map.add(range[2], 0, [["enter", valueToken, context]]);
|
|
2080
|
+
if (rowKind !== 2) {
|
|
2081
|
+
const start = context.events[range[2]];
|
|
2082
|
+
const end = context.events[range[3]];
|
|
2083
|
+
start[1].end = Object.assign({}, end[1].end);
|
|
2084
|
+
start[1].type = "chunkText";
|
|
2085
|
+
start[1].contentType = "text";
|
|
2086
|
+
if (range[3] > range[2] + 1) {
|
|
2087
|
+
const a = range[2] + 1;
|
|
2088
|
+
const b = range[3] - range[2] - 1;
|
|
2089
|
+
map.add(a, b, []);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
map.add(range[3] + 1, 0, [["exit", valueToken, context]]);
|
|
2093
|
+
}
|
|
2094
|
+
if (rowEnd !== void 0) {
|
|
2095
|
+
previousCell.end = Object.assign({}, getPoint(context.events, rowEnd));
|
|
2096
|
+
map.add(rowEnd, 0, [["exit", previousCell, context]]);
|
|
2097
|
+
previousCell = void 0;
|
|
2098
|
+
}
|
|
2099
|
+
return previousCell;
|
|
2100
|
+
}
|
|
2101
|
+
function flushTableEnd(map, context, index, table, tableBody) {
|
|
2102
|
+
const exits = [];
|
|
2103
|
+
const related = getPoint(context.events, index);
|
|
2104
|
+
if (tableBody) {
|
|
2105
|
+
tableBody.end = Object.assign({}, related);
|
|
2106
|
+
exits.push(["exit", tableBody, context]);
|
|
2107
|
+
}
|
|
2108
|
+
table.end = Object.assign({}, related);
|
|
2109
|
+
exits.push(["exit", table, context]);
|
|
2110
|
+
map.add(index + 1, 0, exits);
|
|
2111
|
+
}
|
|
2112
|
+
function getPoint(events, index) {
|
|
2113
|
+
const event = events[index];
|
|
2114
|
+
const side = event[0] === "enter" ? "start" : "end";
|
|
2115
|
+
return event[1][side];
|
|
2116
|
+
}
|
|
2117
|
+
const tasklistCheck = {
|
|
2118
|
+
name: "tasklistCheck",
|
|
2119
|
+
tokenize: tokenizeTasklistCheck
|
|
2120
|
+
};
|
|
2121
|
+
function gfmTaskListItem() {
|
|
2122
|
+
return {
|
|
2123
|
+
text: {
|
|
2124
|
+
[91]: tasklistCheck
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
function tokenizeTasklistCheck(effects, ok2, nok) {
|
|
2129
|
+
const self = this;
|
|
2130
|
+
return open;
|
|
2131
|
+
function open(code2) {
|
|
2132
|
+
if (
|
|
2133
|
+
// Exit if there’s stuff before.
|
|
2134
|
+
self.previous !== null || // Exit if not in the first content that is the first child of a list
|
|
2135
|
+
// item.
|
|
2136
|
+
!self._gfmTasklistFirstContentOfListItem
|
|
2137
|
+
) {
|
|
2138
|
+
return nok(code2);
|
|
2139
|
+
}
|
|
2140
|
+
effects.enter("taskListCheck");
|
|
2141
|
+
effects.enter("taskListCheckMarker");
|
|
2142
|
+
effects.consume(code2);
|
|
2143
|
+
effects.exit("taskListCheckMarker");
|
|
2144
|
+
return inside;
|
|
2145
|
+
}
|
|
2146
|
+
function inside(code2) {
|
|
2147
|
+
if (indexCd3D_8gF.markdownLineEndingOrSpace(code2)) {
|
|
2148
|
+
effects.enter("taskListCheckValueUnchecked");
|
|
2149
|
+
effects.consume(code2);
|
|
2150
|
+
effects.exit("taskListCheckValueUnchecked");
|
|
2151
|
+
return close;
|
|
2152
|
+
}
|
|
2153
|
+
if (code2 === 88 || code2 === 120) {
|
|
2154
|
+
effects.enter("taskListCheckValueChecked");
|
|
2155
|
+
effects.consume(code2);
|
|
2156
|
+
effects.exit("taskListCheckValueChecked");
|
|
2157
|
+
return close;
|
|
2158
|
+
}
|
|
2159
|
+
return nok(code2);
|
|
2160
|
+
}
|
|
2161
|
+
function close(code2) {
|
|
2162
|
+
if (code2 === 93) {
|
|
2163
|
+
effects.enter("taskListCheckMarker");
|
|
2164
|
+
effects.consume(code2);
|
|
2165
|
+
effects.exit("taskListCheckMarker");
|
|
2166
|
+
effects.exit("taskListCheck");
|
|
2167
|
+
return after;
|
|
2168
|
+
}
|
|
2169
|
+
return nok(code2);
|
|
2170
|
+
}
|
|
2171
|
+
function after(code2) {
|
|
2172
|
+
if (indexCd3D_8gF.markdownLineEnding(code2)) {
|
|
2173
|
+
return ok2(code2);
|
|
2174
|
+
}
|
|
2175
|
+
if (indexCd3D_8gF.markdownSpace(code2)) {
|
|
2176
|
+
return effects.check({
|
|
2177
|
+
tokenize: spaceThenNonSpace
|
|
2178
|
+
}, ok2, nok)(code2);
|
|
2179
|
+
}
|
|
2180
|
+
return nok(code2);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
function spaceThenNonSpace(effects, ok2, nok) {
|
|
2184
|
+
return factorySpace(effects, after, "whitespace");
|
|
2185
|
+
function after(code2) {
|
|
2186
|
+
return code2 === null ? nok(code2) : ok2(code2);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function gfm(options) {
|
|
2190
|
+
return combineExtensions([
|
|
2191
|
+
gfmAutolinkLiteral(),
|
|
2192
|
+
gfmFootnote(),
|
|
2193
|
+
gfmStrikethrough(options),
|
|
2194
|
+
gfmTable(),
|
|
2195
|
+
gfmTaskListItem()
|
|
2196
|
+
]);
|
|
2197
|
+
}
|
|
2198
|
+
const emptyOptions = {};
|
|
2199
|
+
function remarkGfm(options) {
|
|
2200
|
+
const self = (
|
|
2201
|
+
/** @type {Processor<Root>} */
|
|
2202
|
+
this
|
|
2203
|
+
);
|
|
2204
|
+
const settings = options || emptyOptions;
|
|
2205
|
+
const data = self.data();
|
|
2206
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
2207
|
+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
2208
|
+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
2209
|
+
micromarkExtensions.push(gfm(settings));
|
|
2210
|
+
fromMarkdownExtensions.push(gfmFromMarkdown());
|
|
2211
|
+
toMarkdownExtensions.push(gfmToMarkdown(settings));
|
|
2212
|
+
}
|
|
2213
|
+
exports.default = remarkGfm;
|