@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.js
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
10
|
};
|
|
11
11
|
var __export = (target, all) => {
|
|
12
|
-
__markAsModule(target);
|
|
13
12
|
for (var name in all)
|
|
14
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
14
|
};
|
|
16
|
-
var
|
|
17
|
-
if (
|
|
18
|
-
for (let key of __getOwnPropNames(
|
|
19
|
-
if (!__hasOwnProp.call(
|
|
20
|
-
__defProp(
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
20
|
}
|
|
22
|
-
return
|
|
23
|
-
};
|
|
24
|
-
var __toModule = (module2) => {
|
|
25
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
21
|
+
return to;
|
|
26
22
|
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
32
|
|
|
28
33
|
// src/grammar/tag.js
|
|
29
34
|
var require_tag = __commonJS({
|
|
@@ -236,8 +241,7 @@ var require_tag = __commonJS({
|
|
|
236
241
|
return value;
|
|
237
242
|
};
|
|
238
243
|
var peg$f18 = function(prefix, head, tail) {
|
|
239
|
-
if (prefix === "@")
|
|
240
|
-
return [head, ...tail];
|
|
244
|
+
if (prefix === "@") return [head, ...tail];
|
|
241
245
|
return new Variable2([head, ...tail]);
|
|
242
246
|
};
|
|
243
247
|
var peg$f19 = function() {
|
|
@@ -290,7 +294,9 @@ var require_tag = __commonJS({
|
|
|
290
294
|
var peg$result;
|
|
291
295
|
if ("startRule" in options) {
|
|
292
296
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
293
|
-
throw new Error(
|
|
297
|
+
throw new Error(
|
|
298
|
+
`Can't start parsing from rule "` + options.startRule + '".'
|
|
299
|
+
);
|
|
294
300
|
}
|
|
295
301
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
296
302
|
}
|
|
@@ -308,7 +314,11 @@ var require_tag = __commonJS({
|
|
|
308
314
|
}
|
|
309
315
|
function expected(description, location2) {
|
|
310
316
|
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
|
311
|
-
throw peg$buildStructuredError(
|
|
317
|
+
throw peg$buildStructuredError(
|
|
318
|
+
[peg$otherExpectation(description)],
|
|
319
|
+
input.substring(peg$savedPos, peg$currPos),
|
|
320
|
+
location2
|
|
321
|
+
);
|
|
312
322
|
}
|
|
313
323
|
function error2(message, location2) {
|
|
314
324
|
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
|
@@ -365,8 +375,7 @@ var require_tag = __commonJS({
|
|
|
365
375
|
var peg$VALIDFILENAME = typeof options.filename === "string" && options.filename.length > 0;
|
|
366
376
|
function peg$computeLocation(startPos, endPos) {
|
|
367
377
|
var loc = {};
|
|
368
|
-
if (peg$VALIDFILENAME)
|
|
369
|
-
loc.filename = options.filename;
|
|
378
|
+
if (peg$VALIDFILENAME) loc.filename = options.filename;
|
|
370
379
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
371
380
|
loc.start = {
|
|
372
381
|
offset: startPos,
|
|
@@ -413,18 +422,26 @@ var require_tag = __commonJS({
|
|
|
413
422
|
return new peg$SyntaxError(message, null, null, location2);
|
|
414
423
|
}
|
|
415
424
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
416
|
-
return new peg$SyntaxError(
|
|
425
|
+
return new peg$SyntaxError(
|
|
426
|
+
peg$SyntaxError.buildMessage(expected2, found, location2),
|
|
427
|
+
expected2,
|
|
428
|
+
found,
|
|
429
|
+
location2
|
|
430
|
+
);
|
|
417
431
|
}
|
|
418
432
|
function peg$buildError() {
|
|
419
433
|
var expected2 = peg$expected[0];
|
|
420
434
|
var failPos = expected2.pos;
|
|
421
|
-
return peg$buildStructuredError(
|
|
435
|
+
return peg$buildStructuredError(
|
|
436
|
+
expected2.variants,
|
|
437
|
+
failPos < input.length ? input.charAt(failPos) : null,
|
|
438
|
+
failPos < input.length ? peg$computeLocation(failPos, failPos + 1) : peg$computeLocation(failPos, failPos)
|
|
439
|
+
);
|
|
422
440
|
}
|
|
423
441
|
function peg$parseTop() {
|
|
424
442
|
var s0;
|
|
425
443
|
var rule$expects = function(expected2) {
|
|
426
|
-
if (peg$silentFails === 0)
|
|
427
|
-
peg$expect(expected2);
|
|
444
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
428
445
|
};
|
|
429
446
|
s0 = peg$parseTopLevelValue();
|
|
430
447
|
if (s0 === peg$FAILED) {
|
|
@@ -441,8 +458,7 @@ var require_tag = __commonJS({
|
|
|
441
458
|
function peg$parseTopLevelValue() {
|
|
442
459
|
var s0, s1;
|
|
443
460
|
var rule$expects = function(expected2) {
|
|
444
|
-
if (peg$silentFails === 0)
|
|
445
|
-
peg$expect(expected2);
|
|
461
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
446
462
|
};
|
|
447
463
|
s0 = peg$currPos;
|
|
448
464
|
s1 = peg$parseVariable();
|
|
@@ -459,8 +475,7 @@ var require_tag = __commonJS({
|
|
|
459
475
|
function peg$parseAnnotation() {
|
|
460
476
|
var s0, s1, s2, s3;
|
|
461
477
|
var rule$expects = function(expected2) {
|
|
462
|
-
if (peg$silentFails === 0)
|
|
463
|
-
peg$expect(expected2);
|
|
478
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
464
479
|
};
|
|
465
480
|
s0 = peg$currPos;
|
|
466
481
|
s1 = peg$parseTagAttributes();
|
|
@@ -482,8 +497,7 @@ var require_tag = __commonJS({
|
|
|
482
497
|
function peg$parseTagOpen() {
|
|
483
498
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
484
499
|
var rule$expects = function(expected2) {
|
|
485
|
-
if (peg$silentFails === 0)
|
|
486
|
-
peg$expect(expected2);
|
|
500
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
487
501
|
};
|
|
488
502
|
s0 = peg$currPos;
|
|
489
503
|
s1 = peg$parseTagName();
|
|
@@ -541,8 +555,7 @@ var require_tag = __commonJS({
|
|
|
541
555
|
function peg$parseTagClose() {
|
|
542
556
|
var s0, s1, s2;
|
|
543
557
|
var rule$expects = function(expected2) {
|
|
544
|
-
if (peg$silentFails === 0)
|
|
545
|
-
peg$expect(expected2);
|
|
558
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
546
559
|
};
|
|
547
560
|
s0 = peg$currPos;
|
|
548
561
|
rule$expects(peg$e0);
|
|
@@ -570,8 +583,7 @@ var require_tag = __commonJS({
|
|
|
570
583
|
function peg$parseTagName() {
|
|
571
584
|
var s0;
|
|
572
585
|
var rule$expects = function(expected2) {
|
|
573
|
-
if (peg$silentFails === 0)
|
|
574
|
-
peg$expect(expected2);
|
|
586
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
575
587
|
};
|
|
576
588
|
rule$expects(peg$e1);
|
|
577
589
|
peg$silentFails++;
|
|
@@ -582,8 +594,7 @@ var require_tag = __commonJS({
|
|
|
582
594
|
function peg$parseTagAttributes() {
|
|
583
595
|
var s0, s1, s2, s3;
|
|
584
596
|
var rule$expects = function(expected2) {
|
|
585
|
-
if (peg$silentFails === 0)
|
|
586
|
-
peg$expect(expected2);
|
|
597
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
587
598
|
};
|
|
588
599
|
s0 = peg$currPos;
|
|
589
600
|
s1 = peg$parseTagAttributesItem();
|
|
@@ -605,8 +616,7 @@ var require_tag = __commonJS({
|
|
|
605
616
|
function peg$parseTagAttributesTail() {
|
|
606
617
|
var s0, s1, s2;
|
|
607
618
|
var rule$expects = function(expected2) {
|
|
608
|
-
if (peg$silentFails === 0)
|
|
609
|
-
peg$expect(expected2);
|
|
619
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
610
620
|
};
|
|
611
621
|
s0 = peg$currPos;
|
|
612
622
|
s1 = [];
|
|
@@ -637,8 +647,7 @@ var require_tag = __commonJS({
|
|
|
637
647
|
function peg$parseTagAttributesItem() {
|
|
638
648
|
var s0, s1;
|
|
639
649
|
var rule$expects = function(expected2) {
|
|
640
|
-
if (peg$silentFails === 0)
|
|
641
|
-
peg$expect(expected2);
|
|
650
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
642
651
|
};
|
|
643
652
|
s0 = peg$currPos;
|
|
644
653
|
s1 = peg$parseTagShortcutId();
|
|
@@ -670,8 +679,7 @@ var require_tag = __commonJS({
|
|
|
670
679
|
function peg$parseTagShortcutClass() {
|
|
671
680
|
var s0, s1, s2;
|
|
672
681
|
var rule$expects = function(expected2) {
|
|
673
|
-
if (peg$silentFails === 0)
|
|
674
|
-
peg$expect(expected2);
|
|
682
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
675
683
|
};
|
|
676
684
|
rule$expects(peg$e2);
|
|
677
685
|
peg$silentFails++;
|
|
@@ -701,8 +709,7 @@ var require_tag = __commonJS({
|
|
|
701
709
|
function peg$parseTagShortcutId() {
|
|
702
710
|
var s0, s1, s2;
|
|
703
711
|
var rule$expects = function(expected2) {
|
|
704
|
-
if (peg$silentFails === 0)
|
|
705
|
-
peg$expect(expected2);
|
|
712
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
706
713
|
};
|
|
707
714
|
rule$expects(peg$e3);
|
|
708
715
|
peg$silentFails++;
|
|
@@ -732,8 +739,7 @@ var require_tag = __commonJS({
|
|
|
732
739
|
function peg$parseTagAttribute() {
|
|
733
740
|
var s0, s1, s2, s3;
|
|
734
741
|
var rule$expects = function(expected2) {
|
|
735
|
-
if (peg$silentFails === 0)
|
|
736
|
-
peg$expect(expected2);
|
|
742
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
737
743
|
};
|
|
738
744
|
s0 = peg$currPos;
|
|
739
745
|
s1 = peg$parseIdentifier();
|
|
@@ -767,8 +773,7 @@ var require_tag = __commonJS({
|
|
|
767
773
|
function peg$parseFunction() {
|
|
768
774
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
769
775
|
var rule$expects = function(expected2) {
|
|
770
|
-
if (peg$silentFails === 0)
|
|
771
|
-
peg$expect(expected2);
|
|
776
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
772
777
|
};
|
|
773
778
|
s0 = peg$currPos;
|
|
774
779
|
s1 = peg$parseIdentifier();
|
|
@@ -827,8 +832,7 @@ var require_tag = __commonJS({
|
|
|
827
832
|
function peg$parseFunctionParameter() {
|
|
828
833
|
var s0, s1, s2, s3;
|
|
829
834
|
var rule$expects = function(expected2) {
|
|
830
|
-
if (peg$silentFails === 0)
|
|
831
|
-
peg$expect(expected2);
|
|
835
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
832
836
|
};
|
|
833
837
|
s0 = peg$currPos;
|
|
834
838
|
s1 = peg$currPos;
|
|
@@ -868,8 +872,7 @@ var require_tag = __commonJS({
|
|
|
868
872
|
function peg$parseFunctionParameterTail() {
|
|
869
873
|
var s0, s1, s2, s3, s4;
|
|
870
874
|
var rule$expects = function(expected2) {
|
|
871
|
-
if (peg$silentFails === 0)
|
|
872
|
-
peg$expect(expected2);
|
|
875
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
873
876
|
};
|
|
874
877
|
s0 = peg$currPos;
|
|
875
878
|
s1 = [];
|
|
@@ -909,8 +912,7 @@ var require_tag = __commonJS({
|
|
|
909
912
|
function peg$parseTrailingComma() {
|
|
910
913
|
var s0, s1, s2;
|
|
911
914
|
var rule$expects = function(expected2) {
|
|
912
|
-
if (peg$silentFails === 0)
|
|
913
|
-
peg$expect(expected2);
|
|
915
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
914
916
|
};
|
|
915
917
|
s0 = peg$currPos;
|
|
916
918
|
s1 = [];
|
|
@@ -941,8 +943,7 @@ var require_tag = __commonJS({
|
|
|
941
943
|
function peg$parseVariable() {
|
|
942
944
|
var s0, s1, s2, s3, s4;
|
|
943
945
|
var rule$expects = function(expected2) {
|
|
944
|
-
if (peg$silentFails === 0)
|
|
945
|
-
peg$expect(expected2);
|
|
946
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
946
947
|
};
|
|
947
948
|
rule$expects(peg$e8);
|
|
948
949
|
peg$silentFails++;
|
|
@@ -978,8 +979,7 @@ var require_tag = __commonJS({
|
|
|
978
979
|
function peg$parseVariableTail() {
|
|
979
980
|
var s0, s1, s2, s3;
|
|
980
981
|
var rule$expects = function(expected2) {
|
|
981
|
-
if (peg$silentFails === 0)
|
|
982
|
-
peg$expect(expected2);
|
|
982
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
983
983
|
};
|
|
984
984
|
s0 = peg$currPos;
|
|
985
985
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
@@ -1042,8 +1042,7 @@ var require_tag = __commonJS({
|
|
|
1042
1042
|
function peg$parseValue() {
|
|
1043
1043
|
var s0;
|
|
1044
1044
|
var rule$expects = function(expected2) {
|
|
1045
|
-
if (peg$silentFails === 0)
|
|
1046
|
-
peg$expect(expected2);
|
|
1045
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1047
1046
|
};
|
|
1048
1047
|
s0 = peg$parseValueNull();
|
|
1049
1048
|
if (s0 === peg$FAILED) {
|
|
@@ -1072,8 +1071,7 @@ var require_tag = __commonJS({
|
|
|
1072
1071
|
function peg$parseValueNull() {
|
|
1073
1072
|
var s0, s1;
|
|
1074
1073
|
var rule$expects = function(expected2) {
|
|
1075
|
-
if (peg$silentFails === 0)
|
|
1076
|
-
peg$expect(expected2);
|
|
1074
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1077
1075
|
};
|
|
1078
1076
|
rule$expects(peg$e9);
|
|
1079
1077
|
peg$silentFails++;
|
|
@@ -1095,8 +1093,7 @@ var require_tag = __commonJS({
|
|
|
1095
1093
|
function peg$parseValueBoolean() {
|
|
1096
1094
|
var s0, s1;
|
|
1097
1095
|
var rule$expects = function(expected2) {
|
|
1098
|
-
if (peg$silentFails === 0)
|
|
1099
|
-
peg$expect(expected2);
|
|
1096
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1100
1097
|
};
|
|
1101
1098
|
rule$expects(peg$e10);
|
|
1102
1099
|
peg$silentFails++;
|
|
@@ -1132,8 +1129,7 @@ var require_tag = __commonJS({
|
|
|
1132
1129
|
function peg$parseValueArray() {
|
|
1133
1130
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1134
1131
|
var rule$expects = function(expected2) {
|
|
1135
|
-
if (peg$silentFails === 0)
|
|
1136
|
-
peg$expect(expected2);
|
|
1132
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1137
1133
|
};
|
|
1138
1134
|
s0 = peg$currPos;
|
|
1139
1135
|
rule$expects(peg$e11);
|
|
@@ -1198,8 +1194,7 @@ var require_tag = __commonJS({
|
|
|
1198
1194
|
function peg$parseValueArrayTail() {
|
|
1199
1195
|
var s0, s1, s2, s3, s4;
|
|
1200
1196
|
var rule$expects = function(expected2) {
|
|
1201
|
-
if (peg$silentFails === 0)
|
|
1202
|
-
peg$expect(expected2);
|
|
1197
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1203
1198
|
};
|
|
1204
1199
|
s0 = peg$currPos;
|
|
1205
1200
|
s1 = [];
|
|
@@ -1239,8 +1234,7 @@ var require_tag = __commonJS({
|
|
|
1239
1234
|
function peg$parseValueHash() {
|
|
1240
1235
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1241
1236
|
var rule$expects = function(expected2) {
|
|
1242
|
-
if (peg$silentFails === 0)
|
|
1243
|
-
peg$expect(expected2);
|
|
1237
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1244
1238
|
};
|
|
1245
1239
|
s0 = peg$currPos;
|
|
1246
1240
|
rule$expects(peg$e13);
|
|
@@ -1305,8 +1299,7 @@ var require_tag = __commonJS({
|
|
|
1305
1299
|
function peg$parseValueHashTail() {
|
|
1306
1300
|
var s0, s1, s2, s3, s4;
|
|
1307
1301
|
var rule$expects = function(expected2) {
|
|
1308
|
-
if (peg$silentFails === 0)
|
|
1309
|
-
peg$expect(expected2);
|
|
1302
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1310
1303
|
};
|
|
1311
1304
|
s0 = peg$currPos;
|
|
1312
1305
|
s1 = [];
|
|
@@ -1346,8 +1339,7 @@ var require_tag = __commonJS({
|
|
|
1346
1339
|
function peg$parseValueHashItem() {
|
|
1347
1340
|
var s0, s1, s2, s3, s4;
|
|
1348
1341
|
var rule$expects = function(expected2) {
|
|
1349
|
-
if (peg$silentFails === 0)
|
|
1350
|
-
peg$expect(expected2);
|
|
1342
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1351
1343
|
};
|
|
1352
1344
|
s0 = peg$currPos;
|
|
1353
1345
|
s1 = peg$parseIdentifier();
|
|
@@ -1390,8 +1382,7 @@ var require_tag = __commonJS({
|
|
|
1390
1382
|
function peg$parseValueNumber() {
|
|
1391
1383
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
1392
1384
|
var rule$expects = function(expected2) {
|
|
1393
|
-
if (peg$silentFails === 0)
|
|
1394
|
-
peg$expect(expected2);
|
|
1385
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1395
1386
|
};
|
|
1396
1387
|
rule$expects(peg$e16);
|
|
1397
1388
|
peg$silentFails++;
|
|
@@ -1480,8 +1471,7 @@ var require_tag = __commonJS({
|
|
|
1480
1471
|
function peg$parseValueString() {
|
|
1481
1472
|
var s0, s1, s2, s3;
|
|
1482
1473
|
var rule$expects = function(expected2) {
|
|
1483
|
-
if (peg$silentFails === 0)
|
|
1484
|
-
peg$expect(expected2);
|
|
1474
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1485
1475
|
};
|
|
1486
1476
|
rule$expects(peg$e17);
|
|
1487
1477
|
peg$silentFails++;
|
|
@@ -1522,8 +1512,7 @@ var require_tag = __commonJS({
|
|
|
1522
1512
|
function peg$parseValueStringChars() {
|
|
1523
1513
|
var s0;
|
|
1524
1514
|
var rule$expects = function(expected2) {
|
|
1525
|
-
if (peg$silentFails === 0)
|
|
1526
|
-
peg$expect(expected2);
|
|
1515
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1527
1516
|
};
|
|
1528
1517
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
1529
1518
|
s0 = input.charAt(peg$currPos);
|
|
@@ -1539,8 +1528,7 @@ var require_tag = __commonJS({
|
|
|
1539
1528
|
function peg$parseValueStringEscapes() {
|
|
1540
1529
|
var s0, s1, s2, s3;
|
|
1541
1530
|
var rule$expects = function(expected2) {
|
|
1542
|
-
if (peg$silentFails === 0)
|
|
1543
|
-
peg$expect(expected2);
|
|
1531
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1544
1532
|
};
|
|
1545
1533
|
s0 = peg$currPos;
|
|
1546
1534
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
@@ -1622,8 +1610,7 @@ var require_tag = __commonJS({
|
|
|
1622
1610
|
function peg$parseIdentifier() {
|
|
1623
1611
|
var s0, s1, s2;
|
|
1624
1612
|
var rule$expects = function(expected2) {
|
|
1625
|
-
if (peg$silentFails === 0)
|
|
1626
|
-
peg$expect(expected2);
|
|
1613
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1627
1614
|
};
|
|
1628
1615
|
rule$expects(peg$e18);
|
|
1629
1616
|
peg$silentFails++;
|
|
@@ -1659,8 +1646,7 @@ var require_tag = __commonJS({
|
|
|
1659
1646
|
function peg$parse_() {
|
|
1660
1647
|
var s0;
|
|
1661
1648
|
var rule$expects = function(expected2) {
|
|
1662
|
-
if (peg$silentFails === 0)
|
|
1663
|
-
peg$expect(expected2);
|
|
1649
|
+
if (peg$silentFails === 0) peg$expect(expected2);
|
|
1664
1650
|
};
|
|
1665
1651
|
rule$expects(peg$e19);
|
|
1666
1652
|
peg$silentFails++;
|
|
@@ -2271,10 +2257,15 @@ var require_utils = __commonJS({
|
|
|
2271
2257
|
}
|
|
2272
2258
|
switch (code2) {
|
|
2273
2259
|
case 9:
|
|
2260
|
+
// \t
|
|
2274
2261
|
case 10:
|
|
2262
|
+
// \n
|
|
2275
2263
|
case 11:
|
|
2264
|
+
// \v
|
|
2276
2265
|
case 12:
|
|
2266
|
+
// \f
|
|
2277
2267
|
case 13:
|
|
2268
|
+
// \r
|
|
2278
2269
|
case 32:
|
|
2279
2270
|
case 160:
|
|
2280
2271
|
case 5760:
|
|
@@ -3097,10 +3088,8 @@ var require_smartquotes = __commonJS({
|
|
|
3097
3088
|
lastChar = text2.charCodeAt(t.index - 1);
|
|
3098
3089
|
} else {
|
|
3099
3090
|
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;
|
|
3091
|
+
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
|
|
3092
|
+
if (!tokens[j].content) continue;
|
|
3104
3093
|
lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
|
|
3105
3094
|
break;
|
|
3106
3095
|
}
|
|
@@ -3110,10 +3099,8 @@ var require_smartquotes = __commonJS({
|
|
|
3110
3099
|
nextChar = text2.charCodeAt(pos);
|
|
3111
3100
|
} else {
|
|
3112
3101
|
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;
|
|
3102
|
+
if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
|
|
3103
|
+
if (!tokens[j].content) continue;
|
|
3117
3104
|
nextChar = tokens[j].content.charCodeAt(0);
|
|
3118
3105
|
break;
|
|
3119
3106
|
}
|
|
@@ -3167,7 +3154,11 @@ var require_smartquotes = __commonJS({
|
|
|
3167
3154
|
closeQuote = state.md.options.quotes[1];
|
|
3168
3155
|
}
|
|
3169
3156
|
token.content = replaceAt(token.content, t.index, closeQuote);
|
|
3170
|
-
tokens[item2.token].content = replaceAt(
|
|
3157
|
+
tokens[item2.token].content = replaceAt(
|
|
3158
|
+
tokens[item2.token].content,
|
|
3159
|
+
item2.pos,
|
|
3160
|
+
openQuote
|
|
3161
|
+
);
|
|
3171
3162
|
pos += closeQuote.length - 1;
|
|
3172
3163
|
if (item2.token === i) {
|
|
3173
3164
|
pos += openQuote.length - 1;
|
|
@@ -3419,10 +3410,8 @@ var require_table = __commonJS({
|
|
|
3419
3410
|
return false;
|
|
3420
3411
|
}
|
|
3421
3412
|
columns = escapedSplit(lineText);
|
|
3422
|
-
if (columns.length && columns[0] === "")
|
|
3423
|
-
|
|
3424
|
-
if (columns.length && columns[columns.length - 1] === "")
|
|
3425
|
-
columns.pop();
|
|
3413
|
+
if (columns.length && columns[0] === "") columns.shift();
|
|
3414
|
+
if (columns.length && columns[columns.length - 1] === "") columns.pop();
|
|
3426
3415
|
columnCount = columns.length;
|
|
3427
3416
|
if (columnCount === 0 || columnCount !== aligns.length) {
|
|
3428
3417
|
return false;
|
|
@@ -3473,10 +3462,8 @@ var require_table = __commonJS({
|
|
|
3473
3462
|
break;
|
|
3474
3463
|
}
|
|
3475
3464
|
columns = escapedSplit(lineText);
|
|
3476
|
-
if (columns.length && columns[0] === "")
|
|
3477
|
-
|
|
3478
|
-
if (columns.length && columns[columns.length - 1] === "")
|
|
3479
|
-
columns.pop();
|
|
3465
|
+
if (columns.length && columns[0] === "") columns.shift();
|
|
3466
|
+
if (columns.length && columns[columns.length - 1] === "") columns.pop();
|
|
3480
3467
|
if (nextLine === startLine + 2) {
|
|
3481
3468
|
token = state.push("tbody_open", "tbody", 1);
|
|
3482
3469
|
token.map = tbodyLines = [startLine + 2, 0];
|
|
@@ -3897,16 +3884,14 @@ var require_list = __commonJS({
|
|
|
3897
3884
|
isOrdered = true;
|
|
3898
3885
|
start = state.bMarks[startLine] + state.tShift[startLine];
|
|
3899
3886
|
markerValue = Number(state.src.slice(start, posAfterMarker - 1));
|
|
3900
|
-
if (isTerminatingParagraph && markerValue !== 1)
|
|
3901
|
-
return false;
|
|
3887
|
+
if (isTerminatingParagraph && markerValue !== 1) return false;
|
|
3902
3888
|
} else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
|
|
3903
3889
|
isOrdered = false;
|
|
3904
3890
|
} else {
|
|
3905
3891
|
return false;
|
|
3906
3892
|
}
|
|
3907
3893
|
if (isTerminatingParagraph) {
|
|
3908
|
-
if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine])
|
|
3909
|
-
return false;
|
|
3894
|
+
if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
|
|
3910
3895
|
}
|
|
3911
3896
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
|
|
3912
3897
|
if (silent) {
|
|
@@ -4569,11 +4554,9 @@ var require_state_block = __commonJS({
|
|
|
4569
4554
|
StateBlock.prototype.push = function(type, tag, nesting) {
|
|
4570
4555
|
var token = new Token(type, tag, nesting);
|
|
4571
4556
|
token.block = true;
|
|
4572
|
-
if (nesting < 0)
|
|
4573
|
-
this.level--;
|
|
4557
|
+
if (nesting < 0) this.level--;
|
|
4574
4558
|
token.level = this.level;
|
|
4575
|
-
if (nesting > 0)
|
|
4576
|
-
this.level++;
|
|
4559
|
+
if (nesting > 0) this.level++;
|
|
4577
4560
|
this.tokens.push(token);
|
|
4578
4561
|
return token;
|
|
4579
4562
|
};
|
|
@@ -4676,6 +4659,8 @@ var require_parser_block = __commonJS({
|
|
|
4676
4659
|
"use strict";
|
|
4677
4660
|
var Ruler = require_ruler();
|
|
4678
4661
|
var _rules = [
|
|
4662
|
+
// First 2 params - rule name & source. Secondary array - list of rules,
|
|
4663
|
+
// which can be terminated by this one.
|
|
4679
4664
|
["table", require_table(), ["paragraph", "reference"]],
|
|
4680
4665
|
["code", require_code()],
|
|
4681
4666
|
["fence", require_fence(), ["paragraph", "reference", "blockquote", "list"]],
|
|
@@ -4806,8 +4791,7 @@ var require_newline = __commonJS({
|
|
|
4806
4791
|
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) {
|
|
4807
4792
|
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) {
|
|
4808
4793
|
ws = pmax - 1;
|
|
4809
|
-
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32)
|
|
4810
|
-
ws--;
|
|
4794
|
+
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--;
|
|
4811
4795
|
state.pending = state.pending.slice(0, ws);
|
|
4812
4796
|
state.push("hardbreak", "br", 0);
|
|
4813
4797
|
} else {
|
|
@@ -4899,8 +4883,7 @@ var require_backticks = __commonJS({
|
|
|
4899
4883
|
marker = state.src.slice(start, pos);
|
|
4900
4884
|
openerLength = marker.length;
|
|
4901
4885
|
if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
|
|
4902
|
-
if (!silent)
|
|
4903
|
-
state.pending += marker;
|
|
4886
|
+
if (!silent) state.pending += marker;
|
|
4904
4887
|
state.pos += openerLength;
|
|
4905
4888
|
return true;
|
|
4906
4889
|
}
|
|
@@ -4923,8 +4906,7 @@ var require_backticks = __commonJS({
|
|
|
4923
4906
|
state.backticks[closerLength] = matchStart;
|
|
4924
4907
|
}
|
|
4925
4908
|
state.backticksScanned = true;
|
|
4926
|
-
if (!silent)
|
|
4927
|
-
state.pending += marker;
|
|
4909
|
+
if (!silent) state.pending += marker;
|
|
4928
4910
|
state.pos += openerLength;
|
|
4929
4911
|
return true;
|
|
4930
4912
|
};
|
|
@@ -4960,6 +4942,7 @@ var require_strikethrough = __commonJS({
|
|
|
4960
4942
|
state.delimiters.push({
|
|
4961
4943
|
marker,
|
|
4962
4944
|
length: 0,
|
|
4945
|
+
// disable "rule of 3" length checks meant for emphasis
|
|
4963
4946
|
token: state.tokens.length - 1,
|
|
4964
4947
|
end: -1,
|
|
4965
4948
|
open: scanned.can_open,
|
|
@@ -5039,10 +5022,22 @@ var require_emphasis = __commonJS({
|
|
|
5039
5022
|
token = state.push("text", "", 0);
|
|
5040
5023
|
token.content = String.fromCharCode(marker);
|
|
5041
5024
|
state.delimiters.push({
|
|
5025
|
+
// Char code of the starting marker (number).
|
|
5026
|
+
//
|
|
5042
5027
|
marker,
|
|
5028
|
+
// Total length of these series of delimiters.
|
|
5029
|
+
//
|
|
5043
5030
|
length: scanned.length,
|
|
5031
|
+
// A position of the token this delimiter corresponds to.
|
|
5032
|
+
//
|
|
5044
5033
|
token: state.tokens.length - 1,
|
|
5034
|
+
// If this delimiter is matched as a valid opener, `end` will be
|
|
5035
|
+
// equal to its position, otherwise it's `-1`.
|
|
5036
|
+
//
|
|
5045
5037
|
end: -1,
|
|
5038
|
+
// Boolean flags that determine if this delimiter could open or close
|
|
5039
|
+
// an emphasis.
|
|
5040
|
+
//
|
|
5046
5041
|
open: scanned.can_open,
|
|
5047
5042
|
close: scanned.can_close
|
|
5048
5043
|
});
|
|
@@ -5061,7 +5056,9 @@ var require_emphasis = __commonJS({
|
|
|
5061
5056
|
continue;
|
|
5062
5057
|
}
|
|
5063
5058
|
endDelim = delimiters[startDelim.end];
|
|
5064
|
-
isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 &&
|
|
5059
|
+
isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 && // check that first two markers match and adjacent
|
|
5060
|
+
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)
|
|
5061
|
+
delimiters[startDelim.end + 1].token === endDelim.token + 1;
|
|
5065
5062
|
ch = String.fromCharCode(startDelim.marker);
|
|
5066
5063
|
token = state.tokens[startDelim.token];
|
|
5067
5064
|
token.type = isStrong ? "strong_open" : "em_open";
|
|
@@ -5294,7 +5291,12 @@ var require_image = __commonJS({
|
|
|
5294
5291
|
}
|
|
5295
5292
|
if (!silent) {
|
|
5296
5293
|
content = state.src.slice(labelStart, labelEnd);
|
|
5297
|
-
state.md.inline.parse(
|
|
5294
|
+
state.md.inline.parse(
|
|
5295
|
+
content,
|
|
5296
|
+
state.md,
|
|
5297
|
+
state.env,
|
|
5298
|
+
tokens = []
|
|
5299
|
+
);
|
|
5298
5300
|
token = state.push("image", "img", 0);
|
|
5299
5301
|
token.attrs = attrs = [["src", href], ["alt", ""]];
|
|
5300
5302
|
token.children = tokens;
|
|
@@ -5324,13 +5326,10 @@ var require_autolink = __commonJS({
|
|
|
5324
5326
|
start = state.pos;
|
|
5325
5327
|
max2 = state.posMax;
|
|
5326
5328
|
for (; ; ) {
|
|
5327
|
-
if (++pos >= max2)
|
|
5328
|
-
return false;
|
|
5329
|
+
if (++pos >= max2) return false;
|
|
5329
5330
|
ch = state.src.charCodeAt(pos);
|
|
5330
|
-
if (ch === 60)
|
|
5331
|
-
|
|
5332
|
-
if (ch === 62)
|
|
5333
|
-
break;
|
|
5331
|
+
if (ch === 60) return false;
|
|
5332
|
+
if (ch === 62) break;
|
|
5334
5333
|
}
|
|
5335
5334
|
url = state.src.slice(start + 1, pos);
|
|
5336
5335
|
if (AUTOLINK_RE.test(url)) {
|
|
@@ -5467,8 +5466,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5467
5466
|
"use strict";
|
|
5468
5467
|
function processDelimiters(state, delimiters) {
|
|
5469
5468
|
var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max2 = delimiters.length;
|
|
5470
|
-
if (!max2)
|
|
5471
|
-
return;
|
|
5469
|
+
if (!max2) return;
|
|
5472
5470
|
var headerIdx = 0;
|
|
5473
5471
|
var lastTokenIdx = -2;
|
|
5474
5472
|
var jumps = [];
|
|
@@ -5480,8 +5478,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5480
5478
|
}
|
|
5481
5479
|
lastTokenIdx = closer.token;
|
|
5482
5480
|
closer.length = closer.length || 0;
|
|
5483
|
-
if (!closer.close)
|
|
5484
|
-
continue;
|
|
5481
|
+
if (!closer.close) continue;
|
|
5485
5482
|
if (!openersBottom.hasOwnProperty(closer.marker)) {
|
|
5486
5483
|
openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1];
|
|
5487
5484
|
}
|
|
@@ -5490,8 +5487,7 @@ var require_balance_pairs = __commonJS({
|
|
|
5490
5487
|
newMinOpenerIdx = openerIdx;
|
|
5491
5488
|
for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
|
|
5492
5489
|
opener = delimiters[openerIdx];
|
|
5493
|
-
if (opener.marker !== closer.marker)
|
|
5494
|
-
continue;
|
|
5490
|
+
if (opener.marker !== closer.marker) continue;
|
|
5495
5491
|
if (opener.open && opener.end < 0) {
|
|
5496
5492
|
isOddMatch = false;
|
|
5497
5493
|
if (opener.close || closer.open) {
|
|
@@ -5538,11 +5534,9 @@ var require_text_collapse = __commonJS({
|
|
|
5538
5534
|
module2.exports = function text_collapse(state) {
|
|
5539
5535
|
var curr, last, level = 0, tokens = state.tokens, max2 = state.tokens.length;
|
|
5540
5536
|
for (curr = last = 0; curr < max2; curr++) {
|
|
5541
|
-
if (tokens[curr].nesting < 0)
|
|
5542
|
-
level--;
|
|
5537
|
+
if (tokens[curr].nesting < 0) level--;
|
|
5543
5538
|
tokens[curr].level = level;
|
|
5544
|
-
if (tokens[curr].nesting > 0)
|
|
5545
|
-
level++;
|
|
5539
|
+
if (tokens[curr].nesting > 0) level++;
|
|
5546
5540
|
if (tokens[curr].type === "text" && curr + 1 < max2 && tokens[curr + 1].type === "text") {
|
|
5547
5541
|
tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
|
|
5548
5542
|
} else {
|
|
@@ -5775,7 +5769,8 @@ var require_re = __commonJS({
|
|
|
5775
5769
|
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
5770
|
re.src_email_name = '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
|
|
5777
5771
|
re.src_xn = "xn--[a-z0-9\\-]{1,59}";
|
|
5778
|
-
re.src_domain_root =
|
|
5772
|
+
re.src_domain_root = // Allow letters & digits (http://test1)
|
|
5773
|
+
"(?:" + re.src_xn + "|" + re.src_pseudo_letter + "{1,63})";
|
|
5779
5774
|
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
5775
|
re.src_host = "(?:(?:(?:(?:" + re.src_domain + ")\\.)*" + re.src_domain + "))";
|
|
5781
5776
|
re.tpl_host_fuzzy = "(?:" + re.src_ip4 + "|(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%)))";
|
|
@@ -5787,8 +5782,12 @@ var require_re = __commonJS({
|
|
|
5787
5782
|
re.tpl_host_port_no_ip_fuzzy_strict = re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
|
|
5788
5783
|
re.tpl_host_fuzzy_test = "localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:" + re.src_ZPCc + "|>|$))";
|
|
5789
5784
|
re.tpl_email_fuzzy = "(^|" + text_separators + '|"|\\(|' + re.src_ZCc + ")(" + re.src_email_name + "@" + re.tpl_host_fuzzy_strict + ")";
|
|
5790
|
-
re.tpl_link_fuzzy =
|
|
5791
|
-
|
|
5785
|
+
re.tpl_link_fuzzy = // Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
5786
|
+
// but can start with > (markdown blockquote)
|
|
5787
|
+
"(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|" + re.src_ZPCc + "))((?![$+<=>^`|\uFF5C])" + re.tpl_host_port_fuzzy_strict + re.src_path + ")";
|
|
5788
|
+
re.tpl_link_no_ip_fuzzy = // Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
5789
|
+
// but can start with > (markdown blockquote)
|
|
5790
|
+
"(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|" + re.src_ZPCc + "))((?![$+<=>^`|\uFF5C])" + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ")";
|
|
5792
5791
|
return re;
|
|
5793
5792
|
};
|
|
5794
5793
|
}
|
|
@@ -5843,7 +5842,10 @@ var require_linkify_it = __commonJS({
|
|
|
5843
5842
|
validate: function(text2, pos, self) {
|
|
5844
5843
|
var tail = text2.slice(pos);
|
|
5845
5844
|
if (!self.re.http) {
|
|
5846
|
-
self.re.http = new RegExp(
|
|
5845
|
+
self.re.http = new RegExp(
|
|
5846
|
+
"^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path,
|
|
5847
|
+
"i"
|
|
5848
|
+
);
|
|
5847
5849
|
}
|
|
5848
5850
|
if (self.re.http.test(tail)) {
|
|
5849
5851
|
return tail.match(self.re.http)[0].length;
|
|
@@ -5857,7 +5859,12 @@ var require_linkify_it = __commonJS({
|
|
|
5857
5859
|
validate: function(text2, pos, self) {
|
|
5858
5860
|
var tail = text2.slice(pos);
|
|
5859
5861
|
if (!self.re.no_http) {
|
|
5860
|
-
self.re.no_http = new RegExp(
|
|
5862
|
+
self.re.no_http = new RegExp(
|
|
5863
|
+
"^" + self.re.src_auth + // Don't allow single-level domains, because of false positives like '//test'
|
|
5864
|
+
// with code comments
|
|
5865
|
+
"(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path,
|
|
5866
|
+
"i"
|
|
5867
|
+
);
|
|
5861
5868
|
}
|
|
5862
5869
|
if (self.re.no_http.test(tail)) {
|
|
5863
5870
|
if (pos >= 3 && text2[pos - 3] === ":") {
|
|
@@ -5875,7 +5882,10 @@ var require_linkify_it = __commonJS({
|
|
|
5875
5882
|
validate: function(text2, pos, self) {
|
|
5876
5883
|
var tail = text2.slice(pos);
|
|
5877
5884
|
if (!self.re.mailto) {
|
|
5878
|
-
self.re.mailto = new RegExp(
|
|
5885
|
+
self.re.mailto = new RegExp(
|
|
5886
|
+
"^" + self.re.src_email_name + "@" + self.re.src_host_strict,
|
|
5887
|
+
"i"
|
|
5888
|
+
);
|
|
5879
5889
|
}
|
|
5880
5890
|
if (self.re.mailto.test(tail)) {
|
|
5881
5891
|
return tail.match(self.re.mailto)[0].length;
|
|
@@ -5968,7 +5978,10 @@ var require_linkify_it = __commonJS({
|
|
|
5968
5978
|
}).map(escapeRE).join("|");
|
|
5969
5979
|
self.re.schema_test = RegExp("(^|(?!_)(?:[><\uFF5C]|" + re.src_ZPCc + "))(" + slist + ")", "i");
|
|
5970
5980
|
self.re.schema_search = RegExp("(^|(?!_)(?:[><\uFF5C]|" + re.src_ZPCc + "))(" + slist + ")", "ig");
|
|
5971
|
-
self.re.pretest = RegExp(
|
|
5981
|
+
self.re.pretest = RegExp(
|
|
5982
|
+
"(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
|
|
5983
|
+
"i"
|
|
5984
|
+
);
|
|
5972
5985
|
resetScanCache(self);
|
|
5973
5986
|
}
|
|
5974
5987
|
function Match(self, shift) {
|
|
@@ -6135,7 +6148,7 @@ var require_punycode = __commonJS({
|
|
|
6135
6148
|
var initialN = 128;
|
|
6136
6149
|
var delimiter = "-";
|
|
6137
6150
|
var regexPunycode = /^xn--/;
|
|
6138
|
-
var regexNonASCII = /[^\0-\
|
|
6151
|
+
var regexNonASCII = /[^\0-\x7F]/;
|
|
6139
6152
|
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
6140
6153
|
var errors = {
|
|
6141
6154
|
"overflow": "Overflow: input needs wider integers to process",
|
|
@@ -6148,24 +6161,24 @@ var require_punycode = __commonJS({
|
|
|
6148
6161
|
function error2(type) {
|
|
6149
6162
|
throw new RangeError(errors[type]);
|
|
6150
6163
|
}
|
|
6151
|
-
function map(array,
|
|
6164
|
+
function map(array, callback) {
|
|
6152
6165
|
const result = [];
|
|
6153
6166
|
let length = array.length;
|
|
6154
6167
|
while (length--) {
|
|
6155
|
-
result[length] =
|
|
6168
|
+
result[length] = callback(array[length]);
|
|
6156
6169
|
}
|
|
6157
6170
|
return result;
|
|
6158
6171
|
}
|
|
6159
|
-
function mapDomain(
|
|
6160
|
-
const parts =
|
|
6172
|
+
function mapDomain(domain, callback) {
|
|
6173
|
+
const parts = domain.split("@");
|
|
6161
6174
|
let result = "";
|
|
6162
6175
|
if (parts.length > 1) {
|
|
6163
6176
|
result = parts[0] + "@";
|
|
6164
|
-
|
|
6177
|
+
domain = parts[1];
|
|
6165
6178
|
}
|
|
6166
|
-
|
|
6167
|
-
const labels =
|
|
6168
|
-
const encoded = map(labels,
|
|
6179
|
+
domain = domain.replace(regexSeparators, ".");
|
|
6180
|
+
const labels = domain.split(".");
|
|
6181
|
+
const encoded = map(labels, callback).join(".");
|
|
6169
6182
|
return result + encoded;
|
|
6170
6183
|
}
|
|
6171
6184
|
function ucs2decode(string) {
|
|
@@ -6188,15 +6201,15 @@ var require_punycode = __commonJS({
|
|
|
6188
6201
|
}
|
|
6189
6202
|
return output;
|
|
6190
6203
|
}
|
|
6191
|
-
var ucs2encode = (
|
|
6204
|
+
var ucs2encode = (codePoints) => String.fromCodePoint(...codePoints);
|
|
6192
6205
|
var basicToDigit = function(codePoint) {
|
|
6193
|
-
if (codePoint
|
|
6194
|
-
return codePoint -
|
|
6206
|
+
if (codePoint >= 48 && codePoint < 58) {
|
|
6207
|
+
return 26 + (codePoint - 48);
|
|
6195
6208
|
}
|
|
6196
|
-
if (codePoint
|
|
6209
|
+
if (codePoint >= 65 && codePoint < 91) {
|
|
6197
6210
|
return codePoint - 65;
|
|
6198
6211
|
}
|
|
6199
|
-
if (codePoint
|
|
6212
|
+
if (codePoint >= 97 && codePoint < 123) {
|
|
6200
6213
|
return codePoint - 97;
|
|
6201
6214
|
}
|
|
6202
6215
|
return base;
|
|
@@ -6230,13 +6243,16 @@ var require_punycode = __commonJS({
|
|
|
6230
6243
|
output.push(input.charCodeAt(j));
|
|
6231
6244
|
}
|
|
6232
6245
|
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
6233
|
-
|
|
6246
|
+
const oldi = i;
|
|
6234
6247
|
for (let w = 1, k = base; ; k += base) {
|
|
6235
6248
|
if (index >= inputLength) {
|
|
6236
6249
|
error2("invalid-input");
|
|
6237
6250
|
}
|
|
6238
6251
|
const digit = basicToDigit(input.charCodeAt(index++));
|
|
6239
|
-
if (digit >= base
|
|
6252
|
+
if (digit >= base) {
|
|
6253
|
+
error2("invalid-input");
|
|
6254
|
+
}
|
|
6255
|
+
if (digit > floor((maxInt - i) / w)) {
|
|
6240
6256
|
error2("overflow");
|
|
6241
6257
|
}
|
|
6242
6258
|
i += digit * w;
|
|
@@ -6264,7 +6280,7 @@ var require_punycode = __commonJS({
|
|
|
6264
6280
|
var encode = function(input) {
|
|
6265
6281
|
const output = [];
|
|
6266
6282
|
input = ucs2decode(input);
|
|
6267
|
-
|
|
6283
|
+
const inputLength = input.length;
|
|
6268
6284
|
let n = initialN;
|
|
6269
6285
|
let delta = 0;
|
|
6270
6286
|
let bias = initialBias;
|
|
@@ -6273,7 +6289,7 @@ var require_punycode = __commonJS({
|
|
|
6273
6289
|
output.push(stringFromCharCode(currentValue));
|
|
6274
6290
|
}
|
|
6275
6291
|
}
|
|
6276
|
-
|
|
6292
|
+
const basicLength = output.length;
|
|
6277
6293
|
let handledCPCount = basicLength;
|
|
6278
6294
|
if (basicLength) {
|
|
6279
6295
|
output.push(delimiter);
|
|
@@ -6295,7 +6311,7 @@ var require_punycode = __commonJS({
|
|
|
6295
6311
|
if (currentValue < n && ++delta > maxInt) {
|
|
6296
6312
|
error2("overflow");
|
|
6297
6313
|
}
|
|
6298
|
-
if (currentValue
|
|
6314
|
+
if (currentValue === n) {
|
|
6299
6315
|
let q = delta;
|
|
6300
6316
|
for (let k = base; ; k += base) {
|
|
6301
6317
|
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
@@ -6304,11 +6320,13 @@ var require_punycode = __commonJS({
|
|
|
6304
6320
|
}
|
|
6305
6321
|
const qMinusT = q - t;
|
|
6306
6322
|
const baseMinusT = base - t;
|
|
6307
|
-
output.push(
|
|
6323
|
+
output.push(
|
|
6324
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
6325
|
+
);
|
|
6308
6326
|
q = floor(qMinusT / baseMinusT);
|
|
6309
6327
|
}
|
|
6310
6328
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
6311
|
-
bias = adapt(delta, handledCPCountPlusOne, handledCPCount
|
|
6329
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
6312
6330
|
delta = 0;
|
|
6313
6331
|
++handledCPCount;
|
|
6314
6332
|
}
|
|
@@ -6329,7 +6347,19 @@ var require_punycode = __commonJS({
|
|
|
6329
6347
|
});
|
|
6330
6348
|
};
|
|
6331
6349
|
var punycode = {
|
|
6332
|
-
|
|
6350
|
+
/**
|
|
6351
|
+
* A string representing the current Punycode.js version number.
|
|
6352
|
+
* @memberOf punycode
|
|
6353
|
+
* @type String
|
|
6354
|
+
*/
|
|
6355
|
+
"version": "2.3.1",
|
|
6356
|
+
/**
|
|
6357
|
+
* An object of methods to convert from JavaScript's internal character
|
|
6358
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
6359
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
6360
|
+
* @memberOf punycode
|
|
6361
|
+
* @type Object
|
|
6362
|
+
*/
|
|
6333
6363
|
"ucs2": {
|
|
6334
6364
|
"decode": ucs2decode,
|
|
6335
6365
|
"encode": ucs2encode
|
|
@@ -6350,14 +6380,33 @@ var require_default = __commonJS({
|
|
|
6350
6380
|
module2.exports = {
|
|
6351
6381
|
options: {
|
|
6352
6382
|
html: false,
|
|
6383
|
+
// Enable HTML tags in source
|
|
6353
6384
|
xhtmlOut: false,
|
|
6385
|
+
// Use '/' to close single tags (<br />)
|
|
6354
6386
|
breaks: false,
|
|
6387
|
+
// Convert '\n' in paragraphs into <br>
|
|
6355
6388
|
langPrefix: "language-",
|
|
6389
|
+
// CSS language prefix for fenced blocks
|
|
6356
6390
|
linkify: false,
|
|
6391
|
+
// autoconvert URL-like texts to links
|
|
6392
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6357
6393
|
typographer: false,
|
|
6394
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6395
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6396
|
+
//
|
|
6397
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6398
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6358
6399
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6400
|
+
/* “”‘’ */
|
|
6401
|
+
// Highlighter function. Should return escaped HTML,
|
|
6402
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6403
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6404
|
+
//
|
|
6405
|
+
// function (/*str, lang*/) { return ''; }
|
|
6406
|
+
//
|
|
6359
6407
|
highlight: null,
|
|
6360
6408
|
maxNesting: 100
|
|
6409
|
+
// Internal protection, recursion limit
|
|
6361
6410
|
},
|
|
6362
6411
|
components: {
|
|
6363
6412
|
core: {},
|
|
@@ -6375,14 +6424,33 @@ var require_zero = __commonJS({
|
|
|
6375
6424
|
module2.exports = {
|
|
6376
6425
|
options: {
|
|
6377
6426
|
html: false,
|
|
6427
|
+
// Enable HTML tags in source
|
|
6378
6428
|
xhtmlOut: false,
|
|
6429
|
+
// Use '/' to close single tags (<br />)
|
|
6379
6430
|
breaks: false,
|
|
6431
|
+
// Convert '\n' in paragraphs into <br>
|
|
6380
6432
|
langPrefix: "language-",
|
|
6433
|
+
// CSS language prefix for fenced blocks
|
|
6381
6434
|
linkify: false,
|
|
6435
|
+
// autoconvert URL-like texts to links
|
|
6436
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6382
6437
|
typographer: false,
|
|
6438
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6439
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6440
|
+
//
|
|
6441
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6442
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6383
6443
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6444
|
+
/* “”‘’ */
|
|
6445
|
+
// Highlighter function. Should return escaped HTML,
|
|
6446
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6447
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6448
|
+
//
|
|
6449
|
+
// function (/*str, lang*/) { return ''; }
|
|
6450
|
+
//
|
|
6384
6451
|
highlight: null,
|
|
6385
6452
|
maxNesting: 20
|
|
6453
|
+
// Internal protection, recursion limit
|
|
6386
6454
|
},
|
|
6387
6455
|
components: {
|
|
6388
6456
|
core: {
|
|
@@ -6418,14 +6486,33 @@ var require_commonmark = __commonJS({
|
|
|
6418
6486
|
module2.exports = {
|
|
6419
6487
|
options: {
|
|
6420
6488
|
html: true,
|
|
6489
|
+
// Enable HTML tags in source
|
|
6421
6490
|
xhtmlOut: true,
|
|
6491
|
+
// Use '/' to close single tags (<br />)
|
|
6422
6492
|
breaks: false,
|
|
6493
|
+
// Convert '\n' in paragraphs into <br>
|
|
6423
6494
|
langPrefix: "language-",
|
|
6495
|
+
// CSS language prefix for fenced blocks
|
|
6424
6496
|
linkify: false,
|
|
6497
|
+
// autoconvert URL-like texts to links
|
|
6498
|
+
// Enable some language-neutral replacements + quotes beautification
|
|
6425
6499
|
typographer: false,
|
|
6500
|
+
// Double + single quotes replacement pairs, when typographer enabled,
|
|
6501
|
+
// and smartquotes on. Could be either a String or an Array.
|
|
6502
|
+
//
|
|
6503
|
+
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
6504
|
+
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
6426
6505
|
quotes: "\u201C\u201D\u2018\u2019",
|
|
6506
|
+
/* “”‘’ */
|
|
6507
|
+
// Highlighter function. Should return escaped HTML,
|
|
6508
|
+
// or '' if the source string is not changed and should be escaped externaly.
|
|
6509
|
+
// If result starts with <pre... internal wrapper is skipped.
|
|
6510
|
+
//
|
|
6511
|
+
// function (/*str, lang*/) { return ''; }
|
|
6512
|
+
//
|
|
6427
6513
|
highlight: null,
|
|
6428
6514
|
maxNesting: 20
|
|
6515
|
+
// Internal protection, recursion limit
|
|
6429
6516
|
},
|
|
6430
6517
|
components: {
|
|
6431
6518
|
core: {
|
|
@@ -6653,7 +6740,8 @@ var require_markdown_it = __commonJS({
|
|
|
6653
6740
|
});
|
|
6654
6741
|
|
|
6655
6742
|
// index.ts
|
|
6656
|
-
|
|
6743
|
+
var index_exports = {};
|
|
6744
|
+
__export(index_exports, {
|
|
6657
6745
|
Ast: () => ast_default,
|
|
6658
6746
|
Node: () => Node,
|
|
6659
6747
|
Tag: () => Tag,
|
|
@@ -6676,6 +6764,7 @@ __export(exports, {
|
|
|
6676
6764
|
validate: () => validate,
|
|
6677
6765
|
validator: () => validator
|
|
6678
6766
|
});
|
|
6767
|
+
module.exports = __toCommonJS(index_exports);
|
|
6679
6768
|
|
|
6680
6769
|
// src/ast/base.ts
|
|
6681
6770
|
var base_exports = {};
|
|
@@ -6696,30 +6785,20 @@ function isVariable(value) {
|
|
|
6696
6785
|
return !!(value?.$$mdtype === "Variable");
|
|
6697
6786
|
}
|
|
6698
6787
|
function* getAstValues(value) {
|
|
6699
|
-
if (value == null || typeof value !== "object")
|
|
6700
|
-
|
|
6701
|
-
if (
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
if (isAst(value))
|
|
6705
|
-
yield value;
|
|
6706
|
-
if (Object.getPrototypeOf(value) !== Object.prototype)
|
|
6707
|
-
return;
|
|
6708
|
-
for (const v of Object.values(value))
|
|
6709
|
-
yield* getAstValues(v);
|
|
6788
|
+
if (value == null || typeof value !== "object") return;
|
|
6789
|
+
if (Array.isArray(value)) for (const v of value) yield* getAstValues(v);
|
|
6790
|
+
if (isAst(value)) yield value;
|
|
6791
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return;
|
|
6792
|
+
for (const v of Object.values(value)) yield* getAstValues(v);
|
|
6710
6793
|
}
|
|
6711
6794
|
function resolve(value, config = {}) {
|
|
6712
|
-
if (value == null || typeof value !== "object")
|
|
6713
|
-
|
|
6714
|
-
if (Array.isArray(value))
|
|
6715
|
-
return value.map((item2) => resolve(item2, config));
|
|
6795
|
+
if (value == null || typeof value !== "object") return value;
|
|
6796
|
+
if (Array.isArray(value)) return value.map((item2) => resolve(item2, config));
|
|
6716
6797
|
if (isAst(value) && value?.resolve instanceof Function)
|
|
6717
6798
|
return value.resolve(config);
|
|
6718
|
-
if (Object.getPrototypeOf(value) !== Object.prototype)
|
|
6719
|
-
return value;
|
|
6799
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return value;
|
|
6720
6800
|
const output = {};
|
|
6721
|
-
for (const [k, v] of Object.entries(value))
|
|
6722
|
-
output[k] = resolve(v, config);
|
|
6801
|
+
for (const [k, v] of Object.entries(value)) output[k] = resolve(v, config);
|
|
6723
6802
|
return output;
|
|
6724
6803
|
}
|
|
6725
6804
|
|
|
@@ -6731,16 +6810,17 @@ var Tag = class {
|
|
|
6731
6810
|
this.attributes = attributes;
|
|
6732
6811
|
this.children = children;
|
|
6733
6812
|
}
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6813
|
+
static {
|
|
6814
|
+
this.isTag = (tag) => {
|
|
6815
|
+
return !!(tag?.$$mdtype === "Tag");
|
|
6816
|
+
};
|
|
6817
|
+
}
|
|
6737
6818
|
};
|
|
6738
6819
|
|
|
6739
6820
|
// src/schema-types/class.ts
|
|
6740
6821
|
var Class = class {
|
|
6741
6822
|
validate(value, _config, key) {
|
|
6742
|
-
if (typeof value === "string" || typeof value === "object")
|
|
6743
|
-
return [];
|
|
6823
|
+
if (typeof value === "string" || typeof value === "object") return [];
|
|
6744
6824
|
return [
|
|
6745
6825
|
{
|
|
6746
6826
|
id: "attribute-type-invalid",
|
|
@@ -6750,12 +6830,9 @@ var Class = class {
|
|
|
6750
6830
|
];
|
|
6751
6831
|
}
|
|
6752
6832
|
transform(value) {
|
|
6753
|
-
if (!value || typeof value === "string")
|
|
6754
|
-
return value;
|
|
6833
|
+
if (!value || typeof value === "string") return value;
|
|
6755
6834
|
const classes = [];
|
|
6756
|
-
for (const [k, v] of Object.entries(value ?? {}))
|
|
6757
|
-
if (v)
|
|
6758
|
-
classes.push(k);
|
|
6835
|
+
for (const [k, v] of Object.entries(value ?? {})) if (v) classes.push(k);
|
|
6759
6836
|
return classes.join(" ");
|
|
6760
6837
|
}
|
|
6761
6838
|
};
|
|
@@ -6763,8 +6840,7 @@ var Class = class {
|
|
|
6763
6840
|
// src/schema-types/id.ts
|
|
6764
6841
|
var Id = class {
|
|
6765
6842
|
validate(value) {
|
|
6766
|
-
if (typeof value === "string" && value.match(/^[a-zA-Z]/))
|
|
6767
|
-
return [];
|
|
6843
|
+
if (typeof value === "string" && value.match(/^[a-zA-Z]/)) return [];
|
|
6768
6844
|
return [
|
|
6769
6845
|
{
|
|
6770
6846
|
id: "attribute-value-invalid",
|
|
@@ -6776,7 +6852,7 @@ var Id = class {
|
|
|
6776
6852
|
};
|
|
6777
6853
|
|
|
6778
6854
|
// src/utils.ts
|
|
6779
|
-
var import_tag =
|
|
6855
|
+
var import_tag = __toESM(require_tag());
|
|
6780
6856
|
|
|
6781
6857
|
// src/ast/variable.ts
|
|
6782
6858
|
var Variable = class {
|
|
@@ -6798,20 +6874,13 @@ var Function2 = class {
|
|
|
6798
6874
|
}
|
|
6799
6875
|
resolve(config = {}) {
|
|
6800
6876
|
const fn = config?.functions?.[this.name];
|
|
6801
|
-
if (!fn)
|
|
6802
|
-
return null;
|
|
6877
|
+
if (!fn) return null;
|
|
6803
6878
|
const parameters = resolve(this.parameters, config);
|
|
6804
6879
|
return fn.transform?.(parameters, config);
|
|
6805
6880
|
}
|
|
6806
6881
|
};
|
|
6807
6882
|
|
|
6808
6883
|
// src/utils.ts
|
|
6809
|
-
var STATES;
|
|
6810
|
-
(function(STATES2) {
|
|
6811
|
-
STATES2[STATES2["normal"] = 0] = "normal";
|
|
6812
|
-
STATES2[STATES2["string"] = 1] = "string";
|
|
6813
|
-
STATES2[STATES2["escape"] = 2] = "escape";
|
|
6814
|
-
})(STATES || (STATES = {}));
|
|
6815
6884
|
var OPEN = "{%";
|
|
6816
6885
|
var CLOSE = "%}";
|
|
6817
6886
|
var IDENTIFIER_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
@@ -6822,28 +6891,26 @@ function isPromise(a) {
|
|
|
6822
6891
|
return a && typeof a === "object" && typeof a.then === "function";
|
|
6823
6892
|
}
|
|
6824
6893
|
function findTagEnd(content, start = 0) {
|
|
6825
|
-
let state = 0
|
|
6894
|
+
let state = 0 /* normal */;
|
|
6826
6895
|
for (let pos = start; pos < content.length; pos++) {
|
|
6827
6896
|
const char = content[pos];
|
|
6828
6897
|
switch (state) {
|
|
6829
|
-
case 1
|
|
6898
|
+
case 1 /* string */:
|
|
6830
6899
|
switch (char) {
|
|
6831
6900
|
case '"':
|
|
6832
|
-
state = 0
|
|
6901
|
+
state = 0 /* normal */;
|
|
6833
6902
|
break;
|
|
6834
6903
|
case "\\":
|
|
6835
|
-
state = 2
|
|
6904
|
+
state = 2 /* escape */;
|
|
6836
6905
|
break;
|
|
6837
6906
|
}
|
|
6838
6907
|
break;
|
|
6839
|
-
case 2
|
|
6840
|
-
state = 1
|
|
6908
|
+
case 2 /* escape */:
|
|
6909
|
+
state = 1 /* string */;
|
|
6841
6910
|
break;
|
|
6842
|
-
case 0
|
|
6843
|
-
if (char === '"')
|
|
6844
|
-
|
|
6845
|
-
else if (content.startsWith(CLOSE, pos))
|
|
6846
|
-
return pos;
|
|
6911
|
+
case 0 /* normal */:
|
|
6912
|
+
if (char === '"') state = 1 /* string */;
|
|
6913
|
+
else if (content.startsWith(CLOSE, pos)) return pos;
|
|
6847
6914
|
}
|
|
6848
6915
|
}
|
|
6849
6916
|
return null;
|
|
@@ -6852,8 +6919,7 @@ function parseTag(content, line, contentStart) {
|
|
|
6852
6919
|
try {
|
|
6853
6920
|
return (0, import_tag.parse)(content, { Variable, Function: Function2 });
|
|
6854
6921
|
} catch (error2) {
|
|
6855
|
-
if (!(error2 instanceof import_tag.SyntaxError))
|
|
6856
|
-
throw error2;
|
|
6922
|
+
if (!(error2 instanceof import_tag.SyntaxError)) throw error2;
|
|
6857
6923
|
const {
|
|
6858
6924
|
message,
|
|
6859
6925
|
location: { start, end }
|
|
@@ -6874,8 +6940,7 @@ function parseTags(content, firstLine = 0) {
|
|
|
6874
6940
|
line++;
|
|
6875
6941
|
continue;
|
|
6876
6942
|
}
|
|
6877
|
-
if (!content.startsWith(OPEN, pos))
|
|
6878
|
-
continue;
|
|
6943
|
+
if (!content.startsWith(OPEN, pos)) continue;
|
|
6879
6944
|
const end = findTagEnd(content, pos);
|
|
6880
6945
|
if (end == null) {
|
|
6881
6946
|
pos = pos + OPEN.length;
|
|
@@ -6932,8 +6997,7 @@ var transformer_default = {
|
|
|
6932
6997
|
const output = {};
|
|
6933
6998
|
const attrs = { ...globalAttributes, ...schema.attributes };
|
|
6934
6999
|
for (const [key, attr] of Object.entries(attrs)) {
|
|
6935
|
-
if (attr.render == false)
|
|
6936
|
-
continue;
|
|
7000
|
+
if (attr.render == false) continue;
|
|
6937
7001
|
const name = typeof attr.render === "string" ? attr.render : key;
|
|
6938
7002
|
let value = node2.attributes[key];
|
|
6939
7003
|
if (typeof attr.type === "function") {
|
|
@@ -6943,23 +7007,22 @@ var transformer_default = {
|
|
|
6943
7007
|
}
|
|
6944
7008
|
}
|
|
6945
7009
|
value = value === void 0 ? attr.default : value;
|
|
6946
|
-
if (value === void 0)
|
|
6947
|
-
continue;
|
|
7010
|
+
if (value === void 0) continue;
|
|
6948
7011
|
output[name] = value;
|
|
6949
7012
|
}
|
|
6950
7013
|
if (schema.slots) {
|
|
6951
7014
|
for (const [key, slot2] of Object.entries(schema.slots)) {
|
|
6952
|
-
if (slot2.render === false)
|
|
6953
|
-
continue;
|
|
7015
|
+
if (slot2.render === false) continue;
|
|
6954
7016
|
const name = typeof slot2.render === "string" ? slot2.render : key;
|
|
6955
|
-
if (node2.slots[key])
|
|
6956
|
-
output[name] = this.node(node2.slots[key], config);
|
|
7017
|
+
if (node2.slots[key]) output[name] = this.node(node2.slots[key], config);
|
|
6957
7018
|
}
|
|
6958
7019
|
}
|
|
6959
7020
|
return output;
|
|
6960
7021
|
},
|
|
6961
7022
|
children(node2, config = {}) {
|
|
6962
|
-
const children = node2.children.flatMap(
|
|
7023
|
+
const children = node2.children.flatMap(
|
|
7024
|
+
(child) => this.node(child, config)
|
|
7025
|
+
);
|
|
6963
7026
|
if (children.some(isPromise)) {
|
|
6964
7027
|
return Promise.all(children);
|
|
6965
7028
|
}
|
|
@@ -6970,18 +7033,19 @@ var transformer_default = {
|
|
|
6970
7033
|
if (schema && schema.transform instanceof Function)
|
|
6971
7034
|
return schema.transform(node2, config);
|
|
6972
7035
|
const children = this.children(node2, config);
|
|
6973
|
-
if (!schema || !schema.render)
|
|
6974
|
-
return children;
|
|
7036
|
+
if (!schema || !schema.render) return children;
|
|
6975
7037
|
const attributes = this.attributes(node2, config);
|
|
6976
7038
|
if (isPromise(attributes) || isPromise(children)) {
|
|
6977
|
-
return Promise.all([attributes, children]).then(
|
|
7039
|
+
return Promise.all([attributes, children]).then(
|
|
7040
|
+
(values) => new Tag(schema.render, ...values)
|
|
7041
|
+
);
|
|
6978
7042
|
}
|
|
6979
7043
|
return new Tag(schema.render, attributes, children);
|
|
6980
7044
|
}
|
|
6981
7045
|
};
|
|
6982
7046
|
|
|
6983
7047
|
// src/ast/node.ts
|
|
6984
|
-
var Node = class {
|
|
7048
|
+
var Node = class _Node {
|
|
6985
7049
|
constructor(type = "node", attributes = {}, children = [], tag) {
|
|
6986
7050
|
this.$$mdtype = "Node";
|
|
6987
7051
|
this.errors = [];
|
|
@@ -7004,13 +7068,15 @@ var Node = class {
|
|
|
7004
7068
|
this.children.push(node2);
|
|
7005
7069
|
}
|
|
7006
7070
|
resolve(config = {}) {
|
|
7007
|
-
return Object.assign(new
|
|
7071
|
+
return Object.assign(new _Node(), this, {
|
|
7008
7072
|
children: this.children.map((child) => child.resolve(config)),
|
|
7009
7073
|
attributes: resolve(this.attributes, config),
|
|
7010
|
-
slots: Object.fromEntries(
|
|
7011
|
-
name,
|
|
7012
|
-
|
|
7013
|
-
|
|
7074
|
+
slots: Object.fromEntries(
|
|
7075
|
+
Object.entries(this.slots).map(([name, slot2]) => [
|
|
7076
|
+
name,
|
|
7077
|
+
slot2.resolve(config)
|
|
7078
|
+
])
|
|
7079
|
+
)
|
|
7014
7080
|
});
|
|
7015
7081
|
}
|
|
7016
7082
|
findSchema(config = {}) {
|
|
@@ -7034,8 +7100,7 @@ var AstTypes = {
|
|
|
7034
7100
|
Variable
|
|
7035
7101
|
};
|
|
7036
7102
|
function reviver(_, value) {
|
|
7037
|
-
if (!value)
|
|
7038
|
-
return value;
|
|
7103
|
+
if (!value) return value;
|
|
7039
7104
|
const klass = AstTypes[value.$$mdtype];
|
|
7040
7105
|
return klass ? Object.assign(new klass(), value) : value;
|
|
7041
7106
|
}
|
|
@@ -7086,20 +7151,19 @@ function formatScalar(v) {
|
|
|
7086
7151
|
return "[" + v.map(formatScalar).join(SEP) + "]";
|
|
7087
7152
|
}
|
|
7088
7153
|
if (typeof v === "object") {
|
|
7089
|
-
return "{" + Object.entries(v).map(
|
|
7154
|
+
return "{" + Object.entries(v).map(
|
|
7155
|
+
([key, value]) => `${isIdentifier(key) ? key : `"${key}"`}: ${formatScalar(value)}`
|
|
7156
|
+
).join(SEP) + "}";
|
|
7090
7157
|
}
|
|
7091
7158
|
return JSON.stringify(v);
|
|
7092
7159
|
}
|
|
7093
7160
|
function formatAnnotationValue(a) {
|
|
7094
7161
|
const formattedValue = formatScalar(a.value);
|
|
7095
|
-
if (formattedValue === void 0)
|
|
7096
|
-
|
|
7097
|
-
if (a.name === "primary")
|
|
7098
|
-
return formattedValue;
|
|
7162
|
+
if (formattedValue === void 0) return void 0;
|
|
7163
|
+
if (a.name === "primary") return formattedValue;
|
|
7099
7164
|
if (a.name === "id" && typeof a.value === "string" && isIdentifier(a.value))
|
|
7100
7165
|
return "#" + a.value;
|
|
7101
|
-
if (a.type === "class" && isIdentifier(a.name))
|
|
7102
|
-
return "." + a.name;
|
|
7166
|
+
if (a.type === "class" && isIdentifier(a.name)) return "." + a.name;
|
|
7103
7167
|
return `${a.name}=${formattedValue}`;
|
|
7104
7168
|
}
|
|
7105
7169
|
function* formatAttributes(n) {
|
|
@@ -7108,8 +7172,7 @@ function* formatAttributes(n) {
|
|
|
7108
7172
|
for (const name of Object.keys(value)) {
|
|
7109
7173
|
yield formatAnnotationValue({ type: "class", name, value });
|
|
7110
7174
|
}
|
|
7111
|
-
else
|
|
7112
|
-
yield formatAnnotationValue({ type: "attribute", name: key, value });
|
|
7175
|
+
else yield formatAnnotationValue({ type: "attribute", name: key, value });
|
|
7113
7176
|
}
|
|
7114
7177
|
}
|
|
7115
7178
|
function* formatAnnotations(n) {
|
|
@@ -7122,12 +7185,9 @@ function* formatAnnotations(n) {
|
|
|
7122
7185
|
function* formatVariable(v) {
|
|
7123
7186
|
yield "$";
|
|
7124
7187
|
yield v.path.map((p, i) => {
|
|
7125
|
-
if (i === 0)
|
|
7126
|
-
|
|
7127
|
-
if (
|
|
7128
|
-
return "." + p;
|
|
7129
|
-
if (typeof p === "number")
|
|
7130
|
-
return `[${p}]`;
|
|
7188
|
+
if (i === 0) return p;
|
|
7189
|
+
if (isIdentifier(p)) return "." + p;
|
|
7190
|
+
if (typeof p === "number") return `[${p}]`;
|
|
7131
7191
|
return `["${p}"]`;
|
|
7132
7192
|
}).join("");
|
|
7133
7193
|
}
|
|
@@ -7141,8 +7201,7 @@ function* trimStart(g) {
|
|
|
7141
7201
|
let n;
|
|
7142
7202
|
do {
|
|
7143
7203
|
const { value, done } = g.next();
|
|
7144
|
-
if (done)
|
|
7145
|
-
return;
|
|
7204
|
+
if (done) return;
|
|
7146
7205
|
n = value.trimStart();
|
|
7147
7206
|
} while (!n.length);
|
|
7148
7207
|
yield n;
|
|
@@ -7249,10 +7308,8 @@ function* formatNode(n, o = {}) {
|
|
|
7249
7308
|
const boundary = "`".repeat(innerFenceLength ? innerFenceLength + 1 : 3);
|
|
7250
7309
|
const needsNlBeforeEndBoundary = !n.attributes.content.endsWith(NL);
|
|
7251
7310
|
yield boundary;
|
|
7252
|
-
if (n.attributes.language)
|
|
7253
|
-
|
|
7254
|
-
if (n.annotations.length)
|
|
7255
|
-
yield SPACE;
|
|
7311
|
+
if (n.attributes.language) yield n.attributes.language;
|
|
7312
|
+
if (n.annotations.length) yield SPACE;
|
|
7256
7313
|
yield* formatAnnotations(n);
|
|
7257
7314
|
yield NL;
|
|
7258
7315
|
yield indent;
|
|
@@ -7270,7 +7327,9 @@ function* formatNode(n, o = {}) {
|
|
|
7270
7327
|
yield indent;
|
|
7271
7328
|
}
|
|
7272
7329
|
const open = OPEN + SPACE;
|
|
7273
|
-
const attributes = [...formatAttributes(n)].filter(
|
|
7330
|
+
const attributes = [...formatAttributes(n)].filter(
|
|
7331
|
+
(v) => v !== void 0
|
|
7332
|
+
);
|
|
7274
7333
|
const tag = [open + n.tag, ...attributes];
|
|
7275
7334
|
const inlineTag = tag.join(SPACE);
|
|
7276
7335
|
const isLongTagOpening = inlineTag.length + open.length * 2 > (o.maxTagOpeningWidth || MAX_TAG_OPENING_WIDTH);
|
|
@@ -7288,15 +7347,15 @@ function* formatNode(n, o = {}) {
|
|
|
7288
7347
|
break;
|
|
7289
7348
|
}
|
|
7290
7349
|
case "list": {
|
|
7291
|
-
const isLoose = n.children.some(
|
|
7350
|
+
const isLoose = n.children.some(
|
|
7351
|
+
(n2) => n2.children.some((c) => c.type === "paragraph")
|
|
7352
|
+
);
|
|
7292
7353
|
for (let i = 0; i < n.children.length; i++) {
|
|
7293
7354
|
const prefix = (() => {
|
|
7294
|
-
if (!n.attributes.ordered)
|
|
7295
|
-
return n.attributes.marker ?? UL;
|
|
7355
|
+
if (!n.attributes.ordered) return n.attributes.marker ?? UL;
|
|
7296
7356
|
let number = "1";
|
|
7297
7357
|
const startNumber = n.attributes.start ?? 1;
|
|
7298
|
-
if (i === 0)
|
|
7299
|
-
number = startNumber.toString();
|
|
7358
|
+
if (i === 0) number = startNumber.toString();
|
|
7300
7359
|
if (o.orderedListMode === "increment") {
|
|
7301
7360
|
number = (parseInt(startNumber) + i).toString();
|
|
7302
7361
|
}
|
|
@@ -7314,8 +7373,7 @@ function* formatNode(n, o = {}) {
|
|
|
7314
7373
|
case "item": {
|
|
7315
7374
|
for (let i = 0; i < n.children.length; i++) {
|
|
7316
7375
|
yield* formatValue(n.children[i], no);
|
|
7317
|
-
if (i === 0)
|
|
7318
|
-
yield* formatAnnotations(n);
|
|
7376
|
+
if (i === 0) yield* formatAnnotations(n);
|
|
7319
7377
|
}
|
|
7320
7378
|
break;
|
|
7321
7379
|
}
|
|
@@ -7383,12 +7441,16 @@ function* formatNode(n, o = {}) {
|
|
|
7383
7441
|
}
|
|
7384
7442
|
const [head, ...rows] = table3;
|
|
7385
7443
|
yield NL;
|
|
7386
|
-
yield* formatTableRow(
|
|
7444
|
+
yield* formatTableRow(
|
|
7445
|
+
head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
|
|
7446
|
+
);
|
|
7387
7447
|
yield NL;
|
|
7388
7448
|
yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
|
|
7389
7449
|
yield NL;
|
|
7390
7450
|
for (const row of rows) {
|
|
7391
|
-
yield* formatTableRow(
|
|
7451
|
+
yield* formatTableRow(
|
|
7452
|
+
row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
|
|
7453
|
+
);
|
|
7392
7454
|
yield NL;
|
|
7393
7455
|
}
|
|
7394
7456
|
}
|
|
@@ -7432,11 +7494,9 @@ function* formatValue(v, o = {}) {
|
|
|
7432
7494
|
break;
|
|
7433
7495
|
}
|
|
7434
7496
|
case "object": {
|
|
7435
|
-
if (v === null)
|
|
7436
|
-
break;
|
|
7497
|
+
if (v === null) break;
|
|
7437
7498
|
if (Array.isArray(v)) {
|
|
7438
|
-
for (const n of v)
|
|
7439
|
-
yield* formatValue(n, o);
|
|
7499
|
+
for (const n of v) yield* formatValue(n, o);
|
|
7440
7500
|
break;
|
|
7441
7501
|
}
|
|
7442
7502
|
switch (v.$$mdtype) {
|
|
@@ -7460,8 +7520,7 @@ function* formatValue(v, o = {}) {
|
|
|
7460
7520
|
}
|
|
7461
7521
|
function format(v, options) {
|
|
7462
7522
|
let doc = "";
|
|
7463
|
-
for (const s2 of formatValue(v, options))
|
|
7464
|
-
doc += s2;
|
|
7523
|
+
for (const s2 of formatValue(v, options)) doc += s2;
|
|
7465
7524
|
return doc.trimStart();
|
|
7466
7525
|
}
|
|
7467
7526
|
|
|
@@ -7495,8 +7554,7 @@ function renderConditions(node2) {
|
|
|
7495
7554
|
condition: "primary" in child.attributes ? child.attributes.primary : true,
|
|
7496
7555
|
children: []
|
|
7497
7556
|
});
|
|
7498
|
-
else
|
|
7499
|
-
conditions[conditions.length - 1].children.push(child);
|
|
7557
|
+
else conditions[conditions.length - 1].children.push(child);
|
|
7500
7558
|
}
|
|
7501
7559
|
return conditions;
|
|
7502
7560
|
}
|
|
@@ -7508,7 +7566,9 @@ var tagIf = {
|
|
|
7508
7566
|
const conditions = renderConditions(node2);
|
|
7509
7567
|
for (const { condition, children } of conditions)
|
|
7510
7568
|
if (truthy(condition)) {
|
|
7511
|
-
const nodes = children.flatMap(
|
|
7569
|
+
const nodes = children.flatMap(
|
|
7570
|
+
(child) => child.transform(config)
|
|
7571
|
+
);
|
|
7512
7572
|
if (nodes.some(isPromise)) {
|
|
7513
7573
|
return Promise.all(nodes).then((nodes2) => nodes2.flat());
|
|
7514
7574
|
}
|
|
@@ -7565,8 +7625,7 @@ var functions_default = { and, or, not, equals, default: defaultFn, debug };
|
|
|
7565
7625
|
function convertToRow(node2, cellType = "td") {
|
|
7566
7626
|
node2.type = "tr";
|
|
7567
7627
|
node2.attributes = {};
|
|
7568
|
-
for (const cell of node2.children)
|
|
7569
|
-
cell.type = cellType;
|
|
7628
|
+
for (const cell of node2.children) cell.type = cellType;
|
|
7570
7629
|
return node2;
|
|
7571
7630
|
}
|
|
7572
7631
|
function isConditionalTag(node2, conditionalTags) {
|
|
@@ -7575,53 +7634,44 @@ function isConditionalTag(node2, conditionalTags) {
|
|
|
7575
7634
|
function isComment(node2) {
|
|
7576
7635
|
return node2.type === "comment" || node2.type === "tag" && node2.tag === "comment";
|
|
7577
7636
|
}
|
|
7578
|
-
function unexpectedNodeError({
|
|
7579
|
-
type,
|
|
7580
|
-
tag
|
|
7581
|
-
}) {
|
|
7637
|
+
function unexpectedNodeError(node2) {
|
|
7582
7638
|
return {
|
|
7583
7639
|
id: "table-syntax",
|
|
7584
7640
|
level: "critical",
|
|
7585
|
-
message: `Found ${type}${tag ? ` ${tag}` : ""} where a list was expected. Make sure all content inside table cells is indented
|
|
7641
|
+
message: `Found ${node2.type}${node2.tag ? ` ${node2.tag}` : ""} where a list was expected. Make sure all content inside table cells is indented.`,
|
|
7642
|
+
location: node2.location
|
|
7586
7643
|
};
|
|
7587
7644
|
}
|
|
7588
7645
|
function transform(document2, conditionalTags = ["if"]) {
|
|
7589
7646
|
for (const node2 of document2.walk()) {
|
|
7590
|
-
if (node2.type !== "tag" || node2.tag !== "table")
|
|
7591
|
-
continue;
|
|
7647
|
+
if (node2.type !== "tag" || node2.tag !== "table") continue;
|
|
7592
7648
|
const [first, ...rest] = node2.children;
|
|
7593
|
-
if (!first || first.type === "table")
|
|
7594
|
-
continue;
|
|
7649
|
+
if (!first || first.type === "table") continue;
|
|
7595
7650
|
const table3 = new ast_default.Node("table", node2.attributes, [
|
|
7596
7651
|
new ast_default.Node("thead"),
|
|
7597
7652
|
new ast_default.Node("tbody")
|
|
7598
7653
|
]);
|
|
7599
7654
|
const [thead2, tbody2] = table3.children;
|
|
7600
|
-
if (first.type === "list")
|
|
7601
|
-
thead2.push(convertToRow(first, "th"));
|
|
7655
|
+
if (first.type === "list") thead2.push(convertToRow(first, "th"));
|
|
7602
7656
|
for (const row of rest) {
|
|
7603
|
-
if (row.type === "list")
|
|
7604
|
-
convertToRow(row);
|
|
7657
|
+
if (row.type === "list") convertToRow(row);
|
|
7605
7658
|
else if (isConditionalTag(row, conditionalTags)) {
|
|
7606
7659
|
const children = [];
|
|
7607
7660
|
for (const child of row.children) {
|
|
7608
|
-
if (child.type === "hr")
|
|
7609
|
-
|
|
7610
|
-
if (child.type === "list")
|
|
7611
|
-
convertToRow(child);
|
|
7661
|
+
if (child.type === "hr") continue;
|
|
7662
|
+
if (child.type === "list") convertToRow(child);
|
|
7612
7663
|
else if (isComment(child) || child.tag === "else" || isConditionalTag(child, conditionalTags)) {
|
|
7613
7664
|
} else {
|
|
7614
|
-
row.errors.push(unexpectedNodeError(
|
|
7665
|
+
row.errors.push(unexpectedNodeError(child));
|
|
7615
7666
|
continue;
|
|
7616
7667
|
}
|
|
7617
7668
|
children.push(child);
|
|
7618
7669
|
}
|
|
7619
7670
|
row.children = children;
|
|
7620
7671
|
} else if (row.type !== "hr" && !isComment(row)) {
|
|
7621
|
-
node2.errors.push(unexpectedNodeError(
|
|
7622
|
-
continue;
|
|
7623
|
-
} else
|
|
7672
|
+
node2.errors.push(unexpectedNodeError(row));
|
|
7624
7673
|
continue;
|
|
7674
|
+
} else continue;
|
|
7625
7675
|
tbody2.push(row);
|
|
7626
7676
|
}
|
|
7627
7677
|
node2.children = [table3];
|
|
@@ -7652,10 +7702,8 @@ function annotate(node2, attributes) {
|
|
|
7652
7702
|
});
|
|
7653
7703
|
node2.attributes[name] = value;
|
|
7654
7704
|
} else if (type === "class")
|
|
7655
|
-
if (node2.attributes.class)
|
|
7656
|
-
|
|
7657
|
-
else
|
|
7658
|
-
node2.attributes.class = { [name]: value };
|
|
7705
|
+
if (node2.attributes.class) node2.attributes.class[name] = value;
|
|
7706
|
+
else node2.attributes.class = { [name]: value };
|
|
7659
7707
|
}
|
|
7660
7708
|
}
|
|
7661
7709
|
function handleAttrs(token, type) {
|
|
@@ -7715,14 +7763,12 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7715
7763
|
nodes[0].attributes.frontmatter = token.content;
|
|
7716
7764
|
return;
|
|
7717
7765
|
}
|
|
7718
|
-
if (token.hidden || token.type === "text" && token.content === "")
|
|
7719
|
-
return;
|
|
7766
|
+
if (token.hidden || token.type === "text" && token.content === "") return;
|
|
7720
7767
|
const errors = token.errors || [];
|
|
7721
7768
|
const parent = nodes[nodes.length - 1];
|
|
7722
7769
|
const { tag, attributes, error: error2 } = token.meta || {};
|
|
7723
7770
|
if (token.type === "annotation") {
|
|
7724
|
-
if (inlineParent)
|
|
7725
|
-
return annotate(inlineParent, attributes);
|
|
7771
|
+
if (inlineParent) return annotate(inlineParent, attributes);
|
|
7726
7772
|
return parent.errors.push({
|
|
7727
7773
|
id: "no-inline-annotations",
|
|
7728
7774
|
level: "error",
|
|
@@ -7730,16 +7776,14 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7730
7776
|
});
|
|
7731
7777
|
}
|
|
7732
7778
|
let typeName = token.type.replace(/_(open|close)$/, "");
|
|
7733
|
-
if (mappings[typeName])
|
|
7734
|
-
typeName = mappings[typeName];
|
|
7779
|
+
if (mappings[typeName]) typeName = mappings[typeName];
|
|
7735
7780
|
if (typeName === "error") {
|
|
7736
7781
|
const { message, location } = error2;
|
|
7737
7782
|
errors.push({ id: "parse-error", level: "critical", message, location });
|
|
7738
7783
|
}
|
|
7739
7784
|
if (token.nesting < 0) {
|
|
7740
7785
|
if (parent.type === typeName && parent.tag === tag) {
|
|
7741
|
-
if (parent.lines && token.map)
|
|
7742
|
-
parent.lines.push(...token.map);
|
|
7786
|
+
if (parent.lines && token.map) parent.lines.push(...token.map);
|
|
7743
7787
|
return nodes.pop();
|
|
7744
7788
|
}
|
|
7745
7789
|
errors.push({
|
|
@@ -7766,20 +7810,15 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7766
7810
|
}
|
|
7767
7811
|
};
|
|
7768
7812
|
}
|
|
7769
|
-
if (inlineParent)
|
|
7770
|
-
node2.inline = true;
|
|
7813
|
+
if (inlineParent) node2.inline = true;
|
|
7771
7814
|
if (attributes && ["tag", "fence", "image"].includes(typeName))
|
|
7772
7815
|
annotate(node2, attributes);
|
|
7773
7816
|
if (handleSlots && tag === "slot" && typeof node2.attributes.primary === "string")
|
|
7774
7817
|
parent.slots[node2.attributes.primary] = node2;
|
|
7775
|
-
else
|
|
7776
|
-
|
|
7777
|
-
if (token.
|
|
7778
|
-
|
|
7779
|
-
if (!Array.isArray(token.children))
|
|
7780
|
-
return;
|
|
7781
|
-
if (node2.type === "inline")
|
|
7782
|
-
inlineParent = parent;
|
|
7818
|
+
else parent.push(node2);
|
|
7819
|
+
if (token.nesting > 0) nodes.push(node2);
|
|
7820
|
+
if (!Array.isArray(token.children)) return;
|
|
7821
|
+
if (node2.type === "inline") inlineParent = parent;
|
|
7783
7822
|
nodes.push(node2);
|
|
7784
7823
|
const isLeafNode = typeName === "image";
|
|
7785
7824
|
if (!isLeafNode) {
|
|
@@ -7791,8 +7830,7 @@ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent)
|
|
|
7791
7830
|
function parser(tokens, args) {
|
|
7792
7831
|
const doc = new Node("document");
|
|
7793
7832
|
const nodes = [doc];
|
|
7794
|
-
if (typeof args === "string")
|
|
7795
|
-
args = { file: args };
|
|
7833
|
+
if (typeof args === "string") args = { file: args };
|
|
7796
7834
|
for (const token of tokens)
|
|
7797
7835
|
handleToken(token, nodes, args?.file, args?.slots, args?.location);
|
|
7798
7836
|
if (nodes.length > 1)
|
|
@@ -7802,8 +7840,7 @@ function parser(tokens, args) {
|
|
|
7802
7840
|
level: "critical",
|
|
7803
7841
|
message: `Node '${node2.tag || node2.type}' is missing closing`
|
|
7804
7842
|
});
|
|
7805
|
-
for (const transform3 of transforms_default)
|
|
7806
|
-
transform3(doc, args?.conditionalTags);
|
|
7843
|
+
for (const transform3 of transforms_default) transform3(doc, args?.conditionalTags);
|
|
7807
7844
|
return doc;
|
|
7808
7845
|
}
|
|
7809
7846
|
|
|
@@ -7862,7 +7899,11 @@ var heading = {
|
|
|
7862
7899
|
level: { type: Number, render: false, required: true }
|
|
7863
7900
|
},
|
|
7864
7901
|
transform(node2, config) {
|
|
7865
|
-
return new Tag(
|
|
7902
|
+
return new Tag(
|
|
7903
|
+
`h${node2.attributes["level"]}`,
|
|
7904
|
+
node2.transformAttributes(config),
|
|
7905
|
+
node2.transformChildren(config)
|
|
7906
|
+
);
|
|
7866
7907
|
}
|
|
7867
7908
|
};
|
|
7868
7909
|
var paragraph = {
|
|
@@ -7875,6 +7916,7 @@ var image = {
|
|
|
7875
7916
|
src: { type: String, required: true },
|
|
7876
7917
|
alt: { type: String },
|
|
7877
7918
|
title: { type: String }
|
|
7919
|
+
// width/height attributes will need to be to be implemented as an extension to markdown-it
|
|
7878
7920
|
}
|
|
7879
7921
|
};
|
|
7880
7922
|
var fence = {
|
|
@@ -7927,7 +7969,11 @@ var list = {
|
|
|
7927
7969
|
marker: { type: String, render: false }
|
|
7928
7970
|
},
|
|
7929
7971
|
transform(node2, config) {
|
|
7930
|
-
return new Tag(
|
|
7972
|
+
return new Tag(
|
|
7973
|
+
node2.attributes.ordered ? "ol" : "ul",
|
|
7974
|
+
node2.transformAttributes(config),
|
|
7975
|
+
node2.transformChildren(config)
|
|
7976
|
+
);
|
|
7931
7977
|
}
|
|
7932
7978
|
};
|
|
7933
7979
|
var hr = {
|
|
@@ -8053,9 +8099,9 @@ var error = {};
|
|
|
8053
8099
|
var node = {};
|
|
8054
8100
|
|
|
8055
8101
|
// src/renderers/html.ts
|
|
8056
|
-
var import_markdown_it =
|
|
8102
|
+
var import_markdown_it = __toESM(require_markdown_it());
|
|
8057
8103
|
var { escapeHtml } = (0, import_markdown_it.default)().utils;
|
|
8058
|
-
var voidElements = new Set([
|
|
8104
|
+
var voidElements = /* @__PURE__ */ new Set([
|
|
8059
8105
|
"area",
|
|
8060
8106
|
"base",
|
|
8061
8107
|
"br",
|
|
@@ -8074,21 +8120,16 @@ var voidElements = new Set([
|
|
|
8074
8120
|
function render(node2) {
|
|
8075
8121
|
if (typeof node2 === "string" || typeof node2 === "number")
|
|
8076
8122
|
return escapeHtml(String(node2));
|
|
8077
|
-
if (Array.isArray(node2))
|
|
8078
|
-
|
|
8079
|
-
if (node2 === null || typeof node2 !== "object" || !Tag.isTag(node2))
|
|
8080
|
-
return "";
|
|
8123
|
+
if (Array.isArray(node2)) return node2.map(render).join("");
|
|
8124
|
+
if (node2 === null || typeof node2 !== "object" || !Tag.isTag(node2)) return "";
|
|
8081
8125
|
const { name, attributes, children = [] } = node2;
|
|
8082
|
-
if (!name)
|
|
8083
|
-
return render(children);
|
|
8126
|
+
if (!name) return render(children);
|
|
8084
8127
|
let output = `<${name}`;
|
|
8085
8128
|
for (const [k, v] of Object.entries(attributes ?? {}))
|
|
8086
8129
|
output += ` ${k.toLowerCase()}="${escapeHtml(String(v))}"`;
|
|
8087
8130
|
output += ">";
|
|
8088
|
-
if (voidElements.has(name))
|
|
8089
|
-
|
|
8090
|
-
if (children.length)
|
|
8091
|
-
output += render(children);
|
|
8131
|
+
if (voidElements.has(name)) return output;
|
|
8132
|
+
if (children.length) output += render(children);
|
|
8092
8133
|
output += `</${name}>`;
|
|
8093
8134
|
return output;
|
|
8094
8135
|
}
|
|
@@ -8099,17 +8140,12 @@ function tagName(name, components) {
|
|
|
8099
8140
|
}
|
|
8100
8141
|
function dynamic(node2, React, { components = {}, resolveTagName = tagName } = {}) {
|
|
8101
8142
|
function deepRender2(value) {
|
|
8102
|
-
if (value == null || typeof value !== "object")
|
|
8103
|
-
|
|
8104
|
-
if (
|
|
8105
|
-
|
|
8106
|
-
if (value.$$mdtype === "Tag")
|
|
8107
|
-
return render3(value);
|
|
8108
|
-
if (typeof value !== "object")
|
|
8109
|
-
return value;
|
|
8143
|
+
if (value == null || typeof value !== "object") return value;
|
|
8144
|
+
if (Array.isArray(value)) return value.map((item2) => deepRender2(item2));
|
|
8145
|
+
if (value.$$mdtype === "Tag") return render3(value);
|
|
8146
|
+
if (typeof value !== "object") return value;
|
|
8110
8147
|
const output = {};
|
|
8111
|
-
for (const [k, v] of Object.entries(value))
|
|
8112
|
-
output[k] = deepRender2(v);
|
|
8148
|
+
for (const [k, v] of Object.entries(value)) output[k] = deepRender2(v);
|
|
8113
8149
|
return output;
|
|
8114
8150
|
}
|
|
8115
8151
|
function render3(node3) {
|
|
@@ -8122,9 +8158,12 @@ function dynamic(node2, React, { components = {}, resolveTagName = tagName } = {
|
|
|
8122
8158
|
attributes: { class: className, ...attrs } = {},
|
|
8123
8159
|
children = []
|
|
8124
8160
|
} = node3;
|
|
8125
|
-
if (className)
|
|
8126
|
-
|
|
8127
|
-
|
|
8161
|
+
if (className) attrs.className = className;
|
|
8162
|
+
return React.createElement(
|
|
8163
|
+
resolveTagName(name, components),
|
|
8164
|
+
Object.keys(attrs).length == 0 ? null : deepRender2(attrs),
|
|
8165
|
+
...children.map(render3)
|
|
8166
|
+
);
|
|
8128
8167
|
}
|
|
8129
8168
|
return render3(node2);
|
|
8130
8169
|
}
|
|
@@ -8137,14 +8176,11 @@ function renderArray(children) {
|
|
|
8137
8176
|
return children.map(render2).join(", ");
|
|
8138
8177
|
}
|
|
8139
8178
|
function deepRender(value) {
|
|
8140
|
-
if (value == null || typeof value !== "object")
|
|
8141
|
-
return JSON.stringify(value);
|
|
8179
|
+
if (value == null || typeof value !== "object") return JSON.stringify(value);
|
|
8142
8180
|
if (Array.isArray(value))
|
|
8143
8181
|
return `[${value.map((item2) => deepRender(item2)).join(", ")}]`;
|
|
8144
|
-
if (value.$$mdtype === "Tag")
|
|
8145
|
-
|
|
8146
|
-
if (typeof value !== "object")
|
|
8147
|
-
return JSON.stringify(value);
|
|
8182
|
+
if (value.$$mdtype === "Tag") return render2(value);
|
|
8183
|
+
if (typeof value !== "object") return JSON.stringify(value);
|
|
8148
8184
|
const object = Object.entries(value).map(([k, v]) => [JSON.stringify(k), deepRender(v)].join(": ")).join(", ");
|
|
8149
8185
|
return `{${object}}`;
|
|
8150
8186
|
}
|
|
@@ -8158,8 +8194,7 @@ function render2(node2) {
|
|
|
8158
8194
|
attributes: { class: className, ...attrs } = {},
|
|
8159
8195
|
children = []
|
|
8160
8196
|
} = node2;
|
|
8161
|
-
if (className)
|
|
8162
|
-
attrs.className = className;
|
|
8197
|
+
if (className) attrs.className = className;
|
|
8163
8198
|
return `React.createElement(
|
|
8164
8199
|
tagName(${JSON.stringify(name)}, components),
|
|
8165
8200
|
${Object.keys(attrs).length == 0 ? "null" : deepRender(attrs)},
|
|
@@ -8207,8 +8242,7 @@ var partial = {
|
|
|
8207
8242
|
const { partials = {} } = config;
|
|
8208
8243
|
const { file, variables } = node2.attributes;
|
|
8209
8244
|
const partial2 = partials[file];
|
|
8210
|
-
if (!partial2)
|
|
8211
|
-
return null;
|
|
8245
|
+
if (!partial2) return null;
|
|
8212
8246
|
const scopedConfig = {
|
|
8213
8247
|
...config,
|
|
8214
8248
|
variables: {
|
|
@@ -8245,10 +8279,10 @@ var tags_default = {
|
|
|
8245
8279
|
};
|
|
8246
8280
|
|
|
8247
8281
|
// src/tokenizer/index.ts
|
|
8248
|
-
var import_lib =
|
|
8282
|
+
var import_lib = __toESM(require_lib());
|
|
8249
8283
|
|
|
8250
8284
|
// src/tokenizer/plugins/annotations.ts
|
|
8251
|
-
var import_tag7 =
|
|
8285
|
+
var import_tag7 = __toESM(require_tag());
|
|
8252
8286
|
function createToken(state, content, contentStart) {
|
|
8253
8287
|
try {
|
|
8254
8288
|
const { type, meta, nesting = 0 } = (0, import_tag7.parse)(content, { Variable, Function: Function2 });
|
|
@@ -8260,8 +8294,7 @@ function createToken(state, content, contentStart) {
|
|
|
8260
8294
|
}
|
|
8261
8295
|
return token;
|
|
8262
8296
|
} catch (error2) {
|
|
8263
|
-
if (!(error2 instanceof import_tag7.SyntaxError))
|
|
8264
|
-
throw error2;
|
|
8297
|
+
if (!(error2 instanceof import_tag7.SyntaxError)) throw error2;
|
|
8265
8298
|
const {
|
|
8266
8299
|
message,
|
|
8267
8300
|
location: { start, end }
|
|
@@ -8278,41 +8311,33 @@ function createToken(state, content, contentStart) {
|
|
|
8278
8311
|
function block(state, startLine, endLine, silent) {
|
|
8279
8312
|
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
8280
8313
|
const finish = state.eMarks[startLine];
|
|
8281
|
-
if (!state.src.startsWith(OPEN, start))
|
|
8282
|
-
return false;
|
|
8314
|
+
if (!state.src.startsWith(OPEN, start)) return false;
|
|
8283
8315
|
const tagEnd = findTagEnd(state.src, start);
|
|
8284
8316
|
const lastPossible = state.src.slice(0, finish).trim().length;
|
|
8285
|
-
if (!tagEnd || tagEnd < lastPossible - CLOSE.length)
|
|
8286
|
-
return false;
|
|
8317
|
+
if (!tagEnd || tagEnd < lastPossible - CLOSE.length) return false;
|
|
8287
8318
|
const contentStart = start + OPEN.length;
|
|
8288
8319
|
const content = state.src.slice(contentStart, tagEnd).trim();
|
|
8289
8320
|
const lines = state.src.slice(start, tagEnd + CLOSE.length).split("\n").length;
|
|
8290
|
-
if (content[0] === "$")
|
|
8291
|
-
|
|
8292
|
-
if (silent)
|
|
8293
|
-
return true;
|
|
8321
|
+
if (content[0] === "$") return false;
|
|
8322
|
+
if (silent) return true;
|
|
8294
8323
|
const token = createToken(state, content, contentStart);
|
|
8295
8324
|
token.map = [startLine, startLine + lines];
|
|
8296
8325
|
state.line += lines;
|
|
8297
8326
|
return true;
|
|
8298
8327
|
}
|
|
8299
8328
|
function inline2(state, silent) {
|
|
8300
|
-
if (!state.src.startsWith(OPEN, state.pos))
|
|
8301
|
-
return false;
|
|
8329
|
+
if (!state.src.startsWith(OPEN, state.pos)) return false;
|
|
8302
8330
|
const tagEnd = findTagEnd(state.src, state.pos);
|
|
8303
|
-
if (!tagEnd)
|
|
8304
|
-
return false;
|
|
8331
|
+
if (!tagEnd) return false;
|
|
8305
8332
|
const content = state.src.slice(state.pos + OPEN.length, tagEnd);
|
|
8306
|
-
if (!silent)
|
|
8307
|
-
createToken(state, content.trim());
|
|
8333
|
+
if (!silent) createToken(state, content.trim());
|
|
8308
8334
|
state.pos = tagEnd + CLOSE.length;
|
|
8309
8335
|
return true;
|
|
8310
8336
|
}
|
|
8311
8337
|
function core(state) {
|
|
8312
8338
|
let token;
|
|
8313
8339
|
for (token of state.tokens) {
|
|
8314
|
-
if (token.type !== "fence")
|
|
8315
|
-
continue;
|
|
8340
|
+
if (token.type !== "fence") continue;
|
|
8316
8341
|
if (token.info.includes(OPEN)) {
|
|
8317
8342
|
const start = token.info.indexOf(OPEN);
|
|
8318
8343
|
const end = findTagEnd(token.info, start);
|
|
@@ -8321,10 +8346,8 @@ function core(state) {
|
|
|
8321
8346
|
const { meta } = (0, import_tag7.parse)(content.trim(), { Variable, Function: Function2 });
|
|
8322
8347
|
token.meta = meta;
|
|
8323
8348
|
} catch (error2) {
|
|
8324
|
-
if (!(error2 instanceof import_tag7.SyntaxError))
|
|
8325
|
-
|
|
8326
|
-
if (!token.errors)
|
|
8327
|
-
token.errors = [];
|
|
8349
|
+
if (!(error2 instanceof import_tag7.SyntaxError)) throw error2;
|
|
8350
|
+
if (!token.errors) token.errors = [];
|
|
8328
8351
|
token.errors.push({
|
|
8329
8352
|
id: "fence-tag-error",
|
|
8330
8353
|
level: "error",
|
|
@@ -8332,7 +8355,9 @@ function core(state) {
|
|
|
8332
8355
|
});
|
|
8333
8356
|
}
|
|
8334
8357
|
}
|
|
8335
|
-
if (token?.meta?.attributes?.find(
|
|
8358
|
+
if (token?.meta?.attributes?.find(
|
|
8359
|
+
(attr) => attr.name === "process" && !attr.value
|
|
8360
|
+
))
|
|
8336
8361
|
continue;
|
|
8337
8362
|
token.children = parseTags(token.content, token.map[0]);
|
|
8338
8363
|
}
|
|
@@ -8352,17 +8377,13 @@ function getLine(state, n) {
|
|
|
8352
8377
|
}
|
|
8353
8378
|
function findClose(state, endLine) {
|
|
8354
8379
|
for (let line = 1; line < endLine; line++)
|
|
8355
|
-
if (getLine(state, line) === fence2)
|
|
8356
|
-
return line;
|
|
8380
|
+
if (getLine(state, line) === fence2) return line;
|
|
8357
8381
|
}
|
|
8358
8382
|
function block2(state, startLine, endLine, silent) {
|
|
8359
|
-
if (startLine != 0 || getLine(state, 0) != fence2)
|
|
8360
|
-
return false;
|
|
8383
|
+
if (startLine != 0 || getLine(state, 0) != fence2) return false;
|
|
8361
8384
|
const close = findClose(state, endLine);
|
|
8362
|
-
if (!close)
|
|
8363
|
-
|
|
8364
|
-
if (silent)
|
|
8365
|
-
return true;
|
|
8385
|
+
if (!close) return false;
|
|
8386
|
+
if (silent) return true;
|
|
8366
8387
|
const token = state.push("frontmatter", "", 0);
|
|
8367
8388
|
token.content = state.src.slice(state.eMarks[0], state.bMarks[close]).trim();
|
|
8368
8389
|
token.map = [0, close];
|
|
@@ -8379,13 +8400,10 @@ var OPEN2 = "<!--";
|
|
|
8379
8400
|
var CLOSE2 = "-->";
|
|
8380
8401
|
function block3(state, startLine, endLine, silent) {
|
|
8381
8402
|
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
8382
|
-
if (!state.src.startsWith(OPEN2, start))
|
|
8383
|
-
return false;
|
|
8403
|
+
if (!state.src.startsWith(OPEN2, start)) return false;
|
|
8384
8404
|
const close = state.src.indexOf(CLOSE2, start);
|
|
8385
|
-
if (close === -1)
|
|
8386
|
-
|
|
8387
|
-
if (silent)
|
|
8388
|
-
return true;
|
|
8405
|
+
if (close === -1) return false;
|
|
8406
|
+
if (silent) return true;
|
|
8389
8407
|
const content = state.src.slice(start + OPEN2.length, close);
|
|
8390
8408
|
const lines = content.split("\n").length;
|
|
8391
8409
|
const token = state.push("comment", "", 0);
|
|
@@ -8395,13 +8413,10 @@ function block3(state, startLine, endLine, silent) {
|
|
|
8395
8413
|
return true;
|
|
8396
8414
|
}
|
|
8397
8415
|
function inline3(state, silent) {
|
|
8398
|
-
if (!state.src.startsWith(OPEN2, state.pos))
|
|
8399
|
-
return false;
|
|
8416
|
+
if (!state.src.startsWith(OPEN2, state.pos)) return false;
|
|
8400
8417
|
const close = state.src.indexOf(CLOSE2, state.pos);
|
|
8401
|
-
if (close === -1)
|
|
8402
|
-
|
|
8403
|
-
if (silent)
|
|
8404
|
-
return true;
|
|
8418
|
+
if (close === -1) return false;
|
|
8419
|
+
if (silent) return true;
|
|
8405
8420
|
const content = state.src.slice(state.pos + OPEN2.length, close);
|
|
8406
8421
|
const token = state.push("comment", "", 0);
|
|
8407
8422
|
token.content = content.trim();
|
|
@@ -8421,10 +8436,10 @@ var Tokenizer = class {
|
|
|
8421
8436
|
this.parser.use(plugin2, "frontmatter", {});
|
|
8422
8437
|
this.parser.disable([
|
|
8423
8438
|
"lheading",
|
|
8439
|
+
// Disable indented `code_block` support https://spec.commonmark.org/0.30/#indented-code-block
|
|
8424
8440
|
"code"
|
|
8425
8441
|
]);
|
|
8426
|
-
if (config.allowComments)
|
|
8427
|
-
this.parser.use(plugin3, "comments", {});
|
|
8442
|
+
if (config.allowComments) this.parser.use(plugin3, "comments", {});
|
|
8428
8443
|
}
|
|
8429
8444
|
tokenize(content) {
|
|
8430
8445
|
return this.parser.parse(content.toString(), {});
|
|
@@ -8440,18 +8455,15 @@ var TypeMappings = {
|
|
|
8440
8455
|
Boolean
|
|
8441
8456
|
};
|
|
8442
8457
|
function validateType(type, value, config, key) {
|
|
8443
|
-
if (!type)
|
|
8444
|
-
return true;
|
|
8458
|
+
if (!type) return true;
|
|
8445
8459
|
if (ast_default.isFunction(value) && config.validation?.validateFunctions) {
|
|
8446
8460
|
const schema = config.functions?.[value.name];
|
|
8447
8461
|
return !schema?.returns ? true : Array.isArray(schema.returns) ? schema.returns.find((t) => t === type) !== void 0 : schema.returns === type;
|
|
8448
8462
|
}
|
|
8449
|
-
if (ast_default.isAst(value))
|
|
8450
|
-
return true;
|
|
8463
|
+
if (ast_default.isAst(value)) return true;
|
|
8451
8464
|
if (Array.isArray(type))
|
|
8452
8465
|
return type.some((t) => validateType(t, value, config, key));
|
|
8453
|
-
if (typeof type === "string")
|
|
8454
|
-
type = TypeMappings[type];
|
|
8466
|
+
if (typeof type === "string") type = TypeMappings[type];
|
|
8455
8467
|
if (typeof type === "function") {
|
|
8456
8468
|
const instance = new type();
|
|
8457
8469
|
if (instance.validate) {
|
|
@@ -8461,10 +8473,8 @@ function validateType(type, value, config, key) {
|
|
|
8461
8473
|
return value != null && value.constructor === type;
|
|
8462
8474
|
}
|
|
8463
8475
|
function typeToString(type) {
|
|
8464
|
-
if (typeof type === "string")
|
|
8465
|
-
|
|
8466
|
-
if (Array.isArray(type))
|
|
8467
|
-
return type.map(typeToString).join(" | ");
|
|
8476
|
+
if (typeof type === "string") return type;
|
|
8477
|
+
if (Array.isArray(type)) return type.map(typeToString).join(" | ");
|
|
8468
8478
|
return type.name;
|
|
8469
8479
|
}
|
|
8470
8480
|
function validateFunction(fn, config) {
|
|
@@ -8478,8 +8488,7 @@ function validateFunction(fn, config) {
|
|
|
8478
8488
|
message: `Undefined function: '${fn.name}'`
|
|
8479
8489
|
}
|
|
8480
8490
|
];
|
|
8481
|
-
if (schema.validate)
|
|
8482
|
-
errors.push(...schema.validate(fn, config));
|
|
8491
|
+
if (schema.validate) errors.push(...schema.validate(fn, config));
|
|
8483
8492
|
if (schema.parameters) {
|
|
8484
8493
|
for (const [key, value] of Object.entries(fn.parameters)) {
|
|
8485
8494
|
const param = schema.parameters?.[key];
|
|
@@ -8491,8 +8500,7 @@ function validateFunction(fn, config) {
|
|
|
8491
8500
|
});
|
|
8492
8501
|
continue;
|
|
8493
8502
|
}
|
|
8494
|
-
if (ast_default.isAst(value) && !ast_default.isFunction(value))
|
|
8495
|
-
continue;
|
|
8503
|
+
if (ast_default.isAst(value) && !ast_default.isFunction(value)) continue;
|
|
8496
8504
|
if (param.type) {
|
|
8497
8505
|
const valid = validateType(param.type, value, config, key);
|
|
8498
8506
|
if (valid === false) {
|
|
@@ -8517,8 +8525,7 @@ function validateFunction(fn, config) {
|
|
|
8517
8525
|
return errors;
|
|
8518
8526
|
}
|
|
8519
8527
|
function displayMatches(matches, n) {
|
|
8520
|
-
if (matches.length <= n)
|
|
8521
|
-
return JSON.stringify(matches);
|
|
8528
|
+
if (matches.length <= n) return JSON.stringify(matches);
|
|
8522
8529
|
const items = matches.slice(0, n).map((item2) => JSON.stringify(item2));
|
|
8523
8530
|
return `[${items.join(",")}, ... ${matches.length - n} more]`;
|
|
8524
8531
|
}
|
|
@@ -8589,8 +8596,7 @@ function validator(node2, config) {
|
|
|
8589
8596
|
message: `Undefined variable: '${value.path.join(".")}'`
|
|
8590
8597
|
});
|
|
8591
8598
|
}
|
|
8592
|
-
} else
|
|
8593
|
-
continue;
|
|
8599
|
+
} else continue;
|
|
8594
8600
|
}
|
|
8595
8601
|
value = value;
|
|
8596
8602
|
if (type) {
|
|
@@ -8606,13 +8612,15 @@ function validator(node2, config) {
|
|
|
8606
8612
|
errors.push(...valid);
|
|
8607
8613
|
}
|
|
8608
8614
|
}
|
|
8609
|
-
if (typeof matches === "function")
|
|
8610
|
-
matches = matches(config);
|
|
8615
|
+
if (typeof matches === "function") matches = matches(config);
|
|
8611
8616
|
if (Array.isArray(matches) && !matches.includes(value))
|
|
8612
8617
|
errors.push({
|
|
8613
8618
|
id: "attribute-value-invalid",
|
|
8614
8619
|
level: errorLevel || "error",
|
|
8615
|
-
message: `Attribute '${key}' must match one of ${displayMatches(
|
|
8620
|
+
message: `Attribute '${key}' must match one of ${displayMatches(
|
|
8621
|
+
matches,
|
|
8622
|
+
8
|
|
8623
|
+
)}. Got '${value}' instead.`
|
|
8616
8624
|
});
|
|
8617
8625
|
if (matches instanceof RegExp && !matches.test(value))
|
|
8618
8626
|
errors.push({
|
|
@@ -8622,8 +8630,7 @@ function validator(node2, config) {
|
|
|
8622
8630
|
});
|
|
8623
8631
|
if (typeof attrib.validate === "function") {
|
|
8624
8632
|
const attribErrors = attrib.validate(value, config, key);
|
|
8625
|
-
if (Array.isArray(attribErrors))
|
|
8626
|
-
errors.push(...attribErrors);
|
|
8633
|
+
if (Array.isArray(attribErrors)) errors.push(...attribErrors);
|
|
8627
8634
|
}
|
|
8628
8635
|
}
|
|
8629
8636
|
for (const [key, { required }] of Object.entries(attributes))
|
|
@@ -8664,18 +8671,32 @@ function* walkWithParents(node2, parents = []) {
|
|
|
8664
8671
|
for (const child of [...Object.values(node2.slots), ...node2.children])
|
|
8665
8672
|
yield* walkWithParents(child, [...parents, node2]);
|
|
8666
8673
|
}
|
|
8674
|
+
function hasValidLocation(error2) {
|
|
8675
|
+
const loc = error2.location;
|
|
8676
|
+
return loc != null && typeof loc.start?.line === "number" && typeof loc.end?.line === "number" && (loc.file === void 0 || typeof loc.file === "string");
|
|
8677
|
+
}
|
|
8678
|
+
function toValidateError(node2, error2) {
|
|
8679
|
+
if (hasValidLocation(error2)) {
|
|
8680
|
+
return {
|
|
8681
|
+
type: node2.type,
|
|
8682
|
+
lines: [error2.location.start.line, error2.location.end.line],
|
|
8683
|
+
location: { file: node2.location?.file, ...error2.location },
|
|
8684
|
+
error: error2
|
|
8685
|
+
};
|
|
8686
|
+
}
|
|
8687
|
+
return { type: node2.type, lines: node2.lines, location: node2.location, error: error2 };
|
|
8688
|
+
}
|
|
8667
8689
|
function validateTree(content, config) {
|
|
8668
8690
|
const output = [...walkWithParents(content)].map(([node2, parents]) => {
|
|
8669
|
-
const { type, lines, location } = node2;
|
|
8670
8691
|
const updatedConfig = {
|
|
8671
8692
|
...config,
|
|
8672
8693
|
validation: { ...config.validation, parents }
|
|
8673
8694
|
};
|
|
8674
8695
|
const errors = validator(node2, updatedConfig);
|
|
8675
8696
|
if (isPromise(errors)) {
|
|
8676
|
-
return errors.then((e) => e.map((error2) => (
|
|
8697
|
+
return errors.then((e) => e.map((error2) => toValidateError(node2, error2)));
|
|
8677
8698
|
}
|
|
8678
|
-
return errors.map((error2) => (
|
|
8699
|
+
return errors.map((error2) => toValidateError(node2, error2));
|
|
8679
8700
|
});
|
|
8680
8701
|
if (output.some(isPromise)) {
|
|
8681
8702
|
return Promise.all(output).then((o) => o.flat());
|
|
@@ -8703,8 +8724,7 @@ function mergeConfig(config = {}) {
|
|
|
8703
8724
|
};
|
|
8704
8725
|
}
|
|
8705
8726
|
function parse3(content, args) {
|
|
8706
|
-
if (typeof content === "string")
|
|
8707
|
-
content = tokenizer.tokenize(content);
|
|
8727
|
+
if (typeof content === "string") content = tokenizer.tokenize(content);
|
|
8708
8728
|
return parser(content, args);
|
|
8709
8729
|
}
|
|
8710
8730
|
function resolve2(content, config) {
|
|
@@ -8734,22 +8754,58 @@ var Markdoc = class {
|
|
|
8734
8754
|
this.validate = (content) => validate(content, this.config);
|
|
8735
8755
|
this.config = config;
|
|
8736
8756
|
}
|
|
8757
|
+
static {
|
|
8758
|
+
this.nodes = schema_exports;
|
|
8759
|
+
}
|
|
8760
|
+
static {
|
|
8761
|
+
this.tags = tags_default;
|
|
8762
|
+
}
|
|
8763
|
+
static {
|
|
8764
|
+
this.functions = functions_default;
|
|
8765
|
+
}
|
|
8766
|
+
static {
|
|
8767
|
+
this.globalAttributes = globalAttributes;
|
|
8768
|
+
}
|
|
8769
|
+
static {
|
|
8770
|
+
this.renderers = renderers_default;
|
|
8771
|
+
}
|
|
8772
|
+
static {
|
|
8773
|
+
this.transforms = transforms_default;
|
|
8774
|
+
}
|
|
8775
|
+
static {
|
|
8776
|
+
this.Ast = ast_default;
|
|
8777
|
+
}
|
|
8778
|
+
static {
|
|
8779
|
+
this.Tag = Tag;
|
|
8780
|
+
}
|
|
8781
|
+
static {
|
|
8782
|
+
this.Tokenizer = Tokenizer;
|
|
8783
|
+
}
|
|
8784
|
+
static {
|
|
8785
|
+
this.parseTags = parseTags;
|
|
8786
|
+
}
|
|
8787
|
+
static {
|
|
8788
|
+
this.transformer = transformer_default;
|
|
8789
|
+
}
|
|
8790
|
+
static {
|
|
8791
|
+
this.validator = validator;
|
|
8792
|
+
}
|
|
8793
|
+
static {
|
|
8794
|
+
this.parse = parse3;
|
|
8795
|
+
}
|
|
8796
|
+
static {
|
|
8797
|
+
this.transform = transform2;
|
|
8798
|
+
}
|
|
8799
|
+
static {
|
|
8800
|
+
this.validate = validate;
|
|
8801
|
+
}
|
|
8802
|
+
static {
|
|
8803
|
+
this.createElement = createElement;
|
|
8804
|
+
}
|
|
8805
|
+
static {
|
|
8806
|
+
this.truthy = truthy;
|
|
8807
|
+
}
|
|
8808
|
+
static {
|
|
8809
|
+
this.format = format;
|
|
8810
|
+
}
|
|
8737
8811
|
};
|
|
8738
|
-
Markdoc.nodes = schema_exports;
|
|
8739
|
-
Markdoc.tags = tags_default;
|
|
8740
|
-
Markdoc.functions = functions_default;
|
|
8741
|
-
Markdoc.globalAttributes = globalAttributes;
|
|
8742
|
-
Markdoc.renderers = renderers_default;
|
|
8743
|
-
Markdoc.transforms = transforms_default;
|
|
8744
|
-
Markdoc.Ast = ast_default;
|
|
8745
|
-
Markdoc.Tag = Tag;
|
|
8746
|
-
Markdoc.Tokenizer = Tokenizer;
|
|
8747
|
-
Markdoc.parseTags = parseTags;
|
|
8748
|
-
Markdoc.transformer = transformer_default;
|
|
8749
|
-
Markdoc.validator = validator;
|
|
8750
|
-
Markdoc.parse = parse3;
|
|
8751
|
-
Markdoc.transform = transform2;
|
|
8752
|
-
Markdoc.validate = validate;
|
|
8753
|
-
Markdoc.createElement = createElement;
|
|
8754
|
-
Markdoc.truthy = truthy;
|
|
8755
|
-
Markdoc.format = format;
|