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