@markdoc/markdoc 0.5.6 → 0.5.7
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/index.d.ts +15 -81
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +513 -457
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +508 -456
- package/dist/index.mjs.map +4 -4
- package/dist/react.js +16 -16
- package/dist/react.js.map +2 -2
- package/dist/src/ast/index.d.ts +3 -14
- package/dist/src/ast/index.d.ts.map +1 -1
- package/dist/src/formatter.d.ts +1 -1
- package/dist/src/formatter.d.ts.map +1 -1
- package/dist/src/renderers/react/react.d.ts +3 -3
- package/dist/src/renderers/react/react.d.ts.map +1 -1
- package/dist/src/renderers/react/static.d.ts +1 -1
- package/dist/src/renderers/react/static.d.ts.map +1 -1
- package/dist/src/tag.d.ts +1 -1
- package/dist/src/tag.d.ts.map +1 -1
- package/dist/src/tags/index.d.ts +5 -60
- package/dist/src/tags/index.d.ts.map +1 -1
- package/dist/src/transformer.d.ts +1 -1
- package/dist/src/transformer.d.ts.map +1 -1
- package/dist/src/transforms/table.d.ts.map +1 -1
- package/dist/src/types.d.ts +21 -21
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/validator.d.ts +3 -23
- package/dist/src/validator.d.ts.map +1 -1
- package/package.json +19 -12
- package/src/transforms/table.test.ts +20 -9
- package/src/transforms/table.ts +6 -13
- package/src/utils.test.ts +1 -1
- package/src/validator.ts +31 -5
package/dist/index.mjs
CHANGED
|
@@ -4,26 +4,29 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
7
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
9
|
};
|
|
11
10
|
var __export = (target, all) => {
|
|
12
|
-
__markAsModule(target);
|
|
13
11
|
for (var name in all)
|
|
14
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
13
|
};
|
|
16
|
-
var
|
|
17
|
-
if (
|
|
18
|
-
for (let key of __getOwnPropNames(
|
|
19
|
-
if (!__hasOwnProp.call(
|
|
20
|
-
__defProp(
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
19
|
}
|
|
22
|
-
return
|
|
23
|
-
};
|
|
24
|
-
var __toModule = (module) => {
|
|
25
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
20
|
+
return to;
|
|
26
21
|
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
27
30
|
|
|
28
31
|
// src/grammar/tag.js
|
|
29
32
|
var require_tag = __commonJS({
|
|
@@ -236,8 +239,7 @@ var require_tag = __commonJS({
|
|
|
236
239
|
return value;
|
|
237
240
|
};
|
|
238
241
|
var peg$f18 = function(prefix, head, tail) {
|
|
239
|
-
if (prefix === "@")
|
|
240
|
-
return [head, ...tail];
|
|
242
|
+
if (prefix === "@") return [head, ...tail];
|
|
241
243
|
return new Variable2([head, ...tail]);
|
|
242
244
|
};
|
|
243
245
|
var peg$f19 = function() {
|
|
@@ -290,7 +292,9 @@ var require_tag = __commonJS({
|
|
|
290
292
|
var peg$result;
|
|
291
293
|
if ("startRule" in options) {
|
|
292
294
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
293
|
-
throw new Error(
|
|
295
|
+
throw new Error(
|
|
296
|
+
`Can't start parsing from rule "` + options.startRule + '".'
|
|
297
|
+
);
|
|
294
298
|
}
|
|
295
299
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
296
300
|
}
|
|
@@ -308,7 +312,11 @@ var require_tag = __commonJS({
|
|
|
308
312
|
}
|
|
309
313
|
function expected(description, location2) {
|
|
310
314
|
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
|
311
|
-
throw peg$buildStructuredError(
|
|
315
|
+
throw peg$buildStructuredError(
|
|
316
|
+
[peg$otherExpectation(description)],
|
|
317
|
+
input.substring(peg$savedPos, peg$currPos),
|
|
318
|
+
location2
|
|
319
|
+
);
|
|
312
320
|
}
|
|
313
321
|
function error2(message, location2) {
|
|
314
322
|
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
|
@@ -365,8 +373,7 @@ var require_tag = __commonJS({
|
|
|
365
373
|
var peg$VALIDFILENAME = typeof options.filename === "string" && options.filename.length > 0;
|
|
366
374
|
function peg$computeLocation(startPos, endPos) {
|
|
367
375
|
var loc = {};
|
|
368
|
-
if (peg$VALIDFILENAME)
|
|
369
|
-
loc.filename = options.filename;
|
|
376
|
+
if (peg$VALIDFILENAME) loc.filename = options.filename;
|
|
370
377
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
371
378
|
loc.start = {
|
|
372
379
|
offset: startPos,
|
|
@@ -413,18 +420,26 @@ var require_tag = __commonJS({
|
|
|
413
420
|
return new peg$SyntaxError(message, null, null, location2);
|
|
414
421
|
}
|
|
415
422
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
416
|
-
return new peg$SyntaxError(
|
|
423
|
+
return new peg$SyntaxError(
|
|
424
|
+
peg$SyntaxError.buildMessage(expected2, found, location2),
|
|
425
|
+
expected2,
|
|
426
|
+
found,
|
|
427
|
+
location2
|
|
428
|
+
);
|
|
417
429
|
}
|
|
418
430
|
function peg$buildError() {
|
|
419
431
|
var expected2 = peg$expected[0];
|
|
420
432
|
var failPos = expected2.pos;
|
|
421
|
-
return peg$buildStructuredError(
|
|
433
|
+
return peg$buildStructuredError(
|
|
434
|
+
expected2.variants,
|
|
435
|
+
failPos < input.length ? input.charAt(failPos) : null,
|
|
436
|
+
failPos < input.length ? peg$computeLocation(failPos, failPos + 1) : peg$computeLocation(failPos, failPos)
|
|
437
|
+
);
|
|
422
438
|
}
|
|
423
439
|
function peg$parseTop() {
|
|
424
440
|
var s0;
|
|
425
441
|
var rule$expects = function(expected2) {
|
|
426
|
-
if (peg$silentFails === 0)
|
|
427
|
-
peg$expect(expected2);
|
|
442
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
428
443
|
};
|
|
429
444
|
s0 = peg$parseTopLevelValue();
|
|
430
445
|
if (s0 === peg$FAILED) {
|
|
@@ -441,8 +456,7 @@ var require_tag = __commonJS({
|
|
|
441
456
|
function peg$parseTopLevelValue() {
|
|
442
457
|
var s0, s1;
|
|
443
458
|
var rule$expects = function(expected2) {
|
|
444
|
-
if (peg$silentFails === 0)
|
|
445
|
-
peg$expect(expected2);
|
|
459
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
446
460
|
};
|
|
447
461
|
s0 = peg$currPos;
|
|
448
462
|
s1 = peg$parseVariable();
|
|
@@ -459,8 +473,7 @@ var require_tag = __commonJS({
|
|
|
459
473
|
function peg$parseAnnotation() {
|
|
460
474
|
var s0, s1, s2, s3;
|
|
461
475
|
var rule$expects = function(expected2) {
|
|
462
|
-
if (peg$silentFails === 0)
|
|
463
|
-
peg$expect(expected2);
|
|
476
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
464
477
|
};
|
|
465
478
|
s0 = peg$currPos;
|
|
466
479
|
s1 = peg$parseTagAttributes();
|
|
@@ -482,8 +495,7 @@ var require_tag = __commonJS({
|
|
|
482
495
|
function peg$parseTagOpen() {
|
|
483
496
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
484
497
|
var rule$expects = function(expected2) {
|
|
485
|
-
if (peg$silentFails === 0)
|
|
486
|
-
peg$expect(expected2);
|
|
498
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
487
499
|
};
|
|
488
500
|
s0 = peg$currPos;
|
|
489
501
|
s1 = peg$parseTagName();
|
|
@@ -541,8 +553,7 @@ var require_tag = __commonJS({
|
|
|
541
553
|
function peg$parseTagClose() {
|
|
542
554
|
var s0, s1, s2;
|
|
543
555
|
var rule$expects = function(expected2) {
|
|
544
|
-
if (peg$silentFails === 0)
|
|
545
|
-
peg$expect(expected2);
|
|
556
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
546
557
|
};
|
|
547
558
|
s0 = peg$currPos;
|
|
548
559
|
rule$expects(peg$e0);
|
|
@@ -570,8 +581,7 @@ var require_tag = __commonJS({
|
|
|
570
581
|
function peg$parseTagName() {
|
|
571
582
|
var s0;
|
|
572
583
|
var rule$expects = function(expected2) {
|
|
573
|
-
if (peg$silentFails === 0)
|
|
574
|
-
peg$expect(expected2);
|
|
584
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
575
585
|
};
|
|
576
586
|
rule$expects(peg$e1);
|
|
577
587
|
peg$silentFails++;
|
|
@@ -582,8 +592,7 @@ var require_tag = __commonJS({
|
|
|
582
592
|
function peg$parseTagAttributes() {
|
|
583
593
|
var s0, s1, s2, s3;
|
|
584
594
|
var rule$expects = function(expected2) {
|
|
585
|
-
if (peg$silentFails === 0)
|
|
586
|
-
peg$expect(expected2);
|
|
595
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
587
596
|
};
|
|
588
597
|
s0 = peg$currPos;
|
|
589
598
|
s1 = peg$parseTagAttributesItem();
|
|
@@ -605,8 +614,7 @@ var require_tag = __commonJS({
|
|
|
605
614
|
function peg$parseTagAttributesTail() {
|
|
606
615
|
var s0, s1, s2;
|
|
607
616
|
var rule$expects = function(expected2) {
|
|
608
|
-
if (peg$silentFails === 0)
|
|
609
|
-
peg$expect(expected2);
|
|
617
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
610
618
|
};
|
|
611
619
|
s0 = peg$currPos;
|
|
612
620
|
s1 = [];
|
|
@@ -637,8 +645,7 @@ var require_tag = __commonJS({
|
|
|
637
645
|
function peg$parseTagAttributesItem() {
|
|
638
646
|
var s0, s1;
|
|
639
647
|
var rule$expects = function(expected2) {
|
|
640
|
-
if (peg$silentFails === 0)
|
|
641
|
-
peg$expect(expected2);
|
|
648
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
642
649
|
};
|
|
643
650
|
s0 = peg$currPos;
|
|
644
651
|
s1 = peg$parseTagShortcutId();
|
|
@@ -670,8 +677,7 @@ var require_tag = __commonJS({
|
|
|
670
677
|
function peg$parseTagShortcutClass() {
|
|
671
678
|
var s0, s1, s2;
|
|
672
679
|
var rule$expects = function(expected2) {
|
|
673
|
-
if (peg$silentFails === 0)
|
|
674
|
-
peg$expect(expected2);
|
|
680
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
675
681
|
};
|
|
676
682
|
rule$expects(peg$e2);
|
|
677
683
|
peg$silentFails++;
|
|
@@ -701,8 +707,7 @@ var require_tag = __commonJS({
|
|
|
701
707
|
function peg$parseTagShortcutId() {
|
|
702
708
|
var s0, s1, s2;
|
|
703
709
|
var rule$expects = function(expected2) {
|
|
704
|
-
if (peg$silentFails === 0)
|
|
705
|
-
peg$expect(expected2);
|
|
710
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
706
711
|
};
|
|
707
712
|
rule$expects(peg$e3);
|
|
708
713
|
peg$silentFails++;
|
|
@@ -732,8 +737,7 @@ var require_tag = __commonJS({
|
|
|
732
737
|
function peg$parseTagAttribute() {
|
|
733
738
|
var s0, s1, s2, s3;
|
|
734
739
|
var rule$expects = function(expected2) {
|
|
735
|
-
if (peg$silentFails === 0)
|
|
736
|
-
peg$expect(expected2);
|
|
740
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
737
741
|
};
|
|
738
742
|
s0 = peg$currPos;
|
|
739
743
|
s1 = peg$parseIdentifier();
|
|
@@ -767,8 +771,7 @@ var require_tag = __commonJS({
|
|
|
767
771
|
function peg$parseFunction() {
|
|
768
772
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
769
773
|
var rule$expects = function(expected2) {
|
|
770
|
-
if (peg$silentFails === 0)
|
|
771
|
-
peg$expect(expected2);
|
|
774
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
772
775
|
};
|
|
773
776
|
s0 = peg$currPos;
|
|
774
777
|
s1 = peg$parseIdentifier();
|
|
@@ -827,8 +830,7 @@ var require_tag = __commonJS({
|
|
|
827
830
|
function peg$parseFunctionParameter() {
|
|
828
831
|
var s0, s1, s2, s3;
|
|
829
832
|
var rule$expects = function(expected2) {
|
|
830
|
-
if (peg$silentFails === 0)
|
|
831
|
-
peg$expect(expected2);
|
|
833
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
832
834
|
};
|
|
833
835
|
s0 = peg$currPos;
|
|
834
836
|
s1 = peg$currPos;
|
|
@@ -868,8 +870,7 @@ var require_tag = __commonJS({
|
|
|
868
870
|
function peg$parseFunctionParameterTail() {
|
|
869
871
|
var s0, s1, s2, s3, s4;
|
|
870
872
|
var rule$expects = function(expected2) {
|
|
871
|
-
if (peg$silentFails === 0)
|
|
872
|
-
peg$expect(expected2);
|
|
873
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
873
874
|
};
|
|
874
875
|
s0 = peg$currPos;
|
|
875
876
|
s1 = [];
|
|
@@ -909,8 +910,7 @@ var require_tag = __commonJS({
|
|
|
909
910
|
function peg$parseTrailingComma() {
|
|
910
911
|
var s0, s1, s2;
|
|
911
912
|
var rule$expects = function(expected2) {
|
|
912
|
-
if (peg$silentFails === 0)
|
|
913
|
-
peg$expect(expected2);
|
|
913
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
914
914
|
};
|
|
915
915
|
s0 = peg$currPos;
|
|
916
916
|
s1 = [];
|
|
@@ -941,8 +941,7 @@ var require_tag = __commonJS({
|
|
|
941
941
|
function peg$parseVariable() {
|
|
942
942
|
var s0, s1, s2, s3, s4;
|
|
943
943
|
var rule$expects = function(expected2) {
|
|
944
|
-
if (peg$silentFails === 0)
|
|
945
|
-
peg$expect(expected2);
|
|
944
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
946
945
|
};
|
|
947
946
|
rule$expects(peg$e8);
|
|
948
947
|
peg$silentFails++;
|
|
@@ -978,8 +977,7 @@ var require_tag = __commonJS({
|
|
|
978
977
|
function peg$parseVariableTail() {
|
|
979
978
|
var s0, s1, s2, s3;
|
|
980
979
|
var rule$expects = function(expected2) {
|
|
981
|
-
if (peg$silentFails === 0)
|
|
982
|
-
peg$expect(expected2);
|
|
980
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
983
981
|
};
|
|
984
982
|
s0 = peg$currPos;
|
|
985
983
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
@@ -1042,8 +1040,7 @@ var require_tag = __commonJS({
|
|
|
1042
1040
|
function peg$parseValue() {
|
|
1043
1041
|
var s0;
|
|
1044
1042
|
var rule$expects = function(expected2) {
|
|
1045
|
-
if (peg$silentFails === 0)
|
|
1046
|
-
peg$expect(expected2);
|
|
1043
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1047
1044
|
};
|
|
1048
1045
|
s0 = peg$parseValueNull();
|
|
1049
1046
|
if (s0 === peg$FAILED) {
|
|
@@ -1072,8 +1069,7 @@ var require_tag = __commonJS({
|
|
|
1072
1069
|
function peg$parseValueNull() {
|
|
1073
1070
|
var s0, s1;
|
|
1074
1071
|
var rule$expects = function(expected2) {
|
|
1075
|
-
if (peg$silentFails === 0)
|
|
1076
|
-
peg$expect(expected2);
|
|
1072
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1077
1073
|
};
|
|
1078
1074
|
rule$expects(peg$e9);
|
|
1079
1075
|
peg$silentFails++;
|
|
@@ -1095,8 +1091,7 @@ var require_tag = __commonJS({
|
|
|
1095
1091
|
function peg$parseValueBoolean() {
|
|
1096
1092
|
var s0, s1;
|
|
1097
1093
|
var rule$expects = function(expected2) {
|
|
1098
|
-
if (peg$silentFails === 0)
|
|
1099
|
-
peg$expect(expected2);
|
|
1094
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1100
1095
|
};
|
|
1101
1096
|
rule$expects(peg$e10);
|
|
1102
1097
|
peg$silentFails++;
|
|
@@ -1132,8 +1127,7 @@ var require_tag = __commonJS({
|
|
|
1132
1127
|
function peg$parseValueArray() {
|
|
1133
1128
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1134
1129
|
var rule$expects = function(expected2) {
|
|
1135
|
-
if (peg$silentFails === 0)
|
|
1136
|
-
peg$expect(expected2);
|
|
1130
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1137
1131
|
};
|
|
1138
1132
|
s0 = peg$currPos;
|
|
1139
1133
|
rule$expects(peg$e11);
|
|
@@ -1198,8 +1192,7 @@ var require_tag = __commonJS({
|
|
|
1198
1192
|
function peg$parseValueArrayTail() {
|
|
1199
1193
|
var s0, s1, s2, s3, s4;
|
|
1200
1194
|
var rule$expects = function(expected2) {
|
|
1201
|
-
if (peg$silentFails === 0)
|
|
1202
|
-
peg$expect(expected2);
|
|
1195
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1203
1196
|
};
|
|
1204
1197
|
s0 = peg$currPos;
|
|
1205
1198
|
s1 = [];
|
|
@@ -1239,8 +1232,7 @@ var require_tag = __commonJS({
|
|
|
1239
1232
|
function peg$parseValueHash() {
|
|
1240
1233
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1241
1234
|
var rule$expects = function(expected2) {
|
|
1242
|
-
if (peg$silentFails === 0)
|
|
1243
|
-
peg$expect(expected2);
|
|
1235
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1244
1236
|
};
|
|
1245
1237
|
s0 = peg$currPos;
|
|
1246
1238
|
rule$expects(peg$e13);
|
|
@@ -1305,8 +1297,7 @@ var require_tag = __commonJS({
|
|
|
1305
1297
|
function peg$parseValueHashTail() {
|
|
1306
1298
|
var s0, s1, s2, s3, s4;
|
|
1307
1299
|
var rule$expects = function(expected2) {
|
|
1308
|
-
if (peg$silentFails === 0)
|
|
1309
|
-
peg$expect(expected2);
|
|
1300
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1310
1301
|
};
|
|
1311
1302
|
s0 = peg$currPos;
|
|
1312
1303
|
s1 = [];
|
|
@@ -1346,8 +1337,7 @@ var require_tag = __commonJS({
|
|
|
1346
1337
|
function peg$parseValueHashItem() {
|
|
1347
1338
|
var s0, s1, s2, s3, s4;
|
|
1348
1339
|
var rule$expects = function(expected2) {
|
|
1349
|
-
if (peg$silentFails === 0)
|
|
1350
|
-
peg$expect(expected2);
|
|
1340
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1351
1341
|
};
|
|
1352
1342
|
s0 = peg$currPos;
|
|
1353
1343
|
s1 = peg$parseIdentifier();
|
|
@@ -1390,8 +1380,7 @@ var require_tag = __commonJS({
|
|
|
1390
1380
|
function peg$parseValueNumber() {
|
|
1391
1381
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1392
1382
|
var rule$expects = function(expected2) {
|
|
1393
|
-
if (peg$silentFails === 0)
|
|
1394
|
-
peg$expect(expected2);
|
|
1383
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1395
1384
|
};
|
|
1396
1385
|
rule$expects(peg$e16);
|
|
1397
1386
|
peg$silentFails++;
|
|
@@ -1480,8 +1469,7 @@ var require_tag = __commonJS({
|
|
|
1480
1469
|
function peg$parseValueString() {
|
|
1481
1470
|
var s0, s1, s2, s3;
|
|
1482
1471
|
var rule$expects = function(expected2) {
|
|
1483
|
-
if (peg$silentFails === 0)
|
|
1484
|
-
peg$expect(expected2);
|
|
1472
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1485
1473
|
};
|
|
1486
1474
|
rule$expects(peg$e17);
|
|
1487
1475
|
peg$silentFails++;
|
|
@@ -1522,8 +1510,7 @@ var require_tag = __commonJS({
|
|
|
1522
1510
|
function peg$parseValueStringChars() {
|
|
1523
1511
|
var s0;
|
|
1524
1512
|
var rule$expects = function(expected2) {
|
|
1525
|
-
if (peg$silentFails === 0)
|
|
1526
|
-
peg$expect(expected2);
|
|
1513
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1527
1514
|
};
|
|
1528
1515
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
1529
1516
|
s0 = input.charAt(peg$currPos);
|
|
@@ -1539,8 +1526,7 @@ var require_tag = __commonJS({
|
|
|
1539
1526
|
function peg$parseValueStringEscapes() {
|
|
1540
1527
|
var s0, s1, s2, s3;
|
|
1541
1528
|
var rule$expects = function(expected2) {
|
|
1542
|
-
if (peg$silentFails === 0)
|
|
1543
|
-
peg$expect(expected2);
|
|
1529
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1544
1530
|
};
|
|
1545
1531
|
s0 = peg$currPos;
|
|
1546
1532
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
@@ -1622,8 +1608,7 @@ var require_tag = __commonJS({
|
|
|
1622
1608
|
function peg$parseIdentifier() {
|
|
1623
1609
|
var s0, s1, s2;
|
|
1624
1610
|
var rule$expects = function(expected2) {
|
|
1625
|
-
if (peg$silentFails === 0)
|
|
1626
|
-
peg$expect(expected2);
|
|
1611
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1627
1612
|
};
|
|
1628
1613
|
rule$expects(peg$e18);
|
|
1629
1614
|
peg$silentFails++;
|
|
@@ -1659,8 +1644,7 @@ var require_tag = __commonJS({
|
|
|
1659
1644
|
function peg$parse_() {
|
|
1660
1645
|
var s0;
|
|
1661
1646
|
var rule$expects = function(expected2) {
|
|
1662
|
-
if (peg$silentFails === 0)
|
|
1663
|
-
peg$expect(expected2);
|
|
1647
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1664
1648
|
};
|
|
1665
1649
|
rule$expects(peg$e19);
|
|
1666
1650
|
peg$silentFails++;
|
|
@@ -2271,10 +2255,15 @@ var require_utils = __commonJS({
|
|
|
2271
2255
|
}
|
|
2272
2256
|
switch (code2) {
|
|
2273
2257
|
case 9:
|
|
2258
|
+
// \t
|
|
2274
2259
|
case 10:
|
|
2260
|
+
// \n
|
|
2275
2261
|
case 11:
|
|
2262
|
+
// \v
|
|
2276
2263
|
case 12:
|
|
2264
|
+
// \f
|
|
2277
2265
|
case 13:
|
|
2266
|
+
// \r
|
|
2278
2267
|
case 32:
|
|
2279
2268
|
case 160:
|
|
2280
2269
|
case 5760:
|
|
@@ -3097,10 +3086,8 @@ var require_smartquotes = __commonJS({
|
|
|
3097
3086
|
lastChar = text2.charCodeAt(t.index - 1);
|
|
3098
3087
|
} else {
|
|
3099
3088
|
for (j = i - 1; j >= 0; j--) {
|
|
3100
|
-
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak")
|
|
3101
|
-
|
|
3102
|
-
if (!tokens[j].content)
|
|
3103
|
-
continue;
|
|
3089
|
+
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
|
|
3090
|
+
if (!tokens[j].content) continue;
|
|
3104
3091
|
lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
|
|
3105
3092
|
break;
|
|
3106
3093
|
}
|
|
@@ -3110,10 +3097,8 @@ var require_smartquotes = __commonJS({
|
|
|
3110
3097
|
nextChar = text2.charCodeAt(pos);
|
|
3111
3098
|
} else {
|
|
3112
3099
|
for (j = i + 1; j < tokens.length; j++) {
|
|
3113
|
-
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak")
|
|
3114
|
-
|
|
3115
|
-
if (!tokens[j].content)
|
|
3116
|
-
continue;
|
|
3100
|
+
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
|
|
3101
|
+
if (!tokens[j].content) continue;
|
|
3117
3102
|
nextChar = tokens[j].content.charCodeAt(0);
|
|
3118
3103
|
break;
|
|
3119
3104
|
}
|
|
@@ -3167,7 +3152,11 @@ var require_smartquotes = __commonJS({
|
|
|
3167
3152
|
closeQuote = state.md.options.quotes[1];
|
|
3168
3153
|
}
|
|
3169
3154
|
token.content = replaceAt(token.content, t.index, closeQuote);
|
|
3170
|
-
tokens[item2.token].content = replaceAt(
|
|
3155
|
+
tokens[item2.token].content = replaceAt(
|
|
3156
|
+
tokens[item2.token].content,
|
|
3157
|
+
item2.pos,
|
|
3158
|
+
openQuote
|
|
3159
|
+
);
|
|
3171
3160
|
pos += closeQuote.length - 1;
|
|
3172
3161
|
if (item2.token === i) {
|
|
3173
3162
|
pos += openQuote.length - 1;
|
|
@@ -3419,10 +3408,8 @@ var require_table = __commonJS({
|
|
|
3419
3408
|
return false;
|
|
3420
3409
|
}
|
|
3421
3410
|
columns = escapedSplit(lineText);
|
|
3422
|
-
if (columns.length && columns[0] === "")
|
|
3423
|
-
|
|
3424
|
-
if (columns.length && columns[columns.length - 1] === "")
|
|
3425
|
-
columns.pop();
|
|
3411
|
+
if (columns.length && columns[0] === "") columns.shift();
|
|
3412
|
+
if (columns.length && columns[columns.length - 1] === "") columns.pop();
|
|
3426
3413
|
columnCount = columns.length;
|
|
3427
3414
|
if (columnCount === 0 || columnCount !== aligns.length) {
|
|
3428
3415
|
return false;
|
|
@@ -3473,10 +3460,8 @@ var require_table = __commonJS({
|
|
|
3473
3460
|
break;
|
|
3474
3461
|
}
|
|
3475
3462
|
columns = escapedSplit(lineText);
|
|
3476
|
-
if (columns.length && columns[0] === "")
|
|
3477
|
-
|
|
3478
|
-
if (columns.length && columns[columns.length - 1] === "")
|
|
3479
|
-
columns.pop();
|
|
3463
|
+
if (columns.length && columns[0] === "") columns.shift();
|
|
3464
|
+
if (columns.length && columns[columns.length - 1] === "") columns.pop();
|
|
3480
3465
|
if (nextLine === startLine + 2) {
|
|
3481
3466
|
token = state.push("tbody_open", "tbody", 1);
|
|
3482
3467
|
token.map = tbodyLines = [startLine + 2, 0];
|
|
@@ -3897,16 +3882,14 @@ var require_list = __commonJS({
|
|
|
3897
3882
|
isOrdered = true;
|
|
3898
3883
|
start = state.bMarks[startLine] + state.tShift[startLine];
|
|
3899
3884
|
markerValue = Number(state.src.slice(start, posAfterMarker - 1));
|
|
3900
|
-
if (isTerminatingParagraph && markerValue !== 1)
|
|
3901
|
-
return false;
|
|
3885
|
+
if (isTerminatingParagraph && markerValue !== 1) return false;
|
|
3902
3886
|
} else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
|
|
3903
3887
|
isOrdered = false;
|
|
3904
3888
|
} else {
|
|
3905
3889
|
return false;
|
|
3906
3890
|
}
|
|
3907
3891
|
if (isTerminatingParagraph) {
|
|
3908
|
-
if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine])
|
|
3909
|
-
return false;
|
|
3892
|
+
if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
|
|
3910
3893
|
}
|
|
3911
3894
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
|
|
3912
3895
|
if (silent) {
|
|
@@ -4569,11 +4552,9 @@ var require_state_block = __commonJS({
|
|
|
4569
4552
|
StateBlock.prototype.push = function(type, tag, nesting) {
|
|
4570
4553
|
var token = new Token(type, tag, nesting);
|
|
4571
4554
|
token.block = true;
|
|
4572
|
-
if (nesting < 0)
|
|
4573
|
-
this.level--;
|
|
4555
|
+
if (nesting < 0) this.level--;
|
|
4574
4556
|
token.level = this.level;
|
|
4575
|
-
if (nesting > 0)
|
|
4576
|
-
this.level++;
|
|
4557
|
+
if (nesting > 0) this.level++;
|
|
4577
4558
|
this.tokens.push(token);
|
|
4578
4559
|
return token;
|
|
4579
4560
|
};
|
|
@@ -4676,6 +4657,8 @@ var require_parser_block = __commonJS({
|
|
|
4676
4657
|
"use strict";
|
|
4677
4658
|
var Ruler = require_ruler();
|
|
4678
4659
|
var _rules = [
|
|
4660
|
+
// First 2 params - rule name & source. Secondary array - list of rules,
|
|
4661
|
+
// which can be terminated by this one.
|
|
4679
4662
|
["table", require_table(), ["paragraph", "reference"]],
|
|
4680
4663
|
["code", require_code()],
|
|
4681
4664
|
["fence", require_fence(), ["paragraph", "reference", "blockquote", "list"]],
|
|
@@ -4806,8 +4789,7 @@ var require_newline = __commonJS({
|
|
|
4806
4789
|
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) {
|
|
4807
4790
|
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) {
|
|
4808
4791
|
ws = pmax - 1;
|
|
4809
|
-
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32)
|
|
4810
|
-
ws--;
|
|
4792
|
+
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--;
|
|
4811
4793
|
state.pending = state.pending.slice(0, ws);
|
|
4812
4794
|
state.push("hardbreak", "br", 0);
|
|
4813
4795
|
} else {
|
|
@@ -4899,8 +4881,7 @@ var require_backticks = __commonJS({
|
|
|
4899
4881
|
marker = state.src.slice(start, pos);
|
|
4900
4882
|
openerLength = marker.length;
|
|
4901
4883
|
if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
|
|
4902
|
-
if (!silent)
|
|
4903
|
-
state.pending += marker;
|
|
4884
|
+
if (!silent) state.pending += marker;
|
|
4904
4885
|
state.pos += openerLength;
|
|
4905
4886
|
return true;
|
|
4906
4887
|
}
|
|
@@ -4923,8 +4904,7 @@ var require_backticks = __commonJS({
|
|
|
4923
4904
|
state.backticks[closerLength] = matchStart;
|
|
4924
4905
|
}
|
|
4925
4906
|
state.backticksScanned = true;
|
|
4926
|
-
if (!silent)
|
|
4927
|
-
state.pending += marker;
|
|
4907
|
+
if (!silent) state.pending += marker;
|
|
4928
4908
|
state.pos += openerLength;
|
|
4929
4909
|
return true;
|
|
4930
4910
|
};
|
|
@@ -4960,6 +4940,7 @@ var require_strikethrough = __commonJS({
|
|
|
4960
4940
|
state.delimiters.push({
|
|
4961
4941
|
marker,
|
|
4962
4942
|
length: 0,
|
|
4943
|
+
// disable "rule of 3" length checks meant for emphasis
|
|
4963
4944
|
token: state.tokens.length - 1,
|
|
4964
4945
|
end: -1,
|
|
4965
4946
|
open: scanned.can_open,
|
|
@@ -5039,10 +5020,22 @@ var require_emphasis = __commonJS({
|
|
|
5039
5020
|
token = state.push("text", "", 0);
|
|
5040
5021
|
token.content = String.fromCharCode(marker);
|
|
5041
5022
|
state.delimiters.push({
|
|
5023
|
+
// Char code of the starting marker (number).
|
|
5024
|
+
//
|
|
5042
5025
|
marker,
|
|
5026
|
+
// Total length of these series of delimiters.
|
|
5027
|
+
//
|
|
5043
5028
|
length: scanned.length,
|
|
5029
|
+
// A position of the token this delimiter corresponds to.
|
|
5030
|
+
//
|
|
5044
5031
|
token: state.tokens.length - 1,
|
|
5032
|
+
// If this delimiter is matched as a valid opener, `end` will be
|
|
5033
|
+
// equal to its position, otherwise it's `-1`.
|
|
5034
|
+
//
|
|
5045
5035
|
end: -1,
|
|
5036
|
+
// Boolean flags that determine if this delimiter could open or close
|
|
5037
|
+
// an emphasis.
|
|
5038
|
+
//
|
|
5046
5039
|
open: scanned.can_open,
|
|
5047
5040
|
close: scanned.can_close
|
|
5048
5041
|
});
|
|
@@ -5061,7 +5054,9 @@ var require_emphasis = __commonJS({
|
|
|
5061
5054
|
continue;
|
|
5062
5055
|
}
|
|
5063
5056
|
endDelim = delimiters[startDelim.end];
|
|
5064
|
-
isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 &&
|
|
5057
|
+
isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 && // check that first two markers match and adjacent
|
|
5058
|
+
delimiters[i - 1].marker === startDelim.marker && delimiters[i - 1].token === startDelim.token - 1 && // check that last two markers are adjacent (we can safely assume they match)
|
|
5059
|
+
delimiters[startDelim.end + 1].token === endDelim.token + 1;
|
|
5065
5060
|
ch = String.fromCharCode(startDelim.marker);
|
|
5066
5061
|
token = state.tokens[startDelim.token];
|
|
5067
5062
|
token.type = isStrong ? "strong_open" : "em_open";
|
|
@@ -5294,7 +5289,12 @@ var require_image = __commonJS({
|
|
|
5294
5289
|
}
|
|
5295
5290
|
if (!silent) {
|
|
5296
5291
|
content = state.src.slice(labelStart, labelEnd);
|
|
5297
|
-
state.md.inline.parse(
|
|
5292
|
+
state.md.inline.parse(
|
|
5293
|
+
content,
|
|
5294
|
+
state.md,
|
|
5295
|
+
state.env,
|
|
5296
|
+
tokens = []
|
|
5297
|
+
);
|
|
5298
5298
|
token = state.push("image", "img", 0);
|
|
5299
5299
|
token.attrs = attrs = [["src", href], ["alt", ""]];
|
|
5300
5300
|
token.children = tokens;
|
|
@@ -5324,13 +5324,10 @@ var require_autolink = __commonJS({
|
|
|
5324
5324
|
start = state.pos;
|
|
5325
5325
|
max2 = state.posMax;
|
|
5326
5326
|
for (; ; ) {
|
|
5327
|
-
if (++pos >= max2)
|
|
5328
|
-
return false;
|
|
5327
|
+
if (++pos >= max2) return false;
|
|
5329
5328
|
ch = state.src.charCodeAt(pos);
|
|
5330
|
-
if (ch === 60)
|
|
5331
|
-
|
|
5332
|
-
if (ch === 62)
|
|
5333
|
-
break;
|
|
5329
|
+
if (ch === 60) return false;
|
|
5330
|
+
if (ch === 62) break;
|
|
5334
5331
|
}
|
|
5335
5332
|
url = state.src.slice(start + 1, pos);
|
|
5336
5333
|
if (AUTOLINK_RE.test(url)) {
|
|
@@ -5467,8 +5464,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5467
5464
|
"use strict";
|
|
5468
5465
|
function processDelimiters(state, delimiters) {
|
|
5469
5466
|
var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max2 = delimiters.length;
|
|
5470
|
-
if (!max2)
|
|
5471
|
-
return;
|
|
5467
|
+
if (!max2) return;
|
|
5472
5468
|
var headerIdx = 0;
|
|
5473
5469
|
var lastTokenIdx = -2;
|
|
5474
5470
|
var jumps = [];
|
|
@@ -5480,8 +5476,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5480
5476
|
}
|
|
5481
5477
|
lastTokenIdx = closer.token;
|
|
5482
5478
|
closer.length = closer.length || 0;
|
|
5483
|
-
if (!closer.close)
|
|
5484
|
-
continue;
|
|
5479
|
+
if (!closer.close) continue;
|
|
5485
5480
|
if (!openersBottom.hasOwnProperty(closer.marker)) {
|
|
5486
5481
|
openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1];
|
|
5487
5482
|
}
|
|
@@ -5490,8 +5485,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5490
5485
|
newMinOpenerIdx = openerIdx;
|
|
5491
5486
|
for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
|
|
5492
5487
|
opener = delimiters[openerIdx];
|
|
5493
|
-
if (opener.marker !== closer.marker)
|
|
5494
|
-
continue;
|
|
5488
|
+
if (opener.marker !== closer.marker) continue;
|
|
5495
5489
|
if (opener.open && opener.end < 0) {
|
|
5496
5490
|
isOddMatch = false;
|
|
5497
5491
|
if (opener.close || closer.open) {
|
|
@@ -5538,11 +5532,9 @@ var require_text_collapse = __commonJS({
|
|
|
5538
5532
|
module.exports = function text_collapse(state) {
|
|
5539
5533
|
var curr, last, level = 0, tokens = state.tokens, max2 = state.tokens.length;
|
|
5540
5534
|
for (curr = last = 0; curr < max2; curr++) {
|
|
5541
|
-
if (tokens[curr].nesting < 0)
|
|
5542
|
-
level--;
|
|
5535
|
+
if (tokens[curr].nesting < 0) level--;
|
|
5543
5536
|
tokens[curr].level = level;
|
|
5544
|
-
if (tokens[curr].nesting > 0)
|
|
5545
|
-
level++;
|
|
5537
|
+
if (tokens[curr].nesting > 0) level++;
|
|
5546
5538
|
if (tokens[curr].type === "text" && curr + 1 < max2 && tokens[curr + 1].type === "text") {
|
|
5547
5539
|
tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
|
|
5548
5540
|
} else {
|
|
@@ -5775,7 +5767,8 @@ var require_re = __commonJS({
|
|
|
5775
5767
|
re.src_path = "(?:[/?#](?:(?!" + re.src_ZCc + "|" + text_separators + `|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!` + re.src_ZCc + "|\\]).)*\\]|\\((?:(?!" + re.src_ZCc + "|[)]).)*\\)|\\{(?:(?!" + re.src_ZCc + '|[}]).)*\\}|\\"(?:(?!' + re.src_ZCc + `|["]).)+\\"|\\'(?:(?!` + re.src_ZCc + "|[']).)+\\'|\\'(?=" + re.src_pseudo_letter + "|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!" + re.src_ZCc + "|[.]).|" + (opts && opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-*)|" : "\\-+|") + ",(?!" + re.src_ZCc + ").|;(?!" + re.src_ZCc + ").|\\!+(?!" + re.src_ZCc + "|[!]).|\\?(?!" + re.src_ZCc + "|[?]).)+|\\/)?";
|
|
5776
5768
|
re.src_email_name = '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
|
|
5777
5769
|
re.src_xn = "xn--[a-z0-9\\-]{1,59}";
|
|
5778
|
-
re.src_domain_root =
|
|
5770
|
+
re.src_domain_root = // Allow letters & digits (http://test1)
|
|
5771
|
+
"(?:" + re.src_xn + "|" + re.src_pseudo_letter + "{1,63})";
|
|
5779
5772
|
re.src_domain = "(?:" + re.src_xn + "|(?:" + re.src_pseudo_letter + ")|(?:" + re.src_pseudo_letter + "(?:-|" + re.src_pseudo_letter + "){0,61}" + re.src_pseudo_letter + "))";
|
|
5780
5773
|
re.src_host = "(?:(?:(?:(?:" + re.src_domain + ")\\.)*" + re.src_domain + "))";
|
|
5781
5774
|
re.tpl_host_fuzzy = "(?:" + re.src_ip4 + "|(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%)))";
|
|
@@ -5787,8 +5780,12 @@ var require_re = __commonJS({
|
|
|
5787
5780
|
re.tpl_host_port_no_ip_fuzzy_strict = re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
|
|
5788
5781
|
re.tpl_host_fuzzy_test = "localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:" + re.src_ZPCc + "|>|$))";
|
|
5789
5782
|
re.tpl_email_fuzzy = "(^|" + text_separators + '|"|\\(|' + re.src_ZCc + ")(" + re.src_email_name + "@" + re.tpl_host_fuzzy_strict + ")";
|
|
5790
|
-
re.tpl_link_fuzzy =
|
|
5791
|
-
|
|
5783
|
+
re.tpl_link_fuzzy = // Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
5784
|
+
// but can start with > (markdown blockquote)
|
|
5785
|
+
"(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|" + re.src_ZPCc + "))((?![$+<=>^`|\uFF5C])" + re.tpl_host_port_fuzzy_strict + re.src_path + ")";
|
|
5786
|
+
re.tpl_link_no_ip_fuzzy = // Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
5787
|
+
// but can start with > (markdown blockquote)
|
|
5788
|
+
"(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|" + re.src_ZPCc + "))((?![$+<=>^`|\uFF5C])" + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ")";
|
|
5792
5789
|
return re;
|
|
5793
5790
|
};
|
|
5794
5791
|
}
|
|
@@ -5843,7 +5840,10 @@ var require_linkify_it = __commonJS({
|
|
|
5843
5840
|
validate: function(text2, pos, self) {
|
|
5844
5841
|
var tail = text2.slice(pos);
|
|
5845
5842
|
if (!self.re.http) {
|
|
5846
|
-
self.re.http = new RegExp(
|
|
5843
|
+
self.re.http = new RegExp(
|
|
5844
|
+
"^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path,
|
|
5845
|
+
"i"
|
|
5846
|
+
);
|
|
5847
5847
|
}
|
|
5848
5848
|
if (self.re.http.test(tail)) {
|
|
5849
5849
|
return tail.match(self.re.http)[0].length;
|
|
@@ -5857,7 +5857,12 @@ var require_linkify_it = __commonJS({
|
|
|
5857
5857
|
validate: function(text2, pos, self) {
|
|
5858
5858
|
var tail = text2.slice(pos);
|
|
5859
5859
|
if (!self.re.no_http) {
|
|
5860
|
-
self.re.no_http = new RegExp(
|
|
5860
|
+
self.re.no_http = new RegExp(
|
|
5861
|
+
"^" + self.re.src_auth + // Don't allow single-level domains, because of false positives like '//test'
|
|
5862
|
+
// with code comments
|
|
5863
|
+
"(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path,
|
|
5864
|
+
"i"
|
|
5865
|
+
);
|
|
5861
5866
|
}
|
|
5862
5867
|
if (self.re.no_http.test(tail)) {
|
|
5863
5868
|
if (pos >= 3 && text2[pos - 3] === ":") {
|
|
@@ -5875,7 +5880,10 @@ var require_linkify_it = __commonJS({
|
|
|
5875
5880
|
validate: function(text2, pos, self) {
|
|
5876
5881
|
var tail = text2.slice(pos);
|
|
5877
5882
|
if (!self.re.mailto) {
|
|
5878
|
-
self.re.mailto = new RegExp(
|
|
5883
|
+
self.re.mailto = new RegExp(
|
|
5884
|
+
"^" + self.re.src_email_name + "@" + self.re.src_host_strict,
|
|
5885
|
+
"i"
|
|
5886
|
+
);
|
|
5879
5887
|
}
|
|
5880
5888
|
if (self.re.mailto.test(tail)) {
|
|
5881
5889
|
return tail.match(self.re.mailto)[0].length;
|
|
@@ -5968,7 +5976,10 @@ var require_linkify_it = __commonJS({
|
|
|
5968
5976
|
}).map(escapeRE).join("|");
|
|
5969
5977
|
self.re.schema_test = RegExp("(^|(?!_)(?:[><\uFF5C]|" + re.src_ZPCc + "))(" + slist + ")", "i");
|
|
5970
5978
|
self.re.schema_search = RegExp("(^|(?!_)(?:[><\uFF5C]|" + re.src_ZPCc + "))(" + slist + ")", "ig");
|
|
5971
|
-
self.re.pretest = RegExp(
|
|
5979
|
+
self.re.pretest = RegExp(
|
|
5980
|
+
"(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
|
|
5981
|
+
"i"
|
|
5982
|
+
);
|
|
5972
5983
|
resetScanCache(self);
|
|
5973
5984
|
}
|
|
5974
5985
|
function Match(self, shift) {
|
|
@@ -6135,7 +6146,7 @@ var require_punycode = __commonJS({
|
|
|
6135
6146
|
var initialN = 128;
|
|
6136
6147
|
var delimiter = "-";
|
|
6137
6148
|
var regexPunycode = /^xn--/;
|
|
6138
|
-
var regexNonASCII = /[^\0-\
|
|
6149
|
+
var regexNonASCII = /[^\0-\x7F]/;
|
|
6139
6150
|
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
6140
6151
|
var errors = {
|
|
6141
6152
|
"overflow": "Overflow: input needs wider integers to process",
|
|
@@ -6148,24 +6159,24 @@ var require_punycode = __commonJS({
|
|
|
6148
6159
|
function error2(type) {
|
|
6149
6160
|
throw new RangeError(errors[type]);
|
|
6150
6161
|
}
|
|
6151
|
-
function map(array,
|
|
6162
|
+
function map(array, callback) {
|
|
6152
6163
|
const result = [];
|
|
6153
6164
|
let length = array.length;
|
|
6154
6165
|
while (length--) {
|
|
6155
|
-
result[length] =
|
|
6166
|
+
result[length] = callback(array[length]);
|
|
6156
6167
|
}
|
|
6157
6168
|
return result;
|
|
6158
6169
|
}
|
|
6159
|
-
function mapDomain(
|
|
6160
|
-
const parts =
|
|
6170
|
+
function mapDomain(domain, callback) {
|
|
6171
|
+
const parts = domain.split("@");
|
|
6161
6172
|
let result = "";
|
|
6162
6173
|
if (parts.length > 1) {
|
|
6163
6174
|
result = parts[0] + "@";
|
|
6164
|
-
|
|
6175
|
+
domain = parts[1];
|
|
6165
6176
|
}
|
|
6166
|
-
|
|
6167
|
-
const labels =
|
|
6168
|
-
const encoded = map(labels,
|
|
6177
|
+
domain = domain.replace(regexSeparators, ".");
|
|
6178
|
+
const labels = domain.split(".");
|
|
6179
|
+
const encoded = map(labels, callback).join(".");
|
|
6169
6180
|
return result + encoded;
|
|
6170
6181
|
}
|
|
6171
6182
|
function ucs2decode(string) {
|
|
@@ -6188,15 +6199,15 @@ var require_punycode = __commonJS({
|
|
|
6188
6199
|
}
|
|
6189
6200
|
return output;
|
|
6190
6201
|
}
|
|
6191
|
-
var ucs2encode = (
|
|
6202
|
+
var ucs2encode = (codePoints) => String.fromCodePoint(...codePoints);
|
|
6192
6203
|
var basicToDigit = function(codePoint) {
|
|
6193
|
-
if (codePoint
|
|
6194
|
-
return codePoint -
|
|
6204
|
+
if (codePoint >= 48 && codePoint < 58) {
|
|
6205
|
+
return 26 + (codePoint - 48);
|
|
6195
6206
|
}
|
|
6196
|
-
if (codePoint
|
|
6207
|
+
if (codePoint >= 65 && codePoint < 91) {
|
|
6197
6208
|
return codePoint - 65;
|
|
6198
6209
|
}
|
|
6199
|
-
if (codePoint
|
|
6210
|
+
if (codePoint >= 97 && codePoint < 123) {
|
|
6200
6211
|
return codePoint - 97;
|
|
6201
6212
|
}
|
|
6202
6213
|
return base;
|
|
@@ -6230,13 +6241,16 @@ var require_punycode = __commonJS({
|
|
|
6230
6241
|
output.push(input.charCodeAt(j));
|
|
6231
6242
|
}
|
|
6232
6243
|
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
6233
|
-
|
|
6244
|
+
const oldi = i;
|
|
6234
6245
|
for (let w = 1, k = base; ; k += base) {
|
|
6235
6246
|
if (index >= inputLength) {
|
|
6236
6247
|
error2("invalid-input");
|
|
6237
6248
|
}
|
|
6238
6249
|
const digit = basicToDigit(input.charCodeAt(index++));
|
|
6239
|
-
if (digit >= base
|
|
6250
|
+
if (digit >= base) {
|
|
6251
|
+
error2("invalid-input");
|
|
6252
|
+
}
|
|
6253
|
+
if (digit > floor((maxInt - i) / w)) {
|
|
6240
6254
|
error2("overflow");
|
|
6241
6255
|
}
|
|
6242
6256
|
i += digit * w;
|
|
@@ -6264,7 +6278,7 @@ var require_punycode = __commonJS({
|
|
|
6264
6278
|
var encode = function(input) {
|
|
6265
6279
|
const output = [];
|
|
6266
6280
|
input = ucs2decode(input);
|
|
6267
|
-
|
|
6281
|
+
const inputLength = input.length;
|
|
6268
6282
|
let n = initialN;
|
|
6269
6283
|
let delta = 0;
|
|
6270
6284
|
let bias = initialBias;
|
|
@@ -6273,7 +6287,7 @@ var require_punycode = __commonJS({
|
|
|
6273
6287
|
output.push(stringFromCharCode(currentValue));
|
|
6274
6288
|
}
|
|
6275
6289
|
}
|
|
6276
|
-
|
|
6290
|
+
const basicLength = output.length;
|
|
6277
6291
|
let handledCPCount = basicLength;
|
|
6278
6292
|
if (basicLength) {
|
|
6279
6293
|
output.push(delimiter);
|
|
@@ -6295,7 +6309,7 @@ var require_punycode = __commonJS({
|
|
|
6295
6309
|
if (currentValue < n && ++delta > maxInt) {
|
|
6296
6310
|
error2("overflow");
|
|
6297
6311
|
}
|
|
6298
|
-
if (currentValue
|
|
6312
|
+
if (currentValue === n) {
|
|
6299
6313
|
let q = delta;
|
|
6300
6314
|
for (let k = base; ; k += base) {
|
|
6301
6315
|
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
@@ -6304,11 +6318,13 @@ var require_punycode = __commonJS({
|
|
|
6304
6318
|
}
|
|
6305
6319
|
const qMinusT = q - t;
|
|
6306
6320
|
const baseMinusT = base - t;
|
|
6307
|
-
output.push(
|
|
6321
|
+
output.push(
|
|
6322
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
6323
|
+
);
|
|
6308
6324
|
q = floor(qMinusT / baseMinusT);
|
|
6309
6325
|
}
|
|
6310
6326
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
6311
|
-
bias = adapt(delta, handledCPCountPlusOne, handledCPCount
|
|
6327
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
6312
6328
|
delta = 0;
|
|
6313
6329
|
++handledCPCount;
|
|
6314
6330
|
}
|
|
@@ -6329,7 +6345,19 @@ var require_punycode = __commonJS({
|
|
|
6329
6345
|
});
|
|
6330
6346
|
};
|
|
6331
6347
|
var punycode = {
|
|
6332
|
-
|
|
6348
|
+
/**
|
|
6349
|
+
* A string representing the current Punycode.js version number.
|
|
6350
|
+
* @memberOf punycode
|
|
6351
|
+
* @type String
|
|
6352
|
+
*/
|
|
6353
|
+
"version": "2.3.1",
|
|
6354
|
+
/**
|
|
6355
|
+
* An object of methods to convert from JavaScript's internal character
|
|
6356
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
6357
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
6358
|
+
* @memberOf punycode
|
|
6359
|
+
* @type Object
|
|
6360
|
+
*/
|
|
6333
6361
|
"ucs2": {
|
|
6334
6362
|
"decode": ucs2decode,
|
|
6335
6363
|
"encode": ucs2encode
|
|
@@ -6350,14 +6378,33 @@ var require_default = __commonJS({
|
|
|
6350
6378
|
module.exports = {
|
|
6351
6379
|
options: {
|
|
6352
6380
|
html: false,
|
|
6381
|
+
// Enable HTML tags in source
|
|
6353
6382
|
xhtmlOut: false,
|
|
6383
|
+
// Use '/' to close single tags (<br />)
|
|
6354
6384
|
breaks: false,
|
|
6385
|
+
// Convert '\n' in paragraphs into <br>
|
|
6355
6386
|
langPrefix: "language-",
|
|
6387
|
+
// CSS language prefix for fenced blocks
|
|
6356
6388
|
linkify: false,
|
|
6389
|
+
// autoconvert URL-like texts to links
|
|
6390
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6357
6391
|
typographer: false,
|
|
6392
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6393
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6394
|
+
//
|
|
6395
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6396
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6358
6397
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6398
|
+
/* “”‘’ */
|
|
6399
|
+
// Highlighter function. Should return escaped HTML,
|
|
6400
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6401
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6402
|
+
//
|
|
6403
|
+
// function (/*str, lang*/) { return ''; }
|
|
6404
|
+
//
|
|
6359
6405
|
highlight: null,
|
|
6360
6406
|
maxNesting: 100
|
|
6407
|
+
// Internal protection, recursion limit
|
|
6361
6408
|
},
|
|
6362
6409
|
components: {
|
|
6363
6410
|
core: {},
|
|
@@ -6375,14 +6422,33 @@ var require_zero = __commonJS({
|
|
|
6375
6422
|
module.exports = {
|
|
6376
6423
|
options: {
|
|
6377
6424
|
html: false,
|
|
6425
|
+
// Enable HTML tags in source
|
|
6378
6426
|
xhtmlOut: false,
|
|
6427
|
+
// Use '/' to close single tags (<br />)
|
|
6379
6428
|
breaks: false,
|
|
6429
|
+
// Convert '\n' in paragraphs into <br>
|
|
6380
6430
|
langPrefix: "language-",
|
|
6431
|
+
// CSS language prefix for fenced blocks
|
|
6381
6432
|
linkify: false,
|
|
6433
|
+
// autoconvert URL-like texts to links
|
|
6434
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6382
6435
|
typographer: false,
|
|
6436
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6437
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6438
|
+
//
|
|
6439
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6440
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6383
6441
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6442
|
+
/* “”‘’ */
|
|
6443
|
+
// Highlighter function. Should return escaped HTML,
|
|
6444
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6445
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6446
|
+
//
|
|
6447
|
+
// function (/*str, lang*/) { return ''; }
|
|
6448
|
+
//
|
|
6384
6449
|
highlight: null,
|
|
6385
6450
|
maxNesting: 20
|
|
6451
|
+
// Internal protection, recursion limit
|
|
6386
6452
|
},
|
|
6387
6453
|
components: {
|
|
6388
6454
|
core: {
|
|
@@ -6418,14 +6484,33 @@ var require_commonmark = __commonJS({
|
|
|
6418
6484
|
module.exports = {
|
|
6419
6485
|
options: {
|
|
6420
6486
|
html: true,
|
|
6487
|
+
// Enable HTML tags in source
|
|
6421
6488
|
xhtmlOut: true,
|
|
6489
|
+
// Use '/' to close single tags (<br />)
|
|
6422
6490
|
breaks: false,
|
|
6491
|
+
// Convert '\n' in paragraphs into <br>
|
|
6423
6492
|
langPrefix: "language-",
|
|
6493
|
+
// CSS language prefix for fenced blocks
|
|
6424
6494
|
linkify: false,
|
|
6495
|
+
// autoconvert URL-like texts to links
|
|
6496
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6425
6497
|
typographer: false,
|
|
6498
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6499
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6500
|
+
//
|
|
6501
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6502
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6426
6503
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6504
|
+
/* “”‘’ */
|
|
6505
|
+
// Highlighter function. Should return escaped HTML,
|
|
6506
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6507
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6508
|
+
//
|
|
6509
|
+
// function (/*str, lang*/) { return ''; }
|
|
6510
|
+
//
|
|
6427
6511
|
highlight: null,
|
|
6428
6512
|
maxNesting: 20
|
|
6513
|
+
// Internal protection, recursion limit
|
|
6429
6514
|
},
|
|
6430
6515
|
components: {
|
|
6431
6516
|
core: {
|
|
@@ -6671,30 +6756,20 @@ function isVariable(value) {
|
|
|
6671
6756
|
return !!(value?.$$mdtype === "Variable");
|
|
6672
6757
|
}
|
|
6673
6758
|
function* getAstValues(value) {
|
|
6674
|
-
if (value == null || typeof value !== "object")
|
|
6675
|
-
|
|
6676
|
-
if (
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
if (isAst(value))
|
|
6680
|
-
yield value;
|
|
6681
|
-
if (Object.getPrototypeOf(value) !== Object.prototype)
|
|
6682
|
-
return;
|
|
6683
|
-
for (const v of Object.values(value))
|
|
6684
|
-
yield* getAstValues(v);
|
|
6759
|
+
if (value == null || typeof value !== "object") return;
|
|
6760
|
+
if (Array.isArray(value)) for (const v of value) yield* getAstValues(v);
|
|
6761
|
+
if (isAst(value)) yield value;
|
|
6762
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return;
|
|
6763
|
+
for (const v of Object.values(value)) yield* getAstValues(v);
|
|
6685
6764
|
}
|
|
6686
6765
|
function resolve(value, config = {}) {
|
|
6687
|
-
if (value == null || typeof value !== "object")
|
|
6688
|
-
|
|
6689
|
-
if (Array.isArray(value))
|
|
6690
|
-
return value.map((item2) => resolve(item2, config));
|
|
6766
|
+
if (value == null || typeof value !== "object") return value;
|
|
6767
|
+
if (Array.isArray(value)) return value.map((item2) => resolve(item2, config));
|
|
6691
6768
|
if (isAst(value) && value?.resolve instanceof Function)
|
|
6692
6769
|
return value.resolve(config);
|
|
6693
|
-
if (Object.getPrototypeOf(value) !== Object.prototype)
|
|
6694
|
-
return value;
|
|
6770
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return value;
|
|
6695
6771
|
const output = {};
|
|
6696
|
-
for (const [k, v] of Object.entries(value))
|
|
6697
|
-
output[k] = resolve(v, config);
|
|
6772
|
+
for (const [k, v] of Object.entries(value)) output[k] = resolve(v, config);
|
|
6698
6773
|
return output;
|
|
6699
6774
|
}
|
|
6700
6775
|
|
|
@@ -6706,16 +6781,17 @@ var Tag = class {
|
|
|
6706
6781
|
this.attributes = attributes;
|
|
6707
6782
|
this.children = children;
|
|
6708
6783
|
}
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6784
|
+
static {
|
|
6785
|
+
this.isTag = (tag) => {
|
|
6786
|
+
return !!(tag?.$$mdtype === "Tag");
|
|
6787
|
+
};
|
|
6788
|
+
}
|
|
6712
6789
|
};
|
|
6713
6790
|
|
|
6714
6791
|
// src/schema-types/class.ts
|
|
6715
6792
|
var Class = class {
|
|
6716
6793
|
validate(value, _config, key) {
|
|
6717
|
-
if (typeof value === "string" || typeof value === "object")
|
|
6718
|
-
return [];
|
|
6794
|
+
if (typeof value === "string" || typeof value === "object") return [];
|
|
6719
6795
|
return [
|
|
6720
6796
|
{
|
|
6721
6797
|
id: "attribute-type-invalid",
|
|
@@ -6725,12 +6801,9 @@ var Class = class {
|
|
|
6725
6801
|
];
|
|
6726
6802
|
}
|
|
6727
6803
|
transform(value) {
|
|
6728
|
-
if (!value || typeof value === "string")
|
|
6729
|
-
return value;
|
|
6804
|
+
if (!value || typeof value === "string") return value;
|
|
6730
6805
|
const classes = [];
|
|
6731
|
-
for (const [k, v] of Object.entries(value ?? {}))
|
|
6732
|
-
if (v)
|
|
6733
|
-
classes.push(k);
|
|
6806
|
+
for (const [k, v] of Object.entries(value ?? {})) if (v) classes.push(k);
|
|
6734
6807
|
return classes.join(" ");
|
|
6735
6808
|
}
|
|
6736
6809
|
};
|
|
@@ -6738,8 +6811,7 @@ var Class = class {
|
|
|
6738
6811
|
// src/schema-types/id.ts
|
|
6739
6812
|
var Id = class {
|
|
6740
6813
|
validate(value) {
|
|
6741
|
-
if (typeof value === "string" && value.match(/^[a-zA-Z]/))
|
|
6742
|
-
return [];
|
|
6814
|
+
if (typeof value === "string" && value.match(/^[a-zA-Z]/)) return [];
|
|
6743
6815
|
return [
|
|
6744
6816
|
{
|
|
6745
6817
|
id: "attribute-value-invalid",
|
|
@@ -6751,7 +6823,7 @@ var Id = class {
|
|
|
6751
6823
|
};
|
|
6752
6824
|
|
|
6753
6825
|
// src/utils.ts
|
|
6754
|
-
var import_tag =
|
|
6826
|
+
var import_tag = __toESM(require_tag());
|
|
6755
6827
|
|
|
6756
6828
|
// src/ast/variable.ts
|
|
6757
6829
|
var Variable = class {
|
|
@@ -6773,20 +6845,13 @@ var Function2 = class {
|
|
|
6773
6845
|
}
|
|
6774
6846
|
resolve(config = {}) {
|
|
6775
6847
|
const fn = config?.functions?.[this.name];
|
|
6776
|
-
if (!fn)
|
|
6777
|
-
return null;
|
|
6848
|
+
if (!fn) return null;
|
|
6778
6849
|
const parameters = resolve(this.parameters, config);
|
|
6779
6850
|
return fn.transform?.(parameters, config);
|
|
6780
6851
|
}
|
|
6781
6852
|
};
|
|
6782
6853
|
|
|
6783
6854
|
// src/utils.ts
|
|
6784
|
-
var STATES;
|
|
6785
|
-
(function(STATES2) {
|
|
6786
|
-
STATES2[STATES2["normal"] = 0] = "normal";
|
|
6787
|
-
STATES2[STATES2["string"] = 1] = "string";
|
|
6788
|
-
STATES2[STATES2["escape"] = 2] = "escape";
|
|
6789
|
-
})(STATES || (STATES = {}));
|
|
6790
6855
|
var OPEN = "{%";
|
|
6791
6856
|
var CLOSE = "%}";
|
|
6792
6857
|
var IDENTIFIER_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
@@ -6797,28 +6862,26 @@ function isPromise(a) {
|
|
|
6797
6862
|
return a && typeof a === "object" && typeof a.then === "function";
|
|
6798
6863
|
}
|
|
6799
6864
|
function findTagEnd(content, start = 0) {
|
|
6800
|
-
let state = 0
|
|
6865
|
+
let state = 0 /* normal */;
|
|
6801
6866
|
for (let pos = start; pos < content.length; pos++) {
|
|
6802
6867
|
const char = content[pos];
|
|
6803
6868
|
switch (state) {
|
|
6804
|
-
case 1
|
|
6869
|
+
case 1 /* string */:
|
|
6805
6870
|
switch (char) {
|
|
6806
6871
|
case '"':
|
|
6807
|
-
state = 0
|
|
6872
|
+
state = 0 /* normal */;
|
|
6808
6873
|
break;
|
|
6809
6874
|
case "\\":
|
|
6810
|
-
state = 2
|
|
6875
|
+
state = 2 /* escape */;
|
|
6811
6876
|
break;
|
|
6812
6877
|
}
|
|
6813
6878
|
break;
|
|
6814
|
-
case 2
|
|
6815
|
-
state = 1
|
|
6879
|
+
case 2 /* escape */:
|
|
6880
|
+
state = 1 /* string */;
|
|
6816
6881
|
break;
|
|
6817
|
-
case 0
|
|
6818
|
-
if (char === '"')
|
|
6819
|
-
|
|
6820
|
-
else if (content.startsWith(CLOSE, pos))
|
|
6821
|
-
return pos;
|
|
6882
|
+
case 0 /* normal */:
|
|
6883
|
+
if (char === '"') state = 1 /* string */;
|
|
6884
|
+
else if (content.startsWith(CLOSE, pos)) return pos;
|
|
6822
6885
|
}
|
|
6823
6886
|
}
|
|
6824
6887
|
return null;
|
|
@@ -6827,8 +6890,7 @@ function parseTag(content, line, contentStart) {
|
|
|
6827
6890
|
try {
|
|
6828
6891
|
return (0, import_tag.parse)(content, { Variable, Function: Function2 });
|
|
6829
6892
|
} catch (error2) {
|
|
6830
|
-
if (!(error2 instanceof import_tag.SyntaxError))
|
|
6831
|
-
throw error2;
|
|
6893
|
+
if (!(error2 instanceof import_tag.SyntaxError)) throw error2;
|
|
6832
6894
|
const {
|
|
6833
6895
|
message,
|
|
6834
6896
|
location: { start, end }
|
|
@@ -6849,8 +6911,7 @@ function parseTags(content, firstLine = 0) {
|
|
|
6849
6911
|
line++;
|
|
6850
6912
|
continue;
|
|
6851
6913
|
}
|
|
6852
|
-
if (!content.startsWith(OPEN, pos))
|
|
6853
|
-
continue;
|
|
6914
|
+
if (!content.startsWith(OPEN, pos)) continue;
|
|
6854
6915
|
const end = findTagEnd(content, pos);
|
|
6855
6916
|
if (end == null) {
|
|
6856
6917
|
pos = pos + OPEN.length;
|
|
@@ -6907,8 +6968,7 @@ var transformer_default = {
|
|
|
6907
6968
|
const output = {};
|
|
6908
6969
|
const attrs = { ...globalAttributes, ...schema.attributes };
|
|
6909
6970
|
for (const [key, attr] of Object.entries(attrs)) {
|
|
6910
|
-
if (attr.render == false)
|
|
6911
|
-
continue;
|
|
6971
|
+
if (attr.render == false) continue;
|
|
6912
6972
|
const name = typeof attr.render === "string" ? attr.render : key;
|
|
6913
6973
|
let value = node2.attributes[key];
|
|
6914
6974
|
if (typeof attr.type === "function") {
|
|
@@ -6918,23 +6978,22 @@ var transformer_default = {
|
|
|
6918
6978
|
}
|
|
6919
6979
|
}
|
|
6920
6980
|
value = value === void 0 ? attr.default : value;
|
|
6921
|
-
if (value === void 0)
|
|
6922
|
-
continue;
|
|
6981
|
+
if (value === void 0) continue;
|
|
6923
6982
|
output[name] = value;
|
|
6924
6983
|
}
|
|
6925
6984
|
if (schema.slots) {
|
|
6926
6985
|
for (const [key, slot2] of Object.entries(schema.slots)) {
|
|
6927
|
-
if (slot2.render === false)
|
|
6928
|
-
continue;
|
|
6986
|
+
if (slot2.render === false) continue;
|
|
6929
6987
|
const name = typeof slot2.render === "string" ? slot2.render : key;
|
|
6930
|
-
if (node2.slots[key])
|
|
6931
|
-
output[name] = this.node(node2.slots[key], config);
|
|
6988
|
+
if (node2.slots[key]) output[name] = this.node(node2.slots[key], config);
|
|
6932
6989
|
}
|
|
6933
6990
|
}
|
|
6934
6991
|
return output;
|
|
6935
6992
|
},
|
|
6936
6993
|
children(node2, config = {}) {
|
|
6937
|
-
const children = node2.children.flatMap(
|
|
6994
|
+
const children = node2.children.flatMap(
|
|
6995
|
+
(child) => this.node(child, config)
|
|
6996
|
+
);
|
|
6938
6997
|
if (children.some(isPromise)) {
|
|
6939
6998
|
return Promise.all(children);
|
|
6940
6999
|
}
|
|
@@ -6945,18 +7004,19 @@ var transformer_default = {
|
|
|
6945
7004
|
if (schema && schema.transform instanceof Function)
|
|
6946
7005
|
return schema.transform(node2, config);
|
|
6947
7006
|
const children = this.children(node2, config);
|
|
6948
|
-
if (!schema || !schema.render)
|
|
6949
|
-
return children;
|
|
7007
|
+
if (!schema || !schema.render) return children;
|
|
6950
7008
|
const attributes = this.attributes(node2, config);
|
|
6951
7009
|
if (isPromise(attributes) || isPromise(children)) {
|
|
6952
|
-
return Promise.all([attributes, children]).then(
|
|
7010
|
+
return Promise.all([attributes, children]).then(
|
|
7011
|
+
(values) => new Tag(schema.render, ...values)
|
|
7012
|
+
);
|
|
6953
7013
|
}
|
|
6954
7014
|
return new Tag(schema.render, attributes, children);
|
|
6955
7015
|
}
|
|
6956
7016
|
};
|
|
6957
7017
|
|
|
6958
7018
|
// src/ast/node.ts
|
|
6959
|
-
var Node = class {
|
|
7019
|
+
var Node = class _Node {
|
|
6960
7020
|
constructor(type = "node", attributes = {}, children = [], tag) {
|
|
6961
7021
|
this.$$mdtype = "Node";
|
|
6962
7022
|
this.errors = [];
|
|
@@ -6979,13 +7039,15 @@ var Node = class {
|
|
|
6979
7039
|
this.children.push(node2);
|
|
6980
7040
|
}
|
|
6981
7041
|
resolve(config = {}) {
|
|
6982
|
-
return Object.assign(new
|
|
7042
|
+
return Object.assign(new _Node(), this, {
|
|
6983
7043
|
children: this.children.map((child) => child.resolve(config)),
|
|
6984
7044
|
attributes: resolve(this.attributes, config),
|
|
6985
|
-
slots: Object.fromEntries(
|
|
6986
|
-
name,
|
|
6987
|
-
|
|
6988
|
-
|
|
7045
|
+
slots: Object.fromEntries(
|
|
7046
|
+
Object.entries(this.slots).map(([name, slot2]) => [
|
|
7047
|
+
name,
|
|
7048
|
+
slot2.resolve(config)
|
|
7049
|
+
])
|
|
7050
|
+
)
|
|
6989
7051
|
});
|
|
6990
7052
|
}
|
|
6991
7053
|
findSchema(config = {}) {
|
|
@@ -7009,8 +7071,7 @@ var AstTypes = {
|
|
|
7009
7071
|
Variable
|
|
7010
7072
|
};
|
|
7011
7073
|
function reviver(_, value) {
|
|
7012
|
-
if (!value)
|
|
7013
|
-
return value;
|
|
7074
|
+
if (!value) return value;
|
|
7014
7075
|
const klass = AstTypes[value.$$mdtype];
|
|
7015
7076
|
return klass ? Object.assign(new klass(), value) : value;
|
|
7016
7077
|
}
|
|
@@ -7061,20 +7122,19 @@ function formatScalar(v) {
|
|
|
7061
7122
|
return "[" + v.map(formatScalar).join(SEP) + "]";
|
|
7062
7123
|
}
|
|
7063
7124
|
if (typeof v === "object") {
|
|
7064
|
-
return "{" + Object.entries(v).map(
|
|
7125
|
+
return "{" + Object.entries(v).map(
|
|
7126
|
+
([key, value]) => `${isIdentifier(key) ? key : `"${key}"`}: ${formatScalar(value)}`
|
|
7127
|
+
).join(SEP) + "}";
|
|
7065
7128
|
}
|
|
7066
7129
|
return JSON.stringify(v);
|
|
7067
7130
|
}
|
|
7068
7131
|
function formatAnnotationValue(a) {
|
|
7069
7132
|
const formattedValue = formatScalar(a.value);
|
|
7070
|
-
if (formattedValue === void 0)
|
|
7071
|
-
|
|
7072
|
-
if (a.name === "primary")
|
|
7073
|
-
return formattedValue;
|
|
7133
|
+
if (formattedValue === void 0) return void 0;
|
|
7134
|
+
if (a.name === "primary") return formattedValue;
|
|
7074
7135
|
if (a.name === "id" && typeof a.value === "string" && isIdentifier(a.value))
|
|
7075
7136
|
return "#" + a.value;
|
|
7076
|
-
if (a.type === "class" && isIdentifier(a.name))
|
|
7077
|
-
return "." + a.name;
|
|
7137
|
+
if (a.type === "class" && isIdentifier(a.name)) return "." + a.name;
|
|
7078
7138
|
return `${a.name}=${formattedValue}`;
|
|
7079
7139
|
}
|
|
7080
7140
|
function* formatAttributes(n) {
|
|
@@ -7083,8 +7143,7 @@ function* formatAttributes(n) {
|
|
|
7083
7143
|
for (const name of Object.keys(value)) {
|
|
7084
7144
|
yield formatAnnotationValue({ type: "class", name, value });
|
|
7085
7145
|
}
|
|
7086
|
-
else
|
|
7087
|
-
yield formatAnnotationValue({ type: "attribute", name: key, value });
|
|
7146
|
+
else yield formatAnnotationValue({ type: "attribute", name: key, value });
|
|
7088
7147
|
}
|
|
7089
7148
|
}
|
|
7090
7149
|
function* formatAnnotations(n) {
|
|
@@ -7097,12 +7156,9 @@ function* formatAnnotations(n) {
|
|
|
7097
7156
|
function* formatVariable(v) {
|
|
7098
7157
|
yield "$";
|
|
7099
7158
|
yield v.path.map((p, i) => {
|
|
7100
|
-
if (i === 0)
|
|
7101
|
-
|
|
7102
|
-
if (
|
|
7103
|
-
return "." + p;
|
|
7104
|
-
if (typeof p === "number")
|
|
7105
|
-
return `[${p}]`;
|
|
7159
|
+
if (i === 0) return p;
|
|
7160
|
+
if (isIdentifier(p)) return "." + p;
|
|
7161
|
+
if (typeof p === "number") return `[${p}]`;
|
|
7106
7162
|
return `["${p}"]`;
|
|
7107
7163
|
}).join("");
|
|
7108
7164
|
}
|
|
@@ -7116,8 +7172,7 @@ function* trimStart(g) {
|
|
|
7116
7172
|
let n;
|
|
7117
7173
|
do {
|
|
7118
7174
|
const { value, done } = g.next();
|
|
7119
|
-
if (done)
|
|
7120
|
-
return;
|
|
7175
|
+
if (done) return;
|
|
7121
7176
|
n = value.trimStart();
|
|
7122
7177
|
} while (!n.length);
|
|
7123
7178
|
yield n;
|
|
@@ -7224,10 +7279,8 @@ function* formatNode(n, o = {}) {
|
|
|
7224
7279
|
const boundary = "`".repeat(innerFenceLength ? innerFenceLength + 1 : 3);
|
|
7225
7280
|
const needsNlBeforeEndBoundary = !n.attributes.content.endsWith(NL);
|
|
7226
7281
|
yield boundary;
|
|
7227
|
-
if (n.attributes.language)
|
|
7228
|
-
|
|
7229
|
-
if (n.annotations.length)
|
|
7230
|
-
yield SPACE;
|
|
7282
|
+
if (n.attributes.language) yield n.attributes.language;
|
|
7283
|
+
if (n.annotations.length) yield SPACE;
|
|
7231
7284
|
yield* formatAnnotations(n);
|
|
7232
7285
|
yield NL;
|
|
7233
7286
|
yield indent;
|
|
@@ -7245,7 +7298,9 @@ function* formatNode(n, o = {}) {
|
|
|
7245
7298
|
yield indent;
|
|
7246
7299
|
}
|
|
7247
7300
|
const open = OPEN + SPACE;
|
|
7248
|
-
const attributes = [...formatAttributes(n)].filter(
|
|
7301
|
+
const attributes = [...formatAttributes(n)].filter(
|
|
7302
|
+
(v) => v !== void 0
|
|
7303
|
+
);
|
|
7249
7304
|
const tag = [open + n.tag, ...attributes];
|
|
7250
7305
|
const inlineTag = tag.join(SPACE);
|
|
7251
7306
|
const isLongTagOpening = inlineTag.length + open.length * 2 > (o.maxTagOpeningWidth || MAX_TAG_OPENING_WIDTH);
|
|
@@ -7263,15 +7318,15 @@ function* formatNode(n, o = {}) {
|
|
|
7263
7318
|
break;
|
|
7264
7319
|
}
|
|
7265
7320
|
case "list": {
|
|
7266
|
-
const isLoose = n.children.some(
|
|
7321
|
+
const isLoose = n.children.some(
|
|
7322
|
+
(n2) => n2.children.some((c) => c.type === "paragraph")
|
|
7323
|
+
);
|
|
7267
7324
|
for (let i = 0; i < n.children.length; i++) {
|
|
7268
7325
|
const prefix = (() => {
|
|
7269
|
-
if (!n.attributes.ordered)
|
|
7270
|
-
return n.attributes.marker ?? UL;
|
|
7326
|
+
if (!n.attributes.ordered) return n.attributes.marker ?? UL;
|
|
7271
7327
|
let number = "1";
|
|
7272
7328
|
const startNumber = n.attributes.start ?? 1;
|
|
7273
|
-
if (i === 0)
|
|
7274
|
-
number = startNumber.toString();
|
|
7329
|
+
if (i === 0) number = startNumber.toString();
|
|
7275
7330
|
if (o.orderedListMode === "increment") {
|
|
7276
7331
|
number = (parseInt(startNumber) + i).toString();
|
|
7277
7332
|
}
|
|
@@ -7289,8 +7344,7 @@ function* formatNode(n, o = {}) {
|
|
|
7289
7344
|
case "item": {
|
|
7290
7345
|
for (let i = 0; i < n.children.length; i++) {
|
|
7291
7346
|
yield* formatValue(n.children[i], no);
|
|
7292
|
-
if (i === 0)
|
|
7293
|
-
yield* formatAnnotations(n);
|
|
7347
|
+
if (i === 0) yield* formatAnnotations(n);
|
|
7294
7348
|
}
|
|
7295
7349
|
break;
|
|
7296
7350
|
}
|
|
@@ -7358,12 +7412,16 @@ function* formatNode(n, o = {}) {
|
|
|
7358
7412
|
}
|
|
7359
7413
|
const [head, ...rows] = table3;
|
|
7360
7414
|
yield NL;
|
|
7361
|
-
yield* formatTableRow(
|
|
7415
|
+
yield* formatTableRow(
|
|
7416
|
+
head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
|
|
7417
|
+
);
|
|
7362
7418
|
yield NL;
|
|
7363
7419
|
yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
|
|
7364
7420
|
yield NL;
|
|
7365
7421
|
for (const row of rows) {
|
|
7366
|
-
yield* formatTableRow(
|
|
7422
|
+
yield* formatTableRow(
|
|
7423
|
+
row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
|
|
7424
|
+
);
|
|
7367
7425
|
yield NL;
|
|
7368
7426
|
}
|
|
7369
7427
|
}
|
|
@@ -7407,11 +7465,9 @@ function* formatValue(v, o = {}) {
|
|
|
7407
7465
|
break;
|
|
7408
7466
|
}
|
|
7409
7467
|
case "object": {
|
|
7410
|
-
if (v === null)
|
|
7411
|
-
break;
|
|
7468
|
+
if (v === null) break;
|
|
7412
7469
|
if (Array.isArray(v)) {
|
|
7413
|
-
for (const n of v)
|
|
7414
|
-
yield* formatValue(n, o);
|
|
7470
|
+
for (const n of v) yield* formatValue(n, o);
|
|
7415
7471
|
break;
|
|
7416
7472
|
}
|
|
7417
7473
|
switch (v.$$mdtype) {
|
|
@@ -7435,8 +7491,7 @@ function* formatValue(v, o = {}) {
|
|
|
7435
7491
|
}
|
|
7436
7492
|
function format(v, options) {
|
|
7437
7493
|
let doc = "";
|
|
7438
|
-
for (const s2 of formatValue(v, options))
|
|
7439
|
-
doc += s2;
|
|
7494
|
+
for (const s2 of formatValue(v, options)) doc += s2;
|
|
7440
7495
|
return doc.trimStart();
|
|
7441
7496
|
}
|
|
7442
7497
|
|
|
@@ -7470,8 +7525,7 @@ function renderConditions(node2) {
|
|
|
7470
7525
|
condition: "primary" in child.attributes ? child.attributes.primary : true,
|
|
7471
7526
|
children: []
|
|
7472
7527
|
});
|
|
7473
|
-
else
|
|
7474
|
-
conditions[conditions.length - 1].children.push(child);
|
|
7528
|
+
else conditions[conditions.length - 1].children.push(child);
|
|
7475
7529
|
}
|
|
7476
7530
|
return conditions;
|
|
7477
7531
|
}
|
|
@@ -7483,7 +7537,9 @@ var tagIf = {
|
|
|
7483
7537
|
const conditions = renderConditions(node2);
|
|
7484
7538
|
for (const { condition, children } of conditions)
|
|
7485
7539
|
if (truthy(condition)) {
|
|
7486
|
-
const nodes = children.flatMap(
|
|
7540
|
+
const nodes = children.flatMap(
|
|
7541
|
+
(child) => child.transform(config)
|
|
7542
|
+
);
|
|
7487
7543
|
if (nodes.some(isPromise)) {
|
|
7488
7544
|
return Promise.all(nodes).then((nodes2) => nodes2.flat());
|
|
7489
7545
|
}
|
|
@@ -7540,8 +7596,7 @@ var functions_default = { and, or, not, equals, default: defaultFn, debug };
|
|
|
7540
7596
|
function convertToRow(node2, cellType = "td") {
|
|
7541
7597
|
node2.type = "tr";
|
|
7542
7598
|
node2.attributes = {};
|
|
7543
|
-
for (const cell of node2.children)
|
|
7544
|
-
cell.type = cellType;
|
|
7599
|
+
for (const cell of node2.children) cell.type = cellType;
|
|
7545
7600
|
return node2;
|
|
7546
7601
|
}
|
|
7547
7602
|
function isConditionalTag(node2, conditionalTags) {
|
|
@@ -7550,53 +7605,44 @@ function isConditionalTag(node2, conditionalTags) {
|
|
|
7550
7605
|
function isComment(node2) {
|
|
7551
7606
|
return node2.type === "comment" || node2.type === "tag" && node2.tag === "comment";
|
|
7552
7607
|
}
|
|
7553
|
-
function unexpectedNodeError({
|
|
7554
|
-
type,
|
|
7555
|
-
tag
|
|
7556
|
-
}) {
|
|
7608
|
+
function unexpectedNodeError(node2) {
|
|
7557
7609
|
return {
|
|
7558
7610
|
id: "table-syntax",
|
|
7559
7611
|
level: "critical",
|
|
7560
|
-
message: `Found ${type}${tag ? ` ${tag}` : ""} where a list was expected. Make sure all content inside table cells is indented
|
|
7612
|
+
message: `Found ${node2.type}${node2.tag ? ` ${node2.tag}` : ""} where a list was expected. Make sure all content inside table cells is indented.`,
|
|
7613
|
+
location: node2.location
|
|
7561
7614
|
};
|
|
7562
7615
|
}
|
|
7563
7616
|
function transform(document2, conditionalTags = ["if"]) {
|
|
7564
7617
|
for (const node2 of document2.walk()) {
|
|
7565
|
-
if (node2.type !== "tag" || node2.tag !== "table")
|
|
7566
|
-
continue;
|
|
7618
|
+
if (node2.type !== "tag" || node2.tag !== "table") continue;
|
|
7567
7619
|
const [first, ...rest] = node2.children;
|
|
7568
|
-
if (!first || first.type === "table")
|
|
7569
|
-
continue;
|
|
7620
|
+
if (!first || first.type === "table") continue;
|
|
7570
7621
|
const table3 = new ast_default.Node("table", node2.attributes, [
|
|
7571
7622
|
new ast_default.Node("thead"),
|
|
7572
7623
|
new ast_default.Node("tbody")
|
|
7573
7624
|
]);
|
|
7574
7625
|
const [thead2, tbody2] = table3.children;
|
|
7575
|
-
if (first.type === "list")
|
|
7576
|
-
thead2.push(convertToRow(first, "th"));
|
|
7626
|
+
if (first.type === "list") thead2.push(convertToRow(first, "th"));
|
|
7577
7627
|
for (const row of rest) {
|
|
7578
|
-
if (row.type === "list")
|
|
7579
|
-
convertToRow(row);
|
|
7628
|
+
if (row.type === "list") convertToRow(row);
|
|
7580
7629
|
else if (isConditionalTag(row, conditionalTags)) {
|
|
7581
7630
|
const children = [];
|
|
7582
7631
|
for (const child of row.children) {
|
|
7583
|
-
if (child.type === "hr")
|
|
7584
|
-
|
|
7585
|
-
if (child.type === "list")
|
|
7586
|
-
convertToRow(child);
|
|
7632
|
+
if (child.type === "hr") continue;
|
|
7633
|
+
if (child.type === "list") convertToRow(child);
|
|
7587
7634
|
else if (isComment(child) || child.tag === "else" || isConditionalTag(child, conditionalTags)) {
|
|
7588
7635
|
} else {
|
|
7589
|
-
row.errors.push(unexpectedNodeError(
|
|
7636
|
+
row.errors.push(unexpectedNodeError(child));
|
|
7590
7637
|
continue;
|
|
7591
7638
|
}
|
|
7592
7639
|
children.push(child);
|
|
7593
7640
|
}
|
|
7594
7641
|
row.children = children;
|
|
7595
7642
|
} else if (row.type !== "hr" && !isComment(row)) {
|
|
7596
|
-
node2.errors.push(unexpectedNodeError(
|
|
7597
|
-
continue;
|
|
7598
|
-
} else
|
|
7643
|
+
node2.errors.push(unexpectedNodeError(row));
|
|
7599
7644
|
continue;
|
|
7645
|
+
} else continue;
|
|
7600
7646
|
tbody2.push(row);
|
|
7601
7647
|
}
|
|
7602
7648
|
node2.children = [table3];
|
|
@@ -7627,10 +7673,8 @@ function annotate(node2, attributes) {
|
|
|
7627
7673
|
});
|
|
7628
7674
|
node2.attributes[name] = value;
|
|
7629
7675
|
} else if (type === "class")
|
|
7630
|
-
if (node2.attributes.class)
|
|
7631
|
-
|
|
7632
|
-
else
|
|
7633
|
-
node2.attributes.class = { [name]: value };
|
|
7676
|
+
if (node2.attributes.class) node2.attributes.class[name] = value;
|
|
7677
|
+
else node2.attributes.class = { [name]: value };
|
|
7634
7678
|
}
|
|
7635
7679
|
}
|
|
7636
7680
|
function handleAttrs(token, type) {
|
|
@@ -7690,14 +7734,12 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7690
7734
|
nodes[0].attributes.frontmatter = token.content;
|
|
7691
7735
|
return;
|
|
7692
7736
|
}
|
|
7693
|
-
if (token.hidden || token.type === "text" && token.content === "")
|
|
7694
|
-
return;
|
|
7737
|
+
if (token.hidden || token.type === "text" && token.content === "") return;
|
|
7695
7738
|
const errors = token.errors || [];
|
|
7696
7739
|
const parent = nodes[nodes.length - 1];
|
|
7697
7740
|
const { tag, attributes, error: error2 } = token.meta || {};
|
|
7698
7741
|
if (token.type === "annotation") {
|
|
7699
|
-
if (inlineParent)
|
|
7700
|
-
return annotate(inlineParent, attributes);
|
|
7742
|
+
if (inlineParent) return annotate(inlineParent, attributes);
|
|
7701
7743
|
return parent.errors.push({
|
|
7702
7744
|
id: "no-inline-annotations",
|
|
7703
7745
|
level: "error",
|
|
@@ -7705,16 +7747,14 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7705
7747
|
});
|
|
7706
7748
|
}
|
|
7707
7749
|
let typeName = token.type.replace(/_(open|close)$/, "");
|
|
7708
|
-
if (mappings[typeName])
|
|
7709
|
-
typeName = mappings[typeName];
|
|
7750
|
+
if (mappings[typeName]) typeName = mappings[typeName];
|
|
7710
7751
|
if (typeName === "error") {
|
|
7711
7752
|
const { message, location } = error2;
|
|
7712
7753
|
errors.push({ id: "parse-error", level: "critical", message, location });
|
|
7713
7754
|
}
|
|
7714
7755
|
if (token.nesting < 0) {
|
|
7715
7756
|
if (parent.type === typeName && parent.tag === tag) {
|
|
7716
|
-
if (parent.lines && token.map)
|
|
7717
|
-
parent.lines.push(...token.map);
|
|
7757
|
+
if (parent.lines && token.map) parent.lines.push(...token.map);
|
|
7718
7758
|
return nodes.pop();
|
|
7719
7759
|
}
|
|
7720
7760
|
errors.push({
|
|
@@ -7741,20 +7781,15 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7741
7781
|
}
|
|
7742
7782
|
};
|
|
7743
7783
|
}
|
|
7744
|
-
if (inlineParent)
|
|
7745
|
-
node2.inline = true;
|
|
7784
|
+
if (inlineParent) node2.inline = true;
|
|
7746
7785
|
if (attributes && ["tag", "fence", "image"].includes(typeName))
|
|
7747
7786
|
annotate(node2, attributes);
|
|
7748
7787
|
if (handleSlots && tag === "slot" && typeof node2.attributes.primary === "string")
|
|
7749
7788
|
parent.slots[node2.attributes.primary] = node2;
|
|
7750
|
-
else
|
|
7751
|
-
|
|
7752
|
-
if (token.
|
|
7753
|
-
|
|
7754
|
-
if (!Array.isArray(token.children))
|
|
7755
|
-
return;
|
|
7756
|
-
if (node2.type === "inline")
|
|
7757
|
-
inlineParent = parent;
|
|
7789
|
+
else parent.push(node2);
|
|
7790
|
+
if (token.nesting > 0) nodes.push(node2);
|
|
7791
|
+
if (!Array.isArray(token.children)) return;
|
|
7792
|
+
if (node2.type === "inline") inlineParent = parent;
|
|
7758
7793
|
nodes.push(node2);
|
|
7759
7794
|
const isLeafNode = typeName === "image";
|
|
7760
7795
|
if (!isLeafNode) {
|
|
@@ -7766,8 +7801,7 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7766
7801
|
function parser(tokens, args) {
|
|
7767
7802
|
const doc = new Node("document");
|
|
7768
7803
|
const nodes = [doc];
|
|
7769
|
-
if (typeof args === "string")
|
|
7770
|
-
args = { file: args };
|
|
7804
|
+
if (typeof args === "string") args = { file: args };
|
|
7771
7805
|
for (const token of tokens)
|
|
7772
7806
|
handleToken(token, nodes, args?.file, args?.slots, args?.location);
|
|
7773
7807
|
if (nodes.length > 1)
|
|
@@ -7777,8 +7811,7 @@ function parser(tokens, args) {
|
|
|
7777
7811
|
level: "critical",
|
|
7778
7812
|
message: `Node '${node2.tag || node2.type}' is missing closing`
|
|
7779
7813
|
});
|
|
7780
|
-
for (const transform3 of transforms_default)
|
|
7781
|
-
transform3(doc, args?.conditionalTags);
|
|
7814
|
+
for (const transform3 of transforms_default) transform3(doc, args?.conditionalTags);
|
|
7782
7815
|
return doc;
|
|
7783
7816
|
}
|
|
7784
7817
|
|
|
@@ -7837,7 +7870,11 @@ var heading = {
|
|
|
7837
7870
|
level: { type: Number, render: false, required: true }
|
|
7838
7871
|
},
|
|
7839
7872
|
transform(node2, config) {
|
|
7840
|
-
return new Tag(
|
|
7873
|
+
return new Tag(
|
|
7874
|
+
`h${node2.attributes["level"]}`,
|
|
7875
|
+
node2.transformAttributes(config),
|
|
7876
|
+
node2.transformChildren(config)
|
|
7877
|
+
);
|
|
7841
7878
|
}
|
|
7842
7879
|
};
|
|
7843
7880
|
var paragraph = {
|
|
@@ -7850,6 +7887,7 @@ var image = {
|
|
|
7850
7887
|
src: { type: String, required: true },
|
|
7851
7888
|
alt: { type: String },
|
|
7852
7889
|
title: { type: String }
|
|
7890
|
+
// width/height attributes will need to be to be implemented as an extension to markdown-it
|
|
7853
7891
|
}
|
|
7854
7892
|
};
|
|
7855
7893
|
var fence = {
|
|
@@ -7902,7 +7940,11 @@ var list = {
|
|
|
7902
7940
|
marker: { type: String, render: false }
|
|
7903
7941
|
},
|
|
7904
7942
|
transform(node2, config) {
|
|
7905
|
-
return new Tag(
|
|
7943
|
+
return new Tag(
|
|
7944
|
+
node2.attributes.ordered ? "ol" : "ul",
|
|
7945
|
+
node2.transformAttributes(config),
|
|
7946
|
+
node2.transformChildren(config)
|
|
7947
|
+
);
|
|
7906
7948
|
}
|
|
7907
7949
|
};
|
|
7908
7950
|
var hr = {
|
|
@@ -8028,9 +8070,9 @@ var error = {};
|
|
|
8028
8070
|
var node = {};
|
|
8029
8071
|
|
|
8030
8072
|
// src/renderers/html.ts
|
|
8031
|
-
var import_markdown_it =
|
|
8073
|
+
var import_markdown_it = __toESM(require_markdown_it());
|
|
8032
8074
|
var { escapeHtml } = (0, import_markdown_it.default)().utils;
|
|
8033
|
-
var voidElements = new Set([
|
|
8075
|
+
var voidElements = /* @__PURE__ */ new Set([
|
|
8034
8076
|
"area",
|
|
8035
8077
|
"base",
|
|
8036
8078
|
"br",
|
|
@@ -8049,21 +8091,16 @@ var voidElements = new Set([
|
|
|
8049
8091
|
function render(node2) {
|
|
8050
8092
|
if (typeof node2 === "string" || typeof node2 === "number")
|
|
8051
8093
|
return escapeHtml(String(node2));
|
|
8052
|
-
if (Array.isArray(node2))
|
|
8053
|
-
|
|
8054
|
-
if (node2 === null || typeof node2 !== "object" || !Tag.isTag(node2))
|
|
8055
|
-
return "";
|
|
8094
|
+
if (Array.isArray(node2)) return node2.map(render).join("");
|
|
8095
|
+
if (node2 === null || typeof node2 !== "object" || !Tag.isTag(node2)) return "";
|
|
8056
8096
|
const { name, attributes, children = [] } = node2;
|
|
8057
|
-
if (!name)
|
|
8058
|
-
return render(children);
|
|
8097
|
+
if (!name) return render(children);
|
|
8059
8098
|
let output = `<${name}`;
|
|
8060
8099
|
for (const [k, v] of Object.entries(attributes ?? {}))
|
|
8061
8100
|
output += ` ${k.toLowerCase()}="${escapeHtml(String(v))}"`;
|
|
8062
8101
|
output += ">";
|
|
8063
|
-
if (voidElements.has(name))
|
|
8064
|
-
|
|
8065
|
-
if (children.length)
|
|
8066
|
-
output += render(children);
|
|
8102
|
+
if (voidElements.has(name)) return output;
|
|
8103
|
+
if (children.length) output += render(children);
|
|
8067
8104
|
output += `</${name}>`;
|
|
8068
8105
|
return output;
|
|
8069
8106
|
}
|
|
@@ -8074,17 +8111,12 @@ function tagName(name, components) {
|
|
|
8074
8111
|
}
|
|
8075
8112
|
function dynamic(node2, React, { components = {}, resolveTagName = tagName } = {}) {
|
|
8076
8113
|
function deepRender2(value) {
|
|
8077
|
-
if (value == null || typeof value !== "object")
|
|
8078
|
-
|
|
8079
|
-
if (
|
|
8080
|
-
|
|
8081
|
-
if (value.$$mdtype === "Tag")
|
|
8082
|
-
return render3(value);
|
|
8083
|
-
if (typeof value !== "object")
|
|
8084
|
-
return value;
|
|
8114
|
+
if (value == null || typeof value !== "object") return value;
|
|
8115
|
+
if (Array.isArray(value)) return value.map((item2) => deepRender2(item2));
|
|
8116
|
+
if (value.$$mdtype === "Tag") return render3(value);
|
|
8117
|
+
if (typeof value !== "object") return value;
|
|
8085
8118
|
const output = {};
|
|
8086
|
-
for (const [k, v] of Object.entries(value))
|
|
8087
|
-
output[k] = deepRender2(v);
|
|
8119
|
+
for (const [k, v] of Object.entries(value)) output[k] = deepRender2(v);
|
|
8088
8120
|
return output;
|
|
8089
8121
|
}
|
|
8090
8122
|
function render3(node3) {
|
|
@@ -8097,9 +8129,12 @@ function dynamic(node2, React, { components = {}, resolveTagName = tagName } = {
|
|
|
8097
8129
|
attributes: { class: className, ...attrs } = {},
|
|
8098
8130
|
children = []
|
|
8099
8131
|
} = node3;
|
|
8100
|
-
if (className)
|
|
8101
|
-
|
|
8102
|
-
|
|
8132
|
+
if (className) attrs.className = className;
|
|
8133
|
+
return React.createElement(
|
|
8134
|
+
resolveTagName(name, components),
|
|
8135
|
+
Object.keys(attrs).length == 0 ? null : deepRender2(attrs),
|
|
8136
|
+
...children.map(render3)
|
|
8137
|
+
);
|
|
8103
8138
|
}
|
|
8104
8139
|
return render3(node2);
|
|
8105
8140
|
}
|
|
@@ -8112,14 +8147,11 @@ function renderArray(children) {
|
|
|
8112
8147
|
return children.map(render2).join(", ");
|
|
8113
8148
|
}
|
|
8114
8149
|
function deepRender(value) {
|
|
8115
|
-
if (value == null || typeof value !== "object")
|
|
8116
|
-
return JSON.stringify(value);
|
|
8150
|
+
if (value == null || typeof value !== "object") return JSON.stringify(value);
|
|
8117
8151
|
if (Array.isArray(value))
|
|
8118
8152
|
return `[${value.map((item2) => deepRender(item2)).join(", ")}]`;
|
|
8119
|
-
if (value.$$mdtype === "Tag")
|
|
8120
|
-
|
|
8121
|
-
if (typeof value !== "object")
|
|
8122
|
-
return JSON.stringify(value);
|
|
8153
|
+
if (value.$$mdtype === "Tag") return render2(value);
|
|
8154
|
+
if (typeof value !== "object") return JSON.stringify(value);
|
|
8123
8155
|
const object = Object.entries(value).map(([k, v]) => [JSON.stringify(k), deepRender(v)].join(": ")).join(", ");
|
|
8124
8156
|
return `{${object}}`;
|
|
8125
8157
|
}
|
|
@@ -8133,8 +8165,7 @@ function render2(node2) {
|
|
|
8133
8165
|
attributes: { class: className, ...attrs } = {},
|
|
8134
8166
|
children = []
|
|
8135
8167
|
} = node2;
|
|
8136
|
-
if (className)
|
|
8137
|
-
attrs.className = className;
|
|
8168
|
+
if (className) attrs.className = className;
|
|
8138
8169
|
return `React.createElement(
|
|
8139
8170
|
tagName(${JSON.stringify(name)}, components),
|
|
8140
8171
|
${Object.keys(attrs).length == 0 ? "null" : deepRender(attrs)},
|
|
@@ -8182,8 +8213,7 @@ var partial = {
|
|
|
8182
8213
|
const { partials = {} } = config;
|
|
8183
8214
|
const { file, variables } = node2.attributes;
|
|
8184
8215
|
const partial2 = partials[file];
|
|
8185
|
-
if (!partial2)
|
|
8186
|
-
return null;
|
|
8216
|
+
if (!partial2) return null;
|
|
8187
8217
|
const scopedConfig = {
|
|
8188
8218
|
...config,
|
|
8189
8219
|
variables: {
|
|
@@ -8220,10 +8250,10 @@ var tags_default = {
|
|
|
8220
8250
|
};
|
|
8221
8251
|
|
|
8222
8252
|
// src/tokenizer/index.ts
|
|
8223
|
-
var import_lib =
|
|
8253
|
+
var import_lib = __toESM(require_lib());
|
|
8224
8254
|
|
|
8225
8255
|
// src/tokenizer/plugins/annotations.ts
|
|
8226
|
-
var import_tag7 =
|
|
8256
|
+
var import_tag7 = __toESM(require_tag());
|
|
8227
8257
|
function createToken(state, content, contentStart) {
|
|
8228
8258
|
try {
|
|
8229
8259
|
const { type, meta, nesting = 0 } = (0, import_tag7.parse)(content, { Variable, Function: Function2 });
|
|
@@ -8235,8 +8265,7 @@ function createToken(state, content, contentStart) {
|
|
|
8235
8265
|
}
|
|
8236
8266
|
return token;
|
|
8237
8267
|
} catch (error2) {
|
|
8238
|
-
if (!(error2 instanceof import_tag7.SyntaxError))
|
|
8239
|
-
throw error2;
|
|
8268
|
+
if (!(error2 instanceof import_tag7.SyntaxError)) throw error2;
|
|
8240
8269
|
const {
|
|
8241
8270
|
message,
|
|
8242
8271
|
location: { start, end }
|
|
@@ -8253,41 +8282,33 @@ function createToken(state, content, contentStart) {
|
|
|
8253
8282
|
function block(state, startLine, endLine, silent) {
|
|
8254
8283
|
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
8255
8284
|
const finish = state.eMarks[startLine];
|
|
8256
|
-
if (!state.src.startsWith(OPEN, start))
|
|
8257
|
-
return false;
|
|
8285
|
+
if (!state.src.startsWith(OPEN, start)) return false;
|
|
8258
8286
|
const tagEnd = findTagEnd(state.src, start);
|
|
8259
8287
|
const lastPossible = state.src.slice(0, finish).trim().length;
|
|
8260
|
-
if (!tagEnd || tagEnd < lastPossible - CLOSE.length)
|
|
8261
|
-
return false;
|
|
8288
|
+
if (!tagEnd || tagEnd < lastPossible - CLOSE.length) return false;
|
|
8262
8289
|
const contentStart = start + OPEN.length;
|
|
8263
8290
|
const content = state.src.slice(contentStart, tagEnd).trim();
|
|
8264
8291
|
const lines = state.src.slice(start, tagEnd + CLOSE.length).split("\n").length;
|
|
8265
|
-
if (content[0] === "$")
|
|
8266
|
-
|
|
8267
|
-
if (silent)
|
|
8268
|
-
return true;
|
|
8292
|
+
if (content[0] === "$") return false;
|
|
8293
|
+
if (silent) return true;
|
|
8269
8294
|
const token = createToken(state, content, contentStart);
|
|
8270
8295
|
token.map = [startLine, startLine + lines];
|
|
8271
8296
|
state.line += lines;
|
|
8272
8297
|
return true;
|
|
8273
8298
|
}
|
|
8274
8299
|
function inline2(state, silent) {
|
|
8275
|
-
if (!state.src.startsWith(OPEN, state.pos))
|
|
8276
|
-
return false;
|
|
8300
|
+
if (!state.src.startsWith(OPEN, state.pos)) return false;
|
|
8277
8301
|
const tagEnd = findTagEnd(state.src, state.pos);
|
|
8278
|
-
if (!tagEnd)
|
|
8279
|
-
return false;
|
|
8302
|
+
if (!tagEnd) return false;
|
|
8280
8303
|
const content = state.src.slice(state.pos + OPEN.length, tagEnd);
|
|
8281
|
-
if (!silent)
|
|
8282
|
-
createToken(state, content.trim());
|
|
8304
|
+
if (!silent) createToken(state, content.trim());
|
|
8283
8305
|
state.pos = tagEnd + CLOSE.length;
|
|
8284
8306
|
return true;
|
|
8285
8307
|
}
|
|
8286
8308
|
function core(state) {
|
|
8287
8309
|
let token;
|
|
8288
8310
|
for (token of state.tokens) {
|
|
8289
|
-
if (token.type !== "fence")
|
|
8290
|
-
continue;
|
|
8311
|
+
if (token.type !== "fence") continue;
|
|
8291
8312
|
if (token.info.includes(OPEN)) {
|
|
8292
8313
|
const start = token.info.indexOf(OPEN);
|
|
8293
8314
|
const end = findTagEnd(token.info, start);
|
|
@@ -8296,10 +8317,8 @@ function core(state) {
|
|
|
8296
8317
|
const { meta } = (0, import_tag7.parse)(content.trim(), { Variable, Function: Function2 });
|
|
8297
8318
|
token.meta = meta;
|
|
8298
8319
|
} catch (error2) {
|
|
8299
|
-
if (!(error2 instanceof import_tag7.SyntaxError))
|
|
8300
|
-
|
|
8301
|
-
if (!token.errors)
|
|
8302
|
-
token.errors = [];
|
|
8320
|
+
if (!(error2 instanceof import_tag7.SyntaxError)) throw error2;
|
|
8321
|
+
if (!token.errors) token.errors = [];
|
|
8303
8322
|
token.errors.push({
|
|
8304
8323
|
id: "fence-tag-error",
|
|
8305
8324
|
level: "error",
|
|
@@ -8307,7 +8326,9 @@ function core(state) {
|
|
|
8307
8326
|
});
|
|
8308
8327
|
}
|
|
8309
8328
|
}
|
|
8310
|
-
if (token?.meta?.attributes?.find(
|
|
8329
|
+
if (token?.meta?.attributes?.find(
|
|
8330
|
+
(attr) => attr.name === "process" && !attr.value
|
|
8331
|
+
))
|
|
8311
8332
|
continue;
|
|
8312
8333
|
token.children = parseTags(token.content, token.map[0]);
|
|
8313
8334
|
}
|
|
@@ -8327,17 +8348,13 @@ function getLine(state, n) {
|
|
|
8327
8348
|
}
|
|
8328
8349
|
function findClose(state, endLine) {
|
|
8329
8350
|
for (let line = 1; line < endLine; line++)
|
|
8330
|
-
if (getLine(state, line) === fence2)
|
|
8331
|
-
return line;
|
|
8351
|
+
if (getLine(state, line) === fence2) return line;
|
|
8332
8352
|
}
|
|
8333
8353
|
function block2(state, startLine, endLine, silent) {
|
|
8334
|
-
if (startLine != 0 || getLine(state, 0) != fence2)
|
|
8335
|
-
return false;
|
|
8354
|
+
if (startLine != 0 || getLine(state, 0) != fence2) return false;
|
|
8336
8355
|
const close = findClose(state, endLine);
|
|
8337
|
-
if (!close)
|
|
8338
|
-
|
|
8339
|
-
if (silent)
|
|
8340
|
-
return true;
|
|
8356
|
+
if (!close) return false;
|
|
8357
|
+
if (silent) return true;
|
|
8341
8358
|
const token = state.push("frontmatter", "", 0);
|
|
8342
8359
|
token.content = state.src.slice(state.eMarks[0], state.bMarks[close]).trim();
|
|
8343
8360
|
token.map = [0, close];
|
|
@@ -8354,13 +8371,10 @@ var OPEN2 = "<!--";
|
|
|
8354
8371
|
var CLOSE2 = "-->";
|
|
8355
8372
|
function block3(state, startLine, endLine, silent) {
|
|
8356
8373
|
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
8357
|
-
if (!state.src.startsWith(OPEN2, start))
|
|
8358
|
-
return false;
|
|
8374
|
+
if (!state.src.startsWith(OPEN2, start)) return false;
|
|
8359
8375
|
const close = state.src.indexOf(CLOSE2, start);
|
|
8360
|
-
if (close === -1)
|
|
8361
|
-
|
|
8362
|
-
if (silent)
|
|
8363
|
-
return true;
|
|
8376
|
+
if (close === -1) return false;
|
|
8377
|
+
if (silent) return true;
|
|
8364
8378
|
const content = state.src.slice(start + OPEN2.length, close);
|
|
8365
8379
|
const lines = content.split("\n").length;
|
|
8366
8380
|
const token = state.push("comment", "", 0);
|
|
@@ -8370,13 +8384,10 @@ function block3(state, startLine, endLine, silent) {
|
|
|
8370
8384
|
return true;
|
|
8371
8385
|
}
|
|
8372
8386
|
function inline3(state, silent) {
|
|
8373
|
-
if (!state.src.startsWith(OPEN2, state.pos))
|
|
8374
|
-
return false;
|
|
8387
|
+
if (!state.src.startsWith(OPEN2, state.pos)) return false;
|
|
8375
8388
|
const close = state.src.indexOf(CLOSE2, state.pos);
|
|
8376
|
-
if (close === -1)
|
|
8377
|
-
|
|
8378
|
-
if (silent)
|
|
8379
|
-
return true;
|
|
8389
|
+
if (close === -1) return false;
|
|
8390
|
+
if (silent) return true;
|
|
8380
8391
|
const content = state.src.slice(state.pos + OPEN2.length, close);
|
|
8381
8392
|
const token = state.push("comment", "", 0);
|
|
8382
8393
|
token.content = content.trim();
|
|
@@ -8396,10 +8407,10 @@ var Tokenizer = class {
|
|
|
8396
8407
|
this.parser.use(plugin2, "frontmatter", {});
|
|
8397
8408
|
this.parser.disable([
|
|
8398
8409
|
"lheading",
|
|
8410
|
+
// Disable indented `code_block` support https://spec.commonmark.org/0.30/#indented-code-block
|
|
8399
8411
|
"code"
|
|
8400
8412
|
]);
|
|
8401
|
-
if (config.allowComments)
|
|
8402
|
-
this.parser.use(plugin3, "comments", {});
|
|
8413
|
+
if (config.allowComments) this.parser.use(plugin3, "comments", {});
|
|
8403
8414
|
}
|
|
8404
8415
|
tokenize(content) {
|
|
8405
8416
|
return this.parser.parse(content.toString(), {});
|
|
@@ -8415,18 +8426,15 @@ var TypeMappings = {
|
|
|
8415
8426
|
Boolean
|
|
8416
8427
|
};
|
|
8417
8428
|
function validateType(type, value, config, key) {
|
|
8418
|
-
if (!type)
|
|
8419
|
-
return true;
|
|
8429
|
+
if (!type) return true;
|
|
8420
8430
|
if (ast_default.isFunction(value) && config.validation?.validateFunctions) {
|
|
8421
8431
|
const schema = config.functions?.[value.name];
|
|
8422
8432
|
return !schema?.returns ? true : Array.isArray(schema.returns) ? schema.returns.find((t) => t === type) !== void 0 : schema.returns === type;
|
|
8423
8433
|
}
|
|
8424
|
-
if (ast_default.isAst(value))
|
|
8425
|
-
return true;
|
|
8434
|
+
if (ast_default.isAst(value)) return true;
|
|
8426
8435
|
if (Array.isArray(type))
|
|
8427
8436
|
return type.some((t) => validateType(t, value, config, key));
|
|
8428
|
-
if (typeof type === "string")
|
|
8429
|
-
type = TypeMappings[type];
|
|
8437
|
+
if (typeof type === "string") type = TypeMappings[type];
|
|
8430
8438
|
if (typeof type === "function") {
|
|
8431
8439
|
const instance = new type();
|
|
8432
8440
|
if (instance.validate) {
|
|
@@ -8436,10 +8444,8 @@ function validateType(type, value, config, key) {
|
|
|
8436
8444
|
return value != null && value.constructor === type;
|
|
8437
8445
|
}
|
|
8438
8446
|
function typeToString(type) {
|
|
8439
|
-
if (typeof type === "string")
|
|
8440
|
-
|
|
8441
|
-
if (Array.isArray(type))
|
|
8442
|
-
return type.map(typeToString).join(" | ");
|
|
8447
|
+
if (typeof type === "string") return type;
|
|
8448
|
+
if (Array.isArray(type)) return type.map(typeToString).join(" | ");
|
|
8443
8449
|
return type.name;
|
|
8444
8450
|
}
|
|
8445
8451
|
function validateFunction(fn, config) {
|
|
@@ -8453,8 +8459,7 @@ function validateFunction(fn, config) {
|
|
|
8453
8459
|
message: `Undefined function: '${fn.name}'`
|
|
8454
8460
|
}
|
|
8455
8461
|
];
|
|
8456
|
-
if (schema.validate)
|
|
8457
|
-
errors.push(...schema.validate(fn, config));
|
|
8462
|
+
if (schema.validate) errors.push(...schema.validate(fn, config));
|
|
8458
8463
|
if (schema.parameters) {
|
|
8459
8464
|
for (const [key, value] of Object.entries(fn.parameters)) {
|
|
8460
8465
|
const param = schema.parameters?.[key];
|
|
@@ -8466,8 +8471,7 @@ function validateFunction(fn, config) {
|
|
|
8466
8471
|
});
|
|
8467
8472
|
continue;
|
|
8468
8473
|
}
|
|
8469
|
-
if (ast_default.isAst(value) && !ast_default.isFunction(value))
|
|
8470
|
-
continue;
|
|
8474
|
+
if (ast_default.isAst(value) && !ast_default.isFunction(value)) continue;
|
|
8471
8475
|
if (param.type) {
|
|
8472
8476
|
const valid = validateType(param.type, value, config, key);
|
|
8473
8477
|
if (valid === false) {
|
|
@@ -8492,8 +8496,7 @@ function validateFunction(fn, config) {
|
|
|
8492
8496
|
return errors;
|
|
8493
8497
|
}
|
|
8494
8498
|
function displayMatches(matches, n) {
|
|
8495
|
-
if (matches.length <= n)
|
|
8496
|
-
return JSON.stringify(matches);
|
|
8499
|
+
if (matches.length <= n) return JSON.stringify(matches);
|
|
8497
8500
|
const items = matches.slice(0, n).map((item2) => JSON.stringify(item2));
|
|
8498
8501
|
return `[${items.join(",")}, ... ${matches.length - n} more]`;
|
|
8499
8502
|
}
|
|
@@ -8564,8 +8567,7 @@ function validator(node2, config) {
|
|
|
8564
8567
|
message: `Undefined variable: '${value.path.join(".")}'`
|
|
8565
8568
|
});
|
|
8566
8569
|
}
|
|
8567
|
-
} else
|
|
8568
|
-
continue;
|
|
8570
|
+
} else continue;
|
|
8569
8571
|
}
|
|
8570
8572
|
value = value;
|
|
8571
8573
|
if (type) {
|
|
@@ -8581,13 +8583,15 @@ function validator(node2, config) {
|
|
|
8581
8583
|
errors.push(...valid);
|
|
8582
8584
|
}
|
|
8583
8585
|
}
|
|
8584
|
-
if (typeof matches === "function")
|
|
8585
|
-
matches = matches(config);
|
|
8586
|
+
if (typeof matches === "function") matches = matches(config);
|
|
8586
8587
|
if (Array.isArray(matches) && !matches.includes(value))
|
|
8587
8588
|
errors.push({
|
|
8588
8589
|
id: "attribute-value-invalid",
|
|
8589
8590
|
level: errorLevel || "error",
|
|
8590
|
-
message: `Attribute '${key}' must match one of ${displayMatches(
|
|
8591
|
+
message: `Attribute '${key}' must match one of ${displayMatches(
|
|
8592
|
+
matches,
|
|
8593
|
+
8
|
|
8594
|
+
)}. Got '${value}' instead.`
|
|
8591
8595
|
});
|
|
8592
8596
|
if (matches instanceof RegExp && !matches.test(value))
|
|
8593
8597
|
errors.push({
|
|
@@ -8597,8 +8601,7 @@ function validator(node2, config) {
|
|
|
8597
8601
|
});
|
|
8598
8602
|
if (typeof attrib.validate === "function") {
|
|
8599
8603
|
const attribErrors = attrib.validate(value, config, key);
|
|
8600
|
-
if (Array.isArray(attribErrors))
|
|
8601
|
-
errors.push(...attribErrors);
|
|
8604
|
+
if (Array.isArray(attribErrors)) errors.push(...attribErrors);
|
|
8602
8605
|
}
|
|
8603
8606
|
}
|
|
8604
8607
|
for (const [key, { required }] of Object.entries(attributes))
|
|
@@ -8639,18 +8642,32 @@ function* walkWithParents(node2, parents = []) {
|
|
|
8639
8642
|
for (const child of [...Object.values(node2.slots), ...node2.children])
|
|
8640
8643
|
yield* walkWithParents(child, [...parents, node2]);
|
|
8641
8644
|
}
|
|
8645
|
+
function hasValidLocation(error2) {
|
|
8646
|
+
const loc = error2.location;
|
|
8647
|
+
return loc != null && typeof loc.start?.line === "number" && typeof loc.end?.line === "number" && (loc.file === void 0 || typeof loc.file === "string");
|
|
8648
|
+
}
|
|
8649
|
+
function toValidateError(node2, error2) {
|
|
8650
|
+
if (hasValidLocation(error2)) {
|
|
8651
|
+
return {
|
|
8652
|
+
type: node2.type,
|
|
8653
|
+
lines: [error2.location.start.line, error2.location.end.line],
|
|
8654
|
+
location: { file: node2.location?.file, ...error2.location },
|
|
8655
|
+
error: error2
|
|
8656
|
+
};
|
|
8657
|
+
}
|
|
8658
|
+
return { type: node2.type, lines: node2.lines, location: node2.location, error: error2 };
|
|
8659
|
+
}
|
|
8642
8660
|
function validateTree(content, config) {
|
|
8643
8661
|
const output = [...walkWithParents(content)].map(([node2, parents]) => {
|
|
8644
|
-
const { type, lines, location } = node2;
|
|
8645
8662
|
const updatedConfig = {
|
|
8646
8663
|
...config,
|
|
8647
8664
|
validation: { ...config.validation, parents }
|
|
8648
8665
|
};
|
|
8649
8666
|
const errors = validator(node2, updatedConfig);
|
|
8650
8667
|
if (isPromise(errors)) {
|
|
8651
|
-
return errors.then((e) => e.map((error2) => (
|
|
8668
|
+
return errors.then((e) => e.map((error2) => toValidateError(node2, error2)));
|
|
8652
8669
|
}
|
|
8653
|
-
return errors.map((error2) => (
|
|
8670
|
+
return errors.map((error2) => toValidateError(node2, error2));
|
|
8654
8671
|
});
|
|
8655
8672
|
if (output.some(isPromise)) {
|
|
8656
8673
|
return Promise.all(output).then((o) => o.flat());
|
|
@@ -8678,8 +8695,7 @@ function mergeConfig(config = {}) {
|
|
|
8678
8695
|
};
|
|
8679
8696
|
}
|
|
8680
8697
|
function parse3(content, args) {
|
|
8681
|
-
if (typeof content === "string")
|
|
8682
|
-
content = tokenizer.tokenize(content);
|
|
8698
|
+
if (typeof content === "string") content = tokenizer.tokenize(content);
|
|
8683
8699
|
return parser(content, args);
|
|
8684
8700
|
}
|
|
8685
8701
|
function resolve2(content, config) {
|
|
@@ -8709,25 +8725,61 @@ var Markdoc = class {
|
|
|
8709
8725
|
this.validate = (content) => validate(content, this.config);
|
|
8710
8726
|
this.config = config;
|
|
8711
8727
|
}
|
|
8728
|
+
static {
|
|
8729
|
+
this.nodes = schema_exports;
|
|
8730
|
+
}
|
|
8731
|
+
static {
|
|
8732
|
+
this.tags = tags_default;
|
|
8733
|
+
}
|
|
8734
|
+
static {
|
|
8735
|
+
this.functions = functions_default;
|
|
8736
|
+
}
|
|
8737
|
+
static {
|
|
8738
|
+
this.globalAttributes = globalAttributes;
|
|
8739
|
+
}
|
|
8740
|
+
static {
|
|
8741
|
+
this.renderers = renderers_default;
|
|
8742
|
+
}
|
|
8743
|
+
static {
|
|
8744
|
+
this.transforms = transforms_default;
|
|
8745
|
+
}
|
|
8746
|
+
static {
|
|
8747
|
+
this.Ast = ast_default;
|
|
8748
|
+
}
|
|
8749
|
+
static {
|
|
8750
|
+
this.Tag = Tag;
|
|
8751
|
+
}
|
|
8752
|
+
static {
|
|
8753
|
+
this.Tokenizer = Tokenizer;
|
|
8754
|
+
}
|
|
8755
|
+
static {
|
|
8756
|
+
this.parseTags = parseTags;
|
|
8757
|
+
}
|
|
8758
|
+
static {
|
|
8759
|
+
this.transformer = transformer_default;
|
|
8760
|
+
}
|
|
8761
|
+
static {
|
|
8762
|
+
this.validator = validator;
|
|
8763
|
+
}
|
|
8764
|
+
static {
|
|
8765
|
+
this.parse = parse3;
|
|
8766
|
+
}
|
|
8767
|
+
static {
|
|
8768
|
+
this.transform = transform2;
|
|
8769
|
+
}
|
|
8770
|
+
static {
|
|
8771
|
+
this.validate = validate;
|
|
8772
|
+
}
|
|
8773
|
+
static {
|
|
8774
|
+
this.createElement = createElement;
|
|
8775
|
+
}
|
|
8776
|
+
static {
|
|
8777
|
+
this.truthy = truthy;
|
|
8778
|
+
}
|
|
8779
|
+
static {
|
|
8780
|
+
this.format = format;
|
|
8781
|
+
}
|
|
8712
8782
|
};
|
|
8713
|
-
Markdoc.nodes = schema_exports;
|
|
8714
|
-
Markdoc.tags = tags_default;
|
|
8715
|
-
Markdoc.functions = functions_default;
|
|
8716
|
-
Markdoc.globalAttributes = globalAttributes;
|
|
8717
|
-
Markdoc.renderers = renderers_default;
|
|
8718
|
-
Markdoc.transforms = transforms_default;
|
|
8719
|
-
Markdoc.Ast = ast_default;
|
|
8720
|
-
Markdoc.Tag = Tag;
|
|
8721
|
-
Markdoc.Tokenizer = Tokenizer;
|
|
8722
|
-
Markdoc.parseTags = parseTags;
|
|
8723
|
-
Markdoc.transformer = transformer_default;
|
|
8724
|
-
Markdoc.validator = validator;
|
|
8725
|
-
Markdoc.parse = parse3;
|
|
8726
|
-
Markdoc.transform = transform2;
|
|
8727
|
-
Markdoc.validate = validate;
|
|
8728
|
-
Markdoc.createElement = createElement;
|
|
8729
|
-
Markdoc.truthy = truthy;
|
|
8730
|
-
Markdoc.format = format;
|
|
8731
8783
|
export {
|
|
8732
8784
|
ast_default as Ast,
|
|
8733
8785
|
Node,
|