@k-l-lambda/portolan 0.0.0-stage → 0.1.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.
@@ -0,0 +1,1920 @@
1
+ // @generated by Peggy 5.1.0.
2
+ //
3
+ // https://peggyjs.org/
4
+
5
+
6
+ class peg$SyntaxError extends SyntaxError {
7
+ constructor(message, expected, found, location) {
8
+ super(message);
9
+ this.expected = expected;
10
+ this.found = found;
11
+ this.location = location;
12
+ this.name = "SyntaxError";
13
+ }
14
+
15
+ format(sources) {
16
+ let str = "Error: " + this.message;
17
+ if (this.location) {
18
+ let src = null;
19
+ const st = sources.find(s => s.source === this.location.source);
20
+ if (st) {
21
+ src = st.text.split(/\r\n|\n|\r/g);
22
+ }
23
+ const s = this.location.start;
24
+ const offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
25
+ ? this.location.source.offset(s)
26
+ : s;
27
+ const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
28
+ if (src) {
29
+ const e = this.location.end;
30
+ const filler = "".padEnd(offset_s.line.toString().length, " ");
31
+ const line = src[s.line - 1];
32
+ const last = s.line === e.line ? e.column : line.length + 1;
33
+ const hatLen = (last - s.column) || 1;
34
+ str += "\n --> " + loc + "\n"
35
+ + filler + " |\n"
36
+ + offset_s.line + " | " + line + "\n"
37
+ + filler + " | " + "".padEnd(s.column - 1, " ")
38
+ + "".padEnd(hatLen, "^");
39
+ } else {
40
+ str += "\n at " + loc;
41
+ }
42
+ }
43
+ return str;
44
+ }
45
+
46
+ static buildMessage(expected, found) {
47
+ function hex(ch) {
48
+ return ch.codePointAt(0).toString(16).toUpperCase();
49
+ }
50
+
51
+ const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode")
52
+ ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu")
53
+ : null;
54
+ function unicodeEscape(s) {
55
+ if (nonPrintable) {
56
+ return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}");
57
+ }
58
+ return s;
59
+ }
60
+
61
+ function literalEscape(s) {
62
+ return unicodeEscape(s
63
+ .replace(/\\/g, "\\\\")
64
+ .replace(/"/g, "\\\"")
65
+ .replace(/\0/g, "\\0")
66
+ .replace(/\t/g, "\\t")
67
+ .replace(/\n/g, "\\n")
68
+ .replace(/\r/g, "\\r")
69
+ .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
70
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
71
+ }
72
+
73
+ function classEscape(s) {
74
+ return unicodeEscape(s
75
+ .replace(/\\/g, "\\\\")
76
+ .replace(/\]/g, "\\]")
77
+ .replace(/\^/g, "\\^")
78
+ .replace(/-/g, "\\-")
79
+ .replace(/\0/g, "\\0")
80
+ .replace(/\t/g, "\\t")
81
+ .replace(/\n/g, "\\n")
82
+ .replace(/\r/g, "\\r")
83
+ .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
84
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
85
+ }
86
+
87
+ const DESCRIBE_EXPECTATION_FNS = {
88
+ literal(expectation) {
89
+ return "\"" + literalEscape(expectation.text) + "\"";
90
+ },
91
+
92
+ class(expectation) {
93
+ const escapedParts = expectation.parts.map(
94
+ part => (Array.isArray(part)
95
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
96
+ : classEscape(part))
97
+ );
98
+
99
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : "");
100
+ },
101
+
102
+ any() {
103
+ return "any character";
104
+ },
105
+
106
+ end() {
107
+ return "end of input";
108
+ },
109
+
110
+ other(expectation) {
111
+ return expectation.description;
112
+ },
113
+ };
114
+
115
+ function describeExpectation(expectation) {
116
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
117
+ }
118
+
119
+ function describeExpected(expected) {
120
+ const descriptions = expected.map(describeExpectation);
121
+ descriptions.sort();
122
+
123
+ if (descriptions.length > 0) {
124
+ let j = 1;
125
+ for (let i = 1; i < descriptions.length; i++) {
126
+ if (descriptions[i - 1] !== descriptions[i]) {
127
+ descriptions[j] = descriptions[i];
128
+ j++;
129
+ }
130
+ }
131
+ descriptions.length = j;
132
+ }
133
+
134
+ switch (descriptions.length) {
135
+ case 1:
136
+ return descriptions[0];
137
+
138
+ case 2:
139
+ return descriptions[0] + " or " + descriptions[1];
140
+
141
+ default:
142
+ return descriptions.slice(0, -1).join(", ")
143
+ + ", or "
144
+ + descriptions[descriptions.length - 1];
145
+ }
146
+ }
147
+
148
+ function describeFound(found) {
149
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
150
+ }
151
+
152
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
153
+ }
154
+ }
155
+
156
+ function peg$parse(input, options) {
157
+ options = options !== undefined ? options : {};
158
+
159
+ const peg$FAILED = {};
160
+ const peg$source = options.grammarSource;
161
+
162
+ const peg$startRuleFunctions = {
163
+ Line: peg$parseLine,
164
+ Inline: peg$parseInline,
165
+ };
166
+ let peg$startRuleFunction = peg$parseLine;
167
+
168
+ const peg$c0 = "%%";
169
+ const peg$c1 = "[";
170
+ const peg$c2 = "]";
171
+ const peg$c3 = ",";
172
+ const peg$c4 = ".rhumb^";
173
+ const peg$c5 = ".rhumb";
174
+ const peg$c6 = "^";
175
+ const peg$c7 = ":";
176
+ const peg$c8 = "`";
177
+ const peg$c9 = "!";
178
+ const peg$c10 = "(";
179
+ const peg$c11 = ")";
180
+ const peg$c12 = "\\";
181
+ const peg$c13 = "<";
182
+ const peg$c14 = ">";
183
+ const peg$c15 = "\"";
184
+
185
+ const peg$r0 = /^[\-*]/;
186
+ const peg$r1 = /^[^\]]/;
187
+ const peg$r2 = /^[ \t]/;
188
+ const peg$r3 = /^[a-z]/;
189
+ const peg$r4 = /^[^ \t,\^:]/;
190
+ const peg$r5 = /^[a-zA-Z0-9_]/;
191
+ const peg$r6 = /^[a-zA-Z0-9_\-]/;
192
+ const peg$r7 = /^[^`]/;
193
+ const peg$r8 = /^[^\]\\]/;
194
+ const peg$r9 = /^[^ \t)]/;
195
+ const peg$r10 = /^[!-\/:-@[-`{-~]/;
196
+ const peg$r11 = /^[^>\n]/;
197
+ const peg$r12 = /^[^"]/;
198
+ const peg$r13 = /^[a-zA-Z]/;
199
+ const peg$r14 = /^[a-zA-Z0-9+.\-]/;
200
+ const peg$r15 = /^[^ \t<>]/;
201
+
202
+ const peg$e0 = peg$anyExpectation();
203
+ const peg$e1 = peg$literalExpectation("%%", false);
204
+ const peg$e2 = peg$classExpectation(["-", "*"], false, false, false);
205
+ const peg$e3 = peg$literalExpectation("[", false);
206
+ const peg$e4 = peg$classExpectation(["]"], true, false, false);
207
+ const peg$e5 = peg$literalExpectation("]", false);
208
+ const peg$e6 = peg$classExpectation([" ", "\t"], false, false, false);
209
+ const peg$e7 = peg$classExpectation([["a", "z"]], false, false, false);
210
+ const peg$e8 = peg$literalExpectation(",", false);
211
+ const peg$e9 = peg$literalExpectation(".rhumb^", false);
212
+ const peg$e10 = peg$classExpectation([" ", "\t", ",", "^", ":"], true, false, false);
213
+ const peg$e11 = peg$literalExpectation(".rhumb", false);
214
+ const peg$e12 = peg$literalExpectation("^", false);
215
+ const peg$e13 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_"], false, false, false);
216
+ const peg$e14 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false, false);
217
+ const peg$e15 = peg$literalExpectation(":", false);
218
+ const peg$e16 = peg$literalExpectation("`", false);
219
+ const peg$e17 = peg$classExpectation(["`"], true, false, false);
220
+ const peg$e18 = peg$literalExpectation("!", false);
221
+ const peg$e19 = peg$literalExpectation("(", false);
222
+ const peg$e20 = peg$literalExpectation(")", false);
223
+ const peg$e21 = peg$classExpectation(["]", "\\"], true, false, false);
224
+ const peg$e22 = peg$literalExpectation("\\", false);
225
+ const peg$e23 = peg$literalExpectation("<", false);
226
+ const peg$e24 = peg$literalExpectation(">", false);
227
+ const peg$e25 = peg$classExpectation([" ", "\t", ")"], true, false, false);
228
+ const peg$e26 = peg$classExpectation([["!", "/"], [":", "@"], ["[", "`"], ["{", "~"]], false, false, false);
229
+ const peg$e27 = peg$classExpectation([">", "\n"], true, false, false);
230
+ const peg$e28 = peg$literalExpectation("\"", false);
231
+ const peg$e29 = peg$classExpectation(["\""], true, false, false);
232
+ const peg$e30 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false, false);
233
+ const peg$e31 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "+", ".", "-"], false, false, false);
234
+ const peg$e32 = peg$classExpectation([" ", "\t", "<", ">"], true, false, false);
235
+
236
+ function peg$f0() { return { type: "blank" }; }
237
+ function peg$f1(text) { return { type: "comment", text }; }
238
+ function peg$f2(marker, box, b) { return b; }
239
+ function peg$f3(marker, box, body) {
240
+ return { type: "node", marker, status: box, body: body ?? "" };
241
+ }
242
+ function peg$f4(marker, text) { return { type: "note", marker, text }; }
243
+ function peg$f5(marker) { return { type: "note", marker, text: "" }; }
244
+ function peg$f6(s) { return s; }
245
+ function peg$f7(from, kind, to, label) {
246
+ return { type: "edge", from, kind, to, label: label ?? null };
247
+ }
248
+ function peg$f8(head, r) { return r; }
249
+ function peg$f9(head, tail) { return [head, ...tail]; }
250
+ function peg$f10(file, id) { return { file, id }; }
251
+ function peg$f11(id) { return { file: null, id }; }
252
+ function peg$f12(text) { return text.trim(); }
253
+ function peg$f13(items) { return items.filter((x) => x !== null); }
254
+ function peg$f14() { return null; }
255
+ function peg$f15() { return null; }
256
+ function peg$f16() { return null; }
257
+ function peg$f17(l) { return l; }
258
+ function peg$f18(text, target) {
259
+ return { text, target, start: range().start };
260
+ }
261
+ function peg$f19(t) { return t.join(""); }
262
+ function peg$f20(c) { return c; }
263
+ function peg$f21(t) {
264
+ return { text: t, target: t, start: range().start };
265
+ }
266
+ function peg$f22() { return null; }
267
+ let peg$currPos = options.peg$currPos | 0;
268
+ let peg$savedPos = peg$currPos;
269
+ const peg$posDetailsCache = [{ line: 1, column: 1 }];
270
+ let peg$maxFailPos = peg$currPos;
271
+ let peg$maxFailExpected = options.peg$maxFailExpected || [];
272
+ let peg$silentFails = options.peg$silentFails | 0;
273
+
274
+ let peg$result;
275
+
276
+ if (options.startRule) {
277
+ if (!(options.startRule in peg$startRuleFunctions)) {
278
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
279
+ }
280
+
281
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
282
+ }
283
+
284
+ function text() {
285
+ return input.substring(peg$savedPos, peg$currPos);
286
+ }
287
+
288
+ function offset() {
289
+ return peg$savedPos;
290
+ }
291
+
292
+ function range() {
293
+ return {
294
+ source: peg$source,
295
+ start: peg$savedPos,
296
+ end: peg$currPos,
297
+ };
298
+ }
299
+
300
+ function location() {
301
+ return peg$computeLocation(peg$savedPos, peg$currPos);
302
+ }
303
+
304
+ function expected(description, location) {
305
+ location = location !== undefined
306
+ ? location
307
+ : peg$computeLocation(peg$savedPos, peg$currPos);
308
+
309
+ throw peg$buildStructuredError(
310
+ [peg$otherExpectation(description)],
311
+ input.substring(peg$savedPos, peg$currPos),
312
+ location
313
+ );
314
+ }
315
+
316
+ function error(message, location) {
317
+ location = location !== undefined
318
+ ? location
319
+ : peg$computeLocation(peg$savedPos, peg$currPos);
320
+
321
+ throw peg$buildSimpleError(message, location);
322
+ }
323
+
324
+ function peg$getUnicode(pos = peg$currPos) {
325
+ const cp = input.codePointAt(pos);
326
+ if (cp === undefined) {
327
+ return "";
328
+ }
329
+ return String.fromCodePoint(cp);
330
+ }
331
+
332
+ function peg$literalExpectation(text, ignoreCase) {
333
+ return { type: "literal", text, ignoreCase };
334
+ }
335
+
336
+ function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
337
+ return { type: "class", parts, inverted, ignoreCase, unicode };
338
+ }
339
+
340
+ function peg$anyExpectation() {
341
+ return { type: "any" };
342
+ }
343
+
344
+ function peg$endExpectation() {
345
+ return { type: "end" };
346
+ }
347
+
348
+ function peg$otherExpectation(description) {
349
+ return { type: "other", description };
350
+ }
351
+
352
+ function peg$computePosDetails(pos) {
353
+ let details = peg$posDetailsCache[pos];
354
+ let p;
355
+
356
+ if (details) {
357
+ return details;
358
+ } else {
359
+ if (pos >= peg$posDetailsCache.length) {
360
+ p = peg$posDetailsCache.length - 1;
361
+ } else {
362
+ p = pos;
363
+ while (!peg$posDetailsCache[--p]) {}
364
+ }
365
+
366
+ details = peg$posDetailsCache[p];
367
+ details = {
368
+ line: details.line,
369
+ column: details.column,
370
+ };
371
+
372
+ while (p < pos) {
373
+ if (input.charCodeAt(p) === 10) {
374
+ details.line++;
375
+ details.column = 1;
376
+ } else {
377
+ details.column++;
378
+ }
379
+
380
+ p++;
381
+ }
382
+
383
+ peg$posDetailsCache[pos] = details;
384
+
385
+ return details;
386
+ }
387
+ }
388
+
389
+ function peg$computeLocation(startPos, endPos, offset) {
390
+ const startPosDetails = peg$computePosDetails(startPos);
391
+ const endPosDetails = peg$computePosDetails(endPos);
392
+
393
+ const res = {
394
+ source: peg$source,
395
+ start: {
396
+ offset: startPos,
397
+ line: startPosDetails.line,
398
+ column: startPosDetails.column,
399
+ },
400
+ end: {
401
+ offset: endPos,
402
+ line: endPosDetails.line,
403
+ column: endPosDetails.column,
404
+ },
405
+ };
406
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
407
+ res.start = peg$source.offset(res.start);
408
+ res.end = peg$source.offset(res.end);
409
+ }
410
+ return res;
411
+ }
412
+
413
+ function peg$fail(expected) {
414
+ if (peg$currPos < peg$maxFailPos) { return; }
415
+
416
+ if (peg$currPos > peg$maxFailPos) {
417
+ peg$maxFailPos = peg$currPos;
418
+ peg$maxFailExpected = [];
419
+ }
420
+
421
+ peg$maxFailExpected.push(expected);
422
+ }
423
+
424
+ function peg$buildSimpleError(message, location) {
425
+ return new peg$SyntaxError(message, null, null, location);
426
+ }
427
+
428
+ function peg$buildStructuredError(expected, found, location) {
429
+ return new peg$SyntaxError(
430
+ peg$SyntaxError.buildMessage(expected, found),
431
+ expected,
432
+ found,
433
+ location
434
+ );
435
+ }
436
+
437
+ function peg$parseLine() {
438
+ let s0;
439
+
440
+ s0 = peg$parseComment();
441
+ if (s0 === peg$FAILED) {
442
+ s0 = peg$parseListItem();
443
+ if (s0 === peg$FAILED) {
444
+ s0 = peg$parseEdge();
445
+ if (s0 === peg$FAILED) {
446
+ s0 = peg$parseBlank();
447
+ }
448
+ }
449
+ }
450
+
451
+ return s0;
452
+ }
453
+
454
+ function peg$parseBlank() {
455
+ let s0, s1, s2, s3;
456
+
457
+ s0 = peg$currPos;
458
+ s1 = peg$parse_();
459
+ if (s1 === peg$FAILED) {
460
+ s1 = null;
461
+ }
462
+ s2 = peg$currPos;
463
+ peg$silentFails++;
464
+ if (input.length > peg$currPos) {
465
+ s3 = input.charAt(peg$currPos);
466
+ peg$currPos++;
467
+ } else {
468
+ s3 = peg$FAILED;
469
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
470
+ }
471
+ peg$silentFails--;
472
+ if (s3 === peg$FAILED) {
473
+ s2 = undefined;
474
+ } else {
475
+ peg$currPos = s2;
476
+ s2 = peg$FAILED;
477
+ }
478
+ if (s2 !== peg$FAILED) {
479
+ peg$savedPos = s0;
480
+ s0 = peg$f0();
481
+ } else {
482
+ peg$currPos = s0;
483
+ s0 = peg$FAILED;
484
+ }
485
+
486
+ return s0;
487
+ }
488
+
489
+ function peg$parseComment() {
490
+ let s0, s1, s2, s3, s4;
491
+
492
+ s0 = peg$currPos;
493
+ if (input.substr(peg$currPos, 2) === peg$c0) {
494
+ s1 = peg$c0;
495
+ peg$currPos += 2;
496
+ } else {
497
+ s1 = peg$FAILED;
498
+ if (peg$silentFails === 0) { peg$fail(peg$e1); }
499
+ }
500
+ if (s1 !== peg$FAILED) {
501
+ s2 = peg$currPos;
502
+ s3 = [];
503
+ if (input.length > peg$currPos) {
504
+ s4 = input.charAt(peg$currPos);
505
+ peg$currPos++;
506
+ } else {
507
+ s4 = peg$FAILED;
508
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
509
+ }
510
+ while (s4 !== peg$FAILED) {
511
+ s3.push(s4);
512
+ if (input.length > peg$currPos) {
513
+ s4 = input.charAt(peg$currPos);
514
+ peg$currPos++;
515
+ } else {
516
+ s4 = peg$FAILED;
517
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
518
+ }
519
+ }
520
+ s2 = input.substring(s2, peg$currPos);
521
+ peg$savedPos = s0;
522
+ s0 = peg$f1(s2);
523
+ } else {
524
+ peg$currPos = s0;
525
+ s0 = peg$FAILED;
526
+ }
527
+
528
+ return s0;
529
+ }
530
+
531
+ function peg$parseListItem() {
532
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8;
533
+
534
+ s0 = peg$currPos;
535
+ s1 = input.charAt(peg$currPos);
536
+ if (peg$r0.test(s1)) {
537
+ peg$currPos++;
538
+ } else {
539
+ s1 = peg$FAILED;
540
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
541
+ }
542
+ if (s1 !== peg$FAILED) {
543
+ s2 = peg$parse_();
544
+ if (s2 !== peg$FAILED) {
545
+ s3 = peg$parseCheckbox();
546
+ if (s3 !== peg$FAILED) {
547
+ s4 = peg$currPos;
548
+ s5 = peg$parse_();
549
+ if (s5 !== peg$FAILED) {
550
+ s6 = peg$currPos;
551
+ s7 = [];
552
+ if (input.length > peg$currPos) {
553
+ s8 = input.charAt(peg$currPos);
554
+ peg$currPos++;
555
+ } else {
556
+ s8 = peg$FAILED;
557
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
558
+ }
559
+ while (s8 !== peg$FAILED) {
560
+ s7.push(s8);
561
+ if (input.length > peg$currPos) {
562
+ s8 = input.charAt(peg$currPos);
563
+ peg$currPos++;
564
+ } else {
565
+ s8 = peg$FAILED;
566
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
567
+ }
568
+ }
569
+ s6 = input.substring(s6, peg$currPos);
570
+ peg$savedPos = s4;
571
+ s4 = peg$f2(s1, s3, s6);
572
+ } else {
573
+ peg$currPos = s4;
574
+ s4 = peg$FAILED;
575
+ }
576
+ if (s4 === peg$FAILED) {
577
+ s4 = null;
578
+ }
579
+ peg$savedPos = s0;
580
+ s0 = peg$f3(s1, s3, s4);
581
+ } else {
582
+ peg$currPos = s0;
583
+ s0 = peg$FAILED;
584
+ }
585
+ } else {
586
+ peg$currPos = s0;
587
+ s0 = peg$FAILED;
588
+ }
589
+ } else {
590
+ peg$currPos = s0;
591
+ s0 = peg$FAILED;
592
+ }
593
+ if (s0 === peg$FAILED) {
594
+ s0 = peg$currPos;
595
+ s1 = input.charAt(peg$currPos);
596
+ if (peg$r0.test(s1)) {
597
+ peg$currPos++;
598
+ } else {
599
+ s1 = peg$FAILED;
600
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
601
+ }
602
+ if (s1 !== peg$FAILED) {
603
+ s2 = peg$parse_();
604
+ if (s2 !== peg$FAILED) {
605
+ s3 = peg$currPos;
606
+ s4 = [];
607
+ if (input.length > peg$currPos) {
608
+ s5 = input.charAt(peg$currPos);
609
+ peg$currPos++;
610
+ } else {
611
+ s5 = peg$FAILED;
612
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
613
+ }
614
+ while (s5 !== peg$FAILED) {
615
+ s4.push(s5);
616
+ if (input.length > peg$currPos) {
617
+ s5 = input.charAt(peg$currPos);
618
+ peg$currPos++;
619
+ } else {
620
+ s5 = peg$FAILED;
621
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
622
+ }
623
+ }
624
+ s3 = input.substring(s3, peg$currPos);
625
+ peg$savedPos = s0;
626
+ s0 = peg$f4(s1, s3);
627
+ } else {
628
+ peg$currPos = s0;
629
+ s0 = peg$FAILED;
630
+ }
631
+ } else {
632
+ peg$currPos = s0;
633
+ s0 = peg$FAILED;
634
+ }
635
+ if (s0 === peg$FAILED) {
636
+ s0 = peg$currPos;
637
+ s1 = input.charAt(peg$currPos);
638
+ if (peg$r0.test(s1)) {
639
+ peg$currPos++;
640
+ } else {
641
+ s1 = peg$FAILED;
642
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
643
+ }
644
+ if (s1 !== peg$FAILED) {
645
+ s2 = peg$parse_();
646
+ if (s2 === peg$FAILED) {
647
+ s2 = null;
648
+ }
649
+ s3 = peg$currPos;
650
+ peg$silentFails++;
651
+ if (input.length > peg$currPos) {
652
+ s4 = input.charAt(peg$currPos);
653
+ peg$currPos++;
654
+ } else {
655
+ s4 = peg$FAILED;
656
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
657
+ }
658
+ peg$silentFails--;
659
+ if (s4 === peg$FAILED) {
660
+ s3 = undefined;
661
+ } else {
662
+ peg$currPos = s3;
663
+ s3 = peg$FAILED;
664
+ }
665
+ if (s3 !== peg$FAILED) {
666
+ peg$savedPos = s0;
667
+ s0 = peg$f5(s1);
668
+ } else {
669
+ peg$currPos = s0;
670
+ s0 = peg$FAILED;
671
+ }
672
+ } else {
673
+ peg$currPos = s0;
674
+ s0 = peg$FAILED;
675
+ }
676
+ }
677
+ }
678
+
679
+ return s0;
680
+ }
681
+
682
+ function peg$parseCheckbox() {
683
+ let s0, s1, s2, s3, s4, s5, s6;
684
+
685
+ s0 = peg$currPos;
686
+ if (input.charCodeAt(peg$currPos) === 91) {
687
+ s1 = peg$c1;
688
+ peg$currPos++;
689
+ } else {
690
+ s1 = peg$FAILED;
691
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
692
+ }
693
+ if (s1 !== peg$FAILED) {
694
+ s2 = input.charAt(peg$currPos);
695
+ if (peg$r1.test(s2)) {
696
+ peg$currPos++;
697
+ } else {
698
+ s2 = peg$FAILED;
699
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
700
+ }
701
+ if (s2 !== peg$FAILED) {
702
+ if (input.charCodeAt(peg$currPos) === 93) {
703
+ s3 = peg$c2;
704
+ peg$currPos++;
705
+ } else {
706
+ s3 = peg$FAILED;
707
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
708
+ }
709
+ if (s3 !== peg$FAILED) {
710
+ s4 = peg$currPos;
711
+ peg$silentFails++;
712
+ s5 = input.charAt(peg$currPos);
713
+ if (peg$r2.test(s5)) {
714
+ peg$currPos++;
715
+ } else {
716
+ s5 = peg$FAILED;
717
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
718
+ }
719
+ if (s5 === peg$FAILED) {
720
+ s5 = peg$currPos;
721
+ peg$silentFails++;
722
+ if (input.length > peg$currPos) {
723
+ s6 = input.charAt(peg$currPos);
724
+ peg$currPos++;
725
+ } else {
726
+ s6 = peg$FAILED;
727
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
728
+ }
729
+ peg$silentFails--;
730
+ if (s6 === peg$FAILED) {
731
+ s5 = undefined;
732
+ } else {
733
+ peg$currPos = s5;
734
+ s5 = peg$FAILED;
735
+ }
736
+ }
737
+ peg$silentFails--;
738
+ if (s5 !== peg$FAILED) {
739
+ peg$currPos = s4;
740
+ s4 = undefined;
741
+ } else {
742
+ s4 = peg$FAILED;
743
+ }
744
+ if (s4 !== peg$FAILED) {
745
+ peg$savedPos = s0;
746
+ s0 = peg$f6(s2);
747
+ } else {
748
+ peg$currPos = s0;
749
+ s0 = peg$FAILED;
750
+ }
751
+ } else {
752
+ peg$currPos = s0;
753
+ s0 = peg$FAILED;
754
+ }
755
+ } else {
756
+ peg$currPos = s0;
757
+ s0 = peg$FAILED;
758
+ }
759
+ } else {
760
+ peg$currPos = s0;
761
+ s0 = peg$FAILED;
762
+ }
763
+
764
+ return s0;
765
+ }
766
+
767
+ function peg$parseEdge() {
768
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
769
+
770
+ s0 = peg$currPos;
771
+ s1 = peg$parseRef();
772
+ if (s1 !== peg$FAILED) {
773
+ s2 = peg$parse_();
774
+ if (s2 !== peg$FAILED) {
775
+ s3 = peg$currPos;
776
+ s4 = [];
777
+ s5 = input.charAt(peg$currPos);
778
+ if (peg$r3.test(s5)) {
779
+ peg$currPos++;
780
+ } else {
781
+ s5 = peg$FAILED;
782
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
783
+ }
784
+ if (s5 !== peg$FAILED) {
785
+ while (s5 !== peg$FAILED) {
786
+ s4.push(s5);
787
+ s5 = input.charAt(peg$currPos);
788
+ if (peg$r3.test(s5)) {
789
+ peg$currPos++;
790
+ } else {
791
+ s5 = peg$FAILED;
792
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
793
+ }
794
+ }
795
+ } else {
796
+ s4 = peg$FAILED;
797
+ }
798
+ if (s4 !== peg$FAILED) {
799
+ s3 = input.substring(s3, peg$currPos);
800
+ } else {
801
+ s3 = s4;
802
+ }
803
+ if (s3 !== peg$FAILED) {
804
+ s4 = peg$parse_();
805
+ if (s4 !== peg$FAILED) {
806
+ s5 = peg$parseRefList();
807
+ if (s5 !== peg$FAILED) {
808
+ s6 = peg$parseLabel();
809
+ if (s6 === peg$FAILED) {
810
+ s6 = null;
811
+ }
812
+ s7 = peg$parse_();
813
+ if (s7 === peg$FAILED) {
814
+ s7 = null;
815
+ }
816
+ s8 = peg$currPos;
817
+ peg$silentFails++;
818
+ if (input.length > peg$currPos) {
819
+ s9 = input.charAt(peg$currPos);
820
+ peg$currPos++;
821
+ } else {
822
+ s9 = peg$FAILED;
823
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
824
+ }
825
+ peg$silentFails--;
826
+ if (s9 === peg$FAILED) {
827
+ s8 = undefined;
828
+ } else {
829
+ peg$currPos = s8;
830
+ s8 = peg$FAILED;
831
+ }
832
+ if (s8 !== peg$FAILED) {
833
+ peg$savedPos = s0;
834
+ s0 = peg$f7(s1, s3, s5, s6);
835
+ } else {
836
+ peg$currPos = s0;
837
+ s0 = peg$FAILED;
838
+ }
839
+ } else {
840
+ peg$currPos = s0;
841
+ s0 = peg$FAILED;
842
+ }
843
+ } else {
844
+ peg$currPos = s0;
845
+ s0 = peg$FAILED;
846
+ }
847
+ } else {
848
+ peg$currPos = s0;
849
+ s0 = peg$FAILED;
850
+ }
851
+ } else {
852
+ peg$currPos = s0;
853
+ s0 = peg$FAILED;
854
+ }
855
+ } else {
856
+ peg$currPos = s0;
857
+ s0 = peg$FAILED;
858
+ }
859
+
860
+ return s0;
861
+ }
862
+
863
+ function peg$parseRefList() {
864
+ let s0, s1, s2, s3, s4, s5, s6, s7;
865
+
866
+ s0 = peg$currPos;
867
+ s1 = peg$parseRef();
868
+ if (s1 !== peg$FAILED) {
869
+ s2 = [];
870
+ s3 = peg$currPos;
871
+ s4 = peg$parse_();
872
+ if (s4 === peg$FAILED) {
873
+ s4 = null;
874
+ }
875
+ if (input.charCodeAt(peg$currPos) === 44) {
876
+ s5 = peg$c3;
877
+ peg$currPos++;
878
+ } else {
879
+ s5 = peg$FAILED;
880
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
881
+ }
882
+ if (s5 !== peg$FAILED) {
883
+ s6 = peg$parse_();
884
+ if (s6 === peg$FAILED) {
885
+ s6 = null;
886
+ }
887
+ s7 = peg$parseRef();
888
+ if (s7 !== peg$FAILED) {
889
+ peg$savedPos = s3;
890
+ s3 = peg$f8(s1, s7);
891
+ } else {
892
+ peg$currPos = s3;
893
+ s3 = peg$FAILED;
894
+ }
895
+ } else {
896
+ peg$currPos = s3;
897
+ s3 = peg$FAILED;
898
+ }
899
+ while (s3 !== peg$FAILED) {
900
+ s2.push(s3);
901
+ s3 = peg$currPos;
902
+ s4 = peg$parse_();
903
+ if (s4 === peg$FAILED) {
904
+ s4 = null;
905
+ }
906
+ if (input.charCodeAt(peg$currPos) === 44) {
907
+ s5 = peg$c3;
908
+ peg$currPos++;
909
+ } else {
910
+ s5 = peg$FAILED;
911
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
912
+ }
913
+ if (s5 !== peg$FAILED) {
914
+ s6 = peg$parse_();
915
+ if (s6 === peg$FAILED) {
916
+ s6 = null;
917
+ }
918
+ s7 = peg$parseRef();
919
+ if (s7 !== peg$FAILED) {
920
+ peg$savedPos = s3;
921
+ s3 = peg$f8(s1, s7);
922
+ } else {
923
+ peg$currPos = s3;
924
+ s3 = peg$FAILED;
925
+ }
926
+ } else {
927
+ peg$currPos = s3;
928
+ s3 = peg$FAILED;
929
+ }
930
+ }
931
+ peg$savedPos = s0;
932
+ s0 = peg$f9(s1, s2);
933
+ } else {
934
+ peg$currPos = s0;
935
+ s0 = peg$FAILED;
936
+ }
937
+
938
+ return s0;
939
+ }
940
+
941
+ function peg$parseRef() {
942
+ let s0, s1, s2, s3, s4, s5, s6;
943
+
944
+ s0 = peg$currPos;
945
+ s1 = peg$currPos;
946
+ s2 = peg$currPos;
947
+ s3 = [];
948
+ s4 = peg$currPos;
949
+ s5 = peg$currPos;
950
+ peg$silentFails++;
951
+ if (input.substr(peg$currPos, 7) === peg$c4) {
952
+ s6 = peg$c4;
953
+ peg$currPos += 7;
954
+ } else {
955
+ s6 = peg$FAILED;
956
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
957
+ }
958
+ peg$silentFails--;
959
+ if (s6 === peg$FAILED) {
960
+ s5 = undefined;
961
+ } else {
962
+ peg$currPos = s5;
963
+ s5 = peg$FAILED;
964
+ }
965
+ if (s5 !== peg$FAILED) {
966
+ s6 = input.charAt(peg$currPos);
967
+ if (peg$r4.test(s6)) {
968
+ peg$currPos++;
969
+ } else {
970
+ s6 = peg$FAILED;
971
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
972
+ }
973
+ if (s6 !== peg$FAILED) {
974
+ s5 = [s5, s6];
975
+ s4 = s5;
976
+ } else {
977
+ peg$currPos = s4;
978
+ s4 = peg$FAILED;
979
+ }
980
+ } else {
981
+ peg$currPos = s4;
982
+ s4 = peg$FAILED;
983
+ }
984
+ if (s4 !== peg$FAILED) {
985
+ while (s4 !== peg$FAILED) {
986
+ s3.push(s4);
987
+ s4 = peg$currPos;
988
+ s5 = peg$currPos;
989
+ peg$silentFails++;
990
+ if (input.substr(peg$currPos, 7) === peg$c4) {
991
+ s6 = peg$c4;
992
+ peg$currPos += 7;
993
+ } else {
994
+ s6 = peg$FAILED;
995
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
996
+ }
997
+ peg$silentFails--;
998
+ if (s6 === peg$FAILED) {
999
+ s5 = undefined;
1000
+ } else {
1001
+ peg$currPos = s5;
1002
+ s5 = peg$FAILED;
1003
+ }
1004
+ if (s5 !== peg$FAILED) {
1005
+ s6 = input.charAt(peg$currPos);
1006
+ if (peg$r4.test(s6)) {
1007
+ peg$currPos++;
1008
+ } else {
1009
+ s6 = peg$FAILED;
1010
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
1011
+ }
1012
+ if (s6 !== peg$FAILED) {
1013
+ s5 = [s5, s6];
1014
+ s4 = s5;
1015
+ } else {
1016
+ peg$currPos = s4;
1017
+ s4 = peg$FAILED;
1018
+ }
1019
+ } else {
1020
+ peg$currPos = s4;
1021
+ s4 = peg$FAILED;
1022
+ }
1023
+ }
1024
+ } else {
1025
+ s3 = peg$FAILED;
1026
+ }
1027
+ if (s3 !== peg$FAILED) {
1028
+ if (input.substr(peg$currPos, 6) === peg$c5) {
1029
+ s4 = peg$c5;
1030
+ peg$currPos += 6;
1031
+ } else {
1032
+ s4 = peg$FAILED;
1033
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
1034
+ }
1035
+ if (s4 !== peg$FAILED) {
1036
+ s3 = [s3, s4];
1037
+ s2 = s3;
1038
+ } else {
1039
+ peg$currPos = s2;
1040
+ s2 = peg$FAILED;
1041
+ }
1042
+ } else {
1043
+ peg$currPos = s2;
1044
+ s2 = peg$FAILED;
1045
+ }
1046
+ if (s2 !== peg$FAILED) {
1047
+ s1 = input.substring(s1, peg$currPos);
1048
+ } else {
1049
+ s1 = s2;
1050
+ }
1051
+ if (s1 !== peg$FAILED) {
1052
+ if (input.charCodeAt(peg$currPos) === 94) {
1053
+ s2 = peg$c6;
1054
+ peg$currPos++;
1055
+ } else {
1056
+ s2 = peg$FAILED;
1057
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
1058
+ }
1059
+ if (s2 !== peg$FAILED) {
1060
+ s3 = peg$parseIdToken();
1061
+ if (s3 !== peg$FAILED) {
1062
+ peg$savedPos = s0;
1063
+ s0 = peg$f10(s1, s3);
1064
+ } else {
1065
+ peg$currPos = s0;
1066
+ s0 = peg$FAILED;
1067
+ }
1068
+ } else {
1069
+ peg$currPos = s0;
1070
+ s0 = peg$FAILED;
1071
+ }
1072
+ } else {
1073
+ peg$currPos = s0;
1074
+ s0 = peg$FAILED;
1075
+ }
1076
+ if (s0 === peg$FAILED) {
1077
+ s0 = peg$currPos;
1078
+ if (input.charCodeAt(peg$currPos) === 94) {
1079
+ s1 = peg$c6;
1080
+ peg$currPos++;
1081
+ } else {
1082
+ s1 = peg$FAILED;
1083
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
1084
+ }
1085
+ if (s1 === peg$FAILED) {
1086
+ s1 = null;
1087
+ }
1088
+ s2 = peg$parseIdToken();
1089
+ if (s2 !== peg$FAILED) {
1090
+ peg$savedPos = s0;
1091
+ s0 = peg$f11(s2);
1092
+ } else {
1093
+ peg$currPos = s0;
1094
+ s0 = peg$FAILED;
1095
+ }
1096
+ }
1097
+
1098
+ return s0;
1099
+ }
1100
+
1101
+ function peg$parseIdToken() {
1102
+ let s0, s1, s2, s3, s4;
1103
+
1104
+ s0 = peg$currPos;
1105
+ s1 = peg$currPos;
1106
+ s2 = input.charAt(peg$currPos);
1107
+ if (peg$r5.test(s2)) {
1108
+ peg$currPos++;
1109
+ } else {
1110
+ s2 = peg$FAILED;
1111
+ if (peg$silentFails === 0) { peg$fail(peg$e13); }
1112
+ }
1113
+ if (s2 !== peg$FAILED) {
1114
+ s3 = [];
1115
+ s4 = input.charAt(peg$currPos);
1116
+ if (peg$r6.test(s4)) {
1117
+ peg$currPos++;
1118
+ } else {
1119
+ s4 = peg$FAILED;
1120
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1121
+ }
1122
+ while (s4 !== peg$FAILED) {
1123
+ s3.push(s4);
1124
+ s4 = input.charAt(peg$currPos);
1125
+ if (peg$r6.test(s4)) {
1126
+ peg$currPos++;
1127
+ } else {
1128
+ s4 = peg$FAILED;
1129
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1130
+ }
1131
+ }
1132
+ s2 = [s2, s3];
1133
+ s1 = s2;
1134
+ } else {
1135
+ peg$currPos = s1;
1136
+ s1 = peg$FAILED;
1137
+ }
1138
+ if (s1 !== peg$FAILED) {
1139
+ s0 = input.substring(s0, peg$currPos);
1140
+ } else {
1141
+ s0 = s1;
1142
+ }
1143
+
1144
+ return s0;
1145
+ }
1146
+
1147
+ function peg$parseLabel() {
1148
+ let s0, s1, s2, s3, s4, s5, s6;
1149
+
1150
+ s0 = peg$currPos;
1151
+ s1 = peg$parse_();
1152
+ if (s1 === peg$FAILED) {
1153
+ s1 = null;
1154
+ }
1155
+ if (input.charCodeAt(peg$currPos) === 58) {
1156
+ s2 = peg$c7;
1157
+ peg$currPos++;
1158
+ } else {
1159
+ s2 = peg$FAILED;
1160
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
1161
+ }
1162
+ if (s2 !== peg$FAILED) {
1163
+ s3 = peg$parse_();
1164
+ if (s3 === peg$FAILED) {
1165
+ s3 = null;
1166
+ }
1167
+ s4 = peg$currPos;
1168
+ s5 = [];
1169
+ if (input.length > peg$currPos) {
1170
+ s6 = input.charAt(peg$currPos);
1171
+ peg$currPos++;
1172
+ } else {
1173
+ s6 = peg$FAILED;
1174
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1175
+ }
1176
+ if (s6 !== peg$FAILED) {
1177
+ while (s6 !== peg$FAILED) {
1178
+ s5.push(s6);
1179
+ if (input.length > peg$currPos) {
1180
+ s6 = input.charAt(peg$currPos);
1181
+ peg$currPos++;
1182
+ } else {
1183
+ s6 = peg$FAILED;
1184
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1185
+ }
1186
+ }
1187
+ } else {
1188
+ s5 = peg$FAILED;
1189
+ }
1190
+ if (s5 !== peg$FAILED) {
1191
+ s4 = input.substring(s4, peg$currPos);
1192
+ } else {
1193
+ s4 = s5;
1194
+ }
1195
+ if (s4 !== peg$FAILED) {
1196
+ peg$savedPos = s0;
1197
+ s0 = peg$f12(s4);
1198
+ } else {
1199
+ peg$currPos = s0;
1200
+ s0 = peg$FAILED;
1201
+ }
1202
+ } else {
1203
+ peg$currPos = s0;
1204
+ s0 = peg$FAILED;
1205
+ }
1206
+
1207
+ return s0;
1208
+ }
1209
+
1210
+ function peg$parse_() {
1211
+ let s0, s1;
1212
+
1213
+ s0 = [];
1214
+ s1 = input.charAt(peg$currPos);
1215
+ if (peg$r2.test(s1)) {
1216
+ peg$currPos++;
1217
+ } else {
1218
+ s1 = peg$FAILED;
1219
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1220
+ }
1221
+ if (s1 !== peg$FAILED) {
1222
+ while (s1 !== peg$FAILED) {
1223
+ s0.push(s1);
1224
+ s1 = input.charAt(peg$currPos);
1225
+ if (peg$r2.test(s1)) {
1226
+ peg$currPos++;
1227
+ } else {
1228
+ s1 = peg$FAILED;
1229
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1230
+ }
1231
+ }
1232
+ } else {
1233
+ s0 = peg$FAILED;
1234
+ }
1235
+
1236
+ return s0;
1237
+ }
1238
+
1239
+ function peg$parseInline() {
1240
+ let s0, s1, s2;
1241
+
1242
+ s0 = peg$currPos;
1243
+ s1 = [];
1244
+ s2 = peg$parseInlineItem();
1245
+ while (s2 !== peg$FAILED) {
1246
+ s1.push(s2);
1247
+ s2 = peg$parseInlineItem();
1248
+ }
1249
+ peg$savedPos = s0;
1250
+ s1 = peg$f13(s1);
1251
+ s0 = s1;
1252
+
1253
+ return s0;
1254
+ }
1255
+
1256
+ function peg$parseInlineItem() {
1257
+ let s0, s1;
1258
+
1259
+ s0 = peg$parseCodeSpan();
1260
+ if (s0 === peg$FAILED) {
1261
+ s0 = peg$parseImage();
1262
+ if (s0 === peg$FAILED) {
1263
+ s0 = peg$parseLink();
1264
+ if (s0 === peg$FAILED) {
1265
+ s0 = peg$parseAutolink();
1266
+ if (s0 === peg$FAILED) {
1267
+ s0 = peg$parseEscaped();
1268
+ if (s0 === peg$FAILED) {
1269
+ s0 = peg$currPos;
1270
+ if (input.length > peg$currPos) {
1271
+ s1 = input.charAt(peg$currPos);
1272
+ peg$currPos++;
1273
+ } else {
1274
+ s1 = peg$FAILED;
1275
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1276
+ }
1277
+ if (s1 !== peg$FAILED) {
1278
+ peg$savedPos = s0;
1279
+ s1 = peg$f14();
1280
+ }
1281
+ s0 = s1;
1282
+ }
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+
1288
+ return s0;
1289
+ }
1290
+
1291
+ function peg$parseCodeSpan() {
1292
+ let s0, s1, s2, s3;
1293
+
1294
+ s0 = peg$currPos;
1295
+ if (input.charCodeAt(peg$currPos) === 96) {
1296
+ s1 = peg$c8;
1297
+ peg$currPos++;
1298
+ } else {
1299
+ s1 = peg$FAILED;
1300
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1301
+ }
1302
+ if (s1 !== peg$FAILED) {
1303
+ s2 = [];
1304
+ s3 = input.charAt(peg$currPos);
1305
+ if (peg$r7.test(s3)) {
1306
+ peg$currPos++;
1307
+ } else {
1308
+ s3 = peg$FAILED;
1309
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
1310
+ }
1311
+ while (s3 !== peg$FAILED) {
1312
+ s2.push(s3);
1313
+ s3 = input.charAt(peg$currPos);
1314
+ if (peg$r7.test(s3)) {
1315
+ peg$currPos++;
1316
+ } else {
1317
+ s3 = peg$FAILED;
1318
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
1319
+ }
1320
+ }
1321
+ if (input.charCodeAt(peg$currPos) === 96) {
1322
+ s3 = peg$c8;
1323
+ peg$currPos++;
1324
+ } else {
1325
+ s3 = peg$FAILED;
1326
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1327
+ }
1328
+ if (s3 !== peg$FAILED) {
1329
+ peg$savedPos = s0;
1330
+ s0 = peg$f15();
1331
+ } else {
1332
+ peg$currPos = s0;
1333
+ s0 = peg$FAILED;
1334
+ }
1335
+ } else {
1336
+ peg$currPos = s0;
1337
+ s0 = peg$FAILED;
1338
+ }
1339
+
1340
+ return s0;
1341
+ }
1342
+
1343
+ function peg$parseImage() {
1344
+ let s0, s1, s2;
1345
+
1346
+ s0 = peg$currPos;
1347
+ if (input.charCodeAt(peg$currPos) === 33) {
1348
+ s1 = peg$c9;
1349
+ peg$currPos++;
1350
+ } else {
1351
+ s1 = peg$FAILED;
1352
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
1353
+ }
1354
+ if (s1 !== peg$FAILED) {
1355
+ s2 = peg$parseLinkBody();
1356
+ if (s2 !== peg$FAILED) {
1357
+ peg$savedPos = s0;
1358
+ s0 = peg$f16();
1359
+ } else {
1360
+ peg$currPos = s0;
1361
+ s0 = peg$FAILED;
1362
+ }
1363
+ } else {
1364
+ peg$currPos = s0;
1365
+ s0 = peg$FAILED;
1366
+ }
1367
+
1368
+ return s0;
1369
+ }
1370
+
1371
+ function peg$parseLink() {
1372
+ let s0, s1;
1373
+
1374
+ s0 = peg$currPos;
1375
+ s1 = peg$parseLinkBody();
1376
+ if (s1 !== peg$FAILED) {
1377
+ peg$savedPos = s0;
1378
+ s1 = peg$f17(s1);
1379
+ }
1380
+ s0 = s1;
1381
+
1382
+ return s0;
1383
+ }
1384
+
1385
+ function peg$parseLinkBody() {
1386
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
1387
+
1388
+ s0 = peg$currPos;
1389
+ if (input.charCodeAt(peg$currPos) === 91) {
1390
+ s1 = peg$c1;
1391
+ peg$currPos++;
1392
+ } else {
1393
+ s1 = peg$FAILED;
1394
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
1395
+ }
1396
+ if (s1 !== peg$FAILED) {
1397
+ s2 = peg$currPos;
1398
+ s3 = peg$parseLinkText();
1399
+ s2 = input.substring(s2, peg$currPos);
1400
+ if (input.charCodeAt(peg$currPos) === 93) {
1401
+ s3 = peg$c2;
1402
+ peg$currPos++;
1403
+ } else {
1404
+ s3 = peg$FAILED;
1405
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
1406
+ }
1407
+ if (s3 !== peg$FAILED) {
1408
+ if (input.charCodeAt(peg$currPos) === 40) {
1409
+ s4 = peg$c10;
1410
+ peg$currPos++;
1411
+ } else {
1412
+ s4 = peg$FAILED;
1413
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
1414
+ }
1415
+ if (s4 !== peg$FAILED) {
1416
+ s5 = peg$parse_();
1417
+ if (s5 === peg$FAILED) {
1418
+ s5 = null;
1419
+ }
1420
+ s6 = peg$parseTarget();
1421
+ if (s6 !== peg$FAILED) {
1422
+ s7 = peg$currPos;
1423
+ s8 = peg$parse_();
1424
+ if (s8 !== peg$FAILED) {
1425
+ s9 = peg$parseLinkTitle();
1426
+ if (s9 !== peg$FAILED) {
1427
+ s8 = [s8, s9];
1428
+ s7 = s8;
1429
+ } else {
1430
+ peg$currPos = s7;
1431
+ s7 = peg$FAILED;
1432
+ }
1433
+ } else {
1434
+ peg$currPos = s7;
1435
+ s7 = peg$FAILED;
1436
+ }
1437
+ if (s7 === peg$FAILED) {
1438
+ s7 = null;
1439
+ }
1440
+ s8 = peg$parse_();
1441
+ if (s8 === peg$FAILED) {
1442
+ s8 = null;
1443
+ }
1444
+ if (input.charCodeAt(peg$currPos) === 41) {
1445
+ s9 = peg$c11;
1446
+ peg$currPos++;
1447
+ } else {
1448
+ s9 = peg$FAILED;
1449
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
1450
+ }
1451
+ if (s9 !== peg$FAILED) {
1452
+ peg$savedPos = s0;
1453
+ s0 = peg$f18(s2, s6);
1454
+ } else {
1455
+ peg$currPos = s0;
1456
+ s0 = peg$FAILED;
1457
+ }
1458
+ } else {
1459
+ peg$currPos = s0;
1460
+ s0 = peg$FAILED;
1461
+ }
1462
+ } else {
1463
+ peg$currPos = s0;
1464
+ s0 = peg$FAILED;
1465
+ }
1466
+ } else {
1467
+ peg$currPos = s0;
1468
+ s0 = peg$FAILED;
1469
+ }
1470
+ } else {
1471
+ peg$currPos = s0;
1472
+ s0 = peg$FAILED;
1473
+ }
1474
+
1475
+ return s0;
1476
+ }
1477
+
1478
+ function peg$parseLinkText() {
1479
+ let s0, s1, s2, s3;
1480
+
1481
+ s0 = [];
1482
+ s1 = input.charAt(peg$currPos);
1483
+ if (peg$r8.test(s1)) {
1484
+ peg$currPos++;
1485
+ } else {
1486
+ s1 = peg$FAILED;
1487
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
1488
+ }
1489
+ if (s1 === peg$FAILED) {
1490
+ s1 = peg$currPos;
1491
+ if (input.charCodeAt(peg$currPos) === 92) {
1492
+ s2 = peg$c12;
1493
+ peg$currPos++;
1494
+ } else {
1495
+ s2 = peg$FAILED;
1496
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
1497
+ }
1498
+ if (s2 !== peg$FAILED) {
1499
+ if (input.length > peg$currPos) {
1500
+ s3 = input.charAt(peg$currPos);
1501
+ peg$currPos++;
1502
+ } else {
1503
+ s3 = peg$FAILED;
1504
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1505
+ }
1506
+ if (s3 !== peg$FAILED) {
1507
+ s2 = [s2, s3];
1508
+ s1 = s2;
1509
+ } else {
1510
+ peg$currPos = s1;
1511
+ s1 = peg$FAILED;
1512
+ }
1513
+ } else {
1514
+ peg$currPos = s1;
1515
+ s1 = peg$FAILED;
1516
+ }
1517
+ }
1518
+ while (s1 !== peg$FAILED) {
1519
+ s0.push(s1);
1520
+ s1 = input.charAt(peg$currPos);
1521
+ if (peg$r8.test(s1)) {
1522
+ peg$currPos++;
1523
+ } else {
1524
+ s1 = peg$FAILED;
1525
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
1526
+ }
1527
+ if (s1 === peg$FAILED) {
1528
+ s1 = peg$currPos;
1529
+ if (input.charCodeAt(peg$currPos) === 92) {
1530
+ s2 = peg$c12;
1531
+ peg$currPos++;
1532
+ } else {
1533
+ s2 = peg$FAILED;
1534
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
1535
+ }
1536
+ if (s2 !== peg$FAILED) {
1537
+ if (input.length > peg$currPos) {
1538
+ s3 = input.charAt(peg$currPos);
1539
+ peg$currPos++;
1540
+ } else {
1541
+ s3 = peg$FAILED;
1542
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1543
+ }
1544
+ if (s3 !== peg$FAILED) {
1545
+ s2 = [s2, s3];
1546
+ s1 = s2;
1547
+ } else {
1548
+ peg$currPos = s1;
1549
+ s1 = peg$FAILED;
1550
+ }
1551
+ } else {
1552
+ peg$currPos = s1;
1553
+ s1 = peg$FAILED;
1554
+ }
1555
+ }
1556
+ }
1557
+
1558
+ return s0;
1559
+ }
1560
+
1561
+ function peg$parseTarget() {
1562
+ let s0, s1, s2, s3;
1563
+
1564
+ s0 = peg$currPos;
1565
+ if (input.charCodeAt(peg$currPos) === 60) {
1566
+ s1 = peg$c13;
1567
+ peg$currPos++;
1568
+ } else {
1569
+ s1 = peg$FAILED;
1570
+ if (peg$silentFails === 0) { peg$fail(peg$e23); }
1571
+ }
1572
+ if (s1 !== peg$FAILED) {
1573
+ s2 = [];
1574
+ s3 = peg$parseTargetChar();
1575
+ while (s3 !== peg$FAILED) {
1576
+ s2.push(s3);
1577
+ s3 = peg$parseTargetChar();
1578
+ }
1579
+ if (input.charCodeAt(peg$currPos) === 62) {
1580
+ s3 = peg$c14;
1581
+ peg$currPos++;
1582
+ } else {
1583
+ s3 = peg$FAILED;
1584
+ if (peg$silentFails === 0) { peg$fail(peg$e24); }
1585
+ }
1586
+ if (s3 !== peg$FAILED) {
1587
+ peg$savedPos = s0;
1588
+ s0 = peg$f19(s2);
1589
+ } else {
1590
+ peg$currPos = s0;
1591
+ s0 = peg$FAILED;
1592
+ }
1593
+ } else {
1594
+ peg$currPos = s0;
1595
+ s0 = peg$FAILED;
1596
+ }
1597
+ if (s0 === peg$FAILED) {
1598
+ s0 = peg$currPos;
1599
+ s1 = [];
1600
+ s2 = input.charAt(peg$currPos);
1601
+ if (peg$r9.test(s2)) {
1602
+ peg$currPos++;
1603
+ } else {
1604
+ s2 = peg$FAILED;
1605
+ if (peg$silentFails === 0) { peg$fail(peg$e25); }
1606
+ }
1607
+ if (s2 !== peg$FAILED) {
1608
+ while (s2 !== peg$FAILED) {
1609
+ s1.push(s2);
1610
+ s2 = input.charAt(peg$currPos);
1611
+ if (peg$r9.test(s2)) {
1612
+ peg$currPos++;
1613
+ } else {
1614
+ s2 = peg$FAILED;
1615
+ if (peg$silentFails === 0) { peg$fail(peg$e25); }
1616
+ }
1617
+ }
1618
+ } else {
1619
+ s1 = peg$FAILED;
1620
+ }
1621
+ if (s1 !== peg$FAILED) {
1622
+ s0 = input.substring(s0, peg$currPos);
1623
+ } else {
1624
+ s0 = s1;
1625
+ }
1626
+ }
1627
+
1628
+ return s0;
1629
+ }
1630
+
1631
+ function peg$parseTargetChar() {
1632
+ let s0, s1, s2;
1633
+
1634
+ s0 = peg$currPos;
1635
+ if (input.charCodeAt(peg$currPos) === 92) {
1636
+ s1 = peg$c12;
1637
+ peg$currPos++;
1638
+ } else {
1639
+ s1 = peg$FAILED;
1640
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
1641
+ }
1642
+ if (s1 !== peg$FAILED) {
1643
+ s2 = input.charAt(peg$currPos);
1644
+ if (peg$r10.test(s2)) {
1645
+ peg$currPos++;
1646
+ } else {
1647
+ s2 = peg$FAILED;
1648
+ if (peg$silentFails === 0) { peg$fail(peg$e26); }
1649
+ }
1650
+ if (s2 !== peg$FAILED) {
1651
+ peg$savedPos = s0;
1652
+ s0 = peg$f20(s2);
1653
+ } else {
1654
+ peg$currPos = s0;
1655
+ s0 = peg$FAILED;
1656
+ }
1657
+ } else {
1658
+ peg$currPos = s0;
1659
+ s0 = peg$FAILED;
1660
+ }
1661
+ if (s0 === peg$FAILED) {
1662
+ s0 = input.charAt(peg$currPos);
1663
+ if (peg$r11.test(s0)) {
1664
+ peg$currPos++;
1665
+ } else {
1666
+ s0 = peg$FAILED;
1667
+ if (peg$silentFails === 0) { peg$fail(peg$e27); }
1668
+ }
1669
+ }
1670
+
1671
+ return s0;
1672
+ }
1673
+
1674
+ function peg$parseLinkTitle() {
1675
+ let s0, s1, s2, s3;
1676
+
1677
+ s0 = peg$currPos;
1678
+ if (input.charCodeAt(peg$currPos) === 34) {
1679
+ s1 = peg$c15;
1680
+ peg$currPos++;
1681
+ } else {
1682
+ s1 = peg$FAILED;
1683
+ if (peg$silentFails === 0) { peg$fail(peg$e28); }
1684
+ }
1685
+ if (s1 !== peg$FAILED) {
1686
+ s2 = [];
1687
+ s3 = input.charAt(peg$currPos);
1688
+ if (peg$r12.test(s3)) {
1689
+ peg$currPos++;
1690
+ } else {
1691
+ s3 = peg$FAILED;
1692
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1693
+ }
1694
+ while (s3 !== peg$FAILED) {
1695
+ s2.push(s3);
1696
+ s3 = input.charAt(peg$currPos);
1697
+ if (peg$r12.test(s3)) {
1698
+ peg$currPos++;
1699
+ } else {
1700
+ s3 = peg$FAILED;
1701
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1702
+ }
1703
+ }
1704
+ if (input.charCodeAt(peg$currPos) === 34) {
1705
+ s3 = peg$c15;
1706
+ peg$currPos++;
1707
+ } else {
1708
+ s3 = peg$FAILED;
1709
+ if (peg$silentFails === 0) { peg$fail(peg$e28); }
1710
+ }
1711
+ if (s3 !== peg$FAILED) {
1712
+ s1 = [s1, s2, s3];
1713
+ s0 = s1;
1714
+ } else {
1715
+ peg$currPos = s0;
1716
+ s0 = peg$FAILED;
1717
+ }
1718
+ } else {
1719
+ peg$currPos = s0;
1720
+ s0 = peg$FAILED;
1721
+ }
1722
+
1723
+ return s0;
1724
+ }
1725
+
1726
+ function peg$parseAutolink() {
1727
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8;
1728
+
1729
+ s0 = peg$currPos;
1730
+ if (input.charCodeAt(peg$currPos) === 60) {
1731
+ s1 = peg$c13;
1732
+ peg$currPos++;
1733
+ } else {
1734
+ s1 = peg$FAILED;
1735
+ if (peg$silentFails === 0) { peg$fail(peg$e23); }
1736
+ }
1737
+ if (s1 !== peg$FAILED) {
1738
+ s2 = peg$currPos;
1739
+ s3 = peg$currPos;
1740
+ s4 = input.charAt(peg$currPos);
1741
+ if (peg$r13.test(s4)) {
1742
+ peg$currPos++;
1743
+ } else {
1744
+ s4 = peg$FAILED;
1745
+ if (peg$silentFails === 0) { peg$fail(peg$e30); }
1746
+ }
1747
+ if (s4 !== peg$FAILED) {
1748
+ s5 = [];
1749
+ s6 = input.charAt(peg$currPos);
1750
+ if (peg$r14.test(s6)) {
1751
+ peg$currPos++;
1752
+ } else {
1753
+ s6 = peg$FAILED;
1754
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
1755
+ }
1756
+ while (s6 !== peg$FAILED) {
1757
+ s5.push(s6);
1758
+ s6 = input.charAt(peg$currPos);
1759
+ if (peg$r14.test(s6)) {
1760
+ peg$currPos++;
1761
+ } else {
1762
+ s6 = peg$FAILED;
1763
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
1764
+ }
1765
+ }
1766
+ if (input.charCodeAt(peg$currPos) === 58) {
1767
+ s6 = peg$c7;
1768
+ peg$currPos++;
1769
+ } else {
1770
+ s6 = peg$FAILED;
1771
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
1772
+ }
1773
+ if (s6 !== peg$FAILED) {
1774
+ s7 = [];
1775
+ s8 = input.charAt(peg$currPos);
1776
+ if (peg$r15.test(s8)) {
1777
+ peg$currPos++;
1778
+ } else {
1779
+ s8 = peg$FAILED;
1780
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
1781
+ }
1782
+ if (s8 !== peg$FAILED) {
1783
+ while (s8 !== peg$FAILED) {
1784
+ s7.push(s8);
1785
+ s8 = input.charAt(peg$currPos);
1786
+ if (peg$r15.test(s8)) {
1787
+ peg$currPos++;
1788
+ } else {
1789
+ s8 = peg$FAILED;
1790
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
1791
+ }
1792
+ }
1793
+ } else {
1794
+ s7 = peg$FAILED;
1795
+ }
1796
+ if (s7 !== peg$FAILED) {
1797
+ s4 = [s4, s5, s6, s7];
1798
+ s3 = s4;
1799
+ } else {
1800
+ peg$currPos = s3;
1801
+ s3 = peg$FAILED;
1802
+ }
1803
+ } else {
1804
+ peg$currPos = s3;
1805
+ s3 = peg$FAILED;
1806
+ }
1807
+ } else {
1808
+ peg$currPos = s3;
1809
+ s3 = peg$FAILED;
1810
+ }
1811
+ if (s3 !== peg$FAILED) {
1812
+ s2 = input.substring(s2, peg$currPos);
1813
+ } else {
1814
+ s2 = s3;
1815
+ }
1816
+ if (s2 !== peg$FAILED) {
1817
+ if (input.charCodeAt(peg$currPos) === 62) {
1818
+ s3 = peg$c14;
1819
+ peg$currPos++;
1820
+ } else {
1821
+ s3 = peg$FAILED;
1822
+ if (peg$silentFails === 0) { peg$fail(peg$e24); }
1823
+ }
1824
+ if (s3 !== peg$FAILED) {
1825
+ peg$savedPos = s0;
1826
+ s0 = peg$f21(s2);
1827
+ } else {
1828
+ peg$currPos = s0;
1829
+ s0 = peg$FAILED;
1830
+ }
1831
+ } else {
1832
+ peg$currPos = s0;
1833
+ s0 = peg$FAILED;
1834
+ }
1835
+ } else {
1836
+ peg$currPos = s0;
1837
+ s0 = peg$FAILED;
1838
+ }
1839
+
1840
+ return s0;
1841
+ }
1842
+
1843
+ function peg$parseEscaped() {
1844
+ let s0, s1, s2;
1845
+
1846
+ s0 = peg$currPos;
1847
+ if (input.charCodeAt(peg$currPos) === 92) {
1848
+ s1 = peg$c12;
1849
+ peg$currPos++;
1850
+ } else {
1851
+ s1 = peg$FAILED;
1852
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
1853
+ }
1854
+ if (s1 !== peg$FAILED) {
1855
+ if (input.length > peg$currPos) {
1856
+ s2 = input.charAt(peg$currPos);
1857
+ peg$currPos++;
1858
+ } else {
1859
+ s2 = peg$FAILED;
1860
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1861
+ }
1862
+ if (s2 !== peg$FAILED) {
1863
+ peg$savedPos = s0;
1864
+ s0 = peg$f22();
1865
+ } else {
1866
+ peg$currPos = s0;
1867
+ s0 = peg$FAILED;
1868
+ }
1869
+ } else {
1870
+ peg$currPos = s0;
1871
+ s0 = peg$FAILED;
1872
+ }
1873
+
1874
+ return s0;
1875
+ }
1876
+
1877
+ peg$result = peg$startRuleFunction();
1878
+
1879
+ const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
1880
+ function peg$throw() {
1881
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1882
+ peg$fail(peg$endExpectation());
1883
+ }
1884
+
1885
+ throw peg$buildStructuredError(
1886
+ peg$maxFailExpected,
1887
+ peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null,
1888
+ peg$maxFailPos < input.length
1889
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1890
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1891
+ );
1892
+ }
1893
+ if (options.peg$library) {
1894
+ return /** @type {any} */ ({
1895
+ peg$result,
1896
+ peg$currPos,
1897
+ peg$FAILED,
1898
+ peg$maxFailExpected,
1899
+ peg$maxFailPos,
1900
+ peg$success,
1901
+ peg$throw: peg$success ? undefined : peg$throw,
1902
+ });
1903
+ }
1904
+ if (peg$success) {
1905
+ return peg$result;
1906
+ } else {
1907
+ peg$throw();
1908
+ }
1909
+ }
1910
+
1911
+ const peg$allowedStartRules = [
1912
+ "Line",
1913
+ "Inline"
1914
+ ];
1915
+
1916
+ export {
1917
+ peg$allowedStartRules as StartRules,
1918
+ peg$SyntaxError as SyntaxError,
1919
+ peg$parse as parse
1920
+ };