links-notation 0.12.0 → 0.13.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 +52 -7
- package/README.ru.md +3 -6
- package/bun.lock +199 -0
- package/dist/index.js +391 -98
- package/package.json +6 -3
- package/src/FormatOptions.js +1 -1
- package/src/Link.js +71 -33
- package/src/LinksGroup.js +2 -2
- package/src/Parser.js +15 -15
- package/src/grammar.pegjs +105 -4
- package/src/index.js +1 -1
- package/src/parser-generated.js +401 -88
- package/tests/ApiTests.test.js +2 -2
- package/tests/EdgeCaseParser.test.js +3 -3
- package/tests/FormatConfig.test.js +32 -10
- package/tests/IndentedIdSyntax.test.js +39 -39
- package/tests/Link.test.js +2 -2
- 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 +9 -9
- package/tests/NestedParser.test.js +5 -3
- package/tests/NestedSelfReference.test.js +4 -2
- package/tests/SingleLineParser.test.js +2 -2
package/src/parser-generated.js
CHANGED
|
@@ -169,14 +169,13 @@ function peg$parse(input, options) {
|
|
|
169
169
|
const peg$c2 = ")";
|
|
170
170
|
const peg$c3 = "\"";
|
|
171
171
|
const peg$c4 = "'";
|
|
172
|
-
const peg$c5 = "
|
|
172
|
+
const peg$c5 = "`";
|
|
173
|
+
const peg$c6 = " ";
|
|
173
174
|
|
|
174
175
|
const peg$r0 = /^[ \t]/;
|
|
175
176
|
const peg$r1 = /^[\r\n]/;
|
|
176
|
-
const peg$r2 = /^[
|
|
177
|
-
const peg$r3 = /^[^
|
|
178
|
-
const peg$r4 = /^[ \t\n\r]/;
|
|
179
|
-
const peg$r5 = /^[^ \t\n\r(:)]/;
|
|
177
|
+
const peg$r2 = /^[ \t\n\r]/;
|
|
178
|
+
const peg$r3 = /^[^ \t\n\r(:)]/;
|
|
180
179
|
|
|
181
180
|
const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
|
|
182
181
|
const peg$e1 = peg$classExpectation(["\r", "\n"], false, false, false);
|
|
@@ -184,13 +183,12 @@ function peg$parse(input, options) {
|
|
|
184
183
|
const peg$e3 = peg$literalExpectation("(", false);
|
|
185
184
|
const peg$e4 = peg$literalExpectation(")", false);
|
|
186
185
|
const peg$e5 = peg$literalExpectation("\"", false);
|
|
187
|
-
const peg$e6 = peg$
|
|
186
|
+
const peg$e6 = peg$anyExpectation();
|
|
188
187
|
const peg$e7 = peg$literalExpectation("'", false);
|
|
189
|
-
const peg$e8 = peg$
|
|
188
|
+
const peg$e8 = peg$literalExpectation("`", false);
|
|
190
189
|
const peg$e9 = peg$literalExpectation(" ", false);
|
|
191
|
-
const peg$e10 = peg$
|
|
192
|
-
const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r"],
|
|
193
|
-
const peg$e12 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
|
|
190
|
+
const peg$e10 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
|
|
191
|
+
const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
|
|
194
192
|
|
|
195
193
|
function peg$f0() { indentationStack = [0]; baseIndentation = null; return true; }
|
|
196
194
|
function peg$f1(links) { return links; }
|
|
@@ -220,12 +218,52 @@ function peg$parse(input, options) {
|
|
|
220
218
|
function peg$f23(v) { return { values: v }; }
|
|
221
219
|
function peg$f24(id) { return { id: id, values: [] }; }
|
|
222
220
|
function peg$f25(chars) { return chars.join(''); }
|
|
223
|
-
function peg$f26(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
function peg$f26() {
|
|
222
|
+
const pos = offset();
|
|
223
|
+
const result = parseQuotedStringAt(input, pos, '"');
|
|
224
|
+
if (result) {
|
|
225
|
+
parsedValue = result.value;
|
|
226
|
+
parsedLength = result.length;
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
function peg$f27(chars) { return parsedValue; }
|
|
232
|
+
function peg$f28(c, cs) { return [c].concat(cs).join(''); }
|
|
233
|
+
function peg$f29() { return parsedLength > 1 && (parsedLength--, true); }
|
|
234
|
+
function peg$f30(c) { return c; }
|
|
235
|
+
function peg$f31() {
|
|
236
|
+
const pos = offset();
|
|
237
|
+
const result = parseQuotedStringAt(input, pos, "'");
|
|
238
|
+
if (result) {
|
|
239
|
+
parsedValue = result.value;
|
|
240
|
+
parsedLength = result.length;
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
function peg$f32(chars) { return parsedValue; }
|
|
246
|
+
function peg$f33(c, cs) { return [c].concat(cs).join(''); }
|
|
247
|
+
function peg$f34() { return parsedLength > 1 && (parsedLength--, true); }
|
|
248
|
+
function peg$f35(c) { return c; }
|
|
249
|
+
function peg$f36() {
|
|
250
|
+
const pos = offset();
|
|
251
|
+
const result = parseQuotedStringAt(input, pos, '`');
|
|
252
|
+
if (result) {
|
|
253
|
+
parsedValue = result.value;
|
|
254
|
+
parsedLength = result.length;
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
function peg$f37(chars) { return parsedValue; }
|
|
260
|
+
function peg$f38(c, cs) { return [c].concat(cs).join(''); }
|
|
261
|
+
function peg$f39() { return parsedLength > 1 && (parsedLength--, true); }
|
|
262
|
+
function peg$f40(c) { return c; }
|
|
263
|
+
function peg$f41(spaces) { setBaseIndentation(spaces); }
|
|
264
|
+
function peg$f42(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
|
|
265
|
+
function peg$f43(spaces) { pushIndentation(spaces); }
|
|
266
|
+
function peg$f44(spaces) { return checkIndentation(spaces); }
|
|
229
267
|
let peg$currPos = options.peg$currPos | 0;
|
|
230
268
|
let peg$savedPos = peg$currPos;
|
|
231
269
|
const peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
@@ -998,12 +1036,9 @@ function peg$parse(input, options) {
|
|
|
998
1036
|
function peg$parsereference() {
|
|
999
1037
|
let s0;
|
|
1000
1038
|
|
|
1001
|
-
s0 = peg$
|
|
1039
|
+
s0 = peg$parsequotedReference();
|
|
1002
1040
|
if (s0 === peg$FAILED) {
|
|
1003
|
-
s0 = peg$
|
|
1004
|
-
if (s0 === peg$FAILED) {
|
|
1005
|
-
s0 = peg$parsesimpleReference();
|
|
1006
|
-
}
|
|
1041
|
+
s0 = peg$parsesimpleReference();
|
|
1007
1042
|
}
|
|
1008
1043
|
|
|
1009
1044
|
return s0;
|
|
@@ -1032,51 +1067,164 @@ function peg$parse(input, options) {
|
|
|
1032
1067
|
return s0;
|
|
1033
1068
|
}
|
|
1034
1069
|
|
|
1035
|
-
function peg$
|
|
1070
|
+
function peg$parsequotedReference() {
|
|
1071
|
+
let s0;
|
|
1072
|
+
|
|
1073
|
+
s0 = peg$parsedoubleQuotedUniversal();
|
|
1074
|
+
if (s0 === peg$FAILED) {
|
|
1075
|
+
s0 = peg$parsesingleQuotedUniversal();
|
|
1076
|
+
if (s0 === peg$FAILED) {
|
|
1077
|
+
s0 = peg$parsebacktickQuotedUniversal();
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
return s0;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function peg$parsedoubleQuotedUniversal() {
|
|
1036
1085
|
let s0, s1, s2, s3;
|
|
1037
1086
|
|
|
1038
1087
|
s0 = peg$currPos;
|
|
1088
|
+
s1 = peg$currPos;
|
|
1089
|
+
peg$silentFails++;
|
|
1039
1090
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1040
|
-
|
|
1091
|
+
s2 = peg$c3;
|
|
1041
1092
|
peg$currPos++;
|
|
1042
1093
|
} else {
|
|
1043
|
-
|
|
1094
|
+
s2 = peg$FAILED;
|
|
1044
1095
|
if (peg$silentFails === 0) { peg$fail(peg$e5); }
|
|
1045
1096
|
}
|
|
1097
|
+
peg$silentFails--;
|
|
1098
|
+
if (s2 !== peg$FAILED) {
|
|
1099
|
+
peg$currPos = s1;
|
|
1100
|
+
s1 = undefined;
|
|
1101
|
+
} else {
|
|
1102
|
+
s1 = peg$FAILED;
|
|
1103
|
+
}
|
|
1104
|
+
if (s1 !== peg$FAILED) {
|
|
1105
|
+
peg$savedPos = peg$currPos;
|
|
1106
|
+
s2 = peg$f26();
|
|
1107
|
+
if (s2) {
|
|
1108
|
+
s2 = undefined;
|
|
1109
|
+
} else {
|
|
1110
|
+
s2 = peg$FAILED;
|
|
1111
|
+
}
|
|
1112
|
+
if (s2 !== peg$FAILED) {
|
|
1113
|
+
s3 = peg$parseconsumeDouble();
|
|
1114
|
+
if (s3 !== peg$FAILED) {
|
|
1115
|
+
peg$savedPos = s0;
|
|
1116
|
+
s0 = peg$f27(s3);
|
|
1117
|
+
} else {
|
|
1118
|
+
peg$currPos = s0;
|
|
1119
|
+
s0 = peg$FAILED;
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
peg$currPos = s0;
|
|
1123
|
+
s0 = peg$FAILED;
|
|
1124
|
+
}
|
|
1125
|
+
} else {
|
|
1126
|
+
peg$currPos = s0;
|
|
1127
|
+
s0 = peg$FAILED;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return s0;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function peg$parseconsumeDouble() {
|
|
1134
|
+
let s0, s1, s2, s3;
|
|
1135
|
+
|
|
1136
|
+
s0 = peg$currPos;
|
|
1137
|
+
if (input.length > peg$currPos) {
|
|
1138
|
+
s1 = input.charAt(peg$currPos);
|
|
1139
|
+
peg$currPos++;
|
|
1140
|
+
} else {
|
|
1141
|
+
s1 = peg$FAILED;
|
|
1142
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1143
|
+
}
|
|
1046
1144
|
if (s1 !== peg$FAILED) {
|
|
1047
1145
|
s2 = [];
|
|
1048
|
-
s3 =
|
|
1049
|
-
|
|
1146
|
+
s3 = peg$parseconsumeDoubleMore();
|
|
1147
|
+
while (s3 !== peg$FAILED) {
|
|
1148
|
+
s2.push(s3);
|
|
1149
|
+
s3 = peg$parseconsumeDoubleMore();
|
|
1150
|
+
}
|
|
1151
|
+
peg$savedPos = s0;
|
|
1152
|
+
s0 = peg$f28(s1, s2);
|
|
1153
|
+
} else {
|
|
1154
|
+
peg$currPos = s0;
|
|
1155
|
+
s0 = peg$FAILED;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
return s0;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
function peg$parseconsumeDoubleMore() {
|
|
1162
|
+
let s0, s1, s2;
|
|
1163
|
+
|
|
1164
|
+
s0 = peg$currPos;
|
|
1165
|
+
peg$savedPos = peg$currPos;
|
|
1166
|
+
s1 = peg$f29();
|
|
1167
|
+
if (s1) {
|
|
1168
|
+
s1 = undefined;
|
|
1169
|
+
} else {
|
|
1170
|
+
s1 = peg$FAILED;
|
|
1171
|
+
}
|
|
1172
|
+
if (s1 !== peg$FAILED) {
|
|
1173
|
+
if (input.length > peg$currPos) {
|
|
1174
|
+
s2 = input.charAt(peg$currPos);
|
|
1050
1175
|
peg$currPos++;
|
|
1051
1176
|
} else {
|
|
1052
|
-
|
|
1177
|
+
s2 = peg$FAILED;
|
|
1053
1178
|
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1054
1179
|
}
|
|
1055
|
-
if (
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1180
|
+
if (s2 !== peg$FAILED) {
|
|
1181
|
+
peg$savedPos = s0;
|
|
1182
|
+
s0 = peg$f30(s2);
|
|
1183
|
+
} else {
|
|
1184
|
+
peg$currPos = s0;
|
|
1185
|
+
s0 = peg$FAILED;
|
|
1186
|
+
}
|
|
1187
|
+
} else {
|
|
1188
|
+
peg$currPos = s0;
|
|
1189
|
+
s0 = peg$FAILED;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
return s0;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
function peg$parsesingleQuotedUniversal() {
|
|
1196
|
+
let s0, s1, s2, s3;
|
|
1197
|
+
|
|
1198
|
+
s0 = peg$currPos;
|
|
1199
|
+
s1 = peg$currPos;
|
|
1200
|
+
peg$silentFails++;
|
|
1201
|
+
if (input.charCodeAt(peg$currPos) === 39) {
|
|
1202
|
+
s2 = peg$c4;
|
|
1203
|
+
peg$currPos++;
|
|
1204
|
+
} else {
|
|
1205
|
+
s2 = peg$FAILED;
|
|
1206
|
+
if (peg$silentFails === 0) { peg$fail(peg$e7); }
|
|
1207
|
+
}
|
|
1208
|
+
peg$silentFails--;
|
|
1209
|
+
if (s2 !== peg$FAILED) {
|
|
1210
|
+
peg$currPos = s1;
|
|
1211
|
+
s1 = undefined;
|
|
1212
|
+
} else {
|
|
1213
|
+
s1 = peg$FAILED;
|
|
1214
|
+
}
|
|
1215
|
+
if (s1 !== peg$FAILED) {
|
|
1216
|
+
peg$savedPos = peg$currPos;
|
|
1217
|
+
s2 = peg$f31();
|
|
1218
|
+
if (s2) {
|
|
1219
|
+
s2 = undefined;
|
|
1066
1220
|
} else {
|
|
1067
1221
|
s2 = peg$FAILED;
|
|
1068
1222
|
}
|
|
1069
1223
|
if (s2 !== peg$FAILED) {
|
|
1070
|
-
|
|
1071
|
-
s3 = peg$c3;
|
|
1072
|
-
peg$currPos++;
|
|
1073
|
-
} else {
|
|
1074
|
-
s3 = peg$FAILED;
|
|
1075
|
-
if (peg$silentFails === 0) { peg$fail(peg$e5); }
|
|
1076
|
-
}
|
|
1224
|
+
s3 = peg$parseconsumeSingle();
|
|
1077
1225
|
if (s3 !== peg$FAILED) {
|
|
1078
1226
|
peg$savedPos = s0;
|
|
1079
|
-
s0 = peg$
|
|
1227
|
+
s0 = peg$f32(s3);
|
|
1080
1228
|
} else {
|
|
1081
1229
|
peg$currPos = s0;
|
|
1082
1230
|
s0 = peg$FAILED;
|
|
@@ -1093,51 +1241,101 @@ function peg$parse(input, options) {
|
|
|
1093
1241
|
return s0;
|
|
1094
1242
|
}
|
|
1095
1243
|
|
|
1096
|
-
function peg$
|
|
1244
|
+
function peg$parseconsumeSingle() {
|
|
1097
1245
|
let s0, s1, s2, s3;
|
|
1098
1246
|
|
|
1099
1247
|
s0 = peg$currPos;
|
|
1100
|
-
if (input.
|
|
1101
|
-
s1 = peg$
|
|
1248
|
+
if (input.length > peg$currPos) {
|
|
1249
|
+
s1 = input.charAt(peg$currPos);
|
|
1102
1250
|
peg$currPos++;
|
|
1103
1251
|
} else {
|
|
1104
1252
|
s1 = peg$FAILED;
|
|
1105
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1253
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1106
1254
|
}
|
|
1107
1255
|
if (s1 !== peg$FAILED) {
|
|
1108
1256
|
s2 = [];
|
|
1109
|
-
s3 =
|
|
1110
|
-
|
|
1257
|
+
s3 = peg$parseconsumeSingleMore();
|
|
1258
|
+
while (s3 !== peg$FAILED) {
|
|
1259
|
+
s2.push(s3);
|
|
1260
|
+
s3 = peg$parseconsumeSingleMore();
|
|
1261
|
+
}
|
|
1262
|
+
peg$savedPos = s0;
|
|
1263
|
+
s0 = peg$f33(s1, s2);
|
|
1264
|
+
} else {
|
|
1265
|
+
peg$currPos = s0;
|
|
1266
|
+
s0 = peg$FAILED;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return s0;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
function peg$parseconsumeSingleMore() {
|
|
1273
|
+
let s0, s1, s2;
|
|
1274
|
+
|
|
1275
|
+
s0 = peg$currPos;
|
|
1276
|
+
peg$savedPos = peg$currPos;
|
|
1277
|
+
s1 = peg$f34();
|
|
1278
|
+
if (s1) {
|
|
1279
|
+
s1 = undefined;
|
|
1280
|
+
} else {
|
|
1281
|
+
s1 = peg$FAILED;
|
|
1282
|
+
}
|
|
1283
|
+
if (s1 !== peg$FAILED) {
|
|
1284
|
+
if (input.length > peg$currPos) {
|
|
1285
|
+
s2 = input.charAt(peg$currPos);
|
|
1111
1286
|
peg$currPos++;
|
|
1112
1287
|
} else {
|
|
1113
|
-
|
|
1114
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1288
|
+
s2 = peg$FAILED;
|
|
1289
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1115
1290
|
}
|
|
1116
|
-
if (
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1291
|
+
if (s2 !== peg$FAILED) {
|
|
1292
|
+
peg$savedPos = s0;
|
|
1293
|
+
s0 = peg$f35(s2);
|
|
1294
|
+
} else {
|
|
1295
|
+
peg$currPos = s0;
|
|
1296
|
+
s0 = peg$FAILED;
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
peg$currPos = s0;
|
|
1300
|
+
s0 = peg$FAILED;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
return s0;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function peg$parsebacktickQuotedUniversal() {
|
|
1307
|
+
let s0, s1, s2, s3;
|
|
1308
|
+
|
|
1309
|
+
s0 = peg$currPos;
|
|
1310
|
+
s1 = peg$currPos;
|
|
1311
|
+
peg$silentFails++;
|
|
1312
|
+
if (input.charCodeAt(peg$currPos) === 96) {
|
|
1313
|
+
s2 = peg$c5;
|
|
1314
|
+
peg$currPos++;
|
|
1315
|
+
} else {
|
|
1316
|
+
s2 = peg$FAILED;
|
|
1317
|
+
if (peg$silentFails === 0) { peg$fail(peg$e8); }
|
|
1318
|
+
}
|
|
1319
|
+
peg$silentFails--;
|
|
1320
|
+
if (s2 !== peg$FAILED) {
|
|
1321
|
+
peg$currPos = s1;
|
|
1322
|
+
s1 = undefined;
|
|
1323
|
+
} else {
|
|
1324
|
+
s1 = peg$FAILED;
|
|
1325
|
+
}
|
|
1326
|
+
if (s1 !== peg$FAILED) {
|
|
1327
|
+
peg$savedPos = peg$currPos;
|
|
1328
|
+
s2 = peg$f36();
|
|
1329
|
+
if (s2) {
|
|
1330
|
+
s2 = undefined;
|
|
1127
1331
|
} else {
|
|
1128
1332
|
s2 = peg$FAILED;
|
|
1129
1333
|
}
|
|
1130
1334
|
if (s2 !== peg$FAILED) {
|
|
1131
|
-
|
|
1132
|
-
s3 = peg$c4;
|
|
1133
|
-
peg$currPos++;
|
|
1134
|
-
} else {
|
|
1135
|
-
s3 = peg$FAILED;
|
|
1136
|
-
if (peg$silentFails === 0) { peg$fail(peg$e7); }
|
|
1137
|
-
}
|
|
1335
|
+
s3 = peg$parseconsumeBacktick();
|
|
1138
1336
|
if (s3 !== peg$FAILED) {
|
|
1139
1337
|
peg$savedPos = s0;
|
|
1140
|
-
s0 = peg$
|
|
1338
|
+
s0 = peg$f37(s3);
|
|
1141
1339
|
} else {
|
|
1142
1340
|
peg$currPos = s0;
|
|
1143
1341
|
s0 = peg$FAILED;
|
|
@@ -1154,13 +1352,75 @@ function peg$parse(input, options) {
|
|
|
1154
1352
|
return s0;
|
|
1155
1353
|
}
|
|
1156
1354
|
|
|
1355
|
+
function peg$parseconsumeBacktick() {
|
|
1356
|
+
let s0, s1, s2, s3;
|
|
1357
|
+
|
|
1358
|
+
s0 = peg$currPos;
|
|
1359
|
+
if (input.length > peg$currPos) {
|
|
1360
|
+
s1 = input.charAt(peg$currPos);
|
|
1361
|
+
peg$currPos++;
|
|
1362
|
+
} else {
|
|
1363
|
+
s1 = peg$FAILED;
|
|
1364
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1365
|
+
}
|
|
1366
|
+
if (s1 !== peg$FAILED) {
|
|
1367
|
+
s2 = [];
|
|
1368
|
+
s3 = peg$parseconsumeBacktickMore();
|
|
1369
|
+
while (s3 !== peg$FAILED) {
|
|
1370
|
+
s2.push(s3);
|
|
1371
|
+
s3 = peg$parseconsumeBacktickMore();
|
|
1372
|
+
}
|
|
1373
|
+
peg$savedPos = s0;
|
|
1374
|
+
s0 = peg$f38(s1, s2);
|
|
1375
|
+
} else {
|
|
1376
|
+
peg$currPos = s0;
|
|
1377
|
+
s0 = peg$FAILED;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
return s0;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function peg$parseconsumeBacktickMore() {
|
|
1384
|
+
let s0, s1, s2;
|
|
1385
|
+
|
|
1386
|
+
s0 = peg$currPos;
|
|
1387
|
+
peg$savedPos = peg$currPos;
|
|
1388
|
+
s1 = peg$f39();
|
|
1389
|
+
if (s1) {
|
|
1390
|
+
s1 = undefined;
|
|
1391
|
+
} else {
|
|
1392
|
+
s1 = peg$FAILED;
|
|
1393
|
+
}
|
|
1394
|
+
if (s1 !== peg$FAILED) {
|
|
1395
|
+
if (input.length > peg$currPos) {
|
|
1396
|
+
s2 = input.charAt(peg$currPos);
|
|
1397
|
+
peg$currPos++;
|
|
1398
|
+
} else {
|
|
1399
|
+
s2 = peg$FAILED;
|
|
1400
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1401
|
+
}
|
|
1402
|
+
if (s2 !== peg$FAILED) {
|
|
1403
|
+
peg$savedPos = s0;
|
|
1404
|
+
s0 = peg$f40(s2);
|
|
1405
|
+
} else {
|
|
1406
|
+
peg$currPos = s0;
|
|
1407
|
+
s0 = peg$FAILED;
|
|
1408
|
+
}
|
|
1409
|
+
} else {
|
|
1410
|
+
peg$currPos = s0;
|
|
1411
|
+
s0 = peg$FAILED;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
return s0;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1157
1417
|
function peg$parseSET_BASE_INDENTATION() {
|
|
1158
1418
|
let s0, s1, s2;
|
|
1159
1419
|
|
|
1160
1420
|
s0 = peg$currPos;
|
|
1161
1421
|
s1 = [];
|
|
1162
1422
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1163
|
-
s2 = peg$
|
|
1423
|
+
s2 = peg$c6;
|
|
1164
1424
|
peg$currPos++;
|
|
1165
1425
|
} else {
|
|
1166
1426
|
s2 = peg$FAILED;
|
|
@@ -1169,7 +1429,7 @@ function peg$parse(input, options) {
|
|
|
1169
1429
|
while (s2 !== peg$FAILED) {
|
|
1170
1430
|
s1.push(s2);
|
|
1171
1431
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1172
|
-
s2 = peg$
|
|
1432
|
+
s2 = peg$c6;
|
|
1173
1433
|
peg$currPos++;
|
|
1174
1434
|
} else {
|
|
1175
1435
|
s2 = peg$FAILED;
|
|
@@ -1177,7 +1437,7 @@ function peg$parse(input, options) {
|
|
|
1177
1437
|
}
|
|
1178
1438
|
}
|
|
1179
1439
|
peg$savedPos = s0;
|
|
1180
|
-
s1 = peg$
|
|
1440
|
+
s1 = peg$f41(s1);
|
|
1181
1441
|
s0 = s1;
|
|
1182
1442
|
|
|
1183
1443
|
return s0;
|
|
@@ -1189,7 +1449,7 @@ function peg$parse(input, options) {
|
|
|
1189
1449
|
s0 = peg$currPos;
|
|
1190
1450
|
s1 = [];
|
|
1191
1451
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1192
|
-
s2 = peg$
|
|
1452
|
+
s2 = peg$c6;
|
|
1193
1453
|
peg$currPos++;
|
|
1194
1454
|
} else {
|
|
1195
1455
|
s2 = peg$FAILED;
|
|
@@ -1198,7 +1458,7 @@ function peg$parse(input, options) {
|
|
|
1198
1458
|
while (s2 !== peg$FAILED) {
|
|
1199
1459
|
s1.push(s2);
|
|
1200
1460
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1201
|
-
s2 = peg$
|
|
1461
|
+
s2 = peg$c6;
|
|
1202
1462
|
peg$currPos++;
|
|
1203
1463
|
} else {
|
|
1204
1464
|
s2 = peg$FAILED;
|
|
@@ -1206,7 +1466,7 @@ function peg$parse(input, options) {
|
|
|
1206
1466
|
}
|
|
1207
1467
|
}
|
|
1208
1468
|
peg$savedPos = peg$currPos;
|
|
1209
|
-
s2 = peg$
|
|
1469
|
+
s2 = peg$f42(s1);
|
|
1210
1470
|
if (s2) {
|
|
1211
1471
|
s2 = undefined;
|
|
1212
1472
|
} else {
|
|
@@ -1214,7 +1474,7 @@ function peg$parse(input, options) {
|
|
|
1214
1474
|
}
|
|
1215
1475
|
if (s2 !== peg$FAILED) {
|
|
1216
1476
|
peg$savedPos = s0;
|
|
1217
|
-
s0 = peg$
|
|
1477
|
+
s0 = peg$f43(s1);
|
|
1218
1478
|
} else {
|
|
1219
1479
|
peg$currPos = s0;
|
|
1220
1480
|
s0 = peg$FAILED;
|
|
@@ -1229,7 +1489,7 @@ function peg$parse(input, options) {
|
|
|
1229
1489
|
s0 = peg$currPos;
|
|
1230
1490
|
s1 = [];
|
|
1231
1491
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1232
|
-
s2 = peg$
|
|
1492
|
+
s2 = peg$c6;
|
|
1233
1493
|
peg$currPos++;
|
|
1234
1494
|
} else {
|
|
1235
1495
|
s2 = peg$FAILED;
|
|
@@ -1238,7 +1498,7 @@ function peg$parse(input, options) {
|
|
|
1238
1498
|
while (s2 !== peg$FAILED) {
|
|
1239
1499
|
s1.push(s2);
|
|
1240
1500
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1241
|
-
s2 = peg$
|
|
1501
|
+
s2 = peg$c6;
|
|
1242
1502
|
peg$currPos++;
|
|
1243
1503
|
} else {
|
|
1244
1504
|
s2 = peg$FAILED;
|
|
@@ -1246,7 +1506,7 @@ function peg$parse(input, options) {
|
|
|
1246
1506
|
}
|
|
1247
1507
|
}
|
|
1248
1508
|
peg$savedPos = peg$currPos;
|
|
1249
|
-
s2 = peg$
|
|
1509
|
+
s2 = peg$f44(s1);
|
|
1250
1510
|
if (s2) {
|
|
1251
1511
|
s2 = undefined;
|
|
1252
1512
|
} else {
|
|
@@ -1314,7 +1574,7 @@ function peg$parse(input, options) {
|
|
|
1314
1574
|
peg$currPos++;
|
|
1315
1575
|
} else {
|
|
1316
1576
|
s1 = peg$FAILED;
|
|
1317
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1577
|
+
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
|
1318
1578
|
}
|
|
1319
1579
|
peg$silentFails--;
|
|
1320
1580
|
if (s1 === peg$FAILED) {
|
|
@@ -1369,11 +1629,11 @@ function peg$parse(input, options) {
|
|
|
1369
1629
|
let s0;
|
|
1370
1630
|
|
|
1371
1631
|
s0 = input.charAt(peg$currPos);
|
|
1372
|
-
if (peg$
|
|
1632
|
+
if (peg$r2.test(s0)) {
|
|
1373
1633
|
peg$currPos++;
|
|
1374
1634
|
} else {
|
|
1375
1635
|
s0 = peg$FAILED;
|
|
1376
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1636
|
+
if (peg$silentFails === 0) { peg$fail(peg$e10); }
|
|
1377
1637
|
}
|
|
1378
1638
|
|
|
1379
1639
|
return s0;
|
|
@@ -1383,11 +1643,11 @@ function peg$parse(input, options) {
|
|
|
1383
1643
|
let s0;
|
|
1384
1644
|
|
|
1385
1645
|
s0 = input.charAt(peg$currPos);
|
|
1386
|
-
if (peg$
|
|
1646
|
+
if (peg$r3.test(s0)) {
|
|
1387
1647
|
peg$currPos++;
|
|
1388
1648
|
} else {
|
|
1389
1649
|
s0 = peg$FAILED;
|
|
1390
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1650
|
+
if (peg$silentFails === 0) { peg$fail(peg$e11); }
|
|
1391
1651
|
}
|
|
1392
1652
|
|
|
1393
1653
|
return s0;
|
|
@@ -1430,6 +1690,59 @@ function peg$parse(input, options) {
|
|
|
1430
1690
|
return indentationStack[indentationStack.length - 1];
|
|
1431
1691
|
}
|
|
1432
1692
|
|
|
1693
|
+
// Universal procedural parser for N-quote strings (any N >= 1)
|
|
1694
|
+
// Parses from the given position in the input string
|
|
1695
|
+
// Returns { value, length } or null
|
|
1696
|
+
function parseQuotedStringAt(inputStr, startPos, quoteChar) {
|
|
1697
|
+
if (startPos >= inputStr.length || inputStr[startPos] !== quoteChar) {
|
|
1698
|
+
return null;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// Count opening quotes
|
|
1702
|
+
let quoteCount = 0;
|
|
1703
|
+
let pos = startPos;
|
|
1704
|
+
while (pos < inputStr.length && inputStr[pos] === quoteChar) {
|
|
1705
|
+
quoteCount++;
|
|
1706
|
+
pos++;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
const closeSeq = quoteChar.repeat(quoteCount);
|
|
1710
|
+
const escapeSeq = quoteChar.repeat(quoteCount * 2);
|
|
1711
|
+
|
|
1712
|
+
let content = '';
|
|
1713
|
+
while (pos < inputStr.length) {
|
|
1714
|
+
// Check for escape sequence (2*N quotes)
|
|
1715
|
+
if (inputStr.substr(pos, escapeSeq.length) === escapeSeq) {
|
|
1716
|
+
content += closeSeq; // 2*N quotes become N quotes
|
|
1717
|
+
pos += escapeSeq.length;
|
|
1718
|
+
continue;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// Check for closing sequence (exactly N quotes)
|
|
1722
|
+
if (inputStr.substr(pos, quoteCount) === closeSeq) {
|
|
1723
|
+
// Verify it's exactly N quotes (not followed by more of same char)
|
|
1724
|
+
const afterClose = pos + quoteCount;
|
|
1725
|
+
if (afterClose >= inputStr.length || inputStr[afterClose] !== quoteChar) {
|
|
1726
|
+
// Found valid closing
|
|
1727
|
+
return {
|
|
1728
|
+
value: content,
|
|
1729
|
+
length: afterClose - startPos
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// Add character to content
|
|
1735
|
+
content += inputStr[pos];
|
|
1736
|
+
pos++;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
return null; // No valid closing found
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// Global state for passing parsed values between predicate and action
|
|
1743
|
+
let parsedValue = null;
|
|
1744
|
+
let parsedLength = 0;
|
|
1745
|
+
|
|
1433
1746
|
peg$result = peg$startRuleFunction();
|
|
1434
1747
|
|
|
1435
1748
|
const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
|
package/tests/ApiTests.test.js
CHANGED
|
@@ -125,7 +125,7 @@ test('test_indented_id_syntax_roundtrip', () => {
|
|
|
125
125
|
|
|
126
126
|
// Validate that we can format with indented syntax using FormatOptions
|
|
127
127
|
const options = new FormatOptions();
|
|
128
|
-
options.maxInlineRefs = 1;
|
|
128
|
+
options.maxInlineRefs = 1; // Force indentation with more than 1 ref
|
|
129
129
|
options.preferInline = false;
|
|
130
130
|
const output = formatLinks(parsed, options);
|
|
131
131
|
expect(output).toBe(input);
|
|
@@ -164,7 +164,7 @@ id2:
|
|
|
164
164
|
|
|
165
165
|
// Validate that we can format with indented syntax using FormatOptions
|
|
166
166
|
const options = new FormatOptions();
|
|
167
|
-
options.maxInlineRefs = 1;
|
|
167
|
+
options.maxInlineRefs = 1; // Force indentation with more than 1 ref
|
|
168
168
|
options.preferInline = false;
|
|
169
169
|
const output = formatLinks(parsed, options);
|
|
170
170
|
expect(output).toBe(input);
|