@jxsuite/parser 4.1.2 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content-loader.js +944 -721
- package/dist/content.js +82 -21
- package/dist/markdown.js +3245 -2485
- package/dist/serialize.js +760 -604
- package/package.json +5 -5
- package/schemas/project.fragment.schema.json +223 -4
- package/src/Content.class.json +4 -0
- package/src/ContentCollection.class.json +7 -5
- package/src/content-loader.ts +64 -17
- package/src/content-rules.ts +8 -220
- package/src/content.ts +138 -32
- package/src/serialize.ts +10 -1
- package/src/types.ts +5 -0
package/dist/content-loader.js
CHANGED
|
@@ -80,6 +80,9 @@ function isRef(value) {
|
|
|
80
80
|
function isNodeObject(value) {
|
|
81
81
|
return isJsonObject(value);
|
|
82
82
|
}
|
|
83
|
+
function isTemplateString(value) {
|
|
84
|
+
return typeof value === "string" && value.includes("${");
|
|
85
|
+
}
|
|
83
86
|
function isPlainTagName(tagName) {
|
|
84
87
|
return typeof tagName === "string";
|
|
85
88
|
}
|
|
@@ -272,6 +275,195 @@ var init_alerts = __esm(() => {
|
|
|
272
275
|
LINE_END = /\r?\n/;
|
|
273
276
|
});
|
|
274
277
|
|
|
278
|
+
// ../../packages/schema/src/content-query.ts
|
|
279
|
+
function isPlainObject(value) {
|
|
280
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
281
|
+
}
|
|
282
|
+
function comparable(value) {
|
|
283
|
+
if (value instanceof Date) {
|
|
284
|
+
if (Number.isNaN(value.getTime())) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const iso = value.toISOString();
|
|
288
|
+
return iso.endsWith("T00:00:00.000Z") ? iso.slice(0, 10) : iso.replace(/\.\d{3}Z$/, "Z");
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
function deepEqual(a, b) {
|
|
293
|
+
if (a === b) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
297
|
+
return a.length === b.length && a.every((item, i) => deepEqual(comparable(item), comparable(b[i])));
|
|
298
|
+
}
|
|
299
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
300
|
+
const keys = Object.keys(a);
|
|
301
|
+
return keys.length === Object.keys(b).length && keys.every((key) => (key in b) && deepEqual(comparable(a[key]), comparable(b[key])));
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
function sameValue(actual, expected) {
|
|
306
|
+
const a = comparable(actual);
|
|
307
|
+
if (Array.isArray(expected) || isPlainObject(expected)) {
|
|
308
|
+
return deepEqual(a, expected);
|
|
309
|
+
}
|
|
310
|
+
if (Array.isArray(a)) {
|
|
311
|
+
return a.some((item) => comparable(item) === expected);
|
|
312
|
+
}
|
|
313
|
+
return a === expected;
|
|
314
|
+
}
|
|
315
|
+
function readField(data, key) {
|
|
316
|
+
if (Object.hasOwn(data, key)) {
|
|
317
|
+
return data[key];
|
|
318
|
+
}
|
|
319
|
+
if (!key.includes(".")) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
return readPath(data, key.split("."));
|
|
323
|
+
}
|
|
324
|
+
function readPath(holder, [part, ...rest]) {
|
|
325
|
+
if (part === undefined || !isPlainObject(holder) || !Object.hasOwn(holder, part)) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const value = holder[part];
|
|
329
|
+
return rest.length === 0 ? value : readPath(value, rest);
|
|
330
|
+
}
|
|
331
|
+
function order(actual, operand) {
|
|
332
|
+
const a = comparable(actual);
|
|
333
|
+
if (isNumber(a) && isNumber(operand)) {
|
|
334
|
+
return a - operand;
|
|
335
|
+
}
|
|
336
|
+
if (isString(a) && isString(operand)) {
|
|
337
|
+
return a < operand ? -1 : a > operand ? 1 : 0;
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
function isNowOperand(operand) {
|
|
342
|
+
return isPlainObject(operand) && operand.$now === true && Object.keys(operand).length === 1;
|
|
343
|
+
}
|
|
344
|
+
function timeOf(value) {
|
|
345
|
+
const time = value instanceof Date ? value.getTime() : isString(value) ? Date.parse(value) : Number.NaN;
|
|
346
|
+
return Number.isNaN(time) ? undefined : time;
|
|
347
|
+
}
|
|
348
|
+
function operatorTest(where, op, operand, ctx) {
|
|
349
|
+
switch (op) {
|
|
350
|
+
case "$eq": {
|
|
351
|
+
return (actual) => sameValue(actual, operand);
|
|
352
|
+
}
|
|
353
|
+
case "$ne": {
|
|
354
|
+
return (actual) => !sameValue(actual, operand);
|
|
355
|
+
}
|
|
356
|
+
case "$in":
|
|
357
|
+
case "$nin": {
|
|
358
|
+
if (!Array.isArray(operand)) {
|
|
359
|
+
throw new TypeError(`${where}.${op}: expected an array, got ${JSON.stringify(operand)}`);
|
|
360
|
+
}
|
|
361
|
+
const hit = (actual) => operand.some((candidate) => sameValue(actual, candidate));
|
|
362
|
+
return op === "$in" ? hit : (actual) => !hit(actual);
|
|
363
|
+
}
|
|
364
|
+
case "$exists": {
|
|
365
|
+
if (!isBoolean(operand)) {
|
|
366
|
+
throw new TypeError(`${where}.$exists: expected true or false, got ${JSON.stringify(operand)}`);
|
|
367
|
+
}
|
|
368
|
+
return (actual) => (actual !== undefined && actual !== null) === operand;
|
|
369
|
+
}
|
|
370
|
+
default: {
|
|
371
|
+
const test = (diff) => op === "$gt" ? diff > 0 : op === "$gte" ? diff >= 0 : op === "$lt" ? diff < 0 : diff <= 0;
|
|
372
|
+
if (isNowOperand(operand)) {
|
|
373
|
+
return (actual) => {
|
|
374
|
+
if (actual === undefined || actual === null) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
const time = timeOf(actual);
|
|
378
|
+
return time === undefined ? ctx.onBadDate : test(time - ctx.now().getTime());
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
if (!isString(operand) && !isNumber(operand)) {
|
|
382
|
+
throw new TypeError(`${where}.${op}: expected a string or number, got ${JSON.stringify(operand)}`);
|
|
383
|
+
}
|
|
384
|
+
return (actual) => {
|
|
385
|
+
const diff = order(actual, operand);
|
|
386
|
+
return diff !== undefined && test(diff);
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function operatorKeys(condition) {
|
|
392
|
+
const keys = Object.keys(condition);
|
|
393
|
+
const dollars = keys.filter((key) => key.startsWith("$"));
|
|
394
|
+
if (dollars.length === 0) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
return dollars.length === keys.length ? keys : [];
|
|
398
|
+
}
|
|
399
|
+
function compileCondition(key, condition, ctx) {
|
|
400
|
+
const where = `${ctx.name}.${key}`;
|
|
401
|
+
if (!isPlainObject(condition)) {
|
|
402
|
+
return (actual) => sameValue(actual, condition);
|
|
403
|
+
}
|
|
404
|
+
const ops = operatorKeys(condition);
|
|
405
|
+
if (ops === null) {
|
|
406
|
+
return (actual) => deepEqual(comparable(actual), condition);
|
|
407
|
+
}
|
|
408
|
+
if (ops.length === 0) {
|
|
409
|
+
throw new TypeError(`${where}: cannot mix $operators with plain keys in one condition`);
|
|
410
|
+
}
|
|
411
|
+
const tests = ops.map((op) => {
|
|
412
|
+
if (!OPERATORS.has(op)) {
|
|
413
|
+
throw new TypeError(`${where}: unknown operator "${op}" (use ${[...OPERATORS].join(", ")})`);
|
|
414
|
+
}
|
|
415
|
+
return operatorTest(where, op, condition[op], ctx);
|
|
416
|
+
});
|
|
417
|
+
return (actual) => tests.every((test) => test(actual));
|
|
418
|
+
}
|
|
419
|
+
function compileFields(query, ctx) {
|
|
420
|
+
return Object.entries(query).map(([key, condition]) => {
|
|
421
|
+
if (key.startsWith("$")) {
|
|
422
|
+
throw new TypeError(`${ctx.name}.${key}: top-level operators are not supported, conditions on different fields already combine with AND`);
|
|
423
|
+
}
|
|
424
|
+
return { key, test: compileCondition(key, condition, ctx) };
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
function compileWhere(where, options = {}) {
|
|
428
|
+
if (where === undefined) {
|
|
429
|
+
return Object.assign(() => true, { why: nothing });
|
|
430
|
+
}
|
|
431
|
+
if (!isPlainObject(where)) {
|
|
432
|
+
throw new TypeError(`"where" must be an object mapping frontmatter fields to conditions`);
|
|
433
|
+
}
|
|
434
|
+
const ctx = { name: "where", now: options.now ?? realClock, onBadDate: false };
|
|
435
|
+
const tests = compileFields(where, ctx);
|
|
436
|
+
return Object.assign((data) => tests.every(({ key, test }) => test(readField(data, key))), {
|
|
437
|
+
why: (data) => tests.find(({ key, test }) => !test(readField(data, key)))?.key
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function compileHold(hold, options = {}) {
|
|
441
|
+
if (hold === undefined) {
|
|
442
|
+
return nothing;
|
|
443
|
+
}
|
|
444
|
+
if (!Array.isArray(hold)) {
|
|
445
|
+
throw new TypeError(`"hold" must be an array of { "label", "when" } rules`);
|
|
446
|
+
}
|
|
447
|
+
const now = options.now ?? realClock;
|
|
448
|
+
const rules = hold.map((rule, index) => {
|
|
449
|
+
const at = `hold[${index}]`;
|
|
450
|
+
if (!isPlainObject(rule) || !isString(rule.label) || rule.label.trim() === "") {
|
|
451
|
+
throw new TypeError(`${at}: expected a non-empty "label"`);
|
|
452
|
+
}
|
|
453
|
+
if (!isPlainObject(rule.when) || Object.keys(rule.when).length === 0) {
|
|
454
|
+
throw new TypeError(`${at}: expected "when" to name at least one frontmatter field`);
|
|
455
|
+
}
|
|
456
|
+
const ctx = { name: `${at}.when`, now, onBadDate: true };
|
|
457
|
+
return { label: rule.label, tests: compileFields(rule.when, ctx) };
|
|
458
|
+
});
|
|
459
|
+
return (data) => rules.find(({ tests }) => tests.every(({ key, test }) => test(readField(data, key))))?.label;
|
|
460
|
+
}
|
|
461
|
+
var OPERATORS, nothing = () => {}, realClock = () => new Date;
|
|
462
|
+
var init_content_query = __esm(() => {
|
|
463
|
+
init_guards();
|
|
464
|
+
OPERATORS = new Set(["$eq", "$ne", "$in", "$nin", "$exists", "$gt", "$gte", "$lt", "$lte"]);
|
|
465
|
+
});
|
|
466
|
+
|
|
275
467
|
// src/content-rules.ts
|
|
276
468
|
function escapeRegExp(text) {
|
|
277
469
|
return text.replaceAll(REGEXP_SPECIAL, String.raw`\$&`);
|
|
@@ -397,7 +589,7 @@ function mayNameDirectory(pattern) {
|
|
|
397
589
|
}
|
|
398
590
|
function compileExclude(patterns) {
|
|
399
591
|
if (patterns === undefined) {
|
|
400
|
-
return { empty: true, excludedBy:
|
|
592
|
+
return { empty: true, excludedBy: nothing2, excludesDir: () => false };
|
|
401
593
|
}
|
|
402
594
|
if (!Array.isArray(patterns)) {
|
|
403
595
|
throw new TypeError(`"exclude" must be an array of glob patterns`);
|
|
@@ -437,152 +629,11 @@ function compileExclude(patterns) {
|
|
|
437
629
|
excludedBy: (path) => files.find((f) => f.re.test(path))?.pattern
|
|
438
630
|
};
|
|
439
631
|
}
|
|
440
|
-
|
|
441
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
442
|
-
}
|
|
443
|
-
function comparable(value) {
|
|
444
|
-
if (value instanceof Date) {
|
|
445
|
-
if (Number.isNaN(value.getTime())) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
const iso = value.toISOString();
|
|
449
|
-
return iso.endsWith("T00:00:00.000Z") ? iso.slice(0, 10) : iso.replace(/\.\d{3}Z$/, "Z");
|
|
450
|
-
}
|
|
451
|
-
return value;
|
|
452
|
-
}
|
|
453
|
-
function deepEqual(a, b) {
|
|
454
|
-
if (a === b) {
|
|
455
|
-
return true;
|
|
456
|
-
}
|
|
457
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
458
|
-
return a.length === b.length && a.every((item, i) => deepEqual(comparable(item), comparable(b[i])));
|
|
459
|
-
}
|
|
460
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
461
|
-
const keys = Object.keys(a);
|
|
462
|
-
return keys.length === Object.keys(b).length && keys.every((key) => (key in b) && deepEqual(comparable(a[key]), comparable(b[key])));
|
|
463
|
-
}
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
function sameValue(actual, expected) {
|
|
467
|
-
const a = comparable(actual);
|
|
468
|
-
if (Array.isArray(expected) || isPlainObject(expected)) {
|
|
469
|
-
return deepEqual(a, expected);
|
|
470
|
-
}
|
|
471
|
-
if (Array.isArray(a)) {
|
|
472
|
-
return a.some((item) => comparable(item) === expected);
|
|
473
|
-
}
|
|
474
|
-
return a === expected;
|
|
475
|
-
}
|
|
476
|
-
function readField(data, key) {
|
|
477
|
-
if (Object.hasOwn(data, key)) {
|
|
478
|
-
return data[key];
|
|
479
|
-
}
|
|
480
|
-
if (!key.includes(".")) {
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
return readPath(data, key.split("."));
|
|
484
|
-
}
|
|
485
|
-
function readPath(holder, [part, ...rest]) {
|
|
486
|
-
if (part === undefined || !isPlainObject(holder) || !Object.hasOwn(holder, part)) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
const value = holder[part];
|
|
490
|
-
return rest.length === 0 ? value : readPath(value, rest);
|
|
491
|
-
}
|
|
492
|
-
function order(actual, operand) {
|
|
493
|
-
const a = comparable(actual);
|
|
494
|
-
if (isNumber(a) && isNumber(operand)) {
|
|
495
|
-
return a - operand;
|
|
496
|
-
}
|
|
497
|
-
if (isString(a) && isString(operand)) {
|
|
498
|
-
return a < operand ? -1 : a > operand ? 1 : 0;
|
|
499
|
-
}
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
function operatorTest(where, op, operand) {
|
|
503
|
-
switch (op) {
|
|
504
|
-
case "$eq": {
|
|
505
|
-
return (actual) => sameValue(actual, operand);
|
|
506
|
-
}
|
|
507
|
-
case "$ne": {
|
|
508
|
-
return (actual) => !sameValue(actual, operand);
|
|
509
|
-
}
|
|
510
|
-
case "$in":
|
|
511
|
-
case "$nin": {
|
|
512
|
-
if (!Array.isArray(operand)) {
|
|
513
|
-
throw new TypeError(`${where}.${op}: expected an array, got ${JSON.stringify(operand)}`);
|
|
514
|
-
}
|
|
515
|
-
const hit = (actual) => operand.some((candidate) => sameValue(actual, candidate));
|
|
516
|
-
return op === "$in" ? hit : (actual) => !hit(actual);
|
|
517
|
-
}
|
|
518
|
-
case "$exists": {
|
|
519
|
-
if (!isBoolean(operand)) {
|
|
520
|
-
throw new TypeError(`${where}.$exists: expected true or false, got ${JSON.stringify(operand)}`);
|
|
521
|
-
}
|
|
522
|
-
return (actual) => (actual !== undefined && actual !== null) === operand;
|
|
523
|
-
}
|
|
524
|
-
default: {
|
|
525
|
-
if (!isString(operand) && !isNumber(operand)) {
|
|
526
|
-
throw new TypeError(`${where}.${op}: expected a string or number, got ${JSON.stringify(operand)}`);
|
|
527
|
-
}
|
|
528
|
-
const test = (diff) => op === "$gt" ? diff > 0 : op === "$gte" ? diff >= 0 : op === "$lt" ? diff < 0 : diff <= 0;
|
|
529
|
-
return (actual) => {
|
|
530
|
-
const diff = order(actual, operand);
|
|
531
|
-
return diff !== undefined && test(diff);
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
function operatorKeys(condition) {
|
|
537
|
-
const keys = Object.keys(condition);
|
|
538
|
-
const dollars = keys.filter((key) => key.startsWith("$"));
|
|
539
|
-
if (dollars.length === 0) {
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
|
-
return dollars.length === keys.length ? keys : [];
|
|
543
|
-
}
|
|
544
|
-
function compileCondition(key, condition) {
|
|
545
|
-
const where = `where.${key}`;
|
|
546
|
-
if (!isPlainObject(condition)) {
|
|
547
|
-
return (actual) => sameValue(actual, condition);
|
|
548
|
-
}
|
|
549
|
-
const ops = operatorKeys(condition);
|
|
550
|
-
if (ops === null) {
|
|
551
|
-
return (actual) => deepEqual(comparable(actual), condition);
|
|
552
|
-
}
|
|
553
|
-
if (ops.length === 0) {
|
|
554
|
-
throw new TypeError(`${where}: cannot mix $operators with plain keys in one condition`);
|
|
555
|
-
}
|
|
556
|
-
const tests = ops.map((op) => {
|
|
557
|
-
if (!OPERATORS.has(op)) {
|
|
558
|
-
throw new TypeError(`${where}: unknown operator "${op}" (use ${[...OPERATORS].join(", ")})`);
|
|
559
|
-
}
|
|
560
|
-
return operatorTest(where, op, condition[op]);
|
|
561
|
-
});
|
|
562
|
-
return (actual) => tests.every((test) => test(actual));
|
|
563
|
-
}
|
|
564
|
-
function compileWhere(where) {
|
|
565
|
-
if (where === undefined) {
|
|
566
|
-
return Object.assign(() => true, { why: nothing });
|
|
567
|
-
}
|
|
568
|
-
if (!isPlainObject(where)) {
|
|
569
|
-
throw new TypeError(`"where" must be an object mapping frontmatter fields to conditions`);
|
|
570
|
-
}
|
|
571
|
-
const tests = Object.entries(where).map(([key, condition]) => {
|
|
572
|
-
if (key.startsWith("$")) {
|
|
573
|
-
throw new TypeError(`where.${key}: top-level operators are not supported, conditions on different fields already combine with AND`);
|
|
574
|
-
}
|
|
575
|
-
return { key, test: compileCondition(key, condition) };
|
|
576
|
-
});
|
|
577
|
-
return Object.assign((data) => tests.every(({ key, test }) => test(readField(data, key))), {
|
|
578
|
-
why: (data) => tests.find(({ key, test }) => !test(readField(data, key)))?.key
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
var nothing = () => {}, REGEXP_SPECIAL, MAX_STAR_RUNS = 4, OPERATORS;
|
|
632
|
+
var nothing2 = () => {}, REGEXP_SPECIAL, MAX_STAR_RUNS = 4;
|
|
582
633
|
var init_content_rules = __esm(() => {
|
|
583
634
|
init_guards();
|
|
635
|
+
init_content_query();
|
|
584
636
|
REGEXP_SPECIAL = /[$()*+.?[\\\]^{|}]/g;
|
|
585
|
-
OPERATORS = new Set(["$eq", "$ne", "$in", "$nin", "$exists", "$gt", "$gte", "$lt", "$lte"]);
|
|
586
637
|
});
|
|
587
638
|
|
|
588
639
|
// ../../node_modules/bail/index.js
|
|
@@ -17660,16 +17711,43 @@ function color(d) {
|
|
|
17660
17711
|
}
|
|
17661
17712
|
|
|
17662
17713
|
// ../../node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/lib/index.js
|
|
17663
|
-
function visitParents(tree,
|
|
17714
|
+
function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
|
|
17715
|
+
if (!tree || typeof tree !== "object") {
|
|
17716
|
+
throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
|
|
17717
|
+
}
|
|
17718
|
+
let preorder = true;
|
|
17664
17719
|
let check;
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17720
|
+
let visitors;
|
|
17721
|
+
let enter;
|
|
17722
|
+
let exit;
|
|
17723
|
+
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
17724
|
+
check = testOrEnterOrVisitors;
|
|
17725
|
+
visitors = enterOrVisitorsOrReverse;
|
|
17726
|
+
if (reverse)
|
|
17727
|
+
preorder = false;
|
|
17668
17728
|
} else {
|
|
17669
|
-
|
|
17729
|
+
visitors = testOrEnterOrVisitors;
|
|
17730
|
+
if (enterOrVisitorsOrReverse)
|
|
17731
|
+
preorder = false;
|
|
17732
|
+
}
|
|
17733
|
+
if (typeof visitors === "function") {
|
|
17734
|
+
enter = visitors;
|
|
17735
|
+
} else if (visitors && typeof visitors === "object") {
|
|
17736
|
+
if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
|
|
17737
|
+
enter = visitors.enter;
|
|
17738
|
+
} else {
|
|
17739
|
+
throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
|
|
17740
|
+
}
|
|
17741
|
+
if (typeof visitors.exit === "function") {
|
|
17742
|
+
exit = visitors.exit;
|
|
17743
|
+
} else {
|
|
17744
|
+
throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
|
|
17745
|
+
}
|
|
17746
|
+
} else {
|
|
17747
|
+
throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
|
|
17670
17748
|
}
|
|
17671
17749
|
const is = convert(check);
|
|
17672
|
-
const step =
|
|
17750
|
+
const step = preorder ? 1 : -1;
|
|
17673
17751
|
factory(tree, undefined, [])();
|
|
17674
17752
|
function factory(node, index, parents) {
|
|
17675
17753
|
const value = node && typeof node === "object" ? node : {};
|
|
@@ -17681,12 +17759,10 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
17681
17759
|
}
|
|
17682
17760
|
return visit;
|
|
17683
17761
|
function visit() {
|
|
17762
|
+
const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
|
|
17684
17763
|
let result = empty;
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
let grandparents;
|
|
17688
|
-
if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
|
|
17689
|
-
result = toResult(visitor(node, parents));
|
|
17764
|
+
if (enter && matches) {
|
|
17765
|
+
result = toResult(enter(node, parents, index));
|
|
17690
17766
|
if (result[0] === EXIT) {
|
|
17691
17767
|
return result;
|
|
17692
17768
|
}
|
|
@@ -17694,11 +17770,11 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
17694
17770
|
if ("children" in node && node.children) {
|
|
17695
17771
|
const nodeAsParent = node;
|
|
17696
17772
|
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
17697
|
-
offset = (
|
|
17698
|
-
grandparents = parents
|
|
17773
|
+
let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
|
|
17774
|
+
const grandparents = [...parents, nodeAsParent];
|
|
17699
17775
|
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
17700
17776
|
const child = nodeAsParent.children[offset];
|
|
17701
|
-
subresult = factory(child, offset, grandparents)();
|
|
17777
|
+
const subresult = factory(child, offset, grandparents)();
|
|
17702
17778
|
if (subresult[0] === EXIT) {
|
|
17703
17779
|
return subresult;
|
|
17704
17780
|
}
|
|
@@ -17706,6 +17782,15 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
17706
17782
|
}
|
|
17707
17783
|
}
|
|
17708
17784
|
}
|
|
17785
|
+
if (exit && matches) {
|
|
17786
|
+
const exitResult = toResult(exit(node, parents, index));
|
|
17787
|
+
if (exitResult[0] === SKIP) {
|
|
17788
|
+
throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
|
|
17789
|
+
}
|
|
17790
|
+
if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
|
|
17791
|
+
return exitResult;
|
|
17792
|
+
}
|
|
17793
|
+
}
|
|
17709
17794
|
return result;
|
|
17710
17795
|
}
|
|
17711
17796
|
}
|
|
@@ -17737,30 +17822,20 @@ function findAndReplace(tree, list, options) {
|
|
|
17737
17822
|
const pairs = toPairs(list);
|
|
17738
17823
|
let pairIndex = -1;
|
|
17739
17824
|
while (++pairIndex < pairs.length) {
|
|
17740
|
-
visitParents(tree,
|
|
17825
|
+
visitParents(tree, visitor);
|
|
17741
17826
|
}
|
|
17742
|
-
function visitor(node, parents) {
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
while (++index < parents.length) {
|
|
17746
|
-
const parent = parents[index];
|
|
17747
|
-
const siblings = grandparent ? grandparent.children : undefined;
|
|
17748
|
-
if (ignored(parent, siblings ? siblings.indexOf(parent) : undefined, grandparent)) {
|
|
17749
|
-
return;
|
|
17750
|
-
}
|
|
17751
|
-
grandparent = parent;
|
|
17752
|
-
}
|
|
17753
|
-
if (grandparent) {
|
|
17754
|
-
return handler(node, parents);
|
|
17827
|
+
function visitor(node, parents, index) {
|
|
17828
|
+
if (node.type === "text" && typeof index === "number") {
|
|
17829
|
+
return handler(node, parents, index);
|
|
17755
17830
|
}
|
|
17831
|
+
if (ignored(node, index, parents[parents.length - 1]))
|
|
17832
|
+
return SKIP;
|
|
17756
17833
|
}
|
|
17757
|
-
function handler(node, parents) {
|
|
17834
|
+
function handler(node, parents, index) {
|
|
17758
17835
|
const parent = parents[parents.length - 1];
|
|
17759
17836
|
const find = pairs[pairIndex][0];
|
|
17760
17837
|
const replace = pairs[pairIndex][1];
|
|
17761
17838
|
let start = 0;
|
|
17762
|
-
const siblings = parent.children;
|
|
17763
|
-
const index = siblings.indexOf(node);
|
|
17764
17839
|
let change = false;
|
|
17765
17840
|
let nodes = [];
|
|
17766
17841
|
find.lastIndex = 0;
|
|
@@ -18609,10 +18684,402 @@ function checkEmphasis(state) {
|
|
|
18609
18684
|
return marker;
|
|
18610
18685
|
}
|
|
18611
18686
|
|
|
18687
|
+
// ../../node_modules/mdast-util-to-markdown/lib/util/character.js
|
|
18688
|
+
function firstCharacter(value) {
|
|
18689
|
+
const code = value.codePointAt(0);
|
|
18690
|
+
return code === undefined ? "" : String.fromCodePoint(code);
|
|
18691
|
+
}
|
|
18692
|
+
function lastCharacter(value) {
|
|
18693
|
+
const code = value.codePointAt(value.length - 2);
|
|
18694
|
+
return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
|
|
18695
|
+
}
|
|
18696
|
+
|
|
18697
|
+
// ../../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
18698
|
+
function encodeCharacterReference(code) {
|
|
18699
|
+
return "&#x" + code.toString(16).toUpperCase() + ";";
|
|
18700
|
+
}
|
|
18701
|
+
|
|
18702
|
+
// ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
18703
|
+
function encodeInfo(outside, inside, marker) {
|
|
18704
|
+
const outsideKind = classifyCharacter(outside);
|
|
18705
|
+
const insideKind = classifyCharacter(inside);
|
|
18706
|
+
if (outsideKind === undefined) {
|
|
18707
|
+
return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
|
|
18708
|
+
}
|
|
18709
|
+
if (outsideKind === 1) {
|
|
18710
|
+
return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
|
|
18711
|
+
}
|
|
18712
|
+
return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
|
|
18713
|
+
}
|
|
18714
|
+
var init_encode_info = __esm(() => {
|
|
18715
|
+
init_dev6();
|
|
18716
|
+
});
|
|
18717
|
+
|
|
18718
|
+
// ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
|
|
18719
|
+
function htmlKind(value) {
|
|
18720
|
+
if (value.charCodeAt(0) !== 60)
|
|
18721
|
+
return;
|
|
18722
|
+
const next = value.charCodeAt(1);
|
|
18723
|
+
if (next === 33) {
|
|
18724
|
+
const code = value.charCodeAt(2);
|
|
18725
|
+
if (code === 45)
|
|
18726
|
+
return 2;
|
|
18727
|
+
if (code === 91)
|
|
18728
|
+
return 5;
|
|
18729
|
+
if (asciiAlpha(code))
|
|
18730
|
+
return 4;
|
|
18731
|
+
return;
|
|
18732
|
+
}
|
|
18733
|
+
if (next === 63)
|
|
18734
|
+
return 3;
|
|
18735
|
+
const closing = next === 47;
|
|
18736
|
+
const start = closing ? 2 : 1;
|
|
18737
|
+
let end = start;
|
|
18738
|
+
let code = value.charCodeAt(end);
|
|
18739
|
+
if (!asciiAlpha(code))
|
|
18740
|
+
return;
|
|
18741
|
+
while (code === 45 || asciiAlphanumeric(code)) {
|
|
18742
|
+
code = value.charCodeAt(++end);
|
|
18743
|
+
}
|
|
18744
|
+
const name = value.slice(start, end).toLowerCase();
|
|
18745
|
+
if (!closing && code !== 47 && htmlRawNames.includes(name)) {
|
|
18746
|
+
return 1;
|
|
18747
|
+
}
|
|
18748
|
+
return htmlBlockNames.includes(name) ? 6 : 7;
|
|
18749
|
+
}
|
|
18750
|
+
var init_html_kind = __esm(() => {
|
|
18751
|
+
init_dev4();
|
|
18752
|
+
init_micromark_util_html_tag_name();
|
|
18753
|
+
});
|
|
18754
|
+
|
|
18755
|
+
// ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
|
|
18756
|
+
function candidates(tokens, involved, runOf) {
|
|
18757
|
+
const related = new Set;
|
|
18758
|
+
for (const token of tokens) {
|
|
18759
|
+
const siblings = runOf.get(token);
|
|
18760
|
+
if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
|
|
18761
|
+
for (const sibling of siblings.tokens) {
|
|
18762
|
+
related.add(sibling.attention);
|
|
18763
|
+
}
|
|
18764
|
+
}
|
|
18765
|
+
}
|
|
18766
|
+
const ordered = [];
|
|
18767
|
+
for (const token of tokens) {
|
|
18768
|
+
if (token.attention && related.delete(token.attention)) {
|
|
18769
|
+
ordered.push(token.attention);
|
|
18770
|
+
}
|
|
18771
|
+
}
|
|
18772
|
+
ordered.reverse();
|
|
18773
|
+
return ordered;
|
|
18774
|
+
}
|
|
18775
|
+
function check(tokens, before, after) {
|
|
18776
|
+
const runs = [];
|
|
18777
|
+
const wrong = new Map;
|
|
18778
|
+
const runOf = new Map;
|
|
18779
|
+
let index = 0;
|
|
18780
|
+
while (index < tokens.length) {
|
|
18781
|
+
if (!tokens[index].attention) {
|
|
18782
|
+
index++;
|
|
18783
|
+
continue;
|
|
18784
|
+
}
|
|
18785
|
+
const marker = tokens[index].value.charAt(0);
|
|
18786
|
+
const strict = builtins.get(marker);
|
|
18787
|
+
let end = index + 1;
|
|
18788
|
+
while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
|
|
18789
|
+
end++;
|
|
18790
|
+
}
|
|
18791
|
+
const head = index ? tokens[index - 1].value : before;
|
|
18792
|
+
const previous = classifyCharacter(head.charCodeAt(head.length - 1));
|
|
18793
|
+
const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
|
|
18794
|
+
const open = !next || next === 2 && Boolean(previous);
|
|
18795
|
+
const close = !previous || previous === 2 && Boolean(next);
|
|
18796
|
+
const run = {
|
|
18797
|
+
tokens: tokens.slice(index, end),
|
|
18798
|
+
markers: [],
|
|
18799
|
+
start: 0,
|
|
18800
|
+
end: 0,
|
|
18801
|
+
open: strict ? open && (Boolean(previous) || !close) : open,
|
|
18802
|
+
close: strict ? close && (Boolean(next) || !open) : close,
|
|
18803
|
+
split: strict !== undefined
|
|
18804
|
+
};
|
|
18805
|
+
for (const token of run.tokens) {
|
|
18806
|
+
wrong.set(token, [...run.tokens]);
|
|
18807
|
+
runOf.set(token, run);
|
|
18808
|
+
let size = token.value.length;
|
|
18809
|
+
while (size--)
|
|
18810
|
+
run.markers.push(token);
|
|
18811
|
+
}
|
|
18812
|
+
run.end = run.markers.length;
|
|
18813
|
+
runs.push(run);
|
|
18814
|
+
index = end;
|
|
18815
|
+
}
|
|
18816
|
+
pair(runs, wrong);
|
|
18817
|
+
index = -1;
|
|
18818
|
+
while (++index < tokens.length) {
|
|
18819
|
+
const involved = wrong.get(tokens[index]);
|
|
18820
|
+
if (involved)
|
|
18821
|
+
return { attention: candidates(tokens, involved, runOf), index };
|
|
18822
|
+
}
|
|
18823
|
+
}
|
|
18824
|
+
function containerPhrasing(parent, state, info) {
|
|
18825
|
+
return serialize2(phrasing2(parent, state, info), info.before, info.after);
|
|
18826
|
+
}
|
|
18827
|
+
function encode(tokens, start) {
|
|
18828
|
+
const token = tokens[start ? 0 : tokens.length - 1];
|
|
18829
|
+
if (!token || token.attention)
|
|
18830
|
+
return;
|
|
18831
|
+
const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
|
|
18832
|
+
const reference = encodeCharacterReference(character.codePointAt(0));
|
|
18833
|
+
if (start) {
|
|
18834
|
+
token.value = reference + token.value.slice(character.length);
|
|
18835
|
+
} else {
|
|
18836
|
+
let value = token.value.slice(0, token.value.length - character.length);
|
|
18837
|
+
let escapes = 0;
|
|
18838
|
+
while (value.charCodeAt(value.length - 1 - escapes) === 92) {
|
|
18839
|
+
escapes++;
|
|
18840
|
+
}
|
|
18841
|
+
if (escapes % 2)
|
|
18842
|
+
value += "\\";
|
|
18843
|
+
token.value = value + reference;
|
|
18844
|
+
}
|
|
18845
|
+
}
|
|
18846
|
+
function improve(items, chosen, mistake, before, after) {
|
|
18847
|
+
for (const attention of mistake.attention) {
|
|
18848
|
+
const current = chosen.get(attention) || attention.sequences[0];
|
|
18849
|
+
for (const sequence of attention.sequences) {
|
|
18850
|
+
if (sequence === current)
|
|
18851
|
+
continue;
|
|
18852
|
+
const trial = new Map(chosen);
|
|
18853
|
+
trial.set(attention, sequence);
|
|
18854
|
+
const tokens = render(items, trial, before, after);
|
|
18855
|
+
const next = check(tokens, before, after);
|
|
18856
|
+
if (!next || next.index > mistake.index) {
|
|
18857
|
+
return { chosen: trial, mistake: next, tokens };
|
|
18858
|
+
}
|
|
18859
|
+
}
|
|
18860
|
+
}
|
|
18861
|
+
}
|
|
18862
|
+
function pair(runs, wrong) {
|
|
18863
|
+
const openersByMarker = new Map;
|
|
18864
|
+
for (const closer of runs) {
|
|
18865
|
+
const marker = closer.tokens[0].value.charAt(0);
|
|
18866
|
+
let openers = openersByMarker.get(marker);
|
|
18867
|
+
if (!openers) {
|
|
18868
|
+
openers = [];
|
|
18869
|
+
openersByMarker.set(marker, openers);
|
|
18870
|
+
}
|
|
18871
|
+
let open = closer.close ? openers.length : 0;
|
|
18872
|
+
while (open-- && closer.start < closer.end) {
|
|
18873
|
+
const opener = openers[open];
|
|
18874
|
+
const openerSize = opener.end - opener.start;
|
|
18875
|
+
const closerSize = closer.end - closer.start;
|
|
18876
|
+
if (closer.split ? (opener.close || closer.open) && closerSize % 3 && !((openerSize + closerSize) % 3) : openerSize !== opener.markers.length || openerSize !== closerSize) {
|
|
18877
|
+
continue;
|
|
18878
|
+
}
|
|
18879
|
+
const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
|
|
18880
|
+
const opening = opener.markers.slice(opener.end - size, opener.end);
|
|
18881
|
+
const closing = closer.markers.slice(closer.start, closer.start + size);
|
|
18882
|
+
const openToken = opening[0];
|
|
18883
|
+
const closeToken = closing[0];
|
|
18884
|
+
if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
|
|
18885
|
+
wrong.delete(openToken);
|
|
18886
|
+
wrong.delete(closeToken);
|
|
18887
|
+
} else {
|
|
18888
|
+
const involved = [...new Set([...opening, ...closing])];
|
|
18889
|
+
for (const token of involved) {
|
|
18890
|
+
const list = wrong.get(token);
|
|
18891
|
+
if (list)
|
|
18892
|
+
list.push(...involved);
|
|
18893
|
+
}
|
|
18894
|
+
}
|
|
18895
|
+
opener.end -= size;
|
|
18896
|
+
closer.start += size;
|
|
18897
|
+
if (opener.start === opener.end)
|
|
18898
|
+
openers.splice(open, 1);
|
|
18899
|
+
open = openers.length;
|
|
18900
|
+
}
|
|
18901
|
+
if (closer.open && closer.start < closer.end)
|
|
18902
|
+
openers.push(closer);
|
|
18903
|
+
}
|
|
18904
|
+
}
|
|
18905
|
+
function attentionSequences(type, markers, sizes) {
|
|
18906
|
+
if (markers.length === 0) {
|
|
18907
|
+
throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
|
|
18908
|
+
}
|
|
18909
|
+
if (sizes.length === 0) {
|
|
18910
|
+
throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
|
|
18911
|
+
}
|
|
18912
|
+
for (const size of sizes) {
|
|
18913
|
+
if (!Number.isSafeInteger(size) || size < 1) {
|
|
18914
|
+
throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
|
|
18915
|
+
}
|
|
18916
|
+
}
|
|
18917
|
+
const sequences = [];
|
|
18918
|
+
for (const marker of markers) {
|
|
18919
|
+
if (marker.length !== 1) {
|
|
18920
|
+
throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
|
|
18921
|
+
}
|
|
18922
|
+
if (!asciiPunctuation(marker.charCodeAt(0))) {
|
|
18923
|
+
throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
|
|
18924
|
+
}
|
|
18925
|
+
for (const size of sizes) {
|
|
18926
|
+
sequences.push(marker.repeat(size));
|
|
18927
|
+
}
|
|
18928
|
+
}
|
|
18929
|
+
return sequences;
|
|
18930
|
+
}
|
|
18931
|
+
function phrasing2(parent, state, info) {
|
|
18932
|
+
const indexStack = state.indexStack;
|
|
18933
|
+
const children = parent.children || [];
|
|
18934
|
+
const results = [];
|
|
18935
|
+
let index = -1;
|
|
18936
|
+
let before = info.before;
|
|
18937
|
+
indexStack.push(-1);
|
|
18938
|
+
let tracker = state.createTracker(info);
|
|
18939
|
+
while (++index < children.length) {
|
|
18940
|
+
const child = children[index];
|
|
18941
|
+
let after;
|
|
18942
|
+
indexStack[indexStack.length - 1] = index;
|
|
18943
|
+
if (index + 1 < children.length) {
|
|
18944
|
+
let handle = state.handle.handlers[children[index + 1].type];
|
|
18945
|
+
if (handle && handle.peek)
|
|
18946
|
+
handle = handle.peek;
|
|
18947
|
+
after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
|
|
18948
|
+
before: "",
|
|
18949
|
+
after: "",
|
|
18950
|
+
...tracker.current()
|
|
18951
|
+
})) : "";
|
|
18952
|
+
} else {
|
|
18953
|
+
after = info.after;
|
|
18954
|
+
}
|
|
18955
|
+
const previous = results[results.length - 1];
|
|
18956
|
+
if (typeof previous === "string" && (before === "\r" || before === `
|
|
18957
|
+
`) && child.type === "html" && htmlKind(child.value) !== 7) {
|
|
18958
|
+
results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
|
|
18959
|
+
before = " ";
|
|
18960
|
+
tracker = state.createTracker(info);
|
|
18961
|
+
tracker.move(serialize2(results, info.before, info.after));
|
|
18962
|
+
}
|
|
18963
|
+
const handle = state.handle.handlers[child.type];
|
|
18964
|
+
if (handle && handle.attention) {
|
|
18965
|
+
const item = attentionItem(child, handle.attention, state, tracker);
|
|
18966
|
+
results.push(item);
|
|
18967
|
+
before = lastCharacter(item.sequences[0]);
|
|
18968
|
+
} else {
|
|
18969
|
+
const value = state.handle(child, parent, state, {
|
|
18970
|
+
...tracker.current(),
|
|
18971
|
+
after,
|
|
18972
|
+
before
|
|
18973
|
+
});
|
|
18974
|
+
if (!value)
|
|
18975
|
+
continue;
|
|
18976
|
+
tracker.move(value);
|
|
18977
|
+
results.push(value);
|
|
18978
|
+
before = lastCharacter(value);
|
|
18979
|
+
}
|
|
18980
|
+
}
|
|
18981
|
+
indexStack.pop();
|
|
18982
|
+
return results;
|
|
18983
|
+
}
|
|
18984
|
+
function attentionItem(node, attention, state, tracker) {
|
|
18985
|
+
const { construct, markers, sizes } = attention(node, state);
|
|
18986
|
+
const sequences = attentionSequences(node.type, markers, sizes);
|
|
18987
|
+
const sequence = sequences[0];
|
|
18988
|
+
const exit = state.enter(construct);
|
|
18989
|
+
tracker.move(sequence);
|
|
18990
|
+
const children = phrasing2(node, state, {
|
|
18991
|
+
...tracker.current(),
|
|
18992
|
+
before: sequence,
|
|
18993
|
+
after: sequence
|
|
18994
|
+
});
|
|
18995
|
+
tracker.move(serialize2(children, sequence, sequence));
|
|
18996
|
+
tracker.move(sequence);
|
|
18997
|
+
exit();
|
|
18998
|
+
return { children, sequences };
|
|
18999
|
+
}
|
|
19000
|
+
function render(items, chosen, before, after) {
|
|
19001
|
+
const tokens = [];
|
|
19002
|
+
let encodeAfter;
|
|
19003
|
+
let previous = lastCharacter(before);
|
|
19004
|
+
let index = -1;
|
|
19005
|
+
while (++index < items.length) {
|
|
19006
|
+
const item = items[index];
|
|
19007
|
+
if (typeof item === "string") {
|
|
19008
|
+
const token = { value: item, attention: undefined };
|
|
19009
|
+
if (encodeAfter && encodeAfter === firstCharacter(item)) {
|
|
19010
|
+
encode([token], true);
|
|
19011
|
+
}
|
|
19012
|
+
encodeAfter = undefined;
|
|
19013
|
+
tokens.push(token);
|
|
19014
|
+
if (token.value)
|
|
19015
|
+
previous = lastCharacter(token.value);
|
|
19016
|
+
continue;
|
|
19017
|
+
}
|
|
19018
|
+
const sequence = chosen.get(item) || item.sequences[0];
|
|
19019
|
+
const marker = sequence.charAt(0);
|
|
19020
|
+
const next = items[index + 1];
|
|
19021
|
+
const outsideBefore = previous;
|
|
19022
|
+
const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
|
|
19023
|
+
const inside = render(item.children, chosen, sequence, sequence);
|
|
19024
|
+
const head = inside.length > 0 ? inside[0].value : "";
|
|
19025
|
+
const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
|
|
19026
|
+
if (open.inside)
|
|
19027
|
+
encode(inside, true);
|
|
19028
|
+
const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
|
|
19029
|
+
const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
|
|
19030
|
+
if (close.inside)
|
|
19031
|
+
encode(inside, false);
|
|
19032
|
+
if (open.outside && outsideBefore !== `
|
|
19033
|
+
` && outsideBefore !== "\r") {
|
|
19034
|
+
encode(tokens, false);
|
|
19035
|
+
}
|
|
19036
|
+
if (close.outside)
|
|
19037
|
+
encodeAfter = outsideAfter;
|
|
19038
|
+
tokens.push({ value: sequence, attention: item }, ...inside, {
|
|
19039
|
+
value: sequence,
|
|
19040
|
+
attention: item
|
|
19041
|
+
});
|
|
19042
|
+
previous = sequence.charAt(sequence.length - 1);
|
|
19043
|
+
}
|
|
19044
|
+
return tokens;
|
|
19045
|
+
}
|
|
19046
|
+
function serialize2(items, before, after) {
|
|
19047
|
+
let chosen = new Map;
|
|
19048
|
+
const initial = render(items, chosen, before, after);
|
|
19049
|
+
let tokens = initial;
|
|
19050
|
+
let mistake = check(tokens, before, after);
|
|
19051
|
+
while (mistake) {
|
|
19052
|
+
const next = improve(items, chosen, mistake, before, after);
|
|
19053
|
+
if (!next) {
|
|
19054
|
+
tokens = initial;
|
|
19055
|
+
break;
|
|
19056
|
+
}
|
|
19057
|
+
chosen = next.chosen;
|
|
19058
|
+
tokens = next.tokens;
|
|
19059
|
+
mistake = next.mistake;
|
|
19060
|
+
}
|
|
19061
|
+
let result = "";
|
|
19062
|
+
for (const token of tokens)
|
|
19063
|
+
result += token.value;
|
|
19064
|
+
return result;
|
|
19065
|
+
}
|
|
19066
|
+
var builtins;
|
|
19067
|
+
var init_container_phrasing = __esm(() => {
|
|
19068
|
+
init_dev4();
|
|
19069
|
+
init_dev6();
|
|
19070
|
+
init_encode_info();
|
|
19071
|
+
init_html_kind();
|
|
19072
|
+
builtins = new Map([
|
|
19073
|
+
["*", false],
|
|
19074
|
+
["_", true]
|
|
19075
|
+
]);
|
|
19076
|
+
});
|
|
19077
|
+
|
|
18612
19078
|
// ../../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
18613
19079
|
function emphasis(node, _, state, info) {
|
|
18614
19080
|
const exit = state.enter("phrasing");
|
|
18615
|
-
const
|
|
19081
|
+
const item = attentionItem(node, attention2, state, state.createTracker(info));
|
|
19082
|
+
const value = serialize2([item], info.before, info.after);
|
|
18616
19083
|
exit();
|
|
18617
19084
|
return value;
|
|
18618
19085
|
}
|
|
@@ -18628,15 +19095,11 @@ function peek(_, _1, state) {
|
|
|
18628
19095
|
return state.options.emphasis || "*";
|
|
18629
19096
|
}
|
|
18630
19097
|
var init_emphasis = __esm(() => {
|
|
19098
|
+
init_container_phrasing();
|
|
18631
19099
|
emphasis.attention = attention2;
|
|
18632
19100
|
emphasis.peek = peek;
|
|
18633
19101
|
});
|
|
18634
19102
|
|
|
18635
|
-
// ../../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
18636
|
-
function encodeCharacterReference(code) {
|
|
18637
|
-
return "&#x" + code.toString(16).toUpperCase() + ";";
|
|
18638
|
-
}
|
|
18639
|
-
|
|
18640
19103
|
// ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/color.node.js
|
|
18641
19104
|
function color2(d) {
|
|
18642
19105
|
return "\x1B[33m" + d + "\x1B[39m";
|
|
@@ -19021,14 +19484,27 @@ function link(node, _, state, info) {
|
|
|
19021
19484
|
const exit = state.enter("link");
|
|
19022
19485
|
let subexit = state.enter("label");
|
|
19023
19486
|
let value = tracker.move("[");
|
|
19024
|
-
|
|
19487
|
+
const text = state.containerPhrasing(node, {
|
|
19025
19488
|
before: value,
|
|
19026
19489
|
after: "](",
|
|
19027
19490
|
...tracker.current()
|
|
19028
|
-
})
|
|
19029
|
-
value += tracker.move(
|
|
19491
|
+
});
|
|
19492
|
+
value += tracker.move(text);
|
|
19030
19493
|
subexit();
|
|
19031
|
-
|
|
19494
|
+
value += tracker.move("](");
|
|
19495
|
+
const enclose = /[\0- \u007F]/.test(node.url);
|
|
19496
|
+
const last = info.before.charAt(info.before.length - 1);
|
|
19497
|
+
let title = node.title || undefined;
|
|
19498
|
+
if (!title && !enclose && (last === `
|
|
19499
|
+
` || last === "\r")) {
|
|
19500
|
+
let index = 0;
|
|
19501
|
+
while (index < text.length && text.charCodeAt(index) !== 93) {
|
|
19502
|
+
index += text.charCodeAt(index) === 92 ? 2 : 1;
|
|
19503
|
+
}
|
|
19504
|
+
if (text.charCodeAt(index + 1) === 58)
|
|
19505
|
+
title = "";
|
|
19506
|
+
}
|
|
19507
|
+
if (!node.url && typeof title === "string" || enclose) {
|
|
19032
19508
|
subexit = state.enter("destinationLiteral");
|
|
19033
19509
|
value += tracker.move("<");
|
|
19034
19510
|
value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
|
|
@@ -19037,15 +19513,15 @@ function link(node, _, state, info) {
|
|
|
19037
19513
|
subexit = state.enter("destinationRaw");
|
|
19038
19514
|
value += tracker.move(state.safe(node.url, {
|
|
19039
19515
|
before: value,
|
|
19040
|
-
after:
|
|
19516
|
+
after: typeof title === "string" ? " " : ")",
|
|
19041
19517
|
...tracker.current()
|
|
19042
19518
|
}));
|
|
19043
19519
|
}
|
|
19044
19520
|
subexit();
|
|
19045
|
-
if (
|
|
19521
|
+
if (typeof title === "string") {
|
|
19046
19522
|
subexit = state.enter(`title${suffix}`);
|
|
19047
19523
|
value += tracker.move(" " + quote);
|
|
19048
|
-
value += tracker.move(state.safe(
|
|
19524
|
+
value += tracker.move(state.safe(title, {
|
|
19049
19525
|
before: value,
|
|
19050
19526
|
after: quote,
|
|
19051
19527
|
...tracker.current()
|
|
@@ -19263,7 +19739,8 @@ function checkStrong(state) {
|
|
|
19263
19739
|
// ../../node_modules/mdast-util-to-markdown/lib/handle/strong.js
|
|
19264
19740
|
function strong(node, _, state, info) {
|
|
19265
19741
|
const exit = state.enter("phrasing");
|
|
19266
|
-
const
|
|
19742
|
+
const item = attentionItem(node, attention3, state, state.createTracker(info));
|
|
19743
|
+
const value = serialize2([item], info.before, info.after);
|
|
19267
19744
|
exit();
|
|
19268
19745
|
return value;
|
|
19269
19746
|
}
|
|
@@ -19279,6 +19756,7 @@ function peek2(_, _1, state) {
|
|
|
19279
19756
|
return state.options.strong || "*";
|
|
19280
19757
|
}
|
|
19281
19758
|
var init_strong = __esm(() => {
|
|
19759
|
+
init_container_phrasing();
|
|
19282
19760
|
strong.attention = attention3;
|
|
19283
19761
|
strong.peek = peek2;
|
|
19284
19762
|
});
|
|
@@ -19286,7 +19764,7 @@ var init_strong = __esm(() => {
|
|
|
19286
19764
|
// ../../node_modules/mdast-util-to-markdown/lib/handle/text.js
|
|
19287
19765
|
function text3(node, parent, state, info) {
|
|
19288
19766
|
const siblings = parent ? parent.children : [];
|
|
19289
|
-
const index =
|
|
19767
|
+
const index = state.indexStack[state.indexStack.length - 1];
|
|
19290
19768
|
return state.safe(node.value, {
|
|
19291
19769
|
...info,
|
|
19292
19770
|
afterNode: siblings[index + 1],
|
|
@@ -19353,63 +19831,44 @@ var init_handle = __esm(() => {
|
|
|
19353
19831
|
};
|
|
19354
19832
|
});
|
|
19355
19833
|
|
|
19356
|
-
// ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
|
|
19357
|
-
function htmlKind(value) {
|
|
19358
|
-
if (value.charCodeAt(0) !== 60)
|
|
19359
|
-
return;
|
|
19360
|
-
const next = value.charCodeAt(1);
|
|
19361
|
-
if (next === 33) {
|
|
19362
|
-
const code = value.charCodeAt(2);
|
|
19363
|
-
if (code === 45)
|
|
19364
|
-
return 2;
|
|
19365
|
-
if (code === 91)
|
|
19366
|
-
return 5;
|
|
19367
|
-
if (asciiAlpha(code))
|
|
19368
|
-
return 4;
|
|
19369
|
-
return;
|
|
19370
|
-
}
|
|
19371
|
-
if (next === 63)
|
|
19372
|
-
return 3;
|
|
19373
|
-
const closing = next === 47;
|
|
19374
|
-
const start = closing ? 2 : 1;
|
|
19375
|
-
let end = start;
|
|
19376
|
-
let code = value.charCodeAt(end);
|
|
19377
|
-
if (!asciiAlpha(code))
|
|
19378
|
-
return;
|
|
19379
|
-
while (code === 45 || asciiAlphanumeric(code)) {
|
|
19380
|
-
code = value.charCodeAt(++end);
|
|
19381
|
-
}
|
|
19382
|
-
const name = value.slice(start, end).toLowerCase();
|
|
19383
|
-
if (!closing && code !== 47 && htmlRawNames.includes(name)) {
|
|
19384
|
-
return 1;
|
|
19385
|
-
}
|
|
19386
|
-
return htmlBlockNames.includes(name) ? 6 : 7;
|
|
19387
|
-
}
|
|
19388
|
-
var init_html_kind = __esm(() => {
|
|
19389
|
-
init_dev4();
|
|
19390
|
-
init_micromark_util_html_tag_name();
|
|
19391
|
-
});
|
|
19392
|
-
|
|
19393
19834
|
// ../../node_modules/mdast-util-to-markdown/lib/join.js
|
|
19394
19835
|
function joinDefaults(left, right, parent, state) {
|
|
19395
19836
|
if (right.type === "code" && formatCodeAsIndented(right, state) && (left.type === "list" || left.type === right.type && formatCodeAsIndented(left, state))) {
|
|
19396
19837
|
return false;
|
|
19397
19838
|
}
|
|
19398
19839
|
if ("spread" in parent && typeof parent.spread === "boolean") {
|
|
19399
|
-
if (
|
|
19400
|
-
return;
|
|
19401
|
-
}
|
|
19840
|
+
if (parent.spread)
|
|
19841
|
+
return 1;
|
|
19402
19842
|
if (left.type === "html") {
|
|
19403
19843
|
const kind = htmlKind(left.value);
|
|
19404
19844
|
if (kind === undefined || kind === 6 || kind === 7)
|
|
19405
19845
|
return 1;
|
|
19406
19846
|
}
|
|
19407
|
-
if (left.type === "
|
|
19847
|
+
if (left.type === "blockquote" && right.type === "blockquote")
|
|
19848
|
+
return 1;
|
|
19849
|
+
if ((left.type === "definition" || left.type === "paragraph") && right.type === "list" && (right.ordered && typeof right.start === "number" && right.start !== 1 || right.children.length > 0 && right.children[0].children.length === 0)) {
|
|
19850
|
+
return 1;
|
|
19851
|
+
}
|
|
19852
|
+
if (left.type === "paragraph" && right.type === "thematicBreak" && checkRule(state) === "-" && !state.options.ruleSpaces) {
|
|
19853
|
+
return 1;
|
|
19854
|
+
}
|
|
19855
|
+
let tail = left;
|
|
19856
|
+
while ((tail.type === "blockquote" || tail.type === "list" || tail.type === "listItem") && tail.children.length > 0) {
|
|
19857
|
+
tail = tail.children[tail.children.length - 1];
|
|
19858
|
+
}
|
|
19859
|
+
if (tail.type !== "definition" && tail.type !== "paragraph")
|
|
19860
|
+
return 0;
|
|
19861
|
+
if (right.type === "code" && formatCodeAsIndented(right, state))
|
|
19862
|
+
return 1;
|
|
19863
|
+
if (right.type === "html") {
|
|
19408
19864
|
const kind = htmlKind(right.value);
|
|
19409
19865
|
if (kind === undefined || kind === 7)
|
|
19410
19866
|
return 1;
|
|
19411
19867
|
}
|
|
19412
|
-
|
|
19868
|
+
if ((left.type === "paragraph" || left !== tail) && (right.type === "definition" || right.type === "heading" && formatHeadingAsSetext(right, state) || right.type === "paragraph")) {
|
|
19869
|
+
return 1;
|
|
19870
|
+
}
|
|
19871
|
+
return 0;
|
|
19413
19872
|
}
|
|
19414
19873
|
}
|
|
19415
19874
|
var join;
|
|
@@ -19482,7 +19941,21 @@ var init_unsafe = __esm(() => {
|
|
|
19482
19941
|
{ atBreak: true, character: "#" },
|
|
19483
19942
|
{ character: "#", inConstruct: "headingAtx", after: `(?:[\r
|
|
19484
19943
|
]|$)` },
|
|
19485
|
-
{
|
|
19944
|
+
{
|
|
19945
|
+
character: "&",
|
|
19946
|
+
after: "[#A-Za-z]",
|
|
19947
|
+
inConstruct: [
|
|
19948
|
+
"codeFencedLangGraveAccent",
|
|
19949
|
+
"codeFencedLangTilde",
|
|
19950
|
+
"codeFencedMetaGraveAccent",
|
|
19951
|
+
"codeFencedMetaTilde",
|
|
19952
|
+
"destinationLiteral",
|
|
19953
|
+
"destinationRaw",
|
|
19954
|
+
"phrasing",
|
|
19955
|
+
"titleApostrophe",
|
|
19956
|
+
"titleQuote"
|
|
19957
|
+
]
|
|
19958
|
+
},
|
|
19486
19959
|
{ character: "'", inConstruct: "titleApostrophe" },
|
|
19487
19960
|
{ character: "(", inConstruct: "destinationRaw" },
|
|
19488
19961
|
{
|
|
@@ -19556,333 +20029,6 @@ function compilePattern(pattern) {
|
|
|
19556
20029
|
return pattern._compiled;
|
|
19557
20030
|
}
|
|
19558
20031
|
|
|
19559
|
-
// ../../node_modules/mdast-util-to-markdown/lib/util/character.js
|
|
19560
|
-
function firstCharacter(value) {
|
|
19561
|
-
const code = value.codePointAt(0);
|
|
19562
|
-
return code === undefined ? "" : String.fromCodePoint(code);
|
|
19563
|
-
}
|
|
19564
|
-
function lastCharacter(value) {
|
|
19565
|
-
const code = value.codePointAt(value.length - 2);
|
|
19566
|
-
return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
|
|
19567
|
-
}
|
|
19568
|
-
|
|
19569
|
-
// ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
19570
|
-
function encodeInfo(outside, inside, marker) {
|
|
19571
|
-
const outsideKind = classifyCharacter(outside);
|
|
19572
|
-
const insideKind = classifyCharacter(inside);
|
|
19573
|
-
if (outsideKind === undefined) {
|
|
19574
|
-
return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
|
|
19575
|
-
}
|
|
19576
|
-
if (outsideKind === 1) {
|
|
19577
|
-
return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
|
|
19578
|
-
}
|
|
19579
|
-
return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
|
|
19580
|
-
}
|
|
19581
|
-
var init_encode_info = __esm(() => {
|
|
19582
|
-
init_dev6();
|
|
19583
|
-
});
|
|
19584
|
-
|
|
19585
|
-
// ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
|
|
19586
|
-
function candidates(tokens, involved, runOf) {
|
|
19587
|
-
const related = new Set;
|
|
19588
|
-
for (const token of tokens) {
|
|
19589
|
-
const siblings = runOf.get(token);
|
|
19590
|
-
if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
|
|
19591
|
-
for (const sibling of siblings.tokens) {
|
|
19592
|
-
related.add(sibling.attention);
|
|
19593
|
-
}
|
|
19594
|
-
}
|
|
19595
|
-
}
|
|
19596
|
-
const ordered = [];
|
|
19597
|
-
for (const token of tokens) {
|
|
19598
|
-
if (token.attention && related.delete(token.attention)) {
|
|
19599
|
-
ordered.push(token.attention);
|
|
19600
|
-
}
|
|
19601
|
-
}
|
|
19602
|
-
ordered.reverse();
|
|
19603
|
-
return ordered;
|
|
19604
|
-
}
|
|
19605
|
-
function check(tokens, before, after) {
|
|
19606
|
-
const runs = [];
|
|
19607
|
-
const wrong = new Map;
|
|
19608
|
-
const runOf = new Map;
|
|
19609
|
-
let index = 0;
|
|
19610
|
-
while (index < tokens.length) {
|
|
19611
|
-
if (!tokens[index].attention) {
|
|
19612
|
-
index++;
|
|
19613
|
-
continue;
|
|
19614
|
-
}
|
|
19615
|
-
const marker = tokens[index].value.charAt(0);
|
|
19616
|
-
const strict = builtins.get(marker);
|
|
19617
|
-
let end = index + 1;
|
|
19618
|
-
while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
|
|
19619
|
-
end++;
|
|
19620
|
-
}
|
|
19621
|
-
const head = index ? tokens[index - 1].value : before;
|
|
19622
|
-
const previous = classifyCharacter(head.charCodeAt(head.length - 1));
|
|
19623
|
-
const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
|
|
19624
|
-
const open = !next || next === 2 && Boolean(previous);
|
|
19625
|
-
const close = !previous || previous === 2 && Boolean(next);
|
|
19626
|
-
const run = {
|
|
19627
|
-
tokens: tokens.slice(index, end),
|
|
19628
|
-
markers: [],
|
|
19629
|
-
start: 0,
|
|
19630
|
-
end: 0,
|
|
19631
|
-
open: strict ? open && (Boolean(previous) || !close) : open,
|
|
19632
|
-
close: strict ? close && (Boolean(next) || !open) : close,
|
|
19633
|
-
split: strict !== undefined
|
|
19634
|
-
};
|
|
19635
|
-
for (const token of run.tokens) {
|
|
19636
|
-
wrong.set(token, [...run.tokens]);
|
|
19637
|
-
runOf.set(token, run);
|
|
19638
|
-
let size = token.value.length;
|
|
19639
|
-
while (size--)
|
|
19640
|
-
run.markers.push(token);
|
|
19641
|
-
}
|
|
19642
|
-
run.end = run.markers.length;
|
|
19643
|
-
runs.push(run);
|
|
19644
|
-
index = end;
|
|
19645
|
-
}
|
|
19646
|
-
pair(runs, wrong);
|
|
19647
|
-
index = -1;
|
|
19648
|
-
while (++index < tokens.length) {
|
|
19649
|
-
const involved = wrong.get(tokens[index]);
|
|
19650
|
-
if (involved)
|
|
19651
|
-
return { attention: candidates(tokens, involved, runOf), index };
|
|
19652
|
-
}
|
|
19653
|
-
}
|
|
19654
|
-
function containerPhrasing(parent, state, info) {
|
|
19655
|
-
return serialize2(phrasing2(parent, state, info), info.before, info.after);
|
|
19656
|
-
}
|
|
19657
|
-
function encode(tokens, start) {
|
|
19658
|
-
const token = tokens[start ? 0 : tokens.length - 1];
|
|
19659
|
-
if (!token || token.attention)
|
|
19660
|
-
return;
|
|
19661
|
-
const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
|
|
19662
|
-
const reference = encodeCharacterReference(character.codePointAt(0));
|
|
19663
|
-
token.value = start ? reference + token.value.slice(character.length) : token.value.slice(0, token.value.length - character.length) + reference;
|
|
19664
|
-
}
|
|
19665
|
-
function improve(items, chosen, mistake, before, after) {
|
|
19666
|
-
for (const attention of mistake.attention) {
|
|
19667
|
-
const current = chosen.get(attention) || attention.sequences[0];
|
|
19668
|
-
for (const sequence of attention.sequences) {
|
|
19669
|
-
if (sequence === current)
|
|
19670
|
-
continue;
|
|
19671
|
-
const trial = new Map(chosen);
|
|
19672
|
-
trial.set(attention, sequence);
|
|
19673
|
-
const tokens = render(items, trial, before, after);
|
|
19674
|
-
const next = check(tokens, before, after);
|
|
19675
|
-
if (!next || next.index > mistake.index) {
|
|
19676
|
-
return { chosen: trial, mistake: next, tokens };
|
|
19677
|
-
}
|
|
19678
|
-
}
|
|
19679
|
-
}
|
|
19680
|
-
}
|
|
19681
|
-
function pair(runs, wrong) {
|
|
19682
|
-
let index = 0;
|
|
19683
|
-
while (index < runs.length) {
|
|
19684
|
-
const closer = runs[index];
|
|
19685
|
-
const marker = closer.tokens[0].value.charAt(0);
|
|
19686
|
-
const closerSize = closer.end - closer.start;
|
|
19687
|
-
let open = closer.close && closerSize ? index : 0;
|
|
19688
|
-
while (open--) {
|
|
19689
|
-
const opener = runs[open];
|
|
19690
|
-
const openerSize = opener.end - opener.start;
|
|
19691
|
-
if (opener.tokens[0].value.charAt(0) === marker && opener.open && openerSize && (closer.split ? !((opener.close || closer.open) && closerSize % 3) || (openerSize + closerSize) % 3 : openerSize === opener.markers.length && openerSize === closerSize)) {
|
|
19692
|
-
const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
|
|
19693
|
-
const opening = opener.markers.slice(opener.end - size, opener.end);
|
|
19694
|
-
const closing = closer.markers.slice(closer.start, closer.start + size);
|
|
19695
|
-
const openToken = opening[0];
|
|
19696
|
-
const closeToken = closing[0];
|
|
19697
|
-
if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
|
|
19698
|
-
wrong.delete(openToken);
|
|
19699
|
-
wrong.delete(closeToken);
|
|
19700
|
-
} else {
|
|
19701
|
-
const involved = [...new Set([...opening, ...closing])];
|
|
19702
|
-
for (const token of involved) {
|
|
19703
|
-
const list = wrong.get(token);
|
|
19704
|
-
if (list)
|
|
19705
|
-
list.push(...involved);
|
|
19706
|
-
}
|
|
19707
|
-
}
|
|
19708
|
-
opener.end -= size;
|
|
19709
|
-
closer.start += size;
|
|
19710
|
-
break;
|
|
19711
|
-
}
|
|
19712
|
-
}
|
|
19713
|
-
if (open === -1 || closer.start === closer.end)
|
|
19714
|
-
index++;
|
|
19715
|
-
}
|
|
19716
|
-
}
|
|
19717
|
-
function attentionSequences(type, markers, sizes) {
|
|
19718
|
-
if (markers.length === 0) {
|
|
19719
|
-
throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
|
|
19720
|
-
}
|
|
19721
|
-
if (sizes.length === 0) {
|
|
19722
|
-
throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
|
|
19723
|
-
}
|
|
19724
|
-
for (const size of sizes) {
|
|
19725
|
-
if (!Number.isSafeInteger(size) || size < 1) {
|
|
19726
|
-
throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
|
|
19727
|
-
}
|
|
19728
|
-
}
|
|
19729
|
-
const sequences = [];
|
|
19730
|
-
for (const marker of markers) {
|
|
19731
|
-
if (marker.length !== 1) {
|
|
19732
|
-
throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
|
|
19733
|
-
}
|
|
19734
|
-
if (!asciiPunctuation(marker.charCodeAt(0))) {
|
|
19735
|
-
throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
|
|
19736
|
-
}
|
|
19737
|
-
for (const size of sizes) {
|
|
19738
|
-
sequences.push(marker.repeat(size));
|
|
19739
|
-
}
|
|
19740
|
-
}
|
|
19741
|
-
return sequences;
|
|
19742
|
-
}
|
|
19743
|
-
function phrasing2(parent, state, info) {
|
|
19744
|
-
const indexStack = state.indexStack;
|
|
19745
|
-
const children = parent.children || [];
|
|
19746
|
-
const results = [];
|
|
19747
|
-
let index = -1;
|
|
19748
|
-
let before = info.before;
|
|
19749
|
-
indexStack.push(-1);
|
|
19750
|
-
let tracker = state.createTracker(info);
|
|
19751
|
-
while (++index < children.length) {
|
|
19752
|
-
const child = children[index];
|
|
19753
|
-
let after;
|
|
19754
|
-
indexStack[indexStack.length - 1] = index;
|
|
19755
|
-
if (index + 1 < children.length) {
|
|
19756
|
-
let handle = state.handle.handlers[children[index + 1].type];
|
|
19757
|
-
if (handle && handle.peek)
|
|
19758
|
-
handle = handle.peek;
|
|
19759
|
-
after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
|
|
19760
|
-
before: "",
|
|
19761
|
-
after: "",
|
|
19762
|
-
...tracker.current()
|
|
19763
|
-
})) : "";
|
|
19764
|
-
} else {
|
|
19765
|
-
after = info.after;
|
|
19766
|
-
}
|
|
19767
|
-
const previous = results[results.length - 1];
|
|
19768
|
-
if (typeof previous === "string" && (before === "\r" || before === `
|
|
19769
|
-
`) && child.type === "html" && htmlKind(child.value) !== 7) {
|
|
19770
|
-
results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
|
|
19771
|
-
before = " ";
|
|
19772
|
-
tracker = state.createTracker(info);
|
|
19773
|
-
tracker.move(serialize2(results, info.before, info.after));
|
|
19774
|
-
}
|
|
19775
|
-
const handle = state.handle.handlers[child.type];
|
|
19776
|
-
if (handle && handle.attention) {
|
|
19777
|
-
const { construct, markers, sizes } = handle.attention(child, state);
|
|
19778
|
-
const sequences = attentionSequences(child.type, markers, sizes);
|
|
19779
|
-
const sequence = sequences[0];
|
|
19780
|
-
const exit = state.enter(construct);
|
|
19781
|
-
tracker.move(sequence);
|
|
19782
|
-
const inside = phrasing2(child, state, {
|
|
19783
|
-
...tracker.current(),
|
|
19784
|
-
before: sequence,
|
|
19785
|
-
after: sequence
|
|
19786
|
-
});
|
|
19787
|
-
tracker.move(serialize2(inside, sequence, sequence));
|
|
19788
|
-
tracker.move(sequence);
|
|
19789
|
-
exit();
|
|
19790
|
-
results.push({ children: inside, sequences });
|
|
19791
|
-
before = sequence.charAt(sequence.length - 1);
|
|
19792
|
-
} else {
|
|
19793
|
-
const value = state.handle(child, parent, state, {
|
|
19794
|
-
...tracker.current(),
|
|
19795
|
-
after,
|
|
19796
|
-
before
|
|
19797
|
-
});
|
|
19798
|
-
if (!value)
|
|
19799
|
-
continue;
|
|
19800
|
-
tracker.move(value);
|
|
19801
|
-
results.push(value);
|
|
19802
|
-
before = lastCharacter(value);
|
|
19803
|
-
}
|
|
19804
|
-
}
|
|
19805
|
-
indexStack.pop();
|
|
19806
|
-
return results;
|
|
19807
|
-
}
|
|
19808
|
-
function render(items, chosen, before, after) {
|
|
19809
|
-
const tokens = [];
|
|
19810
|
-
let encodeAfter;
|
|
19811
|
-
let previous = lastCharacter(before);
|
|
19812
|
-
let index = -1;
|
|
19813
|
-
while (++index < items.length) {
|
|
19814
|
-
const item = items[index];
|
|
19815
|
-
if (typeof item === "string") {
|
|
19816
|
-
const token = { value: item, attention: undefined };
|
|
19817
|
-
if (encodeAfter && encodeAfter === firstCharacter(item)) {
|
|
19818
|
-
encode([token], true);
|
|
19819
|
-
}
|
|
19820
|
-
encodeAfter = undefined;
|
|
19821
|
-
tokens.push(token);
|
|
19822
|
-
if (token.value)
|
|
19823
|
-
previous = lastCharacter(token.value);
|
|
19824
|
-
continue;
|
|
19825
|
-
}
|
|
19826
|
-
const sequence = chosen.get(item) || item.sequences[0];
|
|
19827
|
-
const marker = sequence.charAt(0);
|
|
19828
|
-
const next = items[index + 1];
|
|
19829
|
-
const outsideBefore = previous;
|
|
19830
|
-
const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
|
|
19831
|
-
const inside = render(item.children, chosen, sequence, sequence);
|
|
19832
|
-
const head = inside.length > 0 ? inside[0].value : "";
|
|
19833
|
-
const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
|
|
19834
|
-
if (open.inside)
|
|
19835
|
-
encode(inside, true);
|
|
19836
|
-
const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
|
|
19837
|
-
const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
|
|
19838
|
-
if (close.inside)
|
|
19839
|
-
encode(inside, false);
|
|
19840
|
-
if (open.outside && outsideBefore !== `
|
|
19841
|
-
` && outsideBefore !== "\r") {
|
|
19842
|
-
encode(tokens, false);
|
|
19843
|
-
}
|
|
19844
|
-
if (close.outside)
|
|
19845
|
-
encodeAfter = outsideAfter;
|
|
19846
|
-
tokens.push({ value: sequence, attention: item }, ...inside, {
|
|
19847
|
-
value: sequence,
|
|
19848
|
-
attention: item
|
|
19849
|
-
});
|
|
19850
|
-
previous = sequence.charAt(sequence.length - 1);
|
|
19851
|
-
}
|
|
19852
|
-
return tokens;
|
|
19853
|
-
}
|
|
19854
|
-
function serialize2(items, before, after) {
|
|
19855
|
-
let chosen = new Map;
|
|
19856
|
-
const initial = render(items, chosen, before, after);
|
|
19857
|
-
let tokens = initial;
|
|
19858
|
-
let mistake = check(tokens, before, after);
|
|
19859
|
-
while (mistake) {
|
|
19860
|
-
const next = improve(items, chosen, mistake, before, after);
|
|
19861
|
-
if (!next) {
|
|
19862
|
-
tokens = initial;
|
|
19863
|
-
break;
|
|
19864
|
-
}
|
|
19865
|
-
chosen = next.chosen;
|
|
19866
|
-
tokens = next.tokens;
|
|
19867
|
-
mistake = next.mistake;
|
|
19868
|
-
}
|
|
19869
|
-
let result = "";
|
|
19870
|
-
for (const token of tokens)
|
|
19871
|
-
result += token.value;
|
|
19872
|
-
return result;
|
|
19873
|
-
}
|
|
19874
|
-
var builtins;
|
|
19875
|
-
var init_container_phrasing = __esm(() => {
|
|
19876
|
-
init_dev4();
|
|
19877
|
-
init_dev6();
|
|
19878
|
-
init_encode_info();
|
|
19879
|
-
init_html_kind();
|
|
19880
|
-
builtins = new Map([
|
|
19881
|
-
["*", false],
|
|
19882
|
-
["_", true]
|
|
19883
|
-
]);
|
|
19884
|
-
});
|
|
19885
|
-
|
|
19886
20032
|
// ../../node_modules/mdast-util-to-markdown/lib/util/container-flow.js
|
|
19887
20033
|
function containerFlow(parent, state, info) {
|
|
19888
20034
|
const indexStack = state.indexStack;
|
|
@@ -20013,22 +20159,20 @@ function safe(state, input, config) {
|
|
|
20013
20159
|
continue;
|
|
20014
20160
|
}
|
|
20015
20161
|
}
|
|
20016
|
-
if (position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after || positions[index - 1] === position - 1 && infos[position].before && !infos[position - 1].before && !infos[position - 1].after) {
|
|
20162
|
+
if (position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after || position - 1 >= offset && positions[index - 1] === position - 1 && infos[position].before && !infos[position - 1].before && !infos[position - 1].after) {
|
|
20017
20163
|
continue;
|
|
20018
20164
|
}
|
|
20019
20165
|
if (start !== position) {
|
|
20020
20166
|
const slice = value.slice(start, position);
|
|
20021
20167
|
result.push(percentEncode ? slice : escapeBackslashes(slice, "\\"));
|
|
20022
20168
|
}
|
|
20023
|
-
start = position;
|
|
20169
|
+
start = position + 1;
|
|
20024
20170
|
if (percentEncode) {
|
|
20025
20171
|
result.push("%" + value.charCodeAt(position).toString(16).toUpperCase().padStart(2, "0"));
|
|
20026
|
-
start++;
|
|
20027
20172
|
} else if (/[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || !config.encode.includes(value.charAt(position)))) {
|
|
20028
|
-
result.push("\\");
|
|
20173
|
+
result.push("\\" + value.charAt(position));
|
|
20029
20174
|
} else {
|
|
20030
20175
|
result.push(encodeCharacterReference(value.charCodeAt(position)));
|
|
20031
|
-
start++;
|
|
20032
20176
|
}
|
|
20033
20177
|
}
|
|
20034
20178
|
const rest = value.slice(start, end);
|
|
@@ -22561,84 +22705,9 @@ var init_stringify_entities = __esm(() => {
|
|
|
22561
22705
|
init_lib23();
|
|
22562
22706
|
});
|
|
22563
22707
|
|
|
22564
|
-
// ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/color.node.js
|
|
22565
|
-
function color3(d) {
|
|
22566
|
-
return "\x1B[33m" + d + "\x1B[39m";
|
|
22567
|
-
}
|
|
22568
|
-
|
|
22569
|
-
// ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/index.js
|
|
22570
|
-
function visitParents3(tree, test, visitor, reverse) {
|
|
22571
|
-
let check;
|
|
22572
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
22573
|
-
reverse = visitor;
|
|
22574
|
-
visitor = test;
|
|
22575
|
-
} else {
|
|
22576
|
-
check = test;
|
|
22577
|
-
}
|
|
22578
|
-
const is = convert(check);
|
|
22579
|
-
const step = reverse ? -1 : 1;
|
|
22580
|
-
factory(tree, undefined, [])();
|
|
22581
|
-
function factory(node, index, parents) {
|
|
22582
|
-
const value = node && typeof node === "object" ? node : {};
|
|
22583
|
-
if (typeof value.type === "string") {
|
|
22584
|
-
const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
|
|
22585
|
-
Object.defineProperty(visit, "name", {
|
|
22586
|
-
value: "node (" + color3(node.type + (name ? "<" + name + ">" : "")) + ")"
|
|
22587
|
-
});
|
|
22588
|
-
}
|
|
22589
|
-
return visit;
|
|
22590
|
-
function visit() {
|
|
22591
|
-
let result = empty3;
|
|
22592
|
-
let subresult;
|
|
22593
|
-
let offset;
|
|
22594
|
-
let grandparents;
|
|
22595
|
-
if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
|
|
22596
|
-
result = toResult3(visitor(node, parents));
|
|
22597
|
-
if (result[0] === EXIT3) {
|
|
22598
|
-
return result;
|
|
22599
|
-
}
|
|
22600
|
-
}
|
|
22601
|
-
if ("children" in node && node.children) {
|
|
22602
|
-
const nodeAsParent = node;
|
|
22603
|
-
if (nodeAsParent.children && result[0] !== SKIP3) {
|
|
22604
|
-
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
22605
|
-
grandparents = parents.concat(nodeAsParent);
|
|
22606
|
-
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
22607
|
-
const child = nodeAsParent.children[offset];
|
|
22608
|
-
subresult = factory(child, offset, grandparents)();
|
|
22609
|
-
if (subresult[0] === EXIT3) {
|
|
22610
|
-
return subresult;
|
|
22611
|
-
}
|
|
22612
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
22613
|
-
}
|
|
22614
|
-
}
|
|
22615
|
-
}
|
|
22616
|
-
return result;
|
|
22617
|
-
}
|
|
22618
|
-
}
|
|
22619
|
-
}
|
|
22620
|
-
function toResult3(value) {
|
|
22621
|
-
if (Array.isArray(value)) {
|
|
22622
|
-
return value;
|
|
22623
|
-
}
|
|
22624
|
-
if (typeof value === "number") {
|
|
22625
|
-
return [CONTINUE3, value];
|
|
22626
|
-
}
|
|
22627
|
-
return value === null || value === undefined ? empty3 : [value];
|
|
22628
|
-
}
|
|
22629
|
-
var empty3, CONTINUE3 = true, EXIT3 = false, SKIP3 = "skip";
|
|
22630
|
-
var init_lib24 = __esm(() => {
|
|
22631
|
-
init_unist_util_is();
|
|
22632
|
-
empty3 = [];
|
|
22633
|
-
});
|
|
22634
|
-
|
|
22635
|
-
// ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/index.js
|
|
22636
|
-
var init_unist_util_visit_parents3 = __esm(() => {
|
|
22637
|
-
init_lib24();
|
|
22638
|
-
});
|
|
22639
|
-
|
|
22640
22708
|
// ../../node_modules/mdast-util-directive/lib/index.js
|
|
22641
|
-
function directiveFromMarkdown() {
|
|
22709
|
+
function directiveFromMarkdown(options) {
|
|
22710
|
+
const settings = options || emptyFromMarkdownOptions;
|
|
22642
22711
|
return {
|
|
22643
22712
|
canContainEols: ["textDirective"],
|
|
22644
22713
|
enter: {
|
|
@@ -22652,29 +22721,57 @@ function directiveFromMarkdown() {
|
|
|
22652
22721
|
},
|
|
22653
22722
|
exit: {
|
|
22654
22723
|
directiveContainer: exit3,
|
|
22724
|
+
directiveContainerAttributeClass: exitAttributeShortcut,
|
|
22655
22725
|
directiveContainerAttributeClassValue: exitAttributeClassValue,
|
|
22726
|
+
directiveContainerAttributeId: exitAttributeShortcut,
|
|
22656
22727
|
directiveContainerAttributeIdValue: exitAttributeIdValue,
|
|
22657
22728
|
directiveContainerAttributeName: exitAttributeName,
|
|
22658
22729
|
directiveContainerAttributeValue: exitAttributeValue,
|
|
22730
|
+
directiveContainerAttributeValueLiteral: exitAttributeValueLiteral,
|
|
22659
22731
|
directiveContainerAttributes: exitAttributes,
|
|
22660
22732
|
directiveContainerLabel: exitContainerLabel,
|
|
22661
22733
|
directiveContainerName: exitName,
|
|
22734
|
+
directiveContainerSequence: exitSequence,
|
|
22662
22735
|
directiveLeaf: exit3,
|
|
22736
|
+
directiveLeafAttributeClass: exitAttributeShortcut,
|
|
22663
22737
|
directiveLeafAttributeClassValue: exitAttributeClassValue,
|
|
22738
|
+
directiveLeafAttributeId: exitAttributeShortcut,
|
|
22664
22739
|
directiveLeafAttributeIdValue: exitAttributeIdValue,
|
|
22665
22740
|
directiveLeafAttributeName: exitAttributeName,
|
|
22666
22741
|
directiveLeafAttributeValue: exitAttributeValue,
|
|
22742
|
+
directiveLeafAttributeValueLiteral: exitAttributeValueLiteral,
|
|
22667
22743
|
directiveLeafAttributes: exitAttributes,
|
|
22744
|
+
directiveLeafLabel: exitLabel,
|
|
22668
22745
|
directiveLeafName: exitName,
|
|
22746
|
+
directiveLeafSequence: exitSequence,
|
|
22669
22747
|
directiveText: exit3,
|
|
22748
|
+
directiveTextAttributeClass: exitAttributeShortcut,
|
|
22670
22749
|
directiveTextAttributeClassValue: exitAttributeClassValue,
|
|
22750
|
+
directiveTextAttributeId: exitAttributeShortcut,
|
|
22671
22751
|
directiveTextAttributeIdValue: exitAttributeIdValue,
|
|
22672
22752
|
directiveTextAttributeName: exitAttributeName,
|
|
22673
22753
|
directiveTextAttributeValue: exitAttributeValue,
|
|
22754
|
+
directiveTextAttributeValueLiteral: exitAttributeValueLiteral,
|
|
22674
22755
|
directiveTextAttributes: exitAttributes,
|
|
22756
|
+
directiveTextLabel: exitLabel,
|
|
22757
|
+
directiveTextMarker: exitSequence,
|
|
22675
22758
|
directiveTextName: exitName
|
|
22676
22759
|
}
|
|
22677
22760
|
};
|
|
22761
|
+
function exitSequence(token) {
|
|
22762
|
+
if (!settings.verbose)
|
|
22763
|
+
return;
|
|
22764
|
+
const node = this.stack[this.stack.length - 1];
|
|
22765
|
+
ok(node, "expected `node`");
|
|
22766
|
+
ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
|
|
22767
|
+
const place = { start: point3(token.start), end: point3(token.end) };
|
|
22768
|
+
if (node.data && node.data.position) {
|
|
22769
|
+
ok(node.type === "containerDirective");
|
|
22770
|
+
node.data.position.closing = place;
|
|
22771
|
+
} else {
|
|
22772
|
+
node.data = { position: { opening: place } };
|
|
22773
|
+
}
|
|
22774
|
+
}
|
|
22678
22775
|
}
|
|
22679
22776
|
function directiveToMarkdown(options) {
|
|
22680
22777
|
const settings = options || emptyOptions4;
|
|
@@ -22711,8 +22808,20 @@ function directiveToMarkdown(options) {
|
|
|
22711
22808
|
};
|
|
22712
22809
|
function handleDirective(node, _, state, info) {
|
|
22713
22810
|
const tracker = state.createTracker(info);
|
|
22714
|
-
const sequence = fence3(node);
|
|
22715
22811
|
const exit = state.enter(node.type);
|
|
22812
|
+
let content;
|
|
22813
|
+
if (node.type === "containerDirective") {
|
|
22814
|
+
const head = (node.children || [])[0];
|
|
22815
|
+
const children = inlineDirectiveLabel(head) ? node.children.slice(1) : node.children;
|
|
22816
|
+
if (children && children.length > 0) {
|
|
22817
|
+
const current = tracker.current();
|
|
22818
|
+
content = state.containerFlow({ ...node, children }, {
|
|
22819
|
+
now: { line: current.now.line + 1, column: 1 + current.lineShift },
|
|
22820
|
+
lineShift: current.lineShift
|
|
22821
|
+
});
|
|
22822
|
+
}
|
|
22823
|
+
}
|
|
22824
|
+
const sequence = fence3(node, content ? longestColonLine(content) : 0);
|
|
22716
22825
|
let value = tracker.move(sequence + (node.name || ""));
|
|
22717
22826
|
const attributesValue = attributes(node, state);
|
|
22718
22827
|
const after = info.after.charCodeAt(0);
|
|
@@ -22741,15 +22850,9 @@ function directiveToMarkdown(options) {
|
|
|
22741
22850
|
}
|
|
22742
22851
|
value += tracker.move(attributesValue || (after === 123 ? "{}" : ""));
|
|
22743
22852
|
if (node.type === "containerDirective") {
|
|
22744
|
-
|
|
22745
|
-
let shallow = node;
|
|
22746
|
-
if (inlineDirectiveLabel(head)) {
|
|
22747
|
-
shallow = Object.assign({}, node, { children: node.children.slice(1) });
|
|
22748
|
-
}
|
|
22749
|
-
if (shallow && shallow.children && shallow.children.length > 0) {
|
|
22853
|
+
if (content) {
|
|
22750
22854
|
value += tracker.move(`
|
|
22751
|
-
`);
|
|
22752
|
-
value += tracker.move(state.containerFlow(shallow, tracker.current()));
|
|
22855
|
+
` + content);
|
|
22753
22856
|
}
|
|
22754
22857
|
value += tracker.move(`
|
|
22755
22858
|
` + sequence);
|
|
@@ -22766,16 +22869,15 @@ function directiveToMarkdown(options) {
|
|
|
22766
22869
|
let key;
|
|
22767
22870
|
for (key in attributes) {
|
|
22768
22871
|
if (own9.call(attributes, key) && attributes[key] !== undefined && attributes[key] !== null) {
|
|
22769
|
-
const value = String(attributes[key]);
|
|
22872
|
+
const value = encode2(String(attributes[key]));
|
|
22770
22873
|
if (key === "id") {
|
|
22771
22874
|
id = settings.preferShortcut !== false && shortcut.test(value) ? "#" + value : quoted("id", value, node, state);
|
|
22772
22875
|
} else if (key === "class") {
|
|
22773
22876
|
const list = value.split(/[\t\n\r ]+/);
|
|
22774
22877
|
const classesFullList = [];
|
|
22775
22878
|
const classesList = [];
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
(settings.preferShortcut !== false && shortcut.test(list[index]) ? classesList : classesFullList).push(list[index]);
|
|
22879
|
+
for (const item of list) {
|
|
22880
|
+
(settings.preferShortcut !== false && shortcut.test(item) ? classesList : classesFullList).push(item);
|
|
22779
22881
|
}
|
|
22780
22882
|
classesFull = classesFullList.length > 0 ? quoted("class", classesFullList.join(" "), node, state) : "";
|
|
22781
22883
|
classes = classesList.length > 0 ? "." + classesList.join(".") : "";
|
|
@@ -22823,19 +22925,50 @@ function enter(type, token) {
|
|
|
22823
22925
|
}
|
|
22824
22926
|
function exitName(token) {
|
|
22825
22927
|
const node = this.stack[this.stack.length - 1];
|
|
22928
|
+
ok(node, "expected `node`");
|
|
22826
22929
|
ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
|
|
22827
22930
|
node.name = this.sliceSerialize(token);
|
|
22931
|
+
openingEnd(node, token);
|
|
22828
22932
|
}
|
|
22829
22933
|
function enterContainerLabel(token) {
|
|
22830
22934
|
this.enter({ type: "paragraph", data: { directiveLabel: true }, children: [] }, token);
|
|
22831
22935
|
}
|
|
22832
22936
|
function exitContainerLabel(token) {
|
|
22833
22937
|
this.exit(token);
|
|
22938
|
+
const node = this.stack[this.stack.length - 1];
|
|
22939
|
+
ok(node, "expected `node`");
|
|
22940
|
+
ok(node.type === "containerDirective");
|
|
22941
|
+
openingEnd(node, token);
|
|
22942
|
+
}
|
|
22943
|
+
function exitLabel(token) {
|
|
22944
|
+
const node = this.stack[this.stack.length - 1];
|
|
22945
|
+
ok(node, "expected `node`");
|
|
22946
|
+
ok(node.type === "leafDirective" || node.type === "textDirective");
|
|
22947
|
+
openingEnd(node, token);
|
|
22834
22948
|
}
|
|
22835
22949
|
function enterAttributes() {
|
|
22950
|
+
const node = this.stack[this.stack.length - 1];
|
|
22951
|
+
ok(node, "expected `node`");
|
|
22952
|
+
ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
|
|
22953
|
+
if (node.data && node.data.position) {
|
|
22954
|
+
this.data.directiveAttributePositions = {};
|
|
22955
|
+
}
|
|
22836
22956
|
this.data.directiveAttributes = [];
|
|
22837
22957
|
this.buffer();
|
|
22838
22958
|
}
|
|
22959
|
+
function exitAttributeShortcut(token) {
|
|
22960
|
+
const positions = this.data.directiveAttributePositions;
|
|
22961
|
+
if (positions) {
|
|
22962
|
+
const list = this.data.directiveAttributes;
|
|
22963
|
+
ok(list, "expected `directiveAttributes`");
|
|
22964
|
+
const tail = list[list.length - 1];
|
|
22965
|
+
ok(tail, "expected attribute");
|
|
22966
|
+
positions[tail[0]] = { start: point3(token.start), end: point3(token.end) };
|
|
22967
|
+
}
|
|
22968
|
+
}
|
|
22969
|
+
function exitAttributeValueLiteral(token) {
|
|
22970
|
+
attributeEnd(this, token);
|
|
22971
|
+
}
|
|
22839
22972
|
function exitAttributeIdValue(token) {
|
|
22840
22973
|
const list = this.data.directiveAttributes;
|
|
22841
22974
|
ok(list, "expected `directiveAttributes`");
|
|
@@ -22855,33 +22988,67 @@ function exitAttributeClassValue(token) {
|
|
|
22855
22988
|
function exitAttributeValue(token) {
|
|
22856
22989
|
const list = this.data.directiveAttributes;
|
|
22857
22990
|
ok(list, "expected `directiveAttributes`");
|
|
22858
|
-
list[list.length - 1]
|
|
22859
|
-
|
|
22860
|
-
});
|
|
22991
|
+
const tail = list[list.length - 1];
|
|
22992
|
+
ok(tail, "expected attribute");
|
|
22993
|
+
tail[1] = parseEntities(this.sliceSerialize(token), { attribute: true });
|
|
22994
|
+
attributeEnd(this, token);
|
|
22861
22995
|
}
|
|
22862
22996
|
function exitAttributeName(token) {
|
|
22863
22997
|
const list = this.data.directiveAttributes;
|
|
22864
22998
|
ok(list, "expected `directiveAttributes`");
|
|
22865
|
-
|
|
22999
|
+
const name = this.sliceSerialize(token);
|
|
23000
|
+
list.push([name, ""]);
|
|
23001
|
+
const positions = this.data.directiveAttributePositions;
|
|
23002
|
+
if (positions) {
|
|
23003
|
+
positions[name] = { start: point3(token.start), end: point3(token.end) };
|
|
23004
|
+
}
|
|
22866
23005
|
}
|
|
22867
|
-
function exitAttributes() {
|
|
23006
|
+
function exitAttributes(token) {
|
|
22868
23007
|
const list = this.data.directiveAttributes;
|
|
22869
23008
|
ok(list, "expected `directiveAttributes`");
|
|
22870
23009
|
const cleaned = {};
|
|
22871
|
-
|
|
22872
|
-
while (++index < list.length) {
|
|
22873
|
-
const attribute = list[index];
|
|
23010
|
+
for (const attribute of list) {
|
|
22874
23011
|
if (attribute[0] === "class" && cleaned.class) {
|
|
22875
23012
|
cleaned.class += " " + attribute[1];
|
|
22876
23013
|
} else {
|
|
22877
23014
|
cleaned[attribute[0]] = attribute[1];
|
|
22878
23015
|
}
|
|
22879
23016
|
}
|
|
23017
|
+
const positions = this.data.directiveAttributePositions;
|
|
23018
|
+
this.data.directiveAttributePositions = undefined;
|
|
22880
23019
|
this.data.directiveAttributes = undefined;
|
|
22881
23020
|
this.resume();
|
|
22882
23021
|
const node = this.stack[this.stack.length - 1];
|
|
23022
|
+
ok(node, "expected `node`");
|
|
22883
23023
|
ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
|
|
22884
23024
|
node.attributes = cleaned;
|
|
23025
|
+
if (positions) {
|
|
23026
|
+
ok(node.data && node.data.position, "expected `position`");
|
|
23027
|
+
node.data.position.attributes = positions;
|
|
23028
|
+
}
|
|
23029
|
+
openingEnd(node, token);
|
|
23030
|
+
}
|
|
23031
|
+
function openingEnd(node, token) {
|
|
23032
|
+
if (node.data && node.data.position) {
|
|
23033
|
+
const { opening } = node.data.position;
|
|
23034
|
+
ok(opening, "expected `opening`");
|
|
23035
|
+
opening.end = point3(token.end);
|
|
23036
|
+
}
|
|
23037
|
+
}
|
|
23038
|
+
function attributeEnd(context, token) {
|
|
23039
|
+
const positions = context.data.directiveAttributePositions;
|
|
23040
|
+
if (positions) {
|
|
23041
|
+
const list = context.data.directiveAttributes;
|
|
23042
|
+
ok(list, "expected `directiveAttributes`");
|
|
23043
|
+
const tail = list[list.length - 1];
|
|
23044
|
+
ok(tail, "expected attribute");
|
|
23045
|
+
const position = positions[tail[0]];
|
|
23046
|
+
ok(position, "expected position");
|
|
23047
|
+
position.end = point3(token.end);
|
|
23048
|
+
}
|
|
23049
|
+
}
|
|
23050
|
+
function point3(d) {
|
|
23051
|
+
return { line: d.line, column: d.column, offset: d.offset };
|
|
22885
23052
|
}
|
|
22886
23053
|
function exit3(token) {
|
|
22887
23054
|
this.exit(token);
|
|
@@ -22889,26 +23056,28 @@ function exit3(token) {
|
|
|
22889
23056
|
function peekDirective() {
|
|
22890
23057
|
return ":";
|
|
22891
23058
|
}
|
|
23059
|
+
function encode2(value) {
|
|
23060
|
+
const result = [];
|
|
23061
|
+
let start = 0;
|
|
23062
|
+
let index = value.indexOf("&");
|
|
23063
|
+
while (index !== -1) {
|
|
23064
|
+
const code = value.charCodeAt(index + 1);
|
|
23065
|
+
if (code === 35 || asciiAlpha(code)) {
|
|
23066
|
+
result.push(value.slice(start, index), "&");
|
|
23067
|
+
start = index + 1;
|
|
23068
|
+
}
|
|
23069
|
+
index = value.indexOf("&", index + 1);
|
|
23070
|
+
}
|
|
23071
|
+
result.push(value.slice(start));
|
|
23072
|
+
return result.join("");
|
|
23073
|
+
}
|
|
22892
23074
|
function inlineDirectiveLabel(node) {
|
|
22893
23075
|
return Boolean(node && node.type === "paragraph" && node.data && node.data.directiveLabel);
|
|
22894
23076
|
}
|
|
22895
|
-
function fence3(node) {
|
|
23077
|
+
function fence3(node, longest) {
|
|
22896
23078
|
let size = 0;
|
|
22897
23079
|
if (node.type === "containerDirective") {
|
|
22898
|
-
|
|
22899
|
-
if (node.type === "containerDirective") {
|
|
22900
|
-
let index = parents.length;
|
|
22901
|
-
let nesting = 0;
|
|
22902
|
-
while (index--) {
|
|
22903
|
-
if (parents[index].type === "containerDirective") {
|
|
22904
|
-
nesting++;
|
|
22905
|
-
}
|
|
22906
|
-
}
|
|
22907
|
-
if (nesting > size)
|
|
22908
|
-
size = nesting;
|
|
22909
|
-
}
|
|
22910
|
-
});
|
|
22911
|
-
size += 3;
|
|
23080
|
+
size = Math.max(3, longest + 1);
|
|
22912
23081
|
} else if (node.type === "leafDirective") {
|
|
22913
23082
|
size = 2;
|
|
22914
23083
|
} else {
|
|
@@ -22916,14 +23085,40 @@ function fence3(node) {
|
|
|
22916
23085
|
}
|
|
22917
23086
|
return ":".repeat(size);
|
|
22918
23087
|
}
|
|
22919
|
-
|
|
22920
|
-
|
|
23088
|
+
function longestColonLine(value) {
|
|
23089
|
+
let longest = 0;
|
|
23090
|
+
let index = 0;
|
|
23091
|
+
while (index < value.length) {
|
|
23092
|
+
let size = 0;
|
|
23093
|
+
let code = value.charCodeAt(index);
|
|
23094
|
+
while (code === 9 || code === 32) {
|
|
23095
|
+
code = value.charCodeAt(++index);
|
|
23096
|
+
}
|
|
23097
|
+
while (code === 58) {
|
|
23098
|
+
size++;
|
|
23099
|
+
code = value.charCodeAt(++index);
|
|
23100
|
+
}
|
|
23101
|
+
while (code === 9 || code === 32) {
|
|
23102
|
+
code = value.charCodeAt(++index);
|
|
23103
|
+
}
|
|
23104
|
+
while (!(code === 10 || code === 13 || Number.isNaN(code))) {
|
|
23105
|
+
size = 0;
|
|
23106
|
+
code = value.charCodeAt(++index);
|
|
23107
|
+
}
|
|
23108
|
+
if (size > longest)
|
|
23109
|
+
longest = size;
|
|
23110
|
+
index++;
|
|
23111
|
+
}
|
|
23112
|
+
return longest;
|
|
23113
|
+
}
|
|
23114
|
+
var own9, emptyFromMarkdownOptions, emptyOptions4, shortcut, unquoted;
|
|
23115
|
+
var init_lib24 = __esm(() => {
|
|
22921
23116
|
init_development();
|
|
22922
23117
|
init_dev4();
|
|
22923
23118
|
init_parse_entities();
|
|
22924
23119
|
init_stringify_entities();
|
|
22925
|
-
init_unist_util_visit_parents3();
|
|
22926
23120
|
own9 = {}.hasOwnProperty;
|
|
23121
|
+
emptyFromMarkdownOptions = {};
|
|
22927
23122
|
emptyOptions4 = {};
|
|
22928
23123
|
shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
|
|
22929
23124
|
unquoted = /^[^\t\n\r "'<=>`}]+$/;
|
|
@@ -22931,7 +23126,7 @@ var init_lib25 = __esm(() => {
|
|
|
22931
23126
|
|
|
22932
23127
|
// ../../node_modules/mdast-util-directive/index.js
|
|
22933
23128
|
var init_mdast_util_directive = __esm(() => {
|
|
22934
|
-
|
|
23129
|
+
init_lib24();
|
|
22935
23130
|
});
|
|
22936
23131
|
|
|
22937
23132
|
// ../../node_modules/micromark-extension-directive/dev/lib/factory-attributes.js
|
|
@@ -23547,14 +23742,14 @@ function remarkDirective() {
|
|
|
23547
23742
|
fromMarkdownExtensions.push(directiveFromMarkdown());
|
|
23548
23743
|
toMarkdownExtensions.push(directiveToMarkdown());
|
|
23549
23744
|
}
|
|
23550
|
-
var
|
|
23745
|
+
var init_lib25 = __esm(() => {
|
|
23551
23746
|
init_mdast_util_directive();
|
|
23552
23747
|
init_dev22();
|
|
23553
23748
|
});
|
|
23554
23749
|
|
|
23555
23750
|
// ../../node_modules/remark-directive/index.js
|
|
23556
23751
|
var init_remark_directive = __esm(() => {
|
|
23557
|
-
|
|
23752
|
+
init_lib25();
|
|
23558
23753
|
});
|
|
23559
23754
|
|
|
23560
23755
|
// ../../node_modules/property-information/lib/util/schema.js
|
|
@@ -24814,13 +25009,13 @@ function parseSelector(selector, defaultTagName) {
|
|
|
24814
25009
|
};
|
|
24815
25010
|
}
|
|
24816
25011
|
var search2;
|
|
24817
|
-
var
|
|
25012
|
+
var init_lib26 = __esm(() => {
|
|
24818
25013
|
search2 = /[#.]/g;
|
|
24819
25014
|
});
|
|
24820
25015
|
|
|
24821
25016
|
// ../../node_modules/hast-util-parse-selector/index.js
|
|
24822
25017
|
var init_hast_util_parse_selector = __esm(() => {
|
|
24823
|
-
|
|
25018
|
+
init_lib26();
|
|
24824
25019
|
});
|
|
24825
25020
|
|
|
24826
25021
|
// ../../node_modules/space-separated-tokens/index.js
|
|
@@ -24857,7 +25052,7 @@ function createH(schema, defaultTagName, caseSensitive) {
|
|
|
24857
25052
|
for (const child of children) {
|
|
24858
25053
|
addChild(node.children, child);
|
|
24859
25054
|
}
|
|
24860
|
-
if (node.type === "element" && node.tagName === "template") {
|
|
25055
|
+
if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
|
|
24861
25056
|
node.content = { type: "root", children: node.children };
|
|
24862
25057
|
node.children = [];
|
|
24863
25058
|
}
|
|
@@ -24892,10 +25087,10 @@ function isChild(value) {
|
|
|
24892
25087
|
return false;
|
|
24893
25088
|
}
|
|
24894
25089
|
function addProperty(schema, properties, key, value) {
|
|
24895
|
-
const info = find(schema, key);
|
|
24896
|
-
let result;
|
|
24897
25090
|
if (value === null || value === undefined)
|
|
24898
25091
|
return;
|
|
25092
|
+
const info = find(schema, key);
|
|
25093
|
+
let result;
|
|
24899
25094
|
if (typeof value === "number") {
|
|
24900
25095
|
if (Number.isNaN(value))
|
|
24901
25096
|
return;
|
|
@@ -24925,7 +25120,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
24925
25120
|
result = finalResult;
|
|
24926
25121
|
}
|
|
24927
25122
|
if (info.property === "className" && Array.isArray(properties.className)) {
|
|
24928
|
-
|
|
25123
|
+
const add = result;
|
|
25124
|
+
result = [...properties.className, ...Array.isArray(add) ? add : [add]];
|
|
24929
25125
|
}
|
|
24930
25126
|
properties[info.property] = result;
|
|
24931
25127
|
}
|
|
@@ -25024,7 +25220,7 @@ var init_svg_case_sensitive_tag_names = __esm(() => {
|
|
|
25024
25220
|
|
|
25025
25221
|
// ../../node_modules/hastscript/lib/index.js
|
|
25026
25222
|
var h, s;
|
|
25027
|
-
var
|
|
25223
|
+
var init_lib27 = __esm(() => {
|
|
25028
25224
|
init_property_information();
|
|
25029
25225
|
init_create_h();
|
|
25030
25226
|
init_svg_case_sensitive_tag_names();
|
|
@@ -25034,7 +25230,7 @@ var init_lib28 = __esm(() => {
|
|
|
25034
25230
|
|
|
25035
25231
|
// ../../node_modules/hastscript/index.js
|
|
25036
25232
|
var init_hastscript = __esm(() => {
|
|
25037
|
-
|
|
25233
|
+
init_lib27();
|
|
25038
25234
|
});
|
|
25039
25235
|
|
|
25040
25236
|
// ../../node_modules/vfile-location/lib/index.js
|
|
@@ -25174,7 +25370,7 @@ function all2(state, nodes) {
|
|
|
25174
25370
|
return results;
|
|
25175
25371
|
}
|
|
25176
25372
|
function element(state, node) {
|
|
25177
|
-
const schema = state
|
|
25373
|
+
const { schema } = state;
|
|
25178
25374
|
state.schema = node.namespaceURI === webNamespaces.svg ? svg2 : html3;
|
|
25179
25375
|
let index = -1;
|
|
25180
25376
|
const properties = {};
|
|
@@ -25189,15 +25385,20 @@ function element(state, node) {
|
|
|
25189
25385
|
const result = x(node.tagName, properties, all2(state, node.childNodes));
|
|
25190
25386
|
patch(state, node, result);
|
|
25191
25387
|
if (result.tagName === "template") {
|
|
25192
|
-
|
|
25193
|
-
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
|
|
25388
|
+
if (node.namespaceURI === webNamespaces.html) {
|
|
25389
|
+
const reference = node;
|
|
25390
|
+
const pos = reference.sourceCodeLocation;
|
|
25391
|
+
const startTag = pos && pos.startTag && position2(pos.startTag);
|
|
25392
|
+
const endTag = pos && pos.endTag && position2(pos.endTag);
|
|
25393
|
+
const content = one2(state, reference.content);
|
|
25394
|
+
if (startTag && endTag && state.file) {
|
|
25395
|
+
content.position = { start: startTag.end, end: endTag.start };
|
|
25396
|
+
}
|
|
25397
|
+
result.content = content;
|
|
25398
|
+
} else if (result.content) {
|
|
25399
|
+
result.children = result.content.children;
|
|
25400
|
+
delete result.content;
|
|
25199
25401
|
}
|
|
25200
|
-
result.content = content;
|
|
25201
25402
|
}
|
|
25202
25403
|
state.schema = schema;
|
|
25203
25404
|
return result;
|
|
@@ -25241,23 +25442,23 @@ function createLocation(state, node, location) {
|
|
|
25241
25442
|
return result;
|
|
25242
25443
|
}
|
|
25243
25444
|
function position2(loc) {
|
|
25244
|
-
const start =
|
|
25445
|
+
const start = point4({
|
|
25245
25446
|
line: loc.startLine,
|
|
25246
25447
|
column: loc.startCol,
|
|
25247
25448
|
offset: loc.startOffset
|
|
25248
25449
|
});
|
|
25249
|
-
const end =
|
|
25450
|
+
const end = point4({
|
|
25250
25451
|
line: loc.endLine,
|
|
25251
25452
|
column: loc.endCol,
|
|
25252
25453
|
offset: loc.endOffset
|
|
25253
25454
|
});
|
|
25254
25455
|
return start || end ? { start, end } : undefined;
|
|
25255
25456
|
}
|
|
25256
|
-
function
|
|
25457
|
+
function point4(point) {
|
|
25257
25458
|
return point.line && point.column ? point : undefined;
|
|
25258
25459
|
}
|
|
25259
25460
|
var own10, proto;
|
|
25260
|
-
var
|
|
25461
|
+
var init_lib28 = __esm(() => {
|
|
25261
25462
|
init_development();
|
|
25262
25463
|
init_hastscript();
|
|
25263
25464
|
init_property_information();
|
|
@@ -25269,7 +25470,7 @@ var init_lib29 = __esm(() => {
|
|
|
25269
25470
|
|
|
25270
25471
|
// ../../node_modules/hast-util-from-parse5/index.js
|
|
25271
25472
|
var init_hast_util_from_parse5 = __esm(() => {
|
|
25272
|
-
|
|
25473
|
+
init_lib28();
|
|
25273
25474
|
});
|
|
25274
25475
|
|
|
25275
25476
|
// ../../node_modules/parse5/dist/common/unicode.js
|
|
@@ -33162,7 +33363,7 @@ function visualizeCharacterCode(charCode) {
|
|
|
33162
33363
|
return "0x" + charCode.toString(16).toUpperCase();
|
|
33163
33364
|
}
|
|
33164
33365
|
var base = "https://html.spec.whatwg.org/multipage/parsing.html#parse-error-", dashToCamelRe, formatCRe, formatXRe, fatalities, emptyOptions5;
|
|
33165
|
-
var
|
|
33366
|
+
var init_lib29 = __esm(() => {
|
|
33166
33367
|
init_development();
|
|
33167
33368
|
init_hast_util_from_parse5();
|
|
33168
33369
|
init_dist2();
|
|
@@ -33178,24 +33379,24 @@ var init_lib30 = __esm(() => {
|
|
|
33178
33379
|
|
|
33179
33380
|
// ../../node_modules/hast-util-from-html/index.js
|
|
33180
33381
|
var init_hast_util_from_html = __esm(() => {
|
|
33181
|
-
|
|
33382
|
+
init_lib29();
|
|
33182
33383
|
});
|
|
33183
33384
|
|
|
33184
33385
|
// ../../node_modules/hast-util-whitespace/lib/index.js
|
|
33185
33386
|
function whitespace(thing) {
|
|
33186
|
-
return typeof thing === "object" ? thing.type === "text" ?
|
|
33387
|
+
return typeof thing === "object" ? thing.type === "text" ? empty3(thing.value) : false : empty3(thing);
|
|
33187
33388
|
}
|
|
33188
|
-
function
|
|
33389
|
+
function empty3(value) {
|
|
33189
33390
|
return value.replace(re, "") === "";
|
|
33190
33391
|
}
|
|
33191
33392
|
var re;
|
|
33192
|
-
var
|
|
33393
|
+
var init_lib30 = __esm(() => {
|
|
33193
33394
|
re = /[ \t\n\f\r]/g;
|
|
33194
33395
|
});
|
|
33195
33396
|
|
|
33196
33397
|
// ../../node_modules/hast-util-whitespace/index.js
|
|
33197
33398
|
var init_hast_util_whitespace = __esm(() => {
|
|
33198
|
-
|
|
33399
|
+
init_lib30();
|
|
33199
33400
|
});
|
|
33200
33401
|
|
|
33201
33402
|
// ../../packages/markup/src/html-to-jx.ts
|
|
@@ -34497,7 +34698,7 @@ function isNonRelativeRef(value) {
|
|
|
34497
34698
|
}
|
|
34498
34699
|
var DOCUMENT_EXTENSIONS = new Set([".md", ".markdown", ".mdx"]);
|
|
34499
34700
|
function mountFilterFor(def) {
|
|
34500
|
-
if (!def || def.exclude === undefined && def.where === undefined && def.route === undefined) {
|
|
34701
|
+
if (!def || def.exclude === undefined && def.where === undefined && def.hold === undefined && def.route === undefined) {
|
|
34501
34702
|
return;
|
|
34502
34703
|
}
|
|
34503
34704
|
let exclude;
|
|
@@ -34649,11 +34850,11 @@ function loadContentConfig(projectRoot, projectConfig) {
|
|
|
34649
34850
|
const config = { content: projectConfig?.content ?? {} };
|
|
34650
34851
|
return { config, contentDir };
|
|
34651
34852
|
}
|
|
34652
|
-
async function loadContentSection(section, root, formats, projectConfig) {
|
|
34853
|
+
async function loadContentSection(section, root, formats, projectConfig, includeHeld) {
|
|
34653
34854
|
const contentTypes = new Map;
|
|
34654
34855
|
const mounts = sectionMounts(section, root, projectConfig);
|
|
34655
34856
|
for (const name of Object.keys(section)) {
|
|
34656
|
-
contentTypes.set(name, await loadSectionType(name, { formats, mounts, projectConfig, root, section }));
|
|
34857
|
+
contentTypes.set(name, await loadSectionType(name, { formats, includeHeld, mounts, projectConfig, root, section }));
|
|
34657
34858
|
}
|
|
34658
34859
|
return contentTypes;
|
|
34659
34860
|
}
|
|
@@ -34664,7 +34865,7 @@ function sectionMounts(section, root, projectConfig) {
|
|
|
34664
34865
|
]));
|
|
34665
34866
|
}
|
|
34666
34867
|
async function loadSectionType(name, source) {
|
|
34667
|
-
const { section, root, formats, projectConfig, mounts, onDeferred } = source;
|
|
34868
|
+
const { section, root, formats, projectConfig, mounts, onDeferred, includeHeld } = source;
|
|
34668
34869
|
const contentTypeDef = section[name];
|
|
34669
34870
|
if (!contentTypeDef) {
|
|
34670
34871
|
return [];
|
|
@@ -34673,6 +34874,7 @@ async function loadSectionType(name, source) {
|
|
|
34673
34874
|
const typeSource = contentTypeDef.source;
|
|
34674
34875
|
if (!isString(typeSource) || !typeSource.includes(LOCALE_PLACEHOLDER)) {
|
|
34675
34876
|
return await loadContentType(name, contentTypeDef, root, formats, {
|
|
34877
|
+
includeHeld,
|
|
34676
34878
|
mount: mounts.get(name),
|
|
34677
34879
|
projectConfig,
|
|
34678
34880
|
...deferral
|
|
@@ -34687,6 +34889,7 @@ async function loadSectionType(name, source) {
|
|
|
34687
34889
|
for (const locale of locales) {
|
|
34688
34890
|
const localized = { ...contentTypeDef, source: localeSource(root, typeSource, locale) };
|
|
34689
34891
|
const entries = await loadContentType(name, localized, root, formats, {
|
|
34892
|
+
includeHeld,
|
|
34690
34893
|
locale,
|
|
34691
34894
|
mount: mounts.get(`${name}/${locale}`),
|
|
34692
34895
|
projectConfig,
|
|
@@ -34713,6 +34916,7 @@ var KNOWN_TYPE_KEYS = [
|
|
|
34713
34916
|
"alerts",
|
|
34714
34917
|
"exclude",
|
|
34715
34918
|
"format",
|
|
34919
|
+
"hold",
|
|
34716
34920
|
"idField",
|
|
34717
34921
|
"indexRoute",
|
|
34718
34922
|
"links",
|
|
@@ -34772,7 +34976,8 @@ function compileTypeRules(name, def) {
|
|
|
34772
34976
|
idField: def.idField,
|
|
34773
34977
|
links,
|
|
34774
34978
|
route: parseRouteConfig(def.route, def.indexRoute, name),
|
|
34775
|
-
where: def.where === undefined ? null : compileWhere(def.where)
|
|
34979
|
+
where: def.where === undefined ? null : compileWhere(def.where),
|
|
34980
|
+
hold: def.hold === undefined ? null : compileHold(def.hold)
|
|
34776
34981
|
};
|
|
34777
34982
|
} catch (error) {
|
|
34778
34983
|
const message = errorMessage(error);
|
|
@@ -34787,6 +34992,7 @@ function finishEntries(files, ctx) {
|
|
|
34787
34992
|
const { name, rules } = ctx;
|
|
34788
34993
|
const kept = [];
|
|
34789
34994
|
const unpublished = new Map;
|
|
34995
|
+
const held = [];
|
|
34790
34996
|
let loadedCount = 0;
|
|
34791
34997
|
for (const file of files) {
|
|
34792
34998
|
const keep = [];
|
|
@@ -34796,8 +35002,19 @@ function finishEntries(files, ctx) {
|
|
|
34796
35002
|
if (file.rel !== null && file.entries.length === 1) {
|
|
34797
35003
|
unpublished.set(file.rel, `left out by where.${rules.where.why(entry.data) ?? "filter"}`);
|
|
34798
35004
|
}
|
|
34799
|
-
|
|
35005
|
+
continue;
|
|
35006
|
+
}
|
|
35007
|
+
const hold = rules.hold?.(entry.data);
|
|
35008
|
+
if (hold === undefined) {
|
|
34800
35009
|
keep.push(entry);
|
|
35010
|
+
} else if (ctx.includeHeld === true) {
|
|
35011
|
+
entry._meta = { ...entry._meta, hold };
|
|
35012
|
+
keep.push(entry);
|
|
35013
|
+
} else {
|
|
35014
|
+
held.push(`${file.rel ?? entry.id} (${hold})`);
|
|
35015
|
+
if (file.rel !== null && file.entries.length === 1) {
|
|
35016
|
+
unpublished.set(file.rel, `held: ${hold}`);
|
|
35017
|
+
}
|
|
34801
35018
|
}
|
|
34802
35019
|
}
|
|
34803
35020
|
if (keep.length > 0) {
|
|
@@ -34808,6 +35025,9 @@ function finishEntries(files, ctx) {
|
|
|
34808
35025
|
const [first] = files.flatMap((file) => file.entries);
|
|
34809
35026
|
console.warn(`Content type "${name}": "where" left out all ${loadedCount} entries, so the collection is ` + `empty (it failed on "${first ? rules.where.why(first.data) ?? "?" : "?"}" for the first one). ` + `Check the field names and the value types: YAML \`true\` is a boolean, "true" is text.`);
|
|
34810
35027
|
}
|
|
35028
|
+
if (held.length > 0) {
|
|
35029
|
+
console.info(`Content type "${name}": holding ${held.length} from this build: ${held.join(", ")}`);
|
|
35030
|
+
}
|
|
34811
35031
|
for (const file of kept) {
|
|
34812
35032
|
for (const entry of file.entries) {
|
|
34813
35033
|
if (file.rel !== null) {
|
|
@@ -35075,12 +35295,13 @@ async function loadContentType(name, contentTypeDef, projectRoot, registry, opti
|
|
|
35075
35295
|
if (!source) {
|
|
35076
35296
|
return [];
|
|
35077
35297
|
}
|
|
35078
|
-
const { mount, projectConfig, locale, deferBody, onDeferred } = options;
|
|
35298
|
+
const { mount, projectConfig, locale, deferBody, onDeferred, includeHeld } = options;
|
|
35079
35299
|
const { schema } = contentTypeDef;
|
|
35080
35300
|
const rules = compileTypeRules(name, contentTypeDef);
|
|
35081
35301
|
const finishContext = (extra) => ({
|
|
35082
35302
|
coerceDates: false,
|
|
35083
35303
|
entryExtensions: new Set,
|
|
35304
|
+
includeHeld,
|
|
35084
35305
|
locale,
|
|
35085
35306
|
mount,
|
|
35086
35307
|
name,
|
|
@@ -35369,7 +35590,7 @@ class ContentStore extends Map {
|
|
|
35369
35590
|
}
|
|
35370
35591
|
static async whole(source) {
|
|
35371
35592
|
const store = new ContentStore(source);
|
|
35372
|
-
const loaded = await loadContentSection(source.section, source.root, source.formats, source.projectConfig);
|
|
35593
|
+
const loaded = await loadContentSection(source.section, source.root, source.formats, source.projectConfig, source.includeHeld);
|
|
35373
35594
|
for (const [name, entries] of loaded) {
|
|
35374
35595
|
store.#adopt(name, entries);
|
|
35375
35596
|
store.#loads.set(name, Promise.resolve());
|
|
@@ -35444,8 +35665,9 @@ class ContentStore extends Map {
|
|
|
35444
35665
|
#loadType(name) {
|
|
35445
35666
|
let load = this.#loads.get(name);
|
|
35446
35667
|
if (!load) {
|
|
35447
|
-
const { section, root, formats, projectConfig } = this.#source;
|
|
35668
|
+
const { section, root, formats, projectConfig, includeHeld } = this.#source;
|
|
35448
35669
|
load = loadSectionType(name, {
|
|
35670
|
+
includeHeld,
|
|
35449
35671
|
formats,
|
|
35450
35672
|
mounts: this.#mounts,
|
|
35451
35673
|
onDeferred: (entry, completeBody) => {
|
|
@@ -35496,6 +35718,7 @@ class Content {
|
|
|
35496
35718
|
static async projectData(sectionValue, ctx) {
|
|
35497
35719
|
const source = {
|
|
35498
35720
|
formats: ctx.registry.formats,
|
|
35721
|
+
includeHeld: ctx.includeHeld,
|
|
35499
35722
|
projectConfig: ctx.projectConfig,
|
|
35500
35723
|
root: ctx.root,
|
|
35501
35724
|
section: sectionValue ?? {}
|