links-notation 0.12.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +28 -0
- package/.prettierignore +4 -0
- package/.prettierrc +4 -0
- package/README.md +107 -7
- package/README.ru.md +3 -6
- package/bun.lock +189 -10
- package/dist/index.js +628 -263
- package/eslint.config.js +34 -0
- package/examples/empty_reference.js +43 -0
- package/examples/typescript-example.ts +95 -0
- package/index.d.ts +312 -0
- package/package.json +22 -7
- package/src/FormatOptions.js +1 -1
- package/src/Link.js +78 -34
- package/src/LinksGroup.js +2 -2
- package/src/Parser.js +51 -18
- package/src/grammar.pegjs +190 -15
- package/src/index.js +1 -1
- package/src/parser-generated.js +618 -231
- package/tests/ApiTests.test.js +2 -2
- package/tests/EdgeCaseParser.test.js +3 -3
- package/tests/EmptyReference.test.js +91 -0
- package/tests/FormatConfig.test.js +32 -10
- package/tests/IndentedIdSyntax.test.js +39 -39
- package/tests/Link.test.js +4 -4
- package/tests/LinksGroup.test.js +8 -5
- package/tests/MixedIndentationModes.test.js +35 -35
- package/tests/MultiQuoteParser.test.js +463 -0
- package/tests/MultilineParser.test.js +12 -12
- package/tests/MultilineQuotedString.test.js +13 -11
- package/tests/NestedIndentation.test.js +114 -0
- package/tests/NestedParser.test.js +5 -3
- package/tests/NestedSelfReference.test.js +4 -2
- package/tests/SingleLineParser.test.js +9 -9
- package/tsconfig.json +15 -0
package/dist/index.js
CHANGED
|
@@ -36,9 +36,12 @@ class Link {
|
|
|
36
36
|
return value && typeof value.toLinkOrIdString === "function" ? value.toLinkOrIdString() : String(value);
|
|
37
37
|
}
|
|
38
38
|
static escapeReference(reference) {
|
|
39
|
-
if (
|
|
39
|
+
if (reference === null || reference === undefined) {
|
|
40
40
|
return "";
|
|
41
41
|
}
|
|
42
|
+
if (reference === "") {
|
|
43
|
+
return '""';
|
|
44
|
+
}
|
|
42
45
|
const hasSingleQuote = reference.includes("'");
|
|
43
46
|
const hasDoubleQuote = reference.includes('"');
|
|
44
47
|
const needsQuoting = reference.includes(":") || reference.includes("(") || reference.includes(")") || reference.includes(" ") || reference.includes("\t") || reference.includes(`
|
|
@@ -378,46 +381,40 @@ function peg$parse(input, options) {
|
|
|
378
381
|
document: peg$parsedocument
|
|
379
382
|
};
|
|
380
383
|
let peg$startRuleFunction = peg$parsedocument;
|
|
381
|
-
const peg$c0 = "
|
|
382
|
-
const peg$c1 = "
|
|
383
|
-
const peg$c2 = "
|
|
384
|
+
const peg$c0 = "(";
|
|
385
|
+
const peg$c1 = ")";
|
|
386
|
+
const peg$c2 = ":";
|
|
384
387
|
const peg$c3 = '"';
|
|
385
388
|
const peg$c4 = "'";
|
|
386
|
-
const peg$c5 = "
|
|
389
|
+
const peg$c5 = "`";
|
|
390
|
+
const peg$c6 = " ";
|
|
387
391
|
const peg$r0 = /^[ \t]/;
|
|
388
392
|
const peg$r1 = /^[\r\n]/;
|
|
389
|
-
const peg$r2 = /^[
|
|
390
|
-
const peg$r3 = /^[^
|
|
391
|
-
const peg$r4 = /^[ \t\n\r]/;
|
|
392
|
-
const peg$r5 = /^[^ \t\n\r(:)]/;
|
|
393
|
+
const peg$r2 = /^[ \t\n\r]/;
|
|
394
|
+
const peg$r3 = /^[^ \t\n\r(:)]/;
|
|
393
395
|
const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
|
|
394
396
|
const peg$e1 = peg$classExpectation(["\r", `
|
|
395
397
|
`], false, false, false);
|
|
396
|
-
const peg$e2 = peg$literalExpectation("
|
|
397
|
-
const peg$e3 = peg$literalExpectation("
|
|
398
|
-
const peg$e4 = peg$literalExpectation("
|
|
398
|
+
const peg$e2 = peg$literalExpectation("(", false);
|
|
399
|
+
const peg$e3 = peg$literalExpectation(")", false);
|
|
400
|
+
const peg$e4 = peg$literalExpectation(":", false);
|
|
399
401
|
const peg$e5 = peg$literalExpectation('"', false);
|
|
400
|
-
const peg$e6 = peg$
|
|
402
|
+
const peg$e6 = peg$anyExpectation();
|
|
401
403
|
const peg$e7 = peg$literalExpectation("'", false);
|
|
402
|
-
const peg$e8 = peg$
|
|
404
|
+
const peg$e8 = peg$literalExpectation("`", false);
|
|
403
405
|
const peg$e9 = peg$literalExpectation(" ", false);
|
|
404
|
-
const peg$e10 = peg$
|
|
405
|
-
const peg$e11 = peg$classExpectation([" ", "\t", `
|
|
406
|
+
const peg$e10 = peg$classExpectation([" ", "\t", `
|
|
406
407
|
`, "\r"], false, false, false);
|
|
407
|
-
const peg$
|
|
408
|
+
const peg$e11 = peg$classExpectation([" ", "\t", `
|
|
408
409
|
`, "\r", "(", ":", ")"], true, false, false);
|
|
409
410
|
function peg$f0() {
|
|
410
|
-
|
|
411
|
-
baseIndentation = null;
|
|
412
|
-
return true;
|
|
411
|
+
return resetState();
|
|
413
412
|
}
|
|
414
413
|
function peg$f1(links) {
|
|
415
414
|
return links;
|
|
416
415
|
}
|
|
417
416
|
function peg$f2() {
|
|
418
|
-
|
|
419
|
-
baseIndentation = null;
|
|
420
|
-
return true;
|
|
417
|
+
return resetState();
|
|
421
418
|
}
|
|
422
419
|
function peg$f3() {
|
|
423
420
|
return [];
|
|
@@ -433,7 +430,7 @@ function peg$parse(input, options) {
|
|
|
433
430
|
return l;
|
|
434
431
|
}
|
|
435
432
|
function peg$f7(e, l) {
|
|
436
|
-
return {
|
|
433
|
+
return Object.assign({}, e, { children: l });
|
|
437
434
|
}
|
|
438
435
|
function peg$f8(e) {
|
|
439
436
|
return e;
|
|
@@ -459,27 +456,28 @@ function peg$parse(input, options) {
|
|
|
459
456
|
function peg$f15(vl) {
|
|
460
457
|
return vl;
|
|
461
458
|
}
|
|
462
|
-
function peg$f16(
|
|
463
|
-
|
|
459
|
+
function peg$f16(body) {
|
|
460
|
+
exitNestedContext();
|
|
461
|
+
return body;
|
|
464
462
|
}
|
|
465
|
-
function peg$f17(
|
|
466
|
-
return
|
|
463
|
+
function peg$f17(l) {
|
|
464
|
+
return { nested: l };
|
|
465
|
+
}
|
|
466
|
+
function peg$f18() {
|
|
467
|
+
return { nested: [] };
|
|
467
468
|
}
|
|
468
|
-
function peg$
|
|
469
|
+
function peg$f19() {
|
|
470
|
+
return enterNestedContext();
|
|
471
|
+
}
|
|
472
|
+
function peg$f20(value) {
|
|
469
473
|
return value;
|
|
470
474
|
}
|
|
471
|
-
function peg$
|
|
475
|
+
function peg$f21(list) {
|
|
472
476
|
return list;
|
|
473
477
|
}
|
|
474
|
-
function peg$
|
|
475
|
-
return { id, values: v };
|
|
476
|
-
}
|
|
477
|
-
function peg$f21(id, v) {
|
|
478
|
+
function peg$f22(id, v) {
|
|
478
479
|
return { id, values: v };
|
|
479
480
|
}
|
|
480
|
-
function peg$f22(v) {
|
|
481
|
-
return { values: v };
|
|
482
|
-
}
|
|
483
481
|
function peg$f23(v) {
|
|
484
482
|
return { values: v };
|
|
485
483
|
}
|
|
@@ -489,24 +487,87 @@ function peg$parse(input, options) {
|
|
|
489
487
|
function peg$f25(chars) {
|
|
490
488
|
return chars.join("");
|
|
491
489
|
}
|
|
492
|
-
function peg$f26(
|
|
493
|
-
|
|
490
|
+
function peg$f26() {
|
|
491
|
+
const pos = offset();
|
|
492
|
+
const result = parseQuotedStringAt(input, pos, '"');
|
|
493
|
+
if (result) {
|
|
494
|
+
parsedValue = result.value;
|
|
495
|
+
parsedLength = result.length;
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
function peg$f27(chars) {
|
|
501
|
+
return parsedValue;
|
|
502
|
+
}
|
|
503
|
+
function peg$f28(c, cs) {
|
|
504
|
+
return [c].concat(cs).join("");
|
|
505
|
+
}
|
|
506
|
+
function peg$f29() {
|
|
507
|
+
return parsedLength > 1 && (parsedLength--, true);
|
|
508
|
+
}
|
|
509
|
+
function peg$f30(c) {
|
|
510
|
+
return c;
|
|
511
|
+
}
|
|
512
|
+
function peg$f31() {
|
|
513
|
+
const pos = offset();
|
|
514
|
+
const result = parseQuotedStringAt(input, pos, "'");
|
|
515
|
+
if (result) {
|
|
516
|
+
parsedValue = result.value;
|
|
517
|
+
parsedLength = result.length;
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
function peg$f32(chars) {
|
|
523
|
+
return parsedValue;
|
|
524
|
+
}
|
|
525
|
+
function peg$f33(c, cs) {
|
|
526
|
+
return [c].concat(cs).join("");
|
|
527
|
+
}
|
|
528
|
+
function peg$f34() {
|
|
529
|
+
return parsedLength > 1 && (parsedLength--, true);
|
|
530
|
+
}
|
|
531
|
+
function peg$f35(c) {
|
|
532
|
+
return c;
|
|
533
|
+
}
|
|
534
|
+
function peg$f36() {
|
|
535
|
+
const pos = offset();
|
|
536
|
+
const result = parseQuotedStringAt(input, pos, "`");
|
|
537
|
+
if (result) {
|
|
538
|
+
parsedValue = result.value;
|
|
539
|
+
parsedLength = result.length;
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
function peg$f37(chars) {
|
|
545
|
+
return parsedValue;
|
|
494
546
|
}
|
|
495
|
-
function peg$
|
|
496
|
-
return
|
|
547
|
+
function peg$f38(c, cs) {
|
|
548
|
+
return [c].concat(cs).join("");
|
|
497
549
|
}
|
|
498
|
-
function peg$
|
|
550
|
+
function peg$f39() {
|
|
551
|
+
return parsedLength > 1 && (parsedLength--, true);
|
|
552
|
+
}
|
|
553
|
+
function peg$f40(c) {
|
|
554
|
+
return c;
|
|
555
|
+
}
|
|
556
|
+
function peg$f41(spaces) {
|
|
499
557
|
setBaseIndentation(spaces);
|
|
500
558
|
}
|
|
501
|
-
function peg$
|
|
559
|
+
function peg$f42(spaces) {
|
|
502
560
|
return normalizeIndentation(spaces) > getCurrentIndentation();
|
|
503
561
|
}
|
|
504
|
-
function peg$
|
|
562
|
+
function peg$f43(spaces) {
|
|
505
563
|
pushIndentation(spaces);
|
|
506
564
|
}
|
|
507
|
-
function peg$
|
|
565
|
+
function peg$f44(spaces) {
|
|
508
566
|
return checkIndentation(spaces);
|
|
509
567
|
}
|
|
568
|
+
function peg$f45() {
|
|
569
|
+
return isInsideNestedContext();
|
|
570
|
+
}
|
|
510
571
|
let peg$currPos = options.peg$currPos | 0;
|
|
511
572
|
let peg$savedPos = peg$currPos;
|
|
512
573
|
const peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
@@ -866,7 +927,7 @@ function peg$parse(input, options) {
|
|
|
866
927
|
function peg$parsereferenceOrLink() {
|
|
867
928
|
let s0, s1;
|
|
868
929
|
s0 = peg$currPos;
|
|
869
|
-
s1 = peg$
|
|
930
|
+
s1 = peg$parsenestedGroup();
|
|
870
931
|
if (s1 !== peg$FAILED) {
|
|
871
932
|
peg$savedPos = s0;
|
|
872
933
|
s1 = peg$f9(s1);
|
|
@@ -886,7 +947,7 @@ function peg$parse(input, options) {
|
|
|
886
947
|
function peg$parseanyLink() {
|
|
887
948
|
let s0, s1, s2;
|
|
888
949
|
s0 = peg$currPos;
|
|
889
|
-
s1 = peg$
|
|
950
|
+
s1 = peg$parsenestedGroup();
|
|
890
951
|
if (s1 !== peg$FAILED) {
|
|
891
952
|
s2 = peg$parseeol();
|
|
892
953
|
if (s2 !== peg$FAILED) {
|
|
@@ -920,14 +981,6 @@ function peg$parse(input, options) {
|
|
|
920
981
|
}
|
|
921
982
|
return s0;
|
|
922
983
|
}
|
|
923
|
-
function peg$parsemultiLineAnyLink() {
|
|
924
|
-
let s0;
|
|
925
|
-
s0 = peg$parsemultiLineValueLink();
|
|
926
|
-
if (s0 === peg$FAILED) {
|
|
927
|
-
s0 = peg$parsemultiLineLink();
|
|
928
|
-
}
|
|
929
|
-
return s0;
|
|
930
|
-
}
|
|
931
984
|
function peg$parsesingleLineAnyLink() {
|
|
932
985
|
let s0, s1, s2;
|
|
933
986
|
s0 = peg$currPos;
|
|
@@ -964,32 +1017,97 @@ function peg$parse(input, options) {
|
|
|
964
1017
|
}
|
|
965
1018
|
return s0;
|
|
966
1019
|
}
|
|
967
|
-
function peg$
|
|
968
|
-
let s0, s1, s2;
|
|
1020
|
+
function peg$parsenestedGroup() {
|
|
1021
|
+
let s0, s1, s2, s3;
|
|
969
1022
|
s0 = peg$currPos;
|
|
970
|
-
|
|
1023
|
+
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1024
|
+
s1 = peg$c0;
|
|
1025
|
+
peg$currPos++;
|
|
1026
|
+
} else {
|
|
1027
|
+
s1 = peg$FAILED;
|
|
1028
|
+
if (peg$silentFails === 0) {
|
|
1029
|
+
peg$fail(peg$e2);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
971
1032
|
if (s1 !== peg$FAILED) {
|
|
972
|
-
s2 = peg$
|
|
973
|
-
peg$
|
|
974
|
-
|
|
1033
|
+
s2 = peg$parseENTER_NESTED_CONTEXT();
|
|
1034
|
+
if (s2 !== peg$FAILED) {
|
|
1035
|
+
s3 = peg$parsenestedGroupBody();
|
|
1036
|
+
if (s3 !== peg$FAILED) {
|
|
1037
|
+
peg$savedPos = s0;
|
|
1038
|
+
s0 = peg$f16(s3);
|
|
1039
|
+
} else {
|
|
1040
|
+
peg$currPos = s0;
|
|
1041
|
+
s0 = peg$FAILED;
|
|
1042
|
+
}
|
|
1043
|
+
} else {
|
|
1044
|
+
peg$currPos = s0;
|
|
1045
|
+
s0 = peg$FAILED;
|
|
1046
|
+
}
|
|
975
1047
|
} else {
|
|
976
1048
|
peg$currPos = s0;
|
|
977
1049
|
s0 = peg$FAILED;
|
|
978
1050
|
}
|
|
979
1051
|
return s0;
|
|
980
1052
|
}
|
|
981
|
-
function peg$
|
|
982
|
-
let s0, s1, s2, s3;
|
|
1053
|
+
function peg$parsenestedGroupBody() {
|
|
1054
|
+
let s0, s1, s2, s3, s4;
|
|
983
1055
|
s0 = peg$currPos;
|
|
984
|
-
s1 = peg$
|
|
985
|
-
s2 =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1056
|
+
s1 = peg$parseskipEmptyLines();
|
|
1057
|
+
s2 = peg$parselinks();
|
|
1058
|
+
if (s2 !== peg$FAILED) {
|
|
1059
|
+
s3 = peg$parse_();
|
|
1060
|
+
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1061
|
+
s4 = peg$c1;
|
|
1062
|
+
peg$currPos++;
|
|
1063
|
+
} else {
|
|
1064
|
+
s4 = peg$FAILED;
|
|
1065
|
+
if (peg$silentFails === 0) {
|
|
1066
|
+
peg$fail(peg$e3);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (s4 !== peg$FAILED) {
|
|
1070
|
+
peg$savedPos = s0;
|
|
1071
|
+
s0 = peg$f17(s2);
|
|
1072
|
+
} else {
|
|
1073
|
+
peg$currPos = s0;
|
|
1074
|
+
s0 = peg$FAILED;
|
|
1075
|
+
}
|
|
1076
|
+
} else {
|
|
1077
|
+
peg$currPos = s0;
|
|
1078
|
+
s0 = peg$FAILED;
|
|
1079
|
+
}
|
|
1080
|
+
if (s0 === peg$FAILED) {
|
|
1081
|
+
s0 = peg$currPos;
|
|
1082
|
+
s1 = peg$parse_();
|
|
1083
|
+
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1084
|
+
s2 = peg$c1;
|
|
1085
|
+
peg$currPos++;
|
|
1086
|
+
} else {
|
|
1087
|
+
s2 = peg$FAILED;
|
|
1088
|
+
if (peg$silentFails === 0) {
|
|
1089
|
+
peg$fail(peg$e3);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
if (s2 !== peg$FAILED) {
|
|
1093
|
+
peg$savedPos = s0;
|
|
1094
|
+
s0 = peg$f18();
|
|
1095
|
+
} else {
|
|
1096
|
+
peg$currPos = s0;
|
|
1097
|
+
s0 = peg$FAILED;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return s0;
|
|
1101
|
+
}
|
|
1102
|
+
function peg$parseENTER_NESTED_CONTEXT() {
|
|
1103
|
+
let s0;
|
|
1104
|
+
peg$savedPos = peg$currPos;
|
|
1105
|
+
s0 = peg$f19();
|
|
1106
|
+
if (s0) {
|
|
1107
|
+
s0 = undefined;
|
|
1108
|
+
} else {
|
|
1109
|
+
s0 = peg$FAILED;
|
|
990
1110
|
}
|
|
991
|
-
peg$savedPos = s0;
|
|
992
|
-
s0 = peg$f17(s2);
|
|
993
1111
|
return s0;
|
|
994
1112
|
}
|
|
995
1113
|
function peg$parsesingleLineValueAndWhitespace() {
|
|
@@ -999,7 +1117,7 @@ function peg$parse(input, options) {
|
|
|
999
1117
|
s2 = peg$parsereferenceOrLink();
|
|
1000
1118
|
if (s2 !== peg$FAILED) {
|
|
1001
1119
|
peg$savedPos = s0;
|
|
1002
|
-
s0 = peg$
|
|
1120
|
+
s0 = peg$f20(s2);
|
|
1003
1121
|
} else {
|
|
1004
1122
|
peg$currPos = s0;
|
|
1005
1123
|
s0 = peg$FAILED;
|
|
@@ -1021,7 +1139,7 @@ function peg$parse(input, options) {
|
|
|
1021
1139
|
}
|
|
1022
1140
|
if (s1 !== peg$FAILED) {
|
|
1023
1141
|
peg$savedPos = s0;
|
|
1024
|
-
s1 = peg$
|
|
1142
|
+
s1 = peg$f21(s1);
|
|
1025
1143
|
}
|
|
1026
1144
|
s0 = s1;
|
|
1027
1145
|
return s0;
|
|
@@ -1034,78 +1152,19 @@ function peg$parse(input, options) {
|
|
|
1034
1152
|
if (s2 !== peg$FAILED) {
|
|
1035
1153
|
s3 = peg$parse__();
|
|
1036
1154
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
1037
|
-
s4 = peg$
|
|
1155
|
+
s4 = peg$c2;
|
|
1038
1156
|
peg$currPos++;
|
|
1039
1157
|
} else {
|
|
1040
1158
|
s4 = peg$FAILED;
|
|
1041
1159
|
if (peg$silentFails === 0) {
|
|
1042
|
-
peg$fail(peg$
|
|
1160
|
+
peg$fail(peg$e4);
|
|
1043
1161
|
}
|
|
1044
1162
|
}
|
|
1045
1163
|
if (s4 !== peg$FAILED) {
|
|
1046
1164
|
s5 = peg$parsesingleLineValues();
|
|
1047
1165
|
if (s5 !== peg$FAILED) {
|
|
1048
1166
|
peg$savedPos = s0;
|
|
1049
|
-
s0 = peg$
|
|
1050
|
-
} else {
|
|
1051
|
-
peg$currPos = s0;
|
|
1052
|
-
s0 = peg$FAILED;
|
|
1053
|
-
}
|
|
1054
|
-
} else {
|
|
1055
|
-
peg$currPos = s0;
|
|
1056
|
-
s0 = peg$FAILED;
|
|
1057
|
-
}
|
|
1058
|
-
} else {
|
|
1059
|
-
peg$currPos = s0;
|
|
1060
|
-
s0 = peg$FAILED;
|
|
1061
|
-
}
|
|
1062
|
-
return s0;
|
|
1063
|
-
}
|
|
1064
|
-
function peg$parsemultiLineLink() {
|
|
1065
|
-
let s0, s1, s2, s3, s4, s5, s6, s7, s8;
|
|
1066
|
-
s0 = peg$currPos;
|
|
1067
|
-
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1068
|
-
s1 = peg$c1;
|
|
1069
|
-
peg$currPos++;
|
|
1070
|
-
} else {
|
|
1071
|
-
s1 = peg$FAILED;
|
|
1072
|
-
if (peg$silentFails === 0) {
|
|
1073
|
-
peg$fail(peg$e3);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
if (s1 !== peg$FAILED) {
|
|
1077
|
-
s2 = peg$parse_();
|
|
1078
|
-
s3 = peg$parsereference();
|
|
1079
|
-
if (s3 !== peg$FAILED) {
|
|
1080
|
-
s4 = peg$parse_();
|
|
1081
|
-
if (input.charCodeAt(peg$currPos) === 58) {
|
|
1082
|
-
s5 = peg$c0;
|
|
1083
|
-
peg$currPos++;
|
|
1084
|
-
} else {
|
|
1085
|
-
s5 = peg$FAILED;
|
|
1086
|
-
if (peg$silentFails === 0) {
|
|
1087
|
-
peg$fail(peg$e2);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
if (s5 !== peg$FAILED) {
|
|
1091
|
-
s6 = peg$parsemultiLineValues();
|
|
1092
|
-
s7 = peg$parse_();
|
|
1093
|
-
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1094
|
-
s8 = peg$c2;
|
|
1095
|
-
peg$currPos++;
|
|
1096
|
-
} else {
|
|
1097
|
-
s8 = peg$FAILED;
|
|
1098
|
-
if (peg$silentFails === 0) {
|
|
1099
|
-
peg$fail(peg$e4);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
if (s8 !== peg$FAILED) {
|
|
1103
|
-
peg$savedPos = s0;
|
|
1104
|
-
s0 = peg$f21(s3, s6);
|
|
1105
|
-
} else {
|
|
1106
|
-
peg$currPos = s0;
|
|
1107
|
-
s0 = peg$FAILED;
|
|
1108
|
-
}
|
|
1167
|
+
s0 = peg$f22(s2, s5);
|
|
1109
1168
|
} else {
|
|
1110
1169
|
peg$currPos = s0;
|
|
1111
1170
|
s0 = peg$FAILED;
|
|
@@ -1126,48 +1185,11 @@ function peg$parse(input, options) {
|
|
|
1126
1185
|
s1 = peg$parsesingleLineValues();
|
|
1127
1186
|
if (s1 !== peg$FAILED) {
|
|
1128
1187
|
peg$savedPos = s0;
|
|
1129
|
-
s1 = peg$
|
|
1188
|
+
s1 = peg$f23(s1);
|
|
1130
1189
|
}
|
|
1131
1190
|
s0 = s1;
|
|
1132
1191
|
return s0;
|
|
1133
1192
|
}
|
|
1134
|
-
function peg$parsemultiLineValueLink() {
|
|
1135
|
-
let s0, s1, s2, s3, s4;
|
|
1136
|
-
s0 = peg$currPos;
|
|
1137
|
-
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1138
|
-
s1 = peg$c1;
|
|
1139
|
-
peg$currPos++;
|
|
1140
|
-
} else {
|
|
1141
|
-
s1 = peg$FAILED;
|
|
1142
|
-
if (peg$silentFails === 0) {
|
|
1143
|
-
peg$fail(peg$e3);
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
if (s1 !== peg$FAILED) {
|
|
1147
|
-
s2 = peg$parsemultiLineValues();
|
|
1148
|
-
s3 = peg$parse_();
|
|
1149
|
-
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1150
|
-
s4 = peg$c2;
|
|
1151
|
-
peg$currPos++;
|
|
1152
|
-
} else {
|
|
1153
|
-
s4 = peg$FAILED;
|
|
1154
|
-
if (peg$silentFails === 0) {
|
|
1155
|
-
peg$fail(peg$e4);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
if (s4 !== peg$FAILED) {
|
|
1159
|
-
peg$savedPos = s0;
|
|
1160
|
-
s0 = peg$f23(s2);
|
|
1161
|
-
} else {
|
|
1162
|
-
peg$currPos = s0;
|
|
1163
|
-
s0 = peg$FAILED;
|
|
1164
|
-
}
|
|
1165
|
-
} else {
|
|
1166
|
-
peg$currPos = s0;
|
|
1167
|
-
s0 = peg$FAILED;
|
|
1168
|
-
}
|
|
1169
|
-
return s0;
|
|
1170
|
-
}
|
|
1171
1193
|
function peg$parseindentedIdLink() {
|
|
1172
1194
|
let s0, s1, s2, s3, s4;
|
|
1173
1195
|
s0 = peg$currPos;
|
|
@@ -1175,12 +1197,12 @@ function peg$parse(input, options) {
|
|
|
1175
1197
|
if (s1 !== peg$FAILED) {
|
|
1176
1198
|
s2 = peg$parse__();
|
|
1177
1199
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
1178
|
-
s3 = peg$
|
|
1200
|
+
s3 = peg$c2;
|
|
1179
1201
|
peg$currPos++;
|
|
1180
1202
|
} else {
|
|
1181
1203
|
s3 = peg$FAILED;
|
|
1182
1204
|
if (peg$silentFails === 0) {
|
|
1183
|
-
peg$fail(peg$
|
|
1205
|
+
peg$fail(peg$e4);
|
|
1184
1206
|
}
|
|
1185
1207
|
}
|
|
1186
1208
|
if (s3 !== peg$FAILED) {
|
|
@@ -1204,12 +1226,9 @@ function peg$parse(input, options) {
|
|
|
1204
1226
|
}
|
|
1205
1227
|
function peg$parsereference() {
|
|
1206
1228
|
let s0;
|
|
1207
|
-
s0 = peg$
|
|
1229
|
+
s0 = peg$parsequotedReference();
|
|
1208
1230
|
if (s0 === peg$FAILED) {
|
|
1209
|
-
s0 = peg$
|
|
1210
|
-
if (s0 === peg$FAILED) {
|
|
1211
|
-
s0 = peg$parsesimpleReference();
|
|
1212
|
-
}
|
|
1231
|
+
s0 = peg$parsesimpleReference();
|
|
1213
1232
|
}
|
|
1214
1233
|
return s0;
|
|
1215
1234
|
}
|
|
@@ -1233,58 +1252,159 @@ function peg$parse(input, options) {
|
|
|
1233
1252
|
s0 = s1;
|
|
1234
1253
|
return s0;
|
|
1235
1254
|
}
|
|
1236
|
-
function peg$
|
|
1255
|
+
function peg$parsequotedReference() {
|
|
1256
|
+
let s0;
|
|
1257
|
+
s0 = peg$parsedoubleQuotedUniversal();
|
|
1258
|
+
if (s0 === peg$FAILED) {
|
|
1259
|
+
s0 = peg$parsesingleQuotedUniversal();
|
|
1260
|
+
if (s0 === peg$FAILED) {
|
|
1261
|
+
s0 = peg$parsebacktickQuotedUniversal();
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return s0;
|
|
1265
|
+
}
|
|
1266
|
+
function peg$parsedoubleQuotedUniversal() {
|
|
1237
1267
|
let s0, s1, s2, s3;
|
|
1238
1268
|
s0 = peg$currPos;
|
|
1269
|
+
s1 = peg$currPos;
|
|
1270
|
+
peg$silentFails++;
|
|
1239
1271
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1240
|
-
|
|
1272
|
+
s2 = peg$c3;
|
|
1241
1273
|
peg$currPos++;
|
|
1242
1274
|
} else {
|
|
1243
|
-
|
|
1275
|
+
s2 = peg$FAILED;
|
|
1244
1276
|
if (peg$silentFails === 0) {
|
|
1245
1277
|
peg$fail(peg$e5);
|
|
1246
1278
|
}
|
|
1247
1279
|
}
|
|
1280
|
+
peg$silentFails--;
|
|
1281
|
+
if (s2 !== peg$FAILED) {
|
|
1282
|
+
peg$currPos = s1;
|
|
1283
|
+
s1 = undefined;
|
|
1284
|
+
} else {
|
|
1285
|
+
s1 = peg$FAILED;
|
|
1286
|
+
}
|
|
1287
|
+
if (s1 !== peg$FAILED) {
|
|
1288
|
+
peg$savedPos = peg$currPos;
|
|
1289
|
+
s2 = peg$f26();
|
|
1290
|
+
if (s2) {
|
|
1291
|
+
s2 = undefined;
|
|
1292
|
+
} else {
|
|
1293
|
+
s2 = peg$FAILED;
|
|
1294
|
+
}
|
|
1295
|
+
if (s2 !== peg$FAILED) {
|
|
1296
|
+
s3 = peg$parseconsumeDouble();
|
|
1297
|
+
if (s3 !== peg$FAILED) {
|
|
1298
|
+
peg$savedPos = s0;
|
|
1299
|
+
s0 = peg$f27(s3);
|
|
1300
|
+
} else {
|
|
1301
|
+
peg$currPos = s0;
|
|
1302
|
+
s0 = peg$FAILED;
|
|
1303
|
+
}
|
|
1304
|
+
} else {
|
|
1305
|
+
peg$currPos = s0;
|
|
1306
|
+
s0 = peg$FAILED;
|
|
1307
|
+
}
|
|
1308
|
+
} else {
|
|
1309
|
+
peg$currPos = s0;
|
|
1310
|
+
s0 = peg$FAILED;
|
|
1311
|
+
}
|
|
1312
|
+
return s0;
|
|
1313
|
+
}
|
|
1314
|
+
function peg$parseconsumeDouble() {
|
|
1315
|
+
let s0, s1, s2, s3;
|
|
1316
|
+
s0 = peg$currPos;
|
|
1317
|
+
if (input.length > peg$currPos) {
|
|
1318
|
+
s1 = input.charAt(peg$currPos);
|
|
1319
|
+
peg$currPos++;
|
|
1320
|
+
} else {
|
|
1321
|
+
s1 = peg$FAILED;
|
|
1322
|
+
if (peg$silentFails === 0) {
|
|
1323
|
+
peg$fail(peg$e6);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1248
1326
|
if (s1 !== peg$FAILED) {
|
|
1249
1327
|
s2 = [];
|
|
1250
|
-
s3 =
|
|
1251
|
-
|
|
1328
|
+
s3 = peg$parseconsumeDoubleMore();
|
|
1329
|
+
while (s3 !== peg$FAILED) {
|
|
1330
|
+
s2.push(s3);
|
|
1331
|
+
s3 = peg$parseconsumeDoubleMore();
|
|
1332
|
+
}
|
|
1333
|
+
peg$savedPos = s0;
|
|
1334
|
+
s0 = peg$f28(s1, s2);
|
|
1335
|
+
} else {
|
|
1336
|
+
peg$currPos = s0;
|
|
1337
|
+
s0 = peg$FAILED;
|
|
1338
|
+
}
|
|
1339
|
+
return s0;
|
|
1340
|
+
}
|
|
1341
|
+
function peg$parseconsumeDoubleMore() {
|
|
1342
|
+
let s0, s1, s2;
|
|
1343
|
+
s0 = peg$currPos;
|
|
1344
|
+
peg$savedPos = peg$currPos;
|
|
1345
|
+
s1 = peg$f29();
|
|
1346
|
+
if (s1) {
|
|
1347
|
+
s1 = undefined;
|
|
1348
|
+
} else {
|
|
1349
|
+
s1 = peg$FAILED;
|
|
1350
|
+
}
|
|
1351
|
+
if (s1 !== peg$FAILED) {
|
|
1352
|
+
if (input.length > peg$currPos) {
|
|
1353
|
+
s2 = input.charAt(peg$currPos);
|
|
1252
1354
|
peg$currPos++;
|
|
1253
1355
|
} else {
|
|
1254
|
-
|
|
1356
|
+
s2 = peg$FAILED;
|
|
1255
1357
|
if (peg$silentFails === 0) {
|
|
1256
1358
|
peg$fail(peg$e6);
|
|
1257
1359
|
}
|
|
1258
1360
|
}
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1361
|
+
if (s2 !== peg$FAILED) {
|
|
1362
|
+
peg$savedPos = s0;
|
|
1363
|
+
s0 = peg$f30(s2);
|
|
1364
|
+
} else {
|
|
1365
|
+
peg$currPos = s0;
|
|
1366
|
+
s0 = peg$FAILED;
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
peg$currPos = s0;
|
|
1370
|
+
s0 = peg$FAILED;
|
|
1371
|
+
}
|
|
1372
|
+
return s0;
|
|
1373
|
+
}
|
|
1374
|
+
function peg$parsesingleQuotedUniversal() {
|
|
1375
|
+
let s0, s1, s2, s3;
|
|
1376
|
+
s0 = peg$currPos;
|
|
1377
|
+
s1 = peg$currPos;
|
|
1378
|
+
peg$silentFails++;
|
|
1379
|
+
if (input.charCodeAt(peg$currPos) === 39) {
|
|
1380
|
+
s2 = peg$c4;
|
|
1381
|
+
peg$currPos++;
|
|
1382
|
+
} else {
|
|
1383
|
+
s2 = peg$FAILED;
|
|
1384
|
+
if (peg$silentFails === 0) {
|
|
1385
|
+
peg$fail(peg$e7);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
peg$silentFails--;
|
|
1389
|
+
if (s2 !== peg$FAILED) {
|
|
1390
|
+
peg$currPos = s1;
|
|
1391
|
+
s1 = undefined;
|
|
1392
|
+
} else {
|
|
1393
|
+
s1 = peg$FAILED;
|
|
1394
|
+
}
|
|
1395
|
+
if (s1 !== peg$FAILED) {
|
|
1396
|
+
peg$savedPos = peg$currPos;
|
|
1397
|
+
s2 = peg$f31();
|
|
1398
|
+
if (s2) {
|
|
1399
|
+
s2 = undefined;
|
|
1272
1400
|
} else {
|
|
1273
1401
|
s2 = peg$FAILED;
|
|
1274
1402
|
}
|
|
1275
1403
|
if (s2 !== peg$FAILED) {
|
|
1276
|
-
|
|
1277
|
-
s3 = peg$c3;
|
|
1278
|
-
peg$currPos++;
|
|
1279
|
-
} else {
|
|
1280
|
-
s3 = peg$FAILED;
|
|
1281
|
-
if (peg$silentFails === 0) {
|
|
1282
|
-
peg$fail(peg$e5);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1404
|
+
s3 = peg$parseconsumeSingle();
|
|
1285
1405
|
if (s3 !== peg$FAILED) {
|
|
1286
1406
|
peg$savedPos = s0;
|
|
1287
|
-
s0 = peg$
|
|
1407
|
+
s0 = peg$f32(s3);
|
|
1288
1408
|
} else {
|
|
1289
1409
|
peg$currPos = s0;
|
|
1290
1410
|
s0 = peg$FAILED;
|
|
@@ -1299,58 +1419,100 @@ function peg$parse(input, options) {
|
|
|
1299
1419
|
}
|
|
1300
1420
|
return s0;
|
|
1301
1421
|
}
|
|
1302
|
-
function peg$
|
|
1422
|
+
function peg$parseconsumeSingle() {
|
|
1303
1423
|
let s0, s1, s2, s3;
|
|
1304
1424
|
s0 = peg$currPos;
|
|
1305
|
-
if (input.
|
|
1306
|
-
s1 = peg$
|
|
1425
|
+
if (input.length > peg$currPos) {
|
|
1426
|
+
s1 = input.charAt(peg$currPos);
|
|
1307
1427
|
peg$currPos++;
|
|
1308
1428
|
} else {
|
|
1309
1429
|
s1 = peg$FAILED;
|
|
1310
1430
|
if (peg$silentFails === 0) {
|
|
1311
|
-
peg$fail(peg$
|
|
1431
|
+
peg$fail(peg$e6);
|
|
1312
1432
|
}
|
|
1313
1433
|
}
|
|
1314
1434
|
if (s1 !== peg$FAILED) {
|
|
1315
1435
|
s2 = [];
|
|
1316
|
-
s3 =
|
|
1317
|
-
|
|
1436
|
+
s3 = peg$parseconsumeSingleMore();
|
|
1437
|
+
while (s3 !== peg$FAILED) {
|
|
1438
|
+
s2.push(s3);
|
|
1439
|
+
s3 = peg$parseconsumeSingleMore();
|
|
1440
|
+
}
|
|
1441
|
+
peg$savedPos = s0;
|
|
1442
|
+
s0 = peg$f33(s1, s2);
|
|
1443
|
+
} else {
|
|
1444
|
+
peg$currPos = s0;
|
|
1445
|
+
s0 = peg$FAILED;
|
|
1446
|
+
}
|
|
1447
|
+
return s0;
|
|
1448
|
+
}
|
|
1449
|
+
function peg$parseconsumeSingleMore() {
|
|
1450
|
+
let s0, s1, s2;
|
|
1451
|
+
s0 = peg$currPos;
|
|
1452
|
+
peg$savedPos = peg$currPos;
|
|
1453
|
+
s1 = peg$f34();
|
|
1454
|
+
if (s1) {
|
|
1455
|
+
s1 = undefined;
|
|
1456
|
+
} else {
|
|
1457
|
+
s1 = peg$FAILED;
|
|
1458
|
+
}
|
|
1459
|
+
if (s1 !== peg$FAILED) {
|
|
1460
|
+
if (input.length > peg$currPos) {
|
|
1461
|
+
s2 = input.charAt(peg$currPos);
|
|
1318
1462
|
peg$currPos++;
|
|
1319
1463
|
} else {
|
|
1320
|
-
|
|
1464
|
+
s2 = peg$FAILED;
|
|
1321
1465
|
if (peg$silentFails === 0) {
|
|
1322
|
-
peg$fail(peg$
|
|
1466
|
+
peg$fail(peg$e6);
|
|
1323
1467
|
}
|
|
1324
1468
|
}
|
|
1325
|
-
if (
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1469
|
+
if (s2 !== peg$FAILED) {
|
|
1470
|
+
peg$savedPos = s0;
|
|
1471
|
+
s0 = peg$f35(s2);
|
|
1472
|
+
} else {
|
|
1473
|
+
peg$currPos = s0;
|
|
1474
|
+
s0 = peg$FAILED;
|
|
1475
|
+
}
|
|
1476
|
+
} else {
|
|
1477
|
+
peg$currPos = s0;
|
|
1478
|
+
s0 = peg$FAILED;
|
|
1479
|
+
}
|
|
1480
|
+
return s0;
|
|
1481
|
+
}
|
|
1482
|
+
function peg$parsebacktickQuotedUniversal() {
|
|
1483
|
+
let s0, s1, s2, s3;
|
|
1484
|
+
s0 = peg$currPos;
|
|
1485
|
+
s1 = peg$currPos;
|
|
1486
|
+
peg$silentFails++;
|
|
1487
|
+
if (input.charCodeAt(peg$currPos) === 96) {
|
|
1488
|
+
s2 = peg$c5;
|
|
1489
|
+
peg$currPos++;
|
|
1490
|
+
} else {
|
|
1491
|
+
s2 = peg$FAILED;
|
|
1492
|
+
if (peg$silentFails === 0) {
|
|
1493
|
+
peg$fail(peg$e8);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
peg$silentFails--;
|
|
1497
|
+
if (s2 !== peg$FAILED) {
|
|
1498
|
+
peg$currPos = s1;
|
|
1499
|
+
s1 = undefined;
|
|
1500
|
+
} else {
|
|
1501
|
+
s1 = peg$FAILED;
|
|
1502
|
+
}
|
|
1503
|
+
if (s1 !== peg$FAILED) {
|
|
1504
|
+
peg$savedPos = peg$currPos;
|
|
1505
|
+
s2 = peg$f36();
|
|
1506
|
+
if (s2) {
|
|
1507
|
+
s2 = undefined;
|
|
1338
1508
|
} else {
|
|
1339
1509
|
s2 = peg$FAILED;
|
|
1340
1510
|
}
|
|
1341
1511
|
if (s2 !== peg$FAILED) {
|
|
1342
|
-
|
|
1343
|
-
s3 = peg$c4;
|
|
1344
|
-
peg$currPos++;
|
|
1345
|
-
} else {
|
|
1346
|
-
s3 = peg$FAILED;
|
|
1347
|
-
if (peg$silentFails === 0) {
|
|
1348
|
-
peg$fail(peg$e7);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1512
|
+
s3 = peg$parseconsumeBacktick();
|
|
1351
1513
|
if (s3 !== peg$FAILED) {
|
|
1352
1514
|
peg$savedPos = s0;
|
|
1353
|
-
s0 = peg$
|
|
1515
|
+
s0 = peg$f37(s3);
|
|
1354
1516
|
} else {
|
|
1355
1517
|
peg$currPos = s0;
|
|
1356
1518
|
s0 = peg$FAILED;
|
|
@@ -1365,12 +1527,72 @@ function peg$parse(input, options) {
|
|
|
1365
1527
|
}
|
|
1366
1528
|
return s0;
|
|
1367
1529
|
}
|
|
1530
|
+
function peg$parseconsumeBacktick() {
|
|
1531
|
+
let s0, s1, s2, s3;
|
|
1532
|
+
s0 = peg$currPos;
|
|
1533
|
+
if (input.length > peg$currPos) {
|
|
1534
|
+
s1 = input.charAt(peg$currPos);
|
|
1535
|
+
peg$currPos++;
|
|
1536
|
+
} else {
|
|
1537
|
+
s1 = peg$FAILED;
|
|
1538
|
+
if (peg$silentFails === 0) {
|
|
1539
|
+
peg$fail(peg$e6);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
if (s1 !== peg$FAILED) {
|
|
1543
|
+
s2 = [];
|
|
1544
|
+
s3 = peg$parseconsumeBacktickMore();
|
|
1545
|
+
while (s3 !== peg$FAILED) {
|
|
1546
|
+
s2.push(s3);
|
|
1547
|
+
s3 = peg$parseconsumeBacktickMore();
|
|
1548
|
+
}
|
|
1549
|
+
peg$savedPos = s0;
|
|
1550
|
+
s0 = peg$f38(s1, s2);
|
|
1551
|
+
} else {
|
|
1552
|
+
peg$currPos = s0;
|
|
1553
|
+
s0 = peg$FAILED;
|
|
1554
|
+
}
|
|
1555
|
+
return s0;
|
|
1556
|
+
}
|
|
1557
|
+
function peg$parseconsumeBacktickMore() {
|
|
1558
|
+
let s0, s1, s2;
|
|
1559
|
+
s0 = peg$currPos;
|
|
1560
|
+
peg$savedPos = peg$currPos;
|
|
1561
|
+
s1 = peg$f39();
|
|
1562
|
+
if (s1) {
|
|
1563
|
+
s1 = undefined;
|
|
1564
|
+
} else {
|
|
1565
|
+
s1 = peg$FAILED;
|
|
1566
|
+
}
|
|
1567
|
+
if (s1 !== peg$FAILED) {
|
|
1568
|
+
if (input.length > peg$currPos) {
|
|
1569
|
+
s2 = input.charAt(peg$currPos);
|
|
1570
|
+
peg$currPos++;
|
|
1571
|
+
} else {
|
|
1572
|
+
s2 = peg$FAILED;
|
|
1573
|
+
if (peg$silentFails === 0) {
|
|
1574
|
+
peg$fail(peg$e6);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (s2 !== peg$FAILED) {
|
|
1578
|
+
peg$savedPos = s0;
|
|
1579
|
+
s0 = peg$f40(s2);
|
|
1580
|
+
} else {
|
|
1581
|
+
peg$currPos = s0;
|
|
1582
|
+
s0 = peg$FAILED;
|
|
1583
|
+
}
|
|
1584
|
+
} else {
|
|
1585
|
+
peg$currPos = s0;
|
|
1586
|
+
s0 = peg$FAILED;
|
|
1587
|
+
}
|
|
1588
|
+
return s0;
|
|
1589
|
+
}
|
|
1368
1590
|
function peg$parseSET_BASE_INDENTATION() {
|
|
1369
1591
|
let s0, s1, s2;
|
|
1370
1592
|
s0 = peg$currPos;
|
|
1371
1593
|
s1 = [];
|
|
1372
1594
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1373
|
-
s2 = peg$
|
|
1595
|
+
s2 = peg$c6;
|
|
1374
1596
|
peg$currPos++;
|
|
1375
1597
|
} else {
|
|
1376
1598
|
s2 = peg$FAILED;
|
|
@@ -1381,7 +1603,7 @@ function peg$parse(input, options) {
|
|
|
1381
1603
|
while (s2 !== peg$FAILED) {
|
|
1382
1604
|
s1.push(s2);
|
|
1383
1605
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1384
|
-
s2 = peg$
|
|
1606
|
+
s2 = peg$c6;
|
|
1385
1607
|
peg$currPos++;
|
|
1386
1608
|
} else {
|
|
1387
1609
|
s2 = peg$FAILED;
|
|
@@ -1391,7 +1613,7 @@ function peg$parse(input, options) {
|
|
|
1391
1613
|
}
|
|
1392
1614
|
}
|
|
1393
1615
|
peg$savedPos = s0;
|
|
1394
|
-
s1 = peg$
|
|
1616
|
+
s1 = peg$f41(s1);
|
|
1395
1617
|
s0 = s1;
|
|
1396
1618
|
return s0;
|
|
1397
1619
|
}
|
|
@@ -1400,7 +1622,7 @@ function peg$parse(input, options) {
|
|
|
1400
1622
|
s0 = peg$currPos;
|
|
1401
1623
|
s1 = [];
|
|
1402
1624
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1403
|
-
s2 = peg$
|
|
1625
|
+
s2 = peg$c6;
|
|
1404
1626
|
peg$currPos++;
|
|
1405
1627
|
} else {
|
|
1406
1628
|
s2 = peg$FAILED;
|
|
@@ -1411,7 +1633,7 @@ function peg$parse(input, options) {
|
|
|
1411
1633
|
while (s2 !== peg$FAILED) {
|
|
1412
1634
|
s1.push(s2);
|
|
1413
1635
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1414
|
-
s2 = peg$
|
|
1636
|
+
s2 = peg$c6;
|
|
1415
1637
|
peg$currPos++;
|
|
1416
1638
|
} else {
|
|
1417
1639
|
s2 = peg$FAILED;
|
|
@@ -1421,7 +1643,7 @@ function peg$parse(input, options) {
|
|
|
1421
1643
|
}
|
|
1422
1644
|
}
|
|
1423
1645
|
peg$savedPos = peg$currPos;
|
|
1424
|
-
s2 = peg$
|
|
1646
|
+
s2 = peg$f42(s1);
|
|
1425
1647
|
if (s2) {
|
|
1426
1648
|
s2 = undefined;
|
|
1427
1649
|
} else {
|
|
@@ -1429,7 +1651,7 @@ function peg$parse(input, options) {
|
|
|
1429
1651
|
}
|
|
1430
1652
|
if (s2 !== peg$FAILED) {
|
|
1431
1653
|
peg$savedPos = s0;
|
|
1432
|
-
s0 = peg$
|
|
1654
|
+
s0 = peg$f43(s1);
|
|
1433
1655
|
} else {
|
|
1434
1656
|
peg$currPos = s0;
|
|
1435
1657
|
s0 = peg$FAILED;
|
|
@@ -1441,7 +1663,7 @@ function peg$parse(input, options) {
|
|
|
1441
1663
|
s0 = peg$currPos;
|
|
1442
1664
|
s1 = [];
|
|
1443
1665
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1444
|
-
s2 = peg$
|
|
1666
|
+
s2 = peg$c6;
|
|
1445
1667
|
peg$currPos++;
|
|
1446
1668
|
} else {
|
|
1447
1669
|
s2 = peg$FAILED;
|
|
@@ -1452,7 +1674,7 @@ function peg$parse(input, options) {
|
|
|
1452
1674
|
while (s2 !== peg$FAILED) {
|
|
1453
1675
|
s1.push(s2);
|
|
1454
1676
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1455
|
-
s2 = peg$
|
|
1677
|
+
s2 = peg$c6;
|
|
1456
1678
|
peg$currPos++;
|
|
1457
1679
|
} else {
|
|
1458
1680
|
s2 = peg$FAILED;
|
|
@@ -1462,7 +1684,7 @@ function peg$parse(input, options) {
|
|
|
1462
1684
|
}
|
|
1463
1685
|
}
|
|
1464
1686
|
peg$savedPos = peg$currPos;
|
|
1465
|
-
s2 = peg$
|
|
1687
|
+
s2 = peg$f44(s1);
|
|
1466
1688
|
if (s2) {
|
|
1467
1689
|
s2 = undefined;
|
|
1468
1690
|
} else {
|
|
@@ -1509,6 +1731,9 @@ function peg$parse(input, options) {
|
|
|
1509
1731
|
}
|
|
1510
1732
|
if (s2 === peg$FAILED) {
|
|
1511
1733
|
s2 = peg$parseeof();
|
|
1734
|
+
if (s2 === peg$FAILED) {
|
|
1735
|
+
s2 = peg$parsenestedGroupEnd();
|
|
1736
|
+
}
|
|
1512
1737
|
}
|
|
1513
1738
|
if (s2 !== peg$FAILED) {
|
|
1514
1739
|
s1 = [s1, s2];
|
|
@@ -1519,6 +1744,48 @@ function peg$parse(input, options) {
|
|
|
1519
1744
|
}
|
|
1520
1745
|
return s0;
|
|
1521
1746
|
}
|
|
1747
|
+
function peg$parsenestedGroupEnd() {
|
|
1748
|
+
let s0, s1, s2, s3;
|
|
1749
|
+
s0 = peg$currPos;
|
|
1750
|
+
peg$savedPos = peg$currPos;
|
|
1751
|
+
s1 = peg$f45();
|
|
1752
|
+
if (s1) {
|
|
1753
|
+
s1 = undefined;
|
|
1754
|
+
} else {
|
|
1755
|
+
s1 = peg$FAILED;
|
|
1756
|
+
}
|
|
1757
|
+
if (s1 !== peg$FAILED) {
|
|
1758
|
+
s2 = peg$currPos;
|
|
1759
|
+
peg$silentFails++;
|
|
1760
|
+
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1761
|
+
s3 = peg$c1;
|
|
1762
|
+
peg$currPos++;
|
|
1763
|
+
} else {
|
|
1764
|
+
s3 = peg$FAILED;
|
|
1765
|
+
if (peg$silentFails === 0) {
|
|
1766
|
+
peg$fail(peg$e3);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
peg$silentFails--;
|
|
1770
|
+
if (s3 !== peg$FAILED) {
|
|
1771
|
+
peg$currPos = s2;
|
|
1772
|
+
s2 = undefined;
|
|
1773
|
+
} else {
|
|
1774
|
+
s2 = peg$FAILED;
|
|
1775
|
+
}
|
|
1776
|
+
if (s2 !== peg$FAILED) {
|
|
1777
|
+
s1 = [s1, s2];
|
|
1778
|
+
s0 = s1;
|
|
1779
|
+
} else {
|
|
1780
|
+
peg$currPos = s0;
|
|
1781
|
+
s0 = peg$FAILED;
|
|
1782
|
+
}
|
|
1783
|
+
} else {
|
|
1784
|
+
peg$currPos = s0;
|
|
1785
|
+
s0 = peg$FAILED;
|
|
1786
|
+
}
|
|
1787
|
+
return s0;
|
|
1788
|
+
}
|
|
1522
1789
|
function peg$parseeof() {
|
|
1523
1790
|
let s0, s1;
|
|
1524
1791
|
s0 = peg$currPos;
|
|
@@ -1529,7 +1796,7 @@ function peg$parse(input, options) {
|
|
|
1529
1796
|
} else {
|
|
1530
1797
|
s1 = peg$FAILED;
|
|
1531
1798
|
if (peg$silentFails === 0) {
|
|
1532
|
-
peg$fail(peg$
|
|
1799
|
+
peg$fail(peg$e6);
|
|
1533
1800
|
}
|
|
1534
1801
|
}
|
|
1535
1802
|
peg$silentFails--;
|
|
@@ -1580,12 +1847,12 @@ function peg$parse(input, options) {
|
|
|
1580
1847
|
function peg$parsewhiteSpaceSymbol() {
|
|
1581
1848
|
let s0;
|
|
1582
1849
|
s0 = input.charAt(peg$currPos);
|
|
1583
|
-
if (peg$
|
|
1850
|
+
if (peg$r2.test(s0)) {
|
|
1584
1851
|
peg$currPos++;
|
|
1585
1852
|
} else {
|
|
1586
1853
|
s0 = peg$FAILED;
|
|
1587
1854
|
if (peg$silentFails === 0) {
|
|
1588
|
-
peg$fail(peg$
|
|
1855
|
+
peg$fail(peg$e10);
|
|
1589
1856
|
}
|
|
1590
1857
|
}
|
|
1591
1858
|
return s0;
|
|
@@ -1593,18 +1860,42 @@ function peg$parse(input, options) {
|
|
|
1593
1860
|
function peg$parsereferenceSymbol() {
|
|
1594
1861
|
let s0;
|
|
1595
1862
|
s0 = input.charAt(peg$currPos);
|
|
1596
|
-
if (peg$
|
|
1863
|
+
if (peg$r3.test(s0)) {
|
|
1597
1864
|
peg$currPos++;
|
|
1598
1865
|
} else {
|
|
1599
1866
|
s0 = peg$FAILED;
|
|
1600
1867
|
if (peg$silentFails === 0) {
|
|
1601
|
-
peg$fail(peg$
|
|
1868
|
+
peg$fail(peg$e11);
|
|
1602
1869
|
}
|
|
1603
1870
|
}
|
|
1604
1871
|
return s0;
|
|
1605
1872
|
}
|
|
1606
1873
|
let indentationStack = [0];
|
|
1607
1874
|
let baseIndentation = null;
|
|
1875
|
+
let contextStack = [];
|
|
1876
|
+
function resetState() {
|
|
1877
|
+
indentationStack = [0];
|
|
1878
|
+
baseIndentation = null;
|
|
1879
|
+
contextStack = [];
|
|
1880
|
+
return true;
|
|
1881
|
+
}
|
|
1882
|
+
function enterNestedContext() {
|
|
1883
|
+
contextStack.push({ indentationStack, baseIndentation });
|
|
1884
|
+
indentationStack = [0];
|
|
1885
|
+
baseIndentation = null;
|
|
1886
|
+
return true;
|
|
1887
|
+
}
|
|
1888
|
+
function exitNestedContext() {
|
|
1889
|
+
const saved = contextStack.pop();
|
|
1890
|
+
if (saved) {
|
|
1891
|
+
indentationStack = saved.indentationStack;
|
|
1892
|
+
baseIndentation = saved.baseIndentation;
|
|
1893
|
+
}
|
|
1894
|
+
return true;
|
|
1895
|
+
}
|
|
1896
|
+
function isInsideNestedContext() {
|
|
1897
|
+
return contextStack.length > 0;
|
|
1898
|
+
}
|
|
1608
1899
|
function setBaseIndentation(spaces) {
|
|
1609
1900
|
if (baseIndentation === null) {
|
|
1610
1901
|
baseIndentation = spaces.length;
|
|
@@ -1632,6 +1923,64 @@ function peg$parse(input, options) {
|
|
|
1632
1923
|
function getCurrentIndentation() {
|
|
1633
1924
|
return indentationStack[indentationStack.length - 1];
|
|
1634
1925
|
}
|
|
1926
|
+
function isSubstantiveBody(content) {
|
|
1927
|
+
let depth = 0;
|
|
1928
|
+
let hasVisible = false;
|
|
1929
|
+
for (const c of content) {
|
|
1930
|
+
if (c === "(") {
|
|
1931
|
+
depth++;
|
|
1932
|
+
} else if (c === ")") {
|
|
1933
|
+
depth--;
|
|
1934
|
+
if (depth < 0) {
|
|
1935
|
+
return false;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
if (!/\s/.test(c)) {
|
|
1939
|
+
hasVisible = true;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
return hasVisible && depth === 0;
|
|
1943
|
+
}
|
|
1944
|
+
function parseQuotedStringAt(inputStr, startPos, quoteChar) {
|
|
1945
|
+
if (startPos >= inputStr.length || inputStr[startPos] !== quoteChar) {
|
|
1946
|
+
return null;
|
|
1947
|
+
}
|
|
1948
|
+
let quoteCount = 0;
|
|
1949
|
+
let pos = startPos;
|
|
1950
|
+
while (pos < inputStr.length && inputStr[pos] === quoteChar) {
|
|
1951
|
+
quoteCount++;
|
|
1952
|
+
pos++;
|
|
1953
|
+
}
|
|
1954
|
+
const isEvenRun = quoteCount % 2 === 0;
|
|
1955
|
+
const emptyReference = isEvenRun ? { value: "", length: quoteCount } : null;
|
|
1956
|
+
const closeSeq = quoteChar.repeat(quoteCount);
|
|
1957
|
+
const escapeSeq = quoteChar.repeat(quoteCount * 2);
|
|
1958
|
+
let content = "";
|
|
1959
|
+
while (pos < inputStr.length) {
|
|
1960
|
+
if (inputStr.substr(pos, escapeSeq.length) === escapeSeq) {
|
|
1961
|
+
content += closeSeq;
|
|
1962
|
+
pos += escapeSeq.length;
|
|
1963
|
+
continue;
|
|
1964
|
+
}
|
|
1965
|
+
if (inputStr.substr(pos, quoteCount) === closeSeq) {
|
|
1966
|
+
const afterClose = pos + quoteCount;
|
|
1967
|
+
if (afterClose >= inputStr.length || inputStr[afterClose] !== quoteChar) {
|
|
1968
|
+
if (isEvenRun && !isSubstantiveBody(content)) {
|
|
1969
|
+
return emptyReference;
|
|
1970
|
+
}
|
|
1971
|
+
return {
|
|
1972
|
+
value: content,
|
|
1973
|
+
length: afterClose - startPos
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
content += inputStr[pos];
|
|
1978
|
+
pos++;
|
|
1979
|
+
}
|
|
1980
|
+
return emptyReference;
|
|
1981
|
+
}
|
|
1982
|
+
let parsedValue = null;
|
|
1983
|
+
let parsedLength = 0;
|
|
1635
1984
|
peg$result = peg$startRuleFunction();
|
|
1636
1985
|
const peg$success = peg$result !== peg$FAILED && peg$currPos === input.length;
|
|
1637
1986
|
function peg$throw() {
|
|
@@ -1695,7 +2044,7 @@ class Parser {
|
|
|
1695
2044
|
if (item === null || item === undefined)
|
|
1696
2045
|
return;
|
|
1697
2046
|
if (item.children && item.children.length > 0) {
|
|
1698
|
-
if (item.id && (!item.values || item.values.length === 0)) {
|
|
2047
|
+
if (item.id !== undefined && item.id !== null && (!item.values || item.values.length === 0)) {
|
|
1699
2048
|
const childValues = item.children.map((child) => {
|
|
1700
2049
|
if (child.values && child.values.length === 1) {
|
|
1701
2050
|
return this.transformLink(child.values[0]);
|
|
@@ -1748,21 +2097,37 @@ class Parser {
|
|
|
1748
2097
|
combined._isFromPathCombination = true;
|
|
1749
2098
|
return combined;
|
|
1750
2099
|
}
|
|
2100
|
+
transformNested(nested) {
|
|
2101
|
+
const nestedLinks = [];
|
|
2102
|
+
for (const item of nested) {
|
|
2103
|
+
if (item !== null && item !== undefined) {
|
|
2104
|
+
this.collectLinks(item, [], nestedLinks);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
const wrapsSingleGroup = nested.length === 1 && nested[0] && nested[0].nested !== undefined;
|
|
2108
|
+
if (nestedLinks.length === 1 && !wrapsSingleGroup) {
|
|
2109
|
+
return nestedLinks[0];
|
|
2110
|
+
}
|
|
2111
|
+
return new Link(null, nestedLinks);
|
|
2112
|
+
}
|
|
1751
2113
|
transformLink(item) {
|
|
1752
2114
|
if (item === null || item === undefined)
|
|
1753
2115
|
return null;
|
|
1754
2116
|
if (item instanceof Link) {
|
|
1755
2117
|
return item;
|
|
1756
2118
|
}
|
|
2119
|
+
if (item.nested !== undefined) {
|
|
2120
|
+
return this.transformNested(item.nested);
|
|
2121
|
+
}
|
|
1757
2122
|
if (item.id !== undefined && !item.values && !item.children) {
|
|
1758
2123
|
return new Link(item.id);
|
|
1759
2124
|
}
|
|
1760
2125
|
if (item.values && Array.isArray(item.values)) {
|
|
1761
|
-
const link = new Link(item.id
|
|
2126
|
+
const link = new Link(item.id ?? null, []);
|
|
1762
2127
|
link.values = item.values.map((v) => this.transformLink(v));
|
|
1763
2128
|
return link;
|
|
1764
2129
|
}
|
|
1765
|
-
return new Link(item.id
|
|
2130
|
+
return new Link(item.id ?? null, []);
|
|
1766
2131
|
}
|
|
1767
2132
|
}
|
|
1768
2133
|
// src/FormatOptions.js
|
|
@@ -1794,10 +2159,10 @@ class FormatOptions {
|
|
|
1794
2159
|
class FormatConfig extends FormatOptions {
|
|
1795
2160
|
}
|
|
1796
2161
|
export {
|
|
1797
|
-
|
|
1798
|
-
Parser,
|
|
1799
|
-
LinksGroup,
|
|
1800
|
-
Link,
|
|
2162
|
+
FormatConfig,
|
|
1801
2163
|
FormatOptions,
|
|
1802
|
-
|
|
2164
|
+
Link,
|
|
2165
|
+
LinksGroup,
|
|
2166
|
+
Parser,
|
|
2167
|
+
formatLinks
|
|
1803
2168
|
};
|