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