@markdoc/markdoc 0.5.5 → 0.5.7

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