@quartz-community/remark-obsidian 0.2.2 → 0.2.4
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 +3 -1
- package/dist/index.js +1385 -398
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,12 +57,12 @@ function propertiesFactory(check) {
|
|
|
57
57
|
/** @type {Record<string, unknown>} */
|
|
58
58
|
check
|
|
59
59
|
);
|
|
60
|
-
return castFactory(
|
|
61
|
-
function
|
|
60
|
+
return castFactory(all2);
|
|
61
|
+
function all2(node2) {
|
|
62
62
|
const nodeAsRecord = (
|
|
63
63
|
/** @type {Record<string, unknown>} */
|
|
64
64
|
/** @type {unknown} */
|
|
65
|
-
|
|
65
|
+
node2
|
|
66
66
|
);
|
|
67
67
|
let key;
|
|
68
68
|
for (key in check) {
|
|
@@ -73,8 +73,8 @@ function propertiesFactory(check) {
|
|
|
73
73
|
}
|
|
74
74
|
function typeFactory(check) {
|
|
75
75
|
return castFactory(type);
|
|
76
|
-
function type(
|
|
77
|
-
return
|
|
76
|
+
function type(node2) {
|
|
77
|
+
return node2 && node2.type === check;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
function castFactory(testFunction) {
|
|
@@ -118,10 +118,10 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
118
118
|
const is2 = convert(check);
|
|
119
119
|
const step = reverse ? -1 : 1;
|
|
120
120
|
factory(tree, void 0, [])();
|
|
121
|
-
function factory(
|
|
121
|
+
function factory(node2, index, parents) {
|
|
122
122
|
const value = (
|
|
123
123
|
/** @type {Record<string, unknown>} */
|
|
124
|
-
|
|
124
|
+
node2 && typeof node2 === "object" ? node2 : {}
|
|
125
125
|
);
|
|
126
126
|
if (typeof value.type === "string") {
|
|
127
127
|
const name = (
|
|
@@ -132,7 +132,7 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
132
132
|
)
|
|
133
133
|
);
|
|
134
134
|
Object.defineProperty(visit2, "name", {
|
|
135
|
-
value: "node (" + color(
|
|
135
|
+
value: "node (" + color(node2.type + (name ? "<" + name + ">" : "")) + ")"
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
return visit2;
|
|
@@ -141,16 +141,16 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
141
141
|
let subresult;
|
|
142
142
|
let offset;
|
|
143
143
|
let grandparents;
|
|
144
|
-
if (!test || is2(
|
|
145
|
-
result = toResult(visitor(
|
|
144
|
+
if (!test || is2(node2, index, parents[parents.length - 1] || void 0)) {
|
|
145
|
+
result = toResult(visitor(node2, parents));
|
|
146
146
|
if (result[0] === EXIT) {
|
|
147
147
|
return result;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
if ("children" in
|
|
150
|
+
if ("children" in node2 && node2.children) {
|
|
151
151
|
const nodeAsParent = (
|
|
152
152
|
/** @type {UnistParent} */
|
|
153
|
-
|
|
153
|
+
node2
|
|
154
154
|
);
|
|
155
155
|
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
156
156
|
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
@@ -194,10 +194,10 @@ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
|
194
194
|
reverse = maybeReverse;
|
|
195
195
|
}
|
|
196
196
|
visitParents(tree, test, overload, reverse);
|
|
197
|
-
function overload(
|
|
197
|
+
function overload(node2, parents) {
|
|
198
198
|
const parent = parents[parents.length - 1];
|
|
199
|
-
const index = parent ? parent.children.indexOf(
|
|
200
|
-
return visitor(
|
|
199
|
+
const index = parent ? parent.children.indexOf(node2) : void 0;
|
|
200
|
+
return visitor(node2, index, parent);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -453,8 +453,8 @@ var LEFT_BRACKET = 91;
|
|
|
453
453
|
var BACKSLASH = 92;
|
|
454
454
|
var RIGHT_BRACKET = 93;
|
|
455
455
|
var PIPE = 124;
|
|
456
|
-
function isLineEnding(
|
|
457
|
-
return
|
|
456
|
+
function isLineEnding(code2) {
|
|
457
|
+
return code2 === codes.lineFeed || code2 === codes.carriageReturn;
|
|
458
458
|
}
|
|
459
459
|
function wikilinkSyntax() {
|
|
460
460
|
return {
|
|
@@ -469,151 +469,151 @@ function tokenize(effects, ok3, nok) {
|
|
|
469
469
|
let hasHeading = false;
|
|
470
470
|
let hasAlias = false;
|
|
471
471
|
return start;
|
|
472
|
-
function start(
|
|
473
|
-
if (
|
|
472
|
+
function start(code2) {
|
|
473
|
+
if (code2 === EXCLAMATION) {
|
|
474
474
|
effects.enter("wikilink");
|
|
475
475
|
effects.enter("wikilinkEmbedMarker");
|
|
476
|
-
effects.consume(
|
|
476
|
+
effects.consume(code2);
|
|
477
477
|
effects.exit("wikilinkEmbedMarker");
|
|
478
478
|
return openFirst;
|
|
479
479
|
}
|
|
480
|
-
if (
|
|
480
|
+
if (code2 === LEFT_BRACKET) {
|
|
481
481
|
effects.enter("wikilink");
|
|
482
|
-
return openFirst(
|
|
482
|
+
return openFirst(code2);
|
|
483
483
|
}
|
|
484
|
-
return nok(
|
|
484
|
+
return nok(code2);
|
|
485
485
|
}
|
|
486
|
-
function openFirst(
|
|
487
|
-
if (
|
|
486
|
+
function openFirst(code2) {
|
|
487
|
+
if (code2 !== LEFT_BRACKET) return nok(code2);
|
|
488
488
|
effects.enter("wikilinkMarker");
|
|
489
|
-
effects.consume(
|
|
489
|
+
effects.consume(code2);
|
|
490
490
|
return openSecond;
|
|
491
491
|
}
|
|
492
|
-
function openSecond(
|
|
493
|
-
if (
|
|
494
|
-
effects.consume(
|
|
492
|
+
function openSecond(code2) {
|
|
493
|
+
if (code2 !== LEFT_BRACKET) return nok(code2);
|
|
494
|
+
effects.consume(code2);
|
|
495
495
|
effects.exit("wikilinkMarker");
|
|
496
496
|
return pathStart;
|
|
497
497
|
}
|
|
498
|
-
function pathStart(
|
|
499
|
-
if (
|
|
500
|
-
if (
|
|
501
|
-
if (
|
|
502
|
-
return nok(
|
|
498
|
+
function pathStart(code2) {
|
|
499
|
+
if (code2 === HASH) return headingMarker(code2);
|
|
500
|
+
if (code2 === PIPE) return nok(code2);
|
|
501
|
+
if (code2 === RIGHT_BRACKET || code2 === null || isLineEnding(code2))
|
|
502
|
+
return nok(code2);
|
|
503
503
|
effects.enter("wikilinkPath");
|
|
504
504
|
hasPath = true;
|
|
505
|
-
return path(
|
|
505
|
+
return path(code2);
|
|
506
506
|
}
|
|
507
|
-
function path(
|
|
508
|
-
if (
|
|
509
|
-
effects.consume(
|
|
507
|
+
function path(code2) {
|
|
508
|
+
if (code2 === BACKSLASH) {
|
|
509
|
+
effects.consume(code2);
|
|
510
510
|
return pathEscape;
|
|
511
511
|
}
|
|
512
|
-
if (
|
|
512
|
+
if (code2 === HASH) {
|
|
513
513
|
effects.exit("wikilinkPath");
|
|
514
|
-
return headingMarker(
|
|
514
|
+
return headingMarker(code2);
|
|
515
515
|
}
|
|
516
|
-
if (
|
|
516
|
+
if (code2 === PIPE) {
|
|
517
517
|
effects.exit("wikilinkPath");
|
|
518
|
-
return aliasMarker(
|
|
518
|
+
return aliasMarker(code2);
|
|
519
519
|
}
|
|
520
|
-
if (
|
|
520
|
+
if (code2 === RIGHT_BRACKET) {
|
|
521
521
|
effects.exit("wikilinkPath");
|
|
522
|
-
return closeFirst(
|
|
522
|
+
return closeFirst(code2);
|
|
523
523
|
}
|
|
524
|
-
if (
|
|
525
|
-
effects.consume(
|
|
524
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
525
|
+
effects.consume(code2);
|
|
526
526
|
return path;
|
|
527
527
|
}
|
|
528
|
-
function pathEscape(
|
|
529
|
-
if (
|
|
528
|
+
function pathEscape(code2) {
|
|
529
|
+
if (code2 === PIPE) {
|
|
530
530
|
effects.exit("wikilinkPath");
|
|
531
|
-
return aliasMarker(
|
|
531
|
+
return aliasMarker(code2);
|
|
532
532
|
}
|
|
533
|
-
if (
|
|
534
|
-
effects.consume(
|
|
533
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
534
|
+
effects.consume(code2);
|
|
535
535
|
return path;
|
|
536
536
|
}
|
|
537
|
-
function headingMarker(
|
|
538
|
-
if (
|
|
537
|
+
function headingMarker(code2) {
|
|
538
|
+
if (code2 !== HASH) return nok(code2);
|
|
539
539
|
effects.enter("wikilinkHeadingMarker");
|
|
540
|
-
effects.consume(
|
|
540
|
+
effects.consume(code2);
|
|
541
541
|
effects.exit("wikilinkHeadingMarker");
|
|
542
542
|
return headingStart;
|
|
543
543
|
}
|
|
544
|
-
function headingStart(
|
|
545
|
-
if (
|
|
546
|
-
if (
|
|
544
|
+
function headingStart(code2) {
|
|
545
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
546
|
+
if (code2 === RIGHT_BRACKET) {
|
|
547
547
|
hasHeading = true;
|
|
548
|
-
return closeFirst(
|
|
548
|
+
return closeFirst(code2);
|
|
549
549
|
}
|
|
550
|
-
if (
|
|
550
|
+
if (code2 === PIPE) {
|
|
551
551
|
hasHeading = true;
|
|
552
|
-
return aliasMarker(
|
|
552
|
+
return aliasMarker(code2);
|
|
553
553
|
}
|
|
554
554
|
effects.enter("wikilinkHeading");
|
|
555
555
|
hasHeading = true;
|
|
556
|
-
return
|
|
556
|
+
return heading2(code2);
|
|
557
557
|
}
|
|
558
|
-
function
|
|
559
|
-
if (
|
|
560
|
-
effects.consume(
|
|
558
|
+
function heading2(code2) {
|
|
559
|
+
if (code2 === BACKSLASH) {
|
|
560
|
+
effects.consume(code2);
|
|
561
561
|
return headingEscape;
|
|
562
562
|
}
|
|
563
|
-
if (
|
|
563
|
+
if (code2 === PIPE) {
|
|
564
564
|
effects.exit("wikilinkHeading");
|
|
565
|
-
return aliasMarker(
|
|
565
|
+
return aliasMarker(code2);
|
|
566
566
|
}
|
|
567
|
-
if (
|
|
567
|
+
if (code2 === RIGHT_BRACKET) {
|
|
568
568
|
effects.exit("wikilinkHeading");
|
|
569
|
-
return closeFirst(
|
|
569
|
+
return closeFirst(code2);
|
|
570
570
|
}
|
|
571
|
-
if (
|
|
572
|
-
effects.consume(
|
|
573
|
-
return
|
|
571
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
572
|
+
effects.consume(code2);
|
|
573
|
+
return heading2;
|
|
574
574
|
}
|
|
575
|
-
function headingEscape(
|
|
576
|
-
if (
|
|
575
|
+
function headingEscape(code2) {
|
|
576
|
+
if (code2 === PIPE) {
|
|
577
577
|
effects.exit("wikilinkHeading");
|
|
578
|
-
return aliasMarker(
|
|
578
|
+
return aliasMarker(code2);
|
|
579
579
|
}
|
|
580
|
-
if (
|
|
581
|
-
effects.consume(
|
|
582
|
-
return
|
|
580
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
581
|
+
effects.consume(code2);
|
|
582
|
+
return heading2;
|
|
583
583
|
}
|
|
584
|
-
function aliasMarker(
|
|
585
|
-
if (
|
|
584
|
+
function aliasMarker(code2) {
|
|
585
|
+
if (code2 !== PIPE) return nok(code2);
|
|
586
586
|
effects.enter("wikilinkAliasMarker");
|
|
587
|
-
effects.consume(
|
|
587
|
+
effects.consume(code2);
|
|
588
588
|
effects.exit("wikilinkAliasMarker");
|
|
589
589
|
return aliasStart;
|
|
590
590
|
}
|
|
591
|
-
function aliasStart(
|
|
592
|
-
if (
|
|
593
|
-
if (
|
|
591
|
+
function aliasStart(code2) {
|
|
592
|
+
if (code2 === RIGHT_BRACKET) return closeFirst(code2);
|
|
593
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
594
594
|
effects.enter("wikilinkAlias");
|
|
595
595
|
hasAlias = true;
|
|
596
|
-
return alias(
|
|
596
|
+
return alias(code2);
|
|
597
597
|
}
|
|
598
|
-
function alias(
|
|
599
|
-
if (
|
|
598
|
+
function alias(code2) {
|
|
599
|
+
if (code2 === RIGHT_BRACKET) {
|
|
600
600
|
effects.exit("wikilinkAlias");
|
|
601
|
-
return closeFirst(
|
|
601
|
+
return closeFirst(code2);
|
|
602
602
|
}
|
|
603
|
-
if (
|
|
604
|
-
effects.consume(
|
|
603
|
+
if (code2 === null || isLineEnding(code2)) return nok(code2);
|
|
604
|
+
effects.consume(code2);
|
|
605
605
|
return alias;
|
|
606
606
|
}
|
|
607
|
-
function closeFirst(
|
|
608
|
-
if (
|
|
609
|
-
if (!hasPath && !hasHeading && !hasAlias) return nok(
|
|
607
|
+
function closeFirst(code2) {
|
|
608
|
+
if (code2 !== RIGHT_BRACKET) return nok(code2);
|
|
609
|
+
if (!hasPath && !hasHeading && !hasAlias) return nok(code2);
|
|
610
610
|
effects.enter("wikilinkMarker");
|
|
611
|
-
effects.consume(
|
|
611
|
+
effects.consume(code2);
|
|
612
612
|
return closeSecond;
|
|
613
613
|
}
|
|
614
|
-
function closeSecond(
|
|
615
|
-
if (
|
|
616
|
-
effects.consume(
|
|
614
|
+
function closeSecond(code2) {
|
|
615
|
+
if (code2 !== RIGHT_BRACKET) return nok(code2);
|
|
616
|
+
effects.consume(code2);
|
|
617
617
|
effects.exit("wikilinkMarker");
|
|
618
618
|
effects.exit("wikilink");
|
|
619
619
|
return ok3;
|
|
@@ -622,8 +622,8 @@ function tokenize(effects, ok3, nok) {
|
|
|
622
622
|
|
|
623
623
|
// src/lib/syntax/highlight.ts
|
|
624
624
|
var EQUALS = 61;
|
|
625
|
-
function isLineEnding2(
|
|
626
|
-
return
|
|
625
|
+
function isLineEnding2(code2) {
|
|
626
|
+
return code2 === codes.lineFeed || code2 === codes.carriageReturn;
|
|
627
627
|
}
|
|
628
628
|
function highlightSyntax() {
|
|
629
629
|
return {
|
|
@@ -636,32 +636,32 @@ function tokenize2(effects, ok3, nok) {
|
|
|
636
636
|
const close = { tokenize: tokenizeClose, partial: true };
|
|
637
637
|
let hasContent = false;
|
|
638
638
|
return start;
|
|
639
|
-
function start(
|
|
640
|
-
if (
|
|
639
|
+
function start(code2) {
|
|
640
|
+
if (code2 !== EQUALS) return nok(code2);
|
|
641
641
|
effects.enter("highlight");
|
|
642
642
|
effects.enter("highlightMarker");
|
|
643
|
-
effects.consume(
|
|
643
|
+
effects.consume(code2);
|
|
644
644
|
return openSecond;
|
|
645
645
|
}
|
|
646
|
-
function openSecond(
|
|
647
|
-
if (
|
|
648
|
-
effects.consume(
|
|
646
|
+
function openSecond(code2) {
|
|
647
|
+
if (code2 !== EQUALS) return nok(code2);
|
|
648
|
+
effects.consume(code2);
|
|
649
649
|
effects.exit("highlightMarker");
|
|
650
650
|
effects.enter("highlightContent");
|
|
651
651
|
return content;
|
|
652
652
|
}
|
|
653
|
-
function content(
|
|
654
|
-
if (
|
|
655
|
-
if (!hasContent &&
|
|
656
|
-
if (
|
|
657
|
-
return effects.attempt(close, closeAfter, contentConsume)(
|
|
658
|
-
effects.consume(
|
|
653
|
+
function content(code2) {
|
|
654
|
+
if (code2 === null || isLineEnding2(code2)) return nok(code2);
|
|
655
|
+
if (!hasContent && code2 === EQUALS) return nok(code2);
|
|
656
|
+
if (code2 === EQUALS)
|
|
657
|
+
return effects.attempt(close, closeAfter, contentConsume)(code2);
|
|
658
|
+
effects.consume(code2);
|
|
659
659
|
hasContent = true;
|
|
660
660
|
return content;
|
|
661
661
|
}
|
|
662
|
-
function contentConsume(
|
|
663
|
-
if (
|
|
664
|
-
effects.consume(
|
|
662
|
+
function contentConsume(code2) {
|
|
663
|
+
if (code2 === null || isLineEnding2(code2)) return nok(code2);
|
|
664
|
+
effects.consume(code2);
|
|
665
665
|
return content;
|
|
666
666
|
}
|
|
667
667
|
function tokenizeClose(closeEffects, closeOk, closeNok) {
|
|
@@ -680,9 +680,9 @@ function tokenize2(effects, ok3, nok) {
|
|
|
680
680
|
return closeOk;
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
function closeAfter(
|
|
683
|
+
function closeAfter(code2) {
|
|
684
684
|
effects.exit("highlight");
|
|
685
|
-
return ok3(
|
|
685
|
+
return ok3(code2);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
|
|
@@ -691,8 +691,8 @@ var PERCENT = 37;
|
|
|
691
691
|
var LINE_FEED = -4;
|
|
692
692
|
var CARRIAGE_RETURN = -3;
|
|
693
693
|
var CARRIAGE_RETURN_LINE_FEED = -5;
|
|
694
|
-
function isLineEnding3(
|
|
695
|
-
return
|
|
694
|
+
function isLineEnding3(code2) {
|
|
695
|
+
return code2 === LINE_FEED || code2 === CARRIAGE_RETURN || code2 === CARRIAGE_RETURN_LINE_FEED;
|
|
696
696
|
}
|
|
697
697
|
var commentFlow = {
|
|
698
698
|
tokenize: tokenizeFlow,
|
|
@@ -716,30 +716,30 @@ function commentSyntax() {
|
|
|
716
716
|
function tokenizeText(effects, ok3, nok) {
|
|
717
717
|
const close = { tokenize: tokenizeClose, partial: true };
|
|
718
718
|
return start;
|
|
719
|
-
function start(
|
|
720
|
-
if (
|
|
719
|
+
function start(code2) {
|
|
720
|
+
if (code2 !== PERCENT) return nok(code2);
|
|
721
721
|
effects.enter("comment");
|
|
722
722
|
effects.enter("commentMarker");
|
|
723
|
-
effects.consume(
|
|
723
|
+
effects.consume(code2);
|
|
724
724
|
return openSecond;
|
|
725
725
|
}
|
|
726
|
-
function openSecond(
|
|
727
|
-
if (
|
|
728
|
-
effects.consume(
|
|
726
|
+
function openSecond(code2) {
|
|
727
|
+
if (code2 !== PERCENT) return nok(code2);
|
|
728
|
+
effects.consume(code2);
|
|
729
729
|
effects.exit("commentMarker");
|
|
730
730
|
effects.enter("commentContent");
|
|
731
731
|
return content;
|
|
732
732
|
}
|
|
733
|
-
function content(
|
|
734
|
-
if (
|
|
735
|
-
if (
|
|
736
|
-
return effects.attempt(close, closeAfter, contentConsume)(
|
|
737
|
-
effects.consume(
|
|
733
|
+
function content(code2) {
|
|
734
|
+
if (code2 === null) return nok(code2);
|
|
735
|
+
if (code2 === PERCENT)
|
|
736
|
+
return effects.attempt(close, closeAfter, contentConsume)(code2);
|
|
737
|
+
effects.consume(code2);
|
|
738
738
|
return content;
|
|
739
739
|
}
|
|
740
|
-
function contentConsume(
|
|
741
|
-
if (
|
|
742
|
-
effects.consume(
|
|
740
|
+
function contentConsume(code2) {
|
|
741
|
+
if (code2 === null) return nok(code2);
|
|
742
|
+
effects.consume(code2);
|
|
743
743
|
return content;
|
|
744
744
|
}
|
|
745
745
|
function tokenizeClose(closeEffects, closeOk, closeNok) {
|
|
@@ -758,9 +758,9 @@ function tokenizeText(effects, ok3, nok) {
|
|
|
758
758
|
return closeOk;
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
|
-
function closeAfter(
|
|
761
|
+
function closeAfter(code2) {
|
|
762
762
|
effects.exit("comment");
|
|
763
|
-
return ok3(
|
|
763
|
+
return ok3(code2);
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
function tokenizeFlow(effects, ok3, nok) {
|
|
@@ -770,81 +770,93 @@ function tokenizeFlow(effects, ok3, nok) {
|
|
|
770
770
|
partial: true
|
|
771
771
|
};
|
|
772
772
|
return start;
|
|
773
|
-
function start(
|
|
774
|
-
if (
|
|
773
|
+
function start(code2) {
|
|
774
|
+
if (code2 !== PERCENT) return nok(code2);
|
|
775
775
|
effects.enter("comment");
|
|
776
776
|
effects.enter("commentMarker");
|
|
777
|
-
effects.consume(
|
|
777
|
+
effects.consume(code2);
|
|
778
778
|
return openSecond;
|
|
779
779
|
}
|
|
780
|
-
function openSecond(
|
|
781
|
-
if (
|
|
782
|
-
effects.consume(
|
|
780
|
+
function openSecond(code2) {
|
|
781
|
+
if (code2 !== PERCENT) return nok(code2);
|
|
782
|
+
effects.consume(code2);
|
|
783
783
|
effects.exit("commentMarker");
|
|
784
784
|
return afterOpen;
|
|
785
785
|
}
|
|
786
|
-
function afterOpen(
|
|
787
|
-
if (
|
|
788
|
-
|
|
786
|
+
function afterOpen(code2) {
|
|
787
|
+
if (code2 === null) {
|
|
788
|
+
effects.exit("comment");
|
|
789
|
+
return ok3(code2);
|
|
790
|
+
}
|
|
791
|
+
if (isLineEnding3(code2)) {
|
|
789
792
|
return effects.attempt(
|
|
790
793
|
nonLazyContinuation,
|
|
791
794
|
beforeContentChunk,
|
|
792
|
-
|
|
793
|
-
)(
|
|
795
|
+
afterLazy
|
|
796
|
+
)(code2);
|
|
794
797
|
}
|
|
795
798
|
effects.enter("commentContent");
|
|
796
|
-
return contentChunk(
|
|
799
|
+
return contentChunk(code2);
|
|
797
800
|
}
|
|
798
|
-
function beforeContentChunk(
|
|
799
|
-
if (
|
|
800
|
-
|
|
801
|
+
function beforeContentChunk(code2) {
|
|
802
|
+
if (code2 === null) {
|
|
803
|
+
effects.exit("comment");
|
|
804
|
+
return ok3(code2);
|
|
801
805
|
}
|
|
802
|
-
if (isLineEnding3(
|
|
806
|
+
if (isLineEnding3(code2)) {
|
|
803
807
|
return effects.attempt(
|
|
804
808
|
nonLazyContinuation,
|
|
805
809
|
beforeContentChunk,
|
|
806
|
-
|
|
807
|
-
)(
|
|
810
|
+
afterLazy
|
|
811
|
+
)(code2);
|
|
808
812
|
}
|
|
809
|
-
if (
|
|
810
|
-
return effects.attempt(flowClose, closeAfter, startContent)(
|
|
813
|
+
if (code2 === PERCENT) {
|
|
814
|
+
return effects.attempt(flowClose, closeAfter, startContent)(code2);
|
|
811
815
|
}
|
|
812
816
|
effects.enter("commentContent");
|
|
813
|
-
return contentChunk(
|
|
817
|
+
return contentChunk(code2);
|
|
814
818
|
}
|
|
815
|
-
function startContent(
|
|
819
|
+
function startContent(code2) {
|
|
816
820
|
effects.enter("commentContent");
|
|
817
|
-
effects.consume(
|
|
821
|
+
effects.consume(code2);
|
|
818
822
|
return contentChunk;
|
|
819
823
|
}
|
|
820
|
-
function contentChunk(
|
|
821
|
-
if (
|
|
822
|
-
|
|
823
|
-
|
|
824
|
+
function contentChunk(code2) {
|
|
825
|
+
if (code2 === null) {
|
|
826
|
+
effects.exit("commentContent");
|
|
827
|
+
effects.exit("comment");
|
|
828
|
+
return ok3(code2);
|
|
829
|
+
}
|
|
830
|
+
if (code2 === PERCENT) {
|
|
831
|
+
return effects.attempt(flowClose, closeAfter, contentConsume)(code2);
|
|
824
832
|
}
|
|
825
|
-
if (isLineEnding3(
|
|
833
|
+
if (isLineEnding3(code2)) {
|
|
826
834
|
effects.exit("commentContent");
|
|
827
835
|
return effects.attempt(
|
|
828
836
|
nonLazyContinuation,
|
|
829
837
|
beforeContentChunk,
|
|
830
|
-
|
|
831
|
-
)(
|
|
838
|
+
afterLazy
|
|
839
|
+
)(code2);
|
|
832
840
|
}
|
|
833
|
-
effects.consume(
|
|
841
|
+
effects.consume(code2);
|
|
834
842
|
return contentChunk;
|
|
835
843
|
}
|
|
836
|
-
function contentConsume(
|
|
837
|
-
if (
|
|
838
|
-
|
|
844
|
+
function contentConsume(code2) {
|
|
845
|
+
if (code2 === null) {
|
|
846
|
+
effects.exit("commentContent");
|
|
847
|
+
effects.exit("comment");
|
|
848
|
+
return ok3(code2);
|
|
849
|
+
}
|
|
850
|
+
effects.consume(code2);
|
|
839
851
|
return contentChunk;
|
|
840
852
|
}
|
|
841
|
-
function closeAfter(
|
|
853
|
+
function closeAfter(code2) {
|
|
842
854
|
effects.exit("comment");
|
|
843
|
-
return ok3(
|
|
855
|
+
return ok3(code2);
|
|
844
856
|
}
|
|
845
|
-
function
|
|
857
|
+
function afterLazy(code2) {
|
|
846
858
|
effects.exit("comment");
|
|
847
|
-
return
|
|
859
|
+
return ok3(code2);
|
|
848
860
|
}
|
|
849
861
|
function tokenizeFlowClose(closeEffects, closeOk, closeNok) {
|
|
850
862
|
let inContent = false;
|
|
@@ -877,18 +889,18 @@ function tokenizeFlow(effects, ok3, nok) {
|
|
|
877
889
|
function tokenizeNonLazyContinuation(effects, ok3, nok) {
|
|
878
890
|
const self = this;
|
|
879
891
|
return start;
|
|
880
|
-
function start(
|
|
881
|
-
if (
|
|
882
|
-
return ok3(
|
|
892
|
+
function start(code2) {
|
|
893
|
+
if (code2 === null) {
|
|
894
|
+
return ok3(code2);
|
|
883
895
|
}
|
|
884
|
-
if (!isLineEnding3(
|
|
896
|
+
if (!isLineEnding3(code2)) return nok(code2);
|
|
885
897
|
effects.enter("lineEnding");
|
|
886
|
-
effects.consume(
|
|
898
|
+
effects.consume(code2);
|
|
887
899
|
effects.exit("lineEnding");
|
|
888
900
|
return lineStart;
|
|
889
901
|
}
|
|
890
|
-
function lineStart(
|
|
891
|
-
return self.parser.lazy[self.now().line] ? nok(
|
|
902
|
+
function lineStart(code2) {
|
|
903
|
+
return self.parser.lazy[self.now().line] ? nok(code2) : ok3(code2);
|
|
892
904
|
}
|
|
893
905
|
}
|
|
894
906
|
|
|
@@ -898,18 +910,18 @@ var SLASH = 47;
|
|
|
898
910
|
var DASH = 45;
|
|
899
911
|
var UNDERSCORE = 95;
|
|
900
912
|
var tagCharRegex = /[\p{L}\p{M}\p{Emoji}]/u;
|
|
901
|
-
function isWhitespace(
|
|
902
|
-
return
|
|
913
|
+
function isWhitespace(code2) {
|
|
914
|
+
return code2 === codes.space || code2 === codes.horizontalTab || code2 === codes.lineFeed || code2 === codes.carriageReturn || code2 === codes.carriageReturnLineFeed;
|
|
903
915
|
}
|
|
904
|
-
function isTagChar(
|
|
905
|
-
if (
|
|
906
|
-
if (
|
|
907
|
-
if (
|
|
908
|
-
return tagCharRegex.test(String.fromCodePoint(
|
|
916
|
+
function isTagChar(code2) {
|
|
917
|
+
if (code2 === null || code2 < 0) return false;
|
|
918
|
+
if (code2 >= 48 && code2 <= 57) return true;
|
|
919
|
+
if (code2 === DASH || code2 === UNDERSCORE) return true;
|
|
920
|
+
return tagCharRegex.test(String.fromCodePoint(code2));
|
|
909
921
|
}
|
|
910
|
-
function isNonDigit(
|
|
911
|
-
if (
|
|
912
|
-
return !(
|
|
922
|
+
function isNonDigit(code2) {
|
|
923
|
+
if (code2 === null) return false;
|
|
924
|
+
return !(code2 >= 48 && code2 <= 57);
|
|
913
925
|
}
|
|
914
926
|
function tagSyntax() {
|
|
915
927
|
return {
|
|
@@ -922,47 +934,47 @@ function tokenize3(effects, ok3, nok) {
|
|
|
922
934
|
let hasNonDigit = false;
|
|
923
935
|
const context = this;
|
|
924
936
|
return start;
|
|
925
|
-
function start(
|
|
937
|
+
function start(code2) {
|
|
926
938
|
const previous2 = context.previous;
|
|
927
939
|
const allowedStart = previous2 === null || isWhitespace(previous2) || previous2 === HASH2;
|
|
928
|
-
if (!allowedStart) return nok(
|
|
929
|
-
if (
|
|
940
|
+
if (!allowedStart) return nok(code2);
|
|
941
|
+
if (code2 !== HASH2) return nok(code2);
|
|
930
942
|
effects.enter("tag");
|
|
931
943
|
effects.enter("tagMarker");
|
|
932
|
-
effects.consume(
|
|
944
|
+
effects.consume(code2);
|
|
933
945
|
effects.exit("tagMarker");
|
|
934
946
|
return tagStart;
|
|
935
947
|
}
|
|
936
|
-
function tagStart(
|
|
937
|
-
if (!isTagChar(
|
|
948
|
+
function tagStart(code2) {
|
|
949
|
+
if (!isTagChar(code2)) return nok(code2);
|
|
938
950
|
effects.enter("tagContent");
|
|
939
|
-
if (isNonDigit(
|
|
940
|
-
effects.consume(
|
|
951
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
952
|
+
effects.consume(code2);
|
|
941
953
|
return tagContent;
|
|
942
954
|
}
|
|
943
|
-
function tagContent(
|
|
944
|
-
if (
|
|
945
|
-
effects.consume(
|
|
955
|
+
function tagContent(code2) {
|
|
956
|
+
if (code2 === SLASH) {
|
|
957
|
+
effects.consume(code2);
|
|
946
958
|
return afterSlash;
|
|
947
959
|
}
|
|
948
|
-
if (isTagChar(
|
|
949
|
-
if (isNonDigit(
|
|
950
|
-
effects.consume(
|
|
960
|
+
if (isTagChar(code2)) {
|
|
961
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
962
|
+
effects.consume(code2);
|
|
951
963
|
return tagContent;
|
|
952
964
|
}
|
|
953
|
-
return end(
|
|
965
|
+
return end(code2);
|
|
954
966
|
}
|
|
955
|
-
function afterSlash(
|
|
956
|
-
if (!isTagChar(
|
|
957
|
-
if (isNonDigit(
|
|
958
|
-
effects.consume(
|
|
967
|
+
function afterSlash(code2) {
|
|
968
|
+
if (!isTagChar(code2)) return nok(code2);
|
|
969
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
970
|
+
effects.consume(code2);
|
|
959
971
|
return tagContent;
|
|
960
972
|
}
|
|
961
|
-
function end(
|
|
962
|
-
if (!hasNonDigit) return nok(
|
|
973
|
+
function end(code2) {
|
|
974
|
+
if (!hasNonDigit) return nok(code2);
|
|
963
975
|
effects.exit("tagContent");
|
|
964
976
|
effects.exit("tag");
|
|
965
|
-
return ok3(
|
|
977
|
+
return ok3(code2);
|
|
966
978
|
}
|
|
967
979
|
}
|
|
968
980
|
|
|
@@ -984,29 +996,29 @@ function wikilinkFromMarkdown() {
|
|
|
984
996
|
);
|
|
985
997
|
},
|
|
986
998
|
wikilinkEmbedMarker() {
|
|
987
|
-
const
|
|
988
|
-
|
|
999
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1000
|
+
node2.embedded = true;
|
|
989
1001
|
},
|
|
990
1002
|
wikilinkPath(token) {
|
|
991
|
-
const
|
|
992
|
-
|
|
1003
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1004
|
+
node2.path = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
|
|
993
1005
|
},
|
|
994
1006
|
wikilinkHeading(token) {
|
|
995
|
-
const
|
|
996
|
-
|
|
1007
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1008
|
+
node2.heading = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
|
|
997
1009
|
},
|
|
998
1010
|
wikilinkAlias(token) {
|
|
999
|
-
const
|
|
1000
|
-
|
|
1011
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1012
|
+
node2.alias = this.sliceSerialize(token);
|
|
1001
1013
|
}
|
|
1002
1014
|
},
|
|
1003
1015
|
exit: {
|
|
1004
1016
|
wikilink(token) {
|
|
1005
|
-
const
|
|
1006
|
-
if (
|
|
1007
|
-
if (
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1017
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1018
|
+
if (node2.alias) {
|
|
1019
|
+
if (node2.path.endsWith("\\")) node2.path = node2.path.slice(0, -1);
|
|
1020
|
+
if (node2.heading.endsWith("\\"))
|
|
1021
|
+
node2.heading = node2.heading.slice(0, -1);
|
|
1010
1022
|
}
|
|
1011
1023
|
this.exit(token);
|
|
1012
1024
|
}
|
|
@@ -1024,8 +1036,8 @@ function highlightFromMarkdown() {
|
|
|
1024
1036
|
},
|
|
1025
1037
|
exit: {
|
|
1026
1038
|
highlightContent(token) {
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1039
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1040
|
+
node2.children = [{ type: "text", value: this.sliceSerialize(token) }];
|
|
1029
1041
|
},
|
|
1030
1042
|
highlight(token) {
|
|
1031
1043
|
this.exit(token);
|
|
@@ -1044,8 +1056,8 @@ function commentFromMarkdown() {
|
|
|
1044
1056
|
},
|
|
1045
1057
|
exit: {
|
|
1046
1058
|
commentContent(token) {
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1059
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1060
|
+
node2.value += this.sliceSerialize(token);
|
|
1049
1061
|
},
|
|
1050
1062
|
comment(token) {
|
|
1051
1063
|
this.exit(token);
|
|
@@ -1062,8 +1074,8 @@ function tagFromMarkdown() {
|
|
|
1062
1074
|
this.enter({ type: "tag", value: "" }, token);
|
|
1063
1075
|
},
|
|
1064
1076
|
tagContent(token) {
|
|
1065
|
-
const
|
|
1066
|
-
if (
|
|
1077
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1078
|
+
if (node2.type === "tag") node2.value = this.sliceSerialize(token);
|
|
1067
1079
|
}
|
|
1068
1080
|
},
|
|
1069
1081
|
exit: {
|
|
@@ -1078,11 +1090,11 @@ function tagFromMarkdown() {
|
|
|
1078
1090
|
function wikilinkToMarkdown() {
|
|
1079
1091
|
return {
|
|
1080
1092
|
handlers: {
|
|
1081
|
-
wikilink(
|
|
1082
|
-
const prefix =
|
|
1083
|
-
const
|
|
1084
|
-
const alias =
|
|
1085
|
-
return `${prefix}[[${
|
|
1093
|
+
wikilink(node2) {
|
|
1094
|
+
const prefix = node2.embedded ? "!" : "";
|
|
1095
|
+
const heading2 = node2.heading ? `#${node2.heading}` : "";
|
|
1096
|
+
const alias = node2.alias ? `|${node2.alias}` : "";
|
|
1097
|
+
return `${prefix}[[${node2.path}${heading2}${alias}]]`;
|
|
1086
1098
|
}
|
|
1087
1099
|
}
|
|
1088
1100
|
};
|
|
@@ -1092,9 +1104,9 @@ function wikilinkToMarkdown() {
|
|
|
1092
1104
|
function highlightToMarkdown() {
|
|
1093
1105
|
return {
|
|
1094
1106
|
handlers: {
|
|
1095
|
-
highlight(
|
|
1107
|
+
highlight(node2, _parent, state, info) {
|
|
1096
1108
|
const exit = state.enter("highlight");
|
|
1097
|
-
const content = state.containerPhrasing(
|
|
1109
|
+
const content = state.containerPhrasing(node2, info);
|
|
1098
1110
|
exit();
|
|
1099
1111
|
return `==${content}==`;
|
|
1100
1112
|
}
|
|
@@ -1106,8 +1118,8 @@ function highlightToMarkdown() {
|
|
|
1106
1118
|
function commentToMarkdown() {
|
|
1107
1119
|
return {
|
|
1108
1120
|
handlers: {
|
|
1109
|
-
comment(
|
|
1110
|
-
return `%%${
|
|
1121
|
+
comment(node2) {
|
|
1122
|
+
return `%%${node2.value}%%`;
|
|
1111
1123
|
}
|
|
1112
1124
|
}
|
|
1113
1125
|
};
|
|
@@ -1117,8 +1129,8 @@ function commentToMarkdown() {
|
|
|
1117
1129
|
function tagToMarkdown() {
|
|
1118
1130
|
return {
|
|
1119
1131
|
handlers: {
|
|
1120
|
-
tag(
|
|
1121
|
-
return `#${
|
|
1132
|
+
tag(node2) {
|
|
1133
|
+
return `#${node2.value}`;
|
|
1122
1134
|
}
|
|
1123
1135
|
}
|
|
1124
1136
|
};
|
|
@@ -1126,37 +1138,37 @@ function tagToMarkdown() {
|
|
|
1126
1138
|
|
|
1127
1139
|
// src/lib/task-char.ts
|
|
1128
1140
|
function customTaskCharTransform(tree, source) {
|
|
1129
|
-
visit(tree, "listItem", (
|
|
1130
|
-
if (typeof
|
|
1131
|
-
let char =
|
|
1132
|
-
if (source &&
|
|
1141
|
+
visit(tree, "listItem", (node2) => {
|
|
1142
|
+
if (typeof node2.checked === "boolean") {
|
|
1143
|
+
let char = node2.checked ? "x" : " ";
|
|
1144
|
+
if (source && node2.position?.start?.offset != null) {
|
|
1133
1145
|
const slice = source.slice(
|
|
1134
|
-
|
|
1135
|
-
|
|
1146
|
+
node2.position.start.offset,
|
|
1147
|
+
node2.position.start.offset + 20
|
|
1136
1148
|
);
|
|
1137
1149
|
const m = slice.match(/\[([^\]])\]/);
|
|
1138
1150
|
if (m) {
|
|
1139
1151
|
char = m[1];
|
|
1140
1152
|
}
|
|
1141
1153
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1154
|
+
node2.data ??= {};
|
|
1155
|
+
node2.data.taskChar = char;
|
|
1156
|
+
node2.data.hProperties ??= {};
|
|
1157
|
+
node2.data.hProperties.dataTaskChar = char;
|
|
1146
1158
|
return;
|
|
1147
1159
|
}
|
|
1148
|
-
const firstChild =
|
|
1160
|
+
const firstChild = node2.children?.[0];
|
|
1149
1161
|
if (!firstChild || firstChild.type !== "paragraph") return;
|
|
1150
1162
|
const firstText = firstChild.children?.[0];
|
|
1151
1163
|
if (!firstText || firstText.type !== "text") return;
|
|
1152
1164
|
const match = firstText.value.match(/^\[([^\]])\]\s/);
|
|
1153
1165
|
if (!match) return;
|
|
1154
1166
|
const taskChar = match[1];
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1167
|
+
node2.checked = taskChar !== " ";
|
|
1168
|
+
node2.data ??= {};
|
|
1169
|
+
node2.data.taskChar = taskChar;
|
|
1170
|
+
node2.data.hProperties ??= {};
|
|
1171
|
+
node2.data.hProperties.dataTaskChar = taskChar;
|
|
1160
1172
|
firstText.value = firstText.value.slice(match[0].length);
|
|
1161
1173
|
if (firstText.value.length === 0) {
|
|
1162
1174
|
firstChild.children.shift();
|
|
@@ -1167,6 +1179,234 @@ function customTaskCharTransform(tree, source) {
|
|
|
1167
1179
|
});
|
|
1168
1180
|
}
|
|
1169
1181
|
|
|
1182
|
+
// node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
|
|
1183
|
+
function blockquote(node2, _, state, info) {
|
|
1184
|
+
const exit = state.enter("blockquote");
|
|
1185
|
+
const tracker = state.createTracker(info);
|
|
1186
|
+
tracker.move("> ");
|
|
1187
|
+
tracker.shift(2);
|
|
1188
|
+
const value = state.indentLines(
|
|
1189
|
+
state.containerFlow(node2, tracker.current()),
|
|
1190
|
+
map
|
|
1191
|
+
);
|
|
1192
|
+
exit();
|
|
1193
|
+
return value;
|
|
1194
|
+
}
|
|
1195
|
+
function map(line, _, blank) {
|
|
1196
|
+
return ">" + (blank ? "" : " ") + line;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js
|
|
1200
|
+
function patternInScope(stack, pattern) {
|
|
1201
|
+
return listInScope(stack, pattern.inConstruct, true) && !listInScope(stack, pattern.notInConstruct, false);
|
|
1202
|
+
}
|
|
1203
|
+
function listInScope(stack, list2, none) {
|
|
1204
|
+
if (typeof list2 === "string") {
|
|
1205
|
+
list2 = [list2];
|
|
1206
|
+
}
|
|
1207
|
+
if (!list2 || list2.length === 0) {
|
|
1208
|
+
return none;
|
|
1209
|
+
}
|
|
1210
|
+
let index = -1;
|
|
1211
|
+
while (++index < list2.length) {
|
|
1212
|
+
if (stack.includes(list2[index])) {
|
|
1213
|
+
return true;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return false;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// node_modules/mdast-util-to-markdown/lib/handle/break.js
|
|
1220
|
+
function hardBreak(_, _1, state, info) {
|
|
1221
|
+
let index = -1;
|
|
1222
|
+
while (++index < state.unsafe.length) {
|
|
1223
|
+
if (state.unsafe[index].character === "\n" && patternInScope(state.stack, state.unsafe[index])) {
|
|
1224
|
+
return /[ \t]/.test(info.before) ? "" : " ";
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
return "\\\n";
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// node_modules/longest-streak/index.js
|
|
1231
|
+
function longestStreak(value, substring) {
|
|
1232
|
+
const source = String(value);
|
|
1233
|
+
let index = source.indexOf(substring);
|
|
1234
|
+
let expected = index;
|
|
1235
|
+
let count = 0;
|
|
1236
|
+
let max = 0;
|
|
1237
|
+
if (typeof substring !== "string") {
|
|
1238
|
+
throw new TypeError("Expected substring");
|
|
1239
|
+
}
|
|
1240
|
+
while (index !== -1) {
|
|
1241
|
+
if (index === expected) {
|
|
1242
|
+
if (++count > max) {
|
|
1243
|
+
max = count;
|
|
1244
|
+
}
|
|
1245
|
+
} else {
|
|
1246
|
+
count = 1;
|
|
1247
|
+
}
|
|
1248
|
+
expected = index + substring.length;
|
|
1249
|
+
index = source.indexOf(substring, expected);
|
|
1250
|
+
}
|
|
1251
|
+
return max;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js
|
|
1255
|
+
function formatCodeAsIndented(node2, state) {
|
|
1256
|
+
return Boolean(
|
|
1257
|
+
state.options.fences === false && node2.value && // If there’s no info…
|
|
1258
|
+
!node2.lang && // And there’s a non-whitespace character…
|
|
1259
|
+
/[^ \r\n]/.test(node2.value) && // And the value doesn’t start or end in a blank…
|
|
1260
|
+
!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node2.value)
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-fence.js
|
|
1265
|
+
function checkFence(state) {
|
|
1266
|
+
const marker = state.options.fence || "`";
|
|
1267
|
+
if (marker !== "`" && marker !== "~") {
|
|
1268
|
+
throw new Error(
|
|
1269
|
+
"Cannot serialize code with `" + marker + "` for `options.fence`, expected `` ` `` or `~`"
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
return marker;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
// node_modules/mdast-util-to-markdown/lib/handle/code.js
|
|
1276
|
+
function code(node2, _, state, info) {
|
|
1277
|
+
const marker = checkFence(state);
|
|
1278
|
+
const raw = node2.value || "";
|
|
1279
|
+
const suffix = marker === "`" ? "GraveAccent" : "Tilde";
|
|
1280
|
+
if (formatCodeAsIndented(node2, state)) {
|
|
1281
|
+
const exit2 = state.enter("codeIndented");
|
|
1282
|
+
const value2 = state.indentLines(raw, map2);
|
|
1283
|
+
exit2();
|
|
1284
|
+
return value2;
|
|
1285
|
+
}
|
|
1286
|
+
const tracker = state.createTracker(info);
|
|
1287
|
+
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
|
|
1288
|
+
const exit = state.enter("codeFenced");
|
|
1289
|
+
let value = tracker.move(sequence);
|
|
1290
|
+
if (node2.lang) {
|
|
1291
|
+
const subexit = state.enter(`codeFencedLang${suffix}`);
|
|
1292
|
+
value += tracker.move(
|
|
1293
|
+
state.safe(node2.lang, {
|
|
1294
|
+
before: value,
|
|
1295
|
+
after: " ",
|
|
1296
|
+
encode: ["`"],
|
|
1297
|
+
...tracker.current()
|
|
1298
|
+
})
|
|
1299
|
+
);
|
|
1300
|
+
subexit();
|
|
1301
|
+
}
|
|
1302
|
+
if (node2.lang && node2.meta) {
|
|
1303
|
+
const subexit = state.enter(`codeFencedMeta${suffix}`);
|
|
1304
|
+
value += tracker.move(" ");
|
|
1305
|
+
value += tracker.move(
|
|
1306
|
+
state.safe(node2.meta, {
|
|
1307
|
+
before: value,
|
|
1308
|
+
after: "\n",
|
|
1309
|
+
encode: ["`"],
|
|
1310
|
+
...tracker.current()
|
|
1311
|
+
})
|
|
1312
|
+
);
|
|
1313
|
+
subexit();
|
|
1314
|
+
}
|
|
1315
|
+
value += tracker.move("\n");
|
|
1316
|
+
if (raw) {
|
|
1317
|
+
value += tracker.move(raw + "\n");
|
|
1318
|
+
}
|
|
1319
|
+
value += tracker.move(sequence);
|
|
1320
|
+
exit();
|
|
1321
|
+
return value;
|
|
1322
|
+
}
|
|
1323
|
+
function map2(line, _, blank) {
|
|
1324
|
+
return (blank ? "" : " ") + line;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-quote.js
|
|
1328
|
+
function checkQuote(state) {
|
|
1329
|
+
const marker = state.options.quote || '"';
|
|
1330
|
+
if (marker !== '"' && marker !== "'") {
|
|
1331
|
+
throw new Error(
|
|
1332
|
+
"Cannot serialize title with `" + marker + "` for `options.quote`, expected `\"`, or `'`"
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1335
|
+
return marker;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// node_modules/mdast-util-to-markdown/lib/handle/definition.js
|
|
1339
|
+
function definition(node2, _, state, info) {
|
|
1340
|
+
const quote = checkQuote(state);
|
|
1341
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1342
|
+
const exit = state.enter("definition");
|
|
1343
|
+
let subexit = state.enter("label");
|
|
1344
|
+
const tracker = state.createTracker(info);
|
|
1345
|
+
let value = tracker.move("[");
|
|
1346
|
+
value += tracker.move(
|
|
1347
|
+
state.safe(state.associationId(node2), {
|
|
1348
|
+
before: value,
|
|
1349
|
+
after: "]",
|
|
1350
|
+
...tracker.current()
|
|
1351
|
+
})
|
|
1352
|
+
);
|
|
1353
|
+
value += tracker.move("]: ");
|
|
1354
|
+
subexit();
|
|
1355
|
+
if (
|
|
1356
|
+
// If there’s no url, or…
|
|
1357
|
+
!node2.url || // If there are control characters or whitespace.
|
|
1358
|
+
/[\0- \u007F]/.test(node2.url)
|
|
1359
|
+
) {
|
|
1360
|
+
subexit = state.enter("destinationLiteral");
|
|
1361
|
+
value += tracker.move("<");
|
|
1362
|
+
value += tracker.move(
|
|
1363
|
+
state.safe(node2.url, { before: value, after: ">", ...tracker.current() })
|
|
1364
|
+
);
|
|
1365
|
+
value += tracker.move(">");
|
|
1366
|
+
} else {
|
|
1367
|
+
subexit = state.enter("destinationRaw");
|
|
1368
|
+
value += tracker.move(
|
|
1369
|
+
state.safe(node2.url, {
|
|
1370
|
+
before: value,
|
|
1371
|
+
after: node2.title ? " " : "\n",
|
|
1372
|
+
...tracker.current()
|
|
1373
|
+
})
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
subexit();
|
|
1377
|
+
if (node2.title) {
|
|
1378
|
+
subexit = state.enter(`title${suffix}`);
|
|
1379
|
+
value += tracker.move(" " + quote);
|
|
1380
|
+
value += tracker.move(
|
|
1381
|
+
state.safe(node2.title, {
|
|
1382
|
+
before: value,
|
|
1383
|
+
after: quote,
|
|
1384
|
+
...tracker.current()
|
|
1385
|
+
})
|
|
1386
|
+
);
|
|
1387
|
+
value += tracker.move(quote);
|
|
1388
|
+
subexit();
|
|
1389
|
+
}
|
|
1390
|
+
exit();
|
|
1391
|
+
return value;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js
|
|
1395
|
+
function checkEmphasis(state) {
|
|
1396
|
+
const marker = state.options.emphasis || "*";
|
|
1397
|
+
if (marker !== "*" && marker !== "_") {
|
|
1398
|
+
throw new Error(
|
|
1399
|
+
"Cannot serialize emphasis with `" + marker + "` for `options.emphasis`, expected `*`, or `_`"
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1402
|
+
return marker;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
1406
|
+
function encodeCharacterReference(code2) {
|
|
1407
|
+
return "&#x" + code2.toString(16).toUpperCase() + ";";
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1170
1410
|
// node_modules/micromark-util-character/index.js
|
|
1171
1411
|
var asciiAlpha = regexCheck(/[A-Za-z]/);
|
|
1172
1412
|
var asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
|
|
@@ -1174,19 +1414,786 @@ var asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
|
|
1174
1414
|
var asciiDigit = regexCheck(/\d/);
|
|
1175
1415
|
var asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
|
|
1176
1416
|
var asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
|
|
1177
|
-
function markdownLineEnding(
|
|
1178
|
-
return
|
|
1417
|
+
function markdownLineEnding(code2) {
|
|
1418
|
+
return code2 !== null && code2 < -2;
|
|
1179
1419
|
}
|
|
1180
|
-
function
|
|
1181
|
-
return
|
|
1420
|
+
function markdownLineEndingOrSpace(code2) {
|
|
1421
|
+
return code2 !== null && (code2 < 0 || code2 === 32);
|
|
1422
|
+
}
|
|
1423
|
+
function markdownSpace(code2) {
|
|
1424
|
+
return code2 === -2 || code2 === -1 || code2 === 32;
|
|
1182
1425
|
}
|
|
1183
1426
|
var unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
1184
1427
|
var unicodeWhitespace = regexCheck(/\s/);
|
|
1185
1428
|
function regexCheck(regex) {
|
|
1186
1429
|
return check;
|
|
1187
|
-
function check(
|
|
1188
|
-
return
|
|
1430
|
+
function check(code2) {
|
|
1431
|
+
return code2 !== null && code2 > -1 && regex.test(String.fromCharCode(code2));
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
// node_modules/micromark-util-classify-character/index.js
|
|
1436
|
+
function classifyCharacter(code2) {
|
|
1437
|
+
if (code2 === null || markdownLineEndingOrSpace(code2) || unicodeWhitespace(code2)) {
|
|
1438
|
+
return 1;
|
|
1439
|
+
}
|
|
1440
|
+
if (unicodePunctuation(code2)) {
|
|
1441
|
+
return 2;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
1446
|
+
function encodeInfo(outside, inside, marker) {
|
|
1447
|
+
const outsideKind = classifyCharacter(outside);
|
|
1448
|
+
const insideKind = classifyCharacter(inside);
|
|
1449
|
+
if (outsideKind === void 0) {
|
|
1450
|
+
return insideKind === void 0 ? (
|
|
1451
|
+
// Letter inside:
|
|
1452
|
+
// we have to encode *both* letters for `_` as it is looser.
|
|
1453
|
+
// it already forms for `*` (and GFMs `~`).
|
|
1454
|
+
marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false }
|
|
1455
|
+
) : insideKind === 1 ? (
|
|
1456
|
+
// Whitespace inside: encode both (letter, whitespace).
|
|
1457
|
+
{ inside: true, outside: true }
|
|
1458
|
+
) : (
|
|
1459
|
+
// Punctuation inside: encode outer (letter)
|
|
1460
|
+
{ inside: false, outside: true }
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
if (outsideKind === 1) {
|
|
1464
|
+
return insideKind === void 0 ? (
|
|
1465
|
+
// Letter inside: already forms.
|
|
1466
|
+
{ inside: false, outside: false }
|
|
1467
|
+
) : insideKind === 1 ? (
|
|
1468
|
+
// Whitespace inside: encode both (whitespace).
|
|
1469
|
+
{ inside: true, outside: true }
|
|
1470
|
+
) : (
|
|
1471
|
+
// Punctuation inside: already forms.
|
|
1472
|
+
{ inside: false, outside: false }
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
return insideKind === void 0 ? (
|
|
1476
|
+
// Letter inside: already forms.
|
|
1477
|
+
{ inside: false, outside: false }
|
|
1478
|
+
) : insideKind === 1 ? (
|
|
1479
|
+
// Whitespace inside: encode inner (whitespace).
|
|
1480
|
+
{ inside: true, outside: false }
|
|
1481
|
+
) : (
|
|
1482
|
+
// Punctuation inside: already forms.
|
|
1483
|
+
{ inside: false, outside: false }
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
1488
|
+
emphasis.peek = emphasisPeek;
|
|
1489
|
+
function emphasis(node2, _, state, info) {
|
|
1490
|
+
const marker = checkEmphasis(state);
|
|
1491
|
+
const exit = state.enter("emphasis");
|
|
1492
|
+
const tracker = state.createTracker(info);
|
|
1493
|
+
const before = tracker.move(marker);
|
|
1494
|
+
let between = tracker.move(
|
|
1495
|
+
state.containerPhrasing(node2, {
|
|
1496
|
+
after: marker,
|
|
1497
|
+
before,
|
|
1498
|
+
...tracker.current()
|
|
1499
|
+
})
|
|
1500
|
+
);
|
|
1501
|
+
const betweenHead = between.charCodeAt(0);
|
|
1502
|
+
const open = encodeInfo(
|
|
1503
|
+
info.before.charCodeAt(info.before.length - 1),
|
|
1504
|
+
betweenHead,
|
|
1505
|
+
marker
|
|
1506
|
+
);
|
|
1507
|
+
if (open.inside) {
|
|
1508
|
+
between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
1509
|
+
}
|
|
1510
|
+
const betweenTail = between.charCodeAt(between.length - 1);
|
|
1511
|
+
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
1512
|
+
if (close.inside) {
|
|
1513
|
+
between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
1514
|
+
}
|
|
1515
|
+
const after = tracker.move(marker);
|
|
1516
|
+
exit();
|
|
1517
|
+
state.attentionEncodeSurroundingInfo = {
|
|
1518
|
+
after: close.outside,
|
|
1519
|
+
before: open.outside
|
|
1520
|
+
};
|
|
1521
|
+
return before + between + after;
|
|
1522
|
+
}
|
|
1523
|
+
function emphasisPeek(_, _1, state) {
|
|
1524
|
+
return state.options.emphasis || "*";
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// node_modules/mdast-util-to-string/lib/index.js
|
|
1528
|
+
var emptyOptions = {};
|
|
1529
|
+
function toString(value, options) {
|
|
1530
|
+
const settings = options || emptyOptions;
|
|
1531
|
+
const includeImageAlt = typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true;
|
|
1532
|
+
const includeHtml = typeof settings.includeHtml === "boolean" ? settings.includeHtml : true;
|
|
1533
|
+
return one(value, includeImageAlt, includeHtml);
|
|
1534
|
+
}
|
|
1535
|
+
function one(value, includeImageAlt, includeHtml) {
|
|
1536
|
+
if (node(value)) {
|
|
1537
|
+
if ("value" in value) {
|
|
1538
|
+
return value.type === "html" && !includeHtml ? "" : value.value;
|
|
1539
|
+
}
|
|
1540
|
+
if (includeImageAlt && "alt" in value && value.alt) {
|
|
1541
|
+
return value.alt;
|
|
1542
|
+
}
|
|
1543
|
+
if ("children" in value) {
|
|
1544
|
+
return all(value.children, includeImageAlt, includeHtml);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (Array.isArray(value)) {
|
|
1548
|
+
return all(value, includeImageAlt, includeHtml);
|
|
1549
|
+
}
|
|
1550
|
+
return "";
|
|
1551
|
+
}
|
|
1552
|
+
function all(values, includeImageAlt, includeHtml) {
|
|
1553
|
+
const result = [];
|
|
1554
|
+
let index = -1;
|
|
1555
|
+
while (++index < values.length) {
|
|
1556
|
+
result[index] = one(values[index], includeImageAlt, includeHtml);
|
|
1557
|
+
}
|
|
1558
|
+
return result.join("");
|
|
1559
|
+
}
|
|
1560
|
+
function node(value) {
|
|
1561
|
+
return Boolean(value && typeof value === "object");
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
1565
|
+
function formatHeadingAsSetext(node2, state) {
|
|
1566
|
+
let literalWithBreak = false;
|
|
1567
|
+
visit(node2, function(node3) {
|
|
1568
|
+
if ("value" in node3 && /\r?\n|\r/.test(node3.value) || node3.type === "break") {
|
|
1569
|
+
literalWithBreak = true;
|
|
1570
|
+
return EXIT;
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
return Boolean(
|
|
1574
|
+
(!node2.depth || node2.depth < 3) && toString(node2) && (state.options.setext || literalWithBreak)
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
// node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
1579
|
+
function heading(node2, _, state, info) {
|
|
1580
|
+
const rank = Math.max(Math.min(6, node2.depth || 1), 1);
|
|
1581
|
+
const tracker = state.createTracker(info);
|
|
1582
|
+
if (formatHeadingAsSetext(node2, state)) {
|
|
1583
|
+
const exit2 = state.enter("headingSetext");
|
|
1584
|
+
const subexit2 = state.enter("phrasing");
|
|
1585
|
+
const value2 = state.containerPhrasing(node2, {
|
|
1586
|
+
...tracker.current(),
|
|
1587
|
+
before: "\n",
|
|
1588
|
+
after: "\n"
|
|
1589
|
+
});
|
|
1590
|
+
subexit2();
|
|
1591
|
+
exit2();
|
|
1592
|
+
return value2 + "\n" + (rank === 1 ? "=" : "-").repeat(
|
|
1593
|
+
// The whole size…
|
|
1594
|
+
value2.length - // Minus the position of the character after the last EOL (or
|
|
1595
|
+
// 0 if there is none)…
|
|
1596
|
+
(Math.max(value2.lastIndexOf("\r"), value2.lastIndexOf("\n")) + 1)
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
const sequence = "#".repeat(rank);
|
|
1600
|
+
const exit = state.enter("headingAtx");
|
|
1601
|
+
const subexit = state.enter("phrasing");
|
|
1602
|
+
tracker.move(sequence + " ");
|
|
1603
|
+
let value = state.containerPhrasing(node2, {
|
|
1604
|
+
before: "# ",
|
|
1605
|
+
after: "\n",
|
|
1606
|
+
...tracker.current()
|
|
1607
|
+
});
|
|
1608
|
+
if (/^[\t ]/.test(value)) {
|
|
1609
|
+
value = encodeCharacterReference(value.charCodeAt(0)) + value.slice(1);
|
|
1610
|
+
}
|
|
1611
|
+
value = value ? sequence + " " + value : sequence;
|
|
1612
|
+
if (state.options.closeAtx) {
|
|
1613
|
+
value += " " + sequence;
|
|
1614
|
+
}
|
|
1615
|
+
subexit();
|
|
1616
|
+
exit();
|
|
1617
|
+
return value;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// node_modules/mdast-util-to-markdown/lib/handle/html.js
|
|
1621
|
+
html.peek = htmlPeek;
|
|
1622
|
+
function html(node2) {
|
|
1623
|
+
return node2.value || "";
|
|
1624
|
+
}
|
|
1625
|
+
function htmlPeek() {
|
|
1626
|
+
return "<";
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// node_modules/mdast-util-to-markdown/lib/handle/image.js
|
|
1630
|
+
image.peek = imagePeek;
|
|
1631
|
+
function image(node2, _, state, info) {
|
|
1632
|
+
const quote = checkQuote(state);
|
|
1633
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1634
|
+
const exit = state.enter("image");
|
|
1635
|
+
let subexit = state.enter("label");
|
|
1636
|
+
const tracker = state.createTracker(info);
|
|
1637
|
+
let value = tracker.move("![");
|
|
1638
|
+
value += tracker.move(
|
|
1639
|
+
state.safe(node2.alt, { before: value, after: "]", ...tracker.current() })
|
|
1640
|
+
);
|
|
1641
|
+
value += tracker.move("](");
|
|
1642
|
+
subexit();
|
|
1643
|
+
if (
|
|
1644
|
+
// If there’s no url but there is a title…
|
|
1645
|
+
!node2.url && node2.title || // If there are control characters or whitespace.
|
|
1646
|
+
/[\0- \u007F]/.test(node2.url)
|
|
1647
|
+
) {
|
|
1648
|
+
subexit = state.enter("destinationLiteral");
|
|
1649
|
+
value += tracker.move("<");
|
|
1650
|
+
value += tracker.move(
|
|
1651
|
+
state.safe(node2.url, { before: value, after: ">", ...tracker.current() })
|
|
1652
|
+
);
|
|
1653
|
+
value += tracker.move(">");
|
|
1654
|
+
} else {
|
|
1655
|
+
subexit = state.enter("destinationRaw");
|
|
1656
|
+
value += tracker.move(
|
|
1657
|
+
state.safe(node2.url, {
|
|
1658
|
+
before: value,
|
|
1659
|
+
after: node2.title ? " " : ")",
|
|
1660
|
+
...tracker.current()
|
|
1661
|
+
})
|
|
1662
|
+
);
|
|
1663
|
+
}
|
|
1664
|
+
subexit();
|
|
1665
|
+
if (node2.title) {
|
|
1666
|
+
subexit = state.enter(`title${suffix}`);
|
|
1667
|
+
value += tracker.move(" " + quote);
|
|
1668
|
+
value += tracker.move(
|
|
1669
|
+
state.safe(node2.title, {
|
|
1670
|
+
before: value,
|
|
1671
|
+
after: quote,
|
|
1672
|
+
...tracker.current()
|
|
1673
|
+
})
|
|
1674
|
+
);
|
|
1675
|
+
value += tracker.move(quote);
|
|
1676
|
+
subexit();
|
|
1189
1677
|
}
|
|
1678
|
+
value += tracker.move(")");
|
|
1679
|
+
exit();
|
|
1680
|
+
return value;
|
|
1681
|
+
}
|
|
1682
|
+
function imagePeek() {
|
|
1683
|
+
return "!";
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
|
|
1687
|
+
imageReference.peek = imageReferencePeek;
|
|
1688
|
+
function imageReference(node2, _, state, info) {
|
|
1689
|
+
const type = node2.referenceType;
|
|
1690
|
+
const exit = state.enter("imageReference");
|
|
1691
|
+
let subexit = state.enter("label");
|
|
1692
|
+
const tracker = state.createTracker(info);
|
|
1693
|
+
let value = tracker.move("![");
|
|
1694
|
+
const alt = state.safe(node2.alt, {
|
|
1695
|
+
before: value,
|
|
1696
|
+
after: "]",
|
|
1697
|
+
...tracker.current()
|
|
1698
|
+
});
|
|
1699
|
+
value += tracker.move(alt + "][");
|
|
1700
|
+
subexit();
|
|
1701
|
+
const stack = state.stack;
|
|
1702
|
+
state.stack = [];
|
|
1703
|
+
subexit = state.enter("reference");
|
|
1704
|
+
const reference = state.safe(state.associationId(node2), {
|
|
1705
|
+
before: value,
|
|
1706
|
+
after: "]",
|
|
1707
|
+
...tracker.current()
|
|
1708
|
+
});
|
|
1709
|
+
subexit();
|
|
1710
|
+
state.stack = stack;
|
|
1711
|
+
exit();
|
|
1712
|
+
if (type === "full" || !alt || alt !== reference) {
|
|
1713
|
+
value += tracker.move(reference + "]");
|
|
1714
|
+
} else if (type === "shortcut") {
|
|
1715
|
+
value = value.slice(0, -1);
|
|
1716
|
+
} else {
|
|
1717
|
+
value += tracker.move("]");
|
|
1718
|
+
}
|
|
1719
|
+
return value;
|
|
1720
|
+
}
|
|
1721
|
+
function imageReferencePeek() {
|
|
1722
|
+
return "!";
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
|
|
1726
|
+
inlineCode.peek = inlineCodePeek;
|
|
1727
|
+
function inlineCode(node2, _, state) {
|
|
1728
|
+
let value = node2.value || "";
|
|
1729
|
+
let sequence = "`";
|
|
1730
|
+
let index = -1;
|
|
1731
|
+
while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) {
|
|
1732
|
+
sequence += "`";
|
|
1733
|
+
}
|
|
1734
|
+
if (/[^ \r\n]/.test(value) && (/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value) || /^`|`$/.test(value))) {
|
|
1735
|
+
value = " " + value + " ";
|
|
1736
|
+
}
|
|
1737
|
+
while (++index < state.unsafe.length) {
|
|
1738
|
+
const pattern = state.unsafe[index];
|
|
1739
|
+
const expression = state.compilePattern(pattern);
|
|
1740
|
+
let match;
|
|
1741
|
+
if (!pattern.atBreak) continue;
|
|
1742
|
+
while (match = expression.exec(value)) {
|
|
1743
|
+
let position = match.index;
|
|
1744
|
+
if (value.charCodeAt(position) === 10 && value.charCodeAt(position - 1) === 13) {
|
|
1745
|
+
position--;
|
|
1746
|
+
}
|
|
1747
|
+
value = value.slice(0, position) + " " + value.slice(match.index + 1);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return sequence + value + sequence;
|
|
1751
|
+
}
|
|
1752
|
+
function inlineCodePeek() {
|
|
1753
|
+
return "`";
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
// node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
|
|
1757
|
+
function formatLinkAsAutolink(node2, state) {
|
|
1758
|
+
const raw = toString(node2);
|
|
1759
|
+
return Boolean(
|
|
1760
|
+
!state.options.resourceLink && // If there’s a url…
|
|
1761
|
+
node2.url && // And there’s a no title…
|
|
1762
|
+
!node2.title && // And the content of `node` is a single text node…
|
|
1763
|
+
node2.children && node2.children.length === 1 && node2.children[0].type === "text" && // And if the url is the same as the content…
|
|
1764
|
+
(raw === node2.url || "mailto:" + raw === node2.url) && // And that starts w/ a protocol…
|
|
1765
|
+
/^[a-z][a-z+.-]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
|
|
1766
|
+
// references don’t work), space, or angle brackets…
|
|
1767
|
+
!/[\0- <>\u007F]/.test(node2.url)
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
// node_modules/mdast-util-to-markdown/lib/handle/link.js
|
|
1772
|
+
link.peek = linkPeek;
|
|
1773
|
+
function link(node2, _, state, info) {
|
|
1774
|
+
const quote = checkQuote(state);
|
|
1775
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1776
|
+
const tracker = state.createTracker(info);
|
|
1777
|
+
let exit;
|
|
1778
|
+
let subexit;
|
|
1779
|
+
if (formatLinkAsAutolink(node2, state)) {
|
|
1780
|
+
const stack = state.stack;
|
|
1781
|
+
state.stack = [];
|
|
1782
|
+
exit = state.enter("autolink");
|
|
1783
|
+
let value2 = tracker.move("<");
|
|
1784
|
+
value2 += tracker.move(
|
|
1785
|
+
state.containerPhrasing(node2, {
|
|
1786
|
+
before: value2,
|
|
1787
|
+
after: ">",
|
|
1788
|
+
...tracker.current()
|
|
1789
|
+
})
|
|
1790
|
+
);
|
|
1791
|
+
value2 += tracker.move(">");
|
|
1792
|
+
exit();
|
|
1793
|
+
state.stack = stack;
|
|
1794
|
+
return value2;
|
|
1795
|
+
}
|
|
1796
|
+
exit = state.enter("link");
|
|
1797
|
+
subexit = state.enter("label");
|
|
1798
|
+
let value = tracker.move("[");
|
|
1799
|
+
value += tracker.move(
|
|
1800
|
+
state.containerPhrasing(node2, {
|
|
1801
|
+
before: value,
|
|
1802
|
+
after: "](",
|
|
1803
|
+
...tracker.current()
|
|
1804
|
+
})
|
|
1805
|
+
);
|
|
1806
|
+
value += tracker.move("](");
|
|
1807
|
+
subexit();
|
|
1808
|
+
if (
|
|
1809
|
+
// If there’s no url but there is a title…
|
|
1810
|
+
!node2.url && node2.title || // If there are control characters or whitespace.
|
|
1811
|
+
/[\0- \u007F]/.test(node2.url)
|
|
1812
|
+
) {
|
|
1813
|
+
subexit = state.enter("destinationLiteral");
|
|
1814
|
+
value += tracker.move("<");
|
|
1815
|
+
value += tracker.move(
|
|
1816
|
+
state.safe(node2.url, { before: value, after: ">", ...tracker.current() })
|
|
1817
|
+
);
|
|
1818
|
+
value += tracker.move(">");
|
|
1819
|
+
} else {
|
|
1820
|
+
subexit = state.enter("destinationRaw");
|
|
1821
|
+
value += tracker.move(
|
|
1822
|
+
state.safe(node2.url, {
|
|
1823
|
+
before: value,
|
|
1824
|
+
after: node2.title ? " " : ")",
|
|
1825
|
+
...tracker.current()
|
|
1826
|
+
})
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
subexit();
|
|
1830
|
+
if (node2.title) {
|
|
1831
|
+
subexit = state.enter(`title${suffix}`);
|
|
1832
|
+
value += tracker.move(" " + quote);
|
|
1833
|
+
value += tracker.move(
|
|
1834
|
+
state.safe(node2.title, {
|
|
1835
|
+
before: value,
|
|
1836
|
+
after: quote,
|
|
1837
|
+
...tracker.current()
|
|
1838
|
+
})
|
|
1839
|
+
);
|
|
1840
|
+
value += tracker.move(quote);
|
|
1841
|
+
subexit();
|
|
1842
|
+
}
|
|
1843
|
+
value += tracker.move(")");
|
|
1844
|
+
exit();
|
|
1845
|
+
return value;
|
|
1846
|
+
}
|
|
1847
|
+
function linkPeek(node2, _, state) {
|
|
1848
|
+
return formatLinkAsAutolink(node2, state) ? "<" : "[";
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
|
|
1852
|
+
linkReference.peek = linkReferencePeek;
|
|
1853
|
+
function linkReference(node2, _, state, info) {
|
|
1854
|
+
const type = node2.referenceType;
|
|
1855
|
+
const exit = state.enter("linkReference");
|
|
1856
|
+
let subexit = state.enter("label");
|
|
1857
|
+
const tracker = state.createTracker(info);
|
|
1858
|
+
let value = tracker.move("[");
|
|
1859
|
+
const text2 = state.containerPhrasing(node2, {
|
|
1860
|
+
before: value,
|
|
1861
|
+
after: "]",
|
|
1862
|
+
...tracker.current()
|
|
1863
|
+
});
|
|
1864
|
+
value += tracker.move(text2 + "][");
|
|
1865
|
+
subexit();
|
|
1866
|
+
const stack = state.stack;
|
|
1867
|
+
state.stack = [];
|
|
1868
|
+
subexit = state.enter("reference");
|
|
1869
|
+
const reference = state.safe(state.associationId(node2), {
|
|
1870
|
+
before: value,
|
|
1871
|
+
after: "]",
|
|
1872
|
+
...tracker.current()
|
|
1873
|
+
});
|
|
1874
|
+
subexit();
|
|
1875
|
+
state.stack = stack;
|
|
1876
|
+
exit();
|
|
1877
|
+
if (type === "full" || !text2 || text2 !== reference) {
|
|
1878
|
+
value += tracker.move(reference + "]");
|
|
1879
|
+
} else if (type === "shortcut") {
|
|
1880
|
+
value = value.slice(0, -1);
|
|
1881
|
+
} else {
|
|
1882
|
+
value += tracker.move("]");
|
|
1883
|
+
}
|
|
1884
|
+
return value;
|
|
1885
|
+
}
|
|
1886
|
+
function linkReferencePeek() {
|
|
1887
|
+
return "[";
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
|
|
1891
|
+
function checkBullet(state) {
|
|
1892
|
+
const marker = state.options.bullet || "*";
|
|
1893
|
+
if (marker !== "*" && marker !== "+" && marker !== "-") {
|
|
1894
|
+
throw new Error(
|
|
1895
|
+
"Cannot serialize items with `" + marker + "` for `options.bullet`, expected `*`, `+`, or `-`"
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
return marker;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
|
|
1902
|
+
function checkBulletOther(state) {
|
|
1903
|
+
const bullet = checkBullet(state);
|
|
1904
|
+
const bulletOther = state.options.bulletOther;
|
|
1905
|
+
if (!bulletOther) {
|
|
1906
|
+
return bullet === "*" ? "-" : "*";
|
|
1907
|
+
}
|
|
1908
|
+
if (bulletOther !== "*" && bulletOther !== "+" && bulletOther !== "-") {
|
|
1909
|
+
throw new Error(
|
|
1910
|
+
"Cannot serialize items with `" + bulletOther + "` for `options.bulletOther`, expected `*`, `+`, or `-`"
|
|
1911
|
+
);
|
|
1912
|
+
}
|
|
1913
|
+
if (bulletOther === bullet) {
|
|
1914
|
+
throw new Error(
|
|
1915
|
+
"Expected `bullet` (`" + bullet + "`) and `bulletOther` (`" + bulletOther + "`) to be different"
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
return bulletOther;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
|
|
1922
|
+
function checkBulletOrdered(state) {
|
|
1923
|
+
const marker = state.options.bulletOrdered || ".";
|
|
1924
|
+
if (marker !== "." && marker !== ")") {
|
|
1925
|
+
throw new Error(
|
|
1926
|
+
"Cannot serialize items with `" + marker + "` for `options.bulletOrdered`, expected `.` or `)`"
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
return marker;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-rule.js
|
|
1933
|
+
function checkRule(state) {
|
|
1934
|
+
const marker = state.options.rule || "*";
|
|
1935
|
+
if (marker !== "*" && marker !== "-" && marker !== "_") {
|
|
1936
|
+
throw new Error(
|
|
1937
|
+
"Cannot serialize rules with `" + marker + "` for `options.rule`, expected `*`, `-`, or `_`"
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
return marker;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
// node_modules/mdast-util-to-markdown/lib/handle/list.js
|
|
1944
|
+
function list(node2, parent, state, info) {
|
|
1945
|
+
const exit = state.enter("list");
|
|
1946
|
+
const bulletCurrent = state.bulletCurrent;
|
|
1947
|
+
let bullet = node2.ordered ? checkBulletOrdered(state) : checkBullet(state);
|
|
1948
|
+
const bulletOther = node2.ordered ? bullet === "." ? ")" : "." : checkBulletOther(state);
|
|
1949
|
+
let useDifferentMarker = parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false;
|
|
1950
|
+
if (!node2.ordered) {
|
|
1951
|
+
const firstListItem = node2.children ? node2.children[0] : void 0;
|
|
1952
|
+
if (
|
|
1953
|
+
// Bullet could be used as a thematic break marker:
|
|
1954
|
+
(bullet === "*" || bullet === "-") && // Empty first list item:
|
|
1955
|
+
firstListItem && (!firstListItem.children || !firstListItem.children[0]) && // Directly in two other list items:
|
|
1956
|
+
state.stack[state.stack.length - 1] === "list" && state.stack[state.stack.length - 2] === "listItem" && state.stack[state.stack.length - 3] === "list" && state.stack[state.stack.length - 4] === "listItem" && // That are each the first child.
|
|
1957
|
+
state.indexStack[state.indexStack.length - 1] === 0 && state.indexStack[state.indexStack.length - 2] === 0 && state.indexStack[state.indexStack.length - 3] === 0
|
|
1958
|
+
) {
|
|
1959
|
+
useDifferentMarker = true;
|
|
1960
|
+
}
|
|
1961
|
+
if (checkRule(state) === bullet && firstListItem) {
|
|
1962
|
+
let index = -1;
|
|
1963
|
+
while (++index < node2.children.length) {
|
|
1964
|
+
const item = node2.children[index];
|
|
1965
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
1966
|
+
useDifferentMarker = true;
|
|
1967
|
+
break;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
if (useDifferentMarker) {
|
|
1973
|
+
bullet = bulletOther;
|
|
1974
|
+
}
|
|
1975
|
+
state.bulletCurrent = bullet;
|
|
1976
|
+
const value = state.containerFlow(node2, info);
|
|
1977
|
+
state.bulletLastUsed = bullet;
|
|
1978
|
+
state.bulletCurrent = bulletCurrent;
|
|
1979
|
+
exit();
|
|
1980
|
+
return value;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
|
|
1984
|
+
function checkListItemIndent(state) {
|
|
1985
|
+
const style = state.options.listItemIndent || "one";
|
|
1986
|
+
if (style !== "tab" && style !== "one" && style !== "mixed") {
|
|
1987
|
+
throw new Error(
|
|
1988
|
+
"Cannot serialize items with `" + style + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`"
|
|
1989
|
+
);
|
|
1990
|
+
}
|
|
1991
|
+
return style;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
// node_modules/mdast-util-to-markdown/lib/handle/list-item.js
|
|
1995
|
+
function listItem(node2, parent, state, info) {
|
|
1996
|
+
const listItemIndent = checkListItemIndent(state);
|
|
1997
|
+
let bullet = state.bulletCurrent || checkBullet(state);
|
|
1998
|
+
if (parent && parent.type === "list" && parent.ordered) {
|
|
1999
|
+
bullet = (typeof parent.start === "number" && parent.start > -1 ? parent.start : 1) + (state.options.incrementListMarker === false ? 0 : parent.children.indexOf(node2)) + bullet;
|
|
2000
|
+
}
|
|
2001
|
+
let size = bullet.length + 1;
|
|
2002
|
+
if (listItemIndent === "tab" || listItemIndent === "mixed" && (parent && parent.type === "list" && parent.spread || node2.spread)) {
|
|
2003
|
+
size = Math.ceil(size / 4) * 4;
|
|
2004
|
+
}
|
|
2005
|
+
const tracker = state.createTracker(info);
|
|
2006
|
+
tracker.move(bullet + " ".repeat(size - bullet.length));
|
|
2007
|
+
tracker.shift(size);
|
|
2008
|
+
const exit = state.enter("listItem");
|
|
2009
|
+
const value = state.indentLines(
|
|
2010
|
+
state.containerFlow(node2, tracker.current()),
|
|
2011
|
+
map3
|
|
2012
|
+
);
|
|
2013
|
+
exit();
|
|
2014
|
+
return value;
|
|
2015
|
+
function map3(line, index, blank) {
|
|
2016
|
+
if (index) {
|
|
2017
|
+
return (blank ? "" : " ".repeat(size)) + line;
|
|
2018
|
+
}
|
|
2019
|
+
return (blank ? bullet : bullet + " ".repeat(size - bullet.length)) + line;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
// node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
|
|
2024
|
+
function paragraph(node2, _, state, info) {
|
|
2025
|
+
const exit = state.enter("paragraph");
|
|
2026
|
+
const subexit = state.enter("phrasing");
|
|
2027
|
+
const value = state.containerPhrasing(node2, info);
|
|
2028
|
+
subexit();
|
|
2029
|
+
exit();
|
|
2030
|
+
return value;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
// node_modules/mdast-util-phrasing/lib/index.js
|
|
2034
|
+
var phrasing = (
|
|
2035
|
+
/** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
|
|
2036
|
+
convert([
|
|
2037
|
+
"break",
|
|
2038
|
+
"delete",
|
|
2039
|
+
"emphasis",
|
|
2040
|
+
// To do: next major: removed since footnotes were added to GFM.
|
|
2041
|
+
"footnote",
|
|
2042
|
+
"footnoteReference",
|
|
2043
|
+
"image",
|
|
2044
|
+
"imageReference",
|
|
2045
|
+
"inlineCode",
|
|
2046
|
+
// Enabled by `mdast-util-math`:
|
|
2047
|
+
"inlineMath",
|
|
2048
|
+
"link",
|
|
2049
|
+
"linkReference",
|
|
2050
|
+
// Enabled by `mdast-util-mdx`:
|
|
2051
|
+
"mdxJsxTextElement",
|
|
2052
|
+
// Enabled by `mdast-util-mdx`:
|
|
2053
|
+
"mdxTextExpression",
|
|
2054
|
+
"strong",
|
|
2055
|
+
"text",
|
|
2056
|
+
// Enabled by `mdast-util-directive`:
|
|
2057
|
+
"textDirective"
|
|
2058
|
+
])
|
|
2059
|
+
);
|
|
2060
|
+
|
|
2061
|
+
// node_modules/mdast-util-to-markdown/lib/handle/root.js
|
|
2062
|
+
function root(node2, _, state, info) {
|
|
2063
|
+
const hasPhrasing = node2.children.some(function(d) {
|
|
2064
|
+
return phrasing(d);
|
|
2065
|
+
});
|
|
2066
|
+
const container = hasPhrasing ? state.containerPhrasing : state.containerFlow;
|
|
2067
|
+
return container.call(state, node2, info);
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-strong.js
|
|
2071
|
+
function checkStrong(state) {
|
|
2072
|
+
const marker = state.options.strong || "*";
|
|
2073
|
+
if (marker !== "*" && marker !== "_") {
|
|
2074
|
+
throw new Error(
|
|
2075
|
+
"Cannot serialize strong with `" + marker + "` for `options.strong`, expected `*`, or `_`"
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2078
|
+
return marker;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
// node_modules/mdast-util-to-markdown/lib/handle/strong.js
|
|
2082
|
+
strong.peek = strongPeek;
|
|
2083
|
+
function strong(node2, _, state, info) {
|
|
2084
|
+
const marker = checkStrong(state);
|
|
2085
|
+
const exit = state.enter("strong");
|
|
2086
|
+
const tracker = state.createTracker(info);
|
|
2087
|
+
const before = tracker.move(marker + marker);
|
|
2088
|
+
let between = tracker.move(
|
|
2089
|
+
state.containerPhrasing(node2, {
|
|
2090
|
+
after: marker,
|
|
2091
|
+
before,
|
|
2092
|
+
...tracker.current()
|
|
2093
|
+
})
|
|
2094
|
+
);
|
|
2095
|
+
const betweenHead = between.charCodeAt(0);
|
|
2096
|
+
const open = encodeInfo(
|
|
2097
|
+
info.before.charCodeAt(info.before.length - 1),
|
|
2098
|
+
betweenHead,
|
|
2099
|
+
marker
|
|
2100
|
+
);
|
|
2101
|
+
if (open.inside) {
|
|
2102
|
+
between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
2103
|
+
}
|
|
2104
|
+
const betweenTail = between.charCodeAt(between.length - 1);
|
|
2105
|
+
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
2106
|
+
if (close.inside) {
|
|
2107
|
+
between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
2108
|
+
}
|
|
2109
|
+
const after = tracker.move(marker + marker);
|
|
2110
|
+
exit();
|
|
2111
|
+
state.attentionEncodeSurroundingInfo = {
|
|
2112
|
+
after: close.outside,
|
|
2113
|
+
before: open.outside
|
|
2114
|
+
};
|
|
2115
|
+
return before + between + after;
|
|
2116
|
+
}
|
|
2117
|
+
function strongPeek(_, _1, state) {
|
|
2118
|
+
return state.options.strong || "*";
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// node_modules/mdast-util-to-markdown/lib/handle/text.js
|
|
2122
|
+
function text(node2, _, state, info) {
|
|
2123
|
+
return state.safe(node2.value, info);
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
// node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
|
|
2127
|
+
function checkRuleRepetition(state) {
|
|
2128
|
+
const repetition = state.options.ruleRepetition || 3;
|
|
2129
|
+
if (repetition < 3) {
|
|
2130
|
+
throw new Error(
|
|
2131
|
+
"Cannot serialize rules with repetition `" + repetition + "` for `options.ruleRepetition`, expected `3` or more"
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
return repetition;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
|
|
2138
|
+
function thematicBreak(_, _1, state) {
|
|
2139
|
+
const value = (checkRule(state) + (state.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(state));
|
|
2140
|
+
return state.options.ruleSpaces ? value.slice(0, -1) : value;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
// node_modules/mdast-util-to-markdown/lib/handle/index.js
|
|
2144
|
+
var handle = {
|
|
2145
|
+
blockquote,
|
|
2146
|
+
break: hardBreak,
|
|
2147
|
+
code,
|
|
2148
|
+
definition,
|
|
2149
|
+
emphasis,
|
|
2150
|
+
hardBreak,
|
|
2151
|
+
heading,
|
|
2152
|
+
html,
|
|
2153
|
+
image,
|
|
2154
|
+
imageReference,
|
|
2155
|
+
inlineCode,
|
|
2156
|
+
link,
|
|
2157
|
+
linkReference,
|
|
2158
|
+
list,
|
|
2159
|
+
listItem,
|
|
2160
|
+
paragraph,
|
|
2161
|
+
root,
|
|
2162
|
+
strong,
|
|
2163
|
+
text,
|
|
2164
|
+
thematicBreak
|
|
2165
|
+
};
|
|
2166
|
+
|
|
2167
|
+
// src/lib/mdast/task-char-to-markdown.ts
|
|
2168
|
+
function taskCharToMarkdown() {
|
|
2169
|
+
return {
|
|
2170
|
+
unsafe: [{ atBreak: true, character: "-", after: "[:|-]" }],
|
|
2171
|
+
handlers: {
|
|
2172
|
+
listItem(node2, parent, state, info) {
|
|
2173
|
+
const taskChar = node2.data?.taskChar ?? (typeof node2.checked === "boolean" ? node2.checked ? "x" : " " : null);
|
|
2174
|
+
const head = node2.children[0];
|
|
2175
|
+
const isTask = taskChar !== null && head?.type === "paragraph";
|
|
2176
|
+
if (!isTask) {
|
|
2177
|
+
return handle.listItem(node2, parent, state, info);
|
|
2178
|
+
}
|
|
2179
|
+
const checkbox = `[${taskChar}] `;
|
|
2180
|
+
const tracker = state.createTracker(info);
|
|
2181
|
+
tracker.move(checkbox);
|
|
2182
|
+
const savedChecked = node2.checked;
|
|
2183
|
+
delete node2.checked;
|
|
2184
|
+
let value = handle.listItem(node2, parent, state, {
|
|
2185
|
+
...info,
|
|
2186
|
+
...tracker.current()
|
|
2187
|
+
});
|
|
2188
|
+
node2.checked = savedChecked;
|
|
2189
|
+
value = value.replace(
|
|
2190
|
+
/^([*+-]|\d+\.)([\r\n]| {1,3})/,
|
|
2191
|
+
(match) => match + checkbox
|
|
2192
|
+
);
|
|
2193
|
+
return value;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
1190
2197
|
}
|
|
1191
2198
|
|
|
1192
2199
|
// node_modules/micromark-factory-space/index.js
|
|
@@ -1194,20 +2201,20 @@ function factorySpace(effects, ok3, type, max) {
|
|
|
1194
2201
|
const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
|
|
1195
2202
|
let size = 0;
|
|
1196
2203
|
return start;
|
|
1197
|
-
function start(
|
|
1198
|
-
if (markdownSpace(
|
|
2204
|
+
function start(code2) {
|
|
2205
|
+
if (markdownSpace(code2)) {
|
|
1199
2206
|
effects.enter(type);
|
|
1200
|
-
return prefix(
|
|
2207
|
+
return prefix(code2);
|
|
1201
2208
|
}
|
|
1202
|
-
return ok3(
|
|
2209
|
+
return ok3(code2);
|
|
1203
2210
|
}
|
|
1204
|
-
function prefix(
|
|
1205
|
-
if (markdownSpace(
|
|
1206
|
-
effects.consume(
|
|
2211
|
+
function prefix(code2) {
|
|
2212
|
+
if (markdownSpace(code2) && size++ < limit) {
|
|
2213
|
+
effects.consume(code2);
|
|
1207
2214
|
return prefix;
|
|
1208
2215
|
}
|
|
1209
2216
|
effects.exit(type);
|
|
1210
|
-
return ok3(
|
|
2217
|
+
return ok3(code2);
|
|
1211
2218
|
}
|
|
1212
2219
|
}
|
|
1213
2220
|
|
|
@@ -1227,127 +2234,127 @@ function tokenizeMathFenced(effects, ok3, nok) {
|
|
|
1227
2234
|
const initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
|
|
1228
2235
|
let sizeOpen = 0;
|
|
1229
2236
|
return start;
|
|
1230
|
-
function start(
|
|
2237
|
+
function start(code2) {
|
|
1231
2238
|
effects.enter("mathFlow");
|
|
1232
2239
|
effects.enter("mathFlowFence");
|
|
1233
2240
|
effects.enter("mathFlowFenceSequence");
|
|
1234
|
-
return sequenceOpen(
|
|
2241
|
+
return sequenceOpen(code2);
|
|
1235
2242
|
}
|
|
1236
|
-
function sequenceOpen(
|
|
1237
|
-
if (
|
|
1238
|
-
effects.consume(
|
|
2243
|
+
function sequenceOpen(code2) {
|
|
2244
|
+
if (code2 === 36) {
|
|
2245
|
+
effects.consume(code2);
|
|
1239
2246
|
sizeOpen++;
|
|
1240
2247
|
return sequenceOpen;
|
|
1241
2248
|
}
|
|
1242
2249
|
if (sizeOpen < 2) {
|
|
1243
|
-
return nok(
|
|
2250
|
+
return nok(code2);
|
|
1244
2251
|
}
|
|
1245
2252
|
effects.exit("mathFlowFenceSequence");
|
|
1246
|
-
return factorySpace(effects, metaBefore, "whitespace")(
|
|
2253
|
+
return factorySpace(effects, metaBefore, "whitespace")(code2);
|
|
1247
2254
|
}
|
|
1248
|
-
function metaBefore(
|
|
1249
|
-
if (
|
|
1250
|
-
return metaAfter(
|
|
2255
|
+
function metaBefore(code2) {
|
|
2256
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
2257
|
+
return metaAfter(code2);
|
|
1251
2258
|
}
|
|
1252
2259
|
effects.enter("mathFlowFenceMeta");
|
|
1253
2260
|
effects.enter("chunkString", {
|
|
1254
2261
|
contentType: "string"
|
|
1255
2262
|
});
|
|
1256
|
-
return meta(
|
|
2263
|
+
return meta(code2);
|
|
1257
2264
|
}
|
|
1258
|
-
function meta(
|
|
1259
|
-
if (
|
|
2265
|
+
function meta(code2) {
|
|
2266
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1260
2267
|
effects.exit("chunkString");
|
|
1261
2268
|
effects.exit("mathFlowFenceMeta");
|
|
1262
|
-
return metaAfter(
|
|
2269
|
+
return metaAfter(code2);
|
|
1263
2270
|
}
|
|
1264
|
-
if (
|
|
1265
|
-
return nok(
|
|
2271
|
+
if (code2 === 36) {
|
|
2272
|
+
return nok(code2);
|
|
1266
2273
|
}
|
|
1267
|
-
effects.consume(
|
|
2274
|
+
effects.consume(code2);
|
|
1268
2275
|
return meta;
|
|
1269
2276
|
}
|
|
1270
|
-
function metaAfter(
|
|
2277
|
+
function metaAfter(code2) {
|
|
1271
2278
|
effects.exit("mathFlowFence");
|
|
1272
2279
|
if (self.interrupt) {
|
|
1273
|
-
return ok3(
|
|
2280
|
+
return ok3(code2);
|
|
1274
2281
|
}
|
|
1275
|
-
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(
|
|
2282
|
+
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
|
|
1276
2283
|
}
|
|
1277
|
-
function beforeNonLazyContinuation(
|
|
2284
|
+
function beforeNonLazyContinuation(code2) {
|
|
1278
2285
|
return effects.attempt({
|
|
1279
2286
|
tokenize: tokenizeClosingFence,
|
|
1280
2287
|
partial: true
|
|
1281
|
-
}, after, contentStart)(
|
|
2288
|
+
}, after, contentStart)(code2);
|
|
1282
2289
|
}
|
|
1283
|
-
function contentStart(
|
|
1284
|
-
return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(
|
|
2290
|
+
function contentStart(code2) {
|
|
2291
|
+
return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(code2);
|
|
1285
2292
|
}
|
|
1286
|
-
function beforeContentChunk(
|
|
1287
|
-
if (
|
|
1288
|
-
return after(
|
|
2293
|
+
function beforeContentChunk(code2) {
|
|
2294
|
+
if (code2 === null) {
|
|
2295
|
+
return after(code2);
|
|
1289
2296
|
}
|
|
1290
|
-
if (markdownLineEnding(
|
|
1291
|
-
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(
|
|
2297
|
+
if (markdownLineEnding(code2)) {
|
|
2298
|
+
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
|
|
1292
2299
|
}
|
|
1293
2300
|
effects.enter("mathFlowValue");
|
|
1294
|
-
return contentChunk(
|
|
2301
|
+
return contentChunk(code2);
|
|
1295
2302
|
}
|
|
1296
|
-
function contentChunk(
|
|
1297
|
-
if (
|
|
2303
|
+
function contentChunk(code2) {
|
|
2304
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1298
2305
|
effects.exit("mathFlowValue");
|
|
1299
|
-
return beforeContentChunk(
|
|
2306
|
+
return beforeContentChunk(code2);
|
|
1300
2307
|
}
|
|
1301
|
-
effects.consume(
|
|
2308
|
+
effects.consume(code2);
|
|
1302
2309
|
return contentChunk;
|
|
1303
2310
|
}
|
|
1304
|
-
function after(
|
|
2311
|
+
function after(code2) {
|
|
1305
2312
|
effects.exit("mathFlow");
|
|
1306
|
-
return ok3(
|
|
2313
|
+
return ok3(code2);
|
|
1307
2314
|
}
|
|
1308
2315
|
function tokenizeClosingFence(effects2, ok4, nok2) {
|
|
1309
2316
|
let size = 0;
|
|
1310
2317
|
return factorySpace(effects2, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
|
|
1311
|
-
function beforeSequenceClose(
|
|
2318
|
+
function beforeSequenceClose(code2) {
|
|
1312
2319
|
effects2.enter("mathFlowFence");
|
|
1313
2320
|
effects2.enter("mathFlowFenceSequence");
|
|
1314
|
-
return sequenceClose(
|
|
2321
|
+
return sequenceClose(code2);
|
|
1315
2322
|
}
|
|
1316
|
-
function sequenceClose(
|
|
1317
|
-
if (
|
|
2323
|
+
function sequenceClose(code2) {
|
|
2324
|
+
if (code2 === 36) {
|
|
1318
2325
|
size++;
|
|
1319
|
-
effects2.consume(
|
|
2326
|
+
effects2.consume(code2);
|
|
1320
2327
|
return sequenceClose;
|
|
1321
2328
|
}
|
|
1322
2329
|
if (size < sizeOpen) {
|
|
1323
|
-
return nok2(
|
|
2330
|
+
return nok2(code2);
|
|
1324
2331
|
}
|
|
1325
2332
|
effects2.exit("mathFlowFenceSequence");
|
|
1326
|
-
return factorySpace(effects2, afterSequenceClose, "whitespace")(
|
|
2333
|
+
return factorySpace(effects2, afterSequenceClose, "whitespace")(code2);
|
|
1327
2334
|
}
|
|
1328
|
-
function afterSequenceClose(
|
|
1329
|
-
if (
|
|
2335
|
+
function afterSequenceClose(code2) {
|
|
2336
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1330
2337
|
effects2.exit("mathFlowFence");
|
|
1331
|
-
return ok4(
|
|
2338
|
+
return ok4(code2);
|
|
1332
2339
|
}
|
|
1333
|
-
return nok2(
|
|
2340
|
+
return nok2(code2);
|
|
1334
2341
|
}
|
|
1335
2342
|
}
|
|
1336
2343
|
}
|
|
1337
2344
|
function tokenizeNonLazyContinuation2(effects, ok3, nok) {
|
|
1338
2345
|
const self = this;
|
|
1339
2346
|
return start;
|
|
1340
|
-
function start(
|
|
1341
|
-
if (
|
|
1342
|
-
return ok3(
|
|
2347
|
+
function start(code2) {
|
|
2348
|
+
if (code2 === null) {
|
|
2349
|
+
return ok3(code2);
|
|
1343
2350
|
}
|
|
1344
2351
|
effects.enter("lineEnding");
|
|
1345
|
-
effects.consume(
|
|
2352
|
+
effects.consume(code2);
|
|
1346
2353
|
effects.exit("lineEnding");
|
|
1347
2354
|
return lineStart;
|
|
1348
2355
|
}
|
|
1349
|
-
function lineStart(
|
|
1350
|
-
return self.parser.lazy[self.now().line] ? nok(
|
|
2356
|
+
function lineStart(code2) {
|
|
2357
|
+
return self.parser.lazy[self.now().line] ? nok(code2) : ok3(code2);
|
|
1351
2358
|
}
|
|
1352
2359
|
}
|
|
1353
2360
|
|
|
@@ -1370,68 +2377,68 @@ function mathText(options) {
|
|
|
1370
2377
|
let size;
|
|
1371
2378
|
let token;
|
|
1372
2379
|
return start;
|
|
1373
|
-
function start(
|
|
2380
|
+
function start(code2) {
|
|
1374
2381
|
effects.enter("mathText");
|
|
1375
2382
|
effects.enter("mathTextSequence");
|
|
1376
|
-
return sequenceOpen(
|
|
2383
|
+
return sequenceOpen(code2);
|
|
1377
2384
|
}
|
|
1378
|
-
function sequenceOpen(
|
|
1379
|
-
if (
|
|
1380
|
-
effects.consume(
|
|
2385
|
+
function sequenceOpen(code2) {
|
|
2386
|
+
if (code2 === 36) {
|
|
2387
|
+
effects.consume(code2);
|
|
1381
2388
|
sizeOpen++;
|
|
1382
2389
|
return sequenceOpen;
|
|
1383
2390
|
}
|
|
1384
2391
|
if (sizeOpen < 2 && !single) {
|
|
1385
|
-
return nok(
|
|
2392
|
+
return nok(code2);
|
|
1386
2393
|
}
|
|
1387
2394
|
effects.exit("mathTextSequence");
|
|
1388
|
-
return between(
|
|
2395
|
+
return between(code2);
|
|
1389
2396
|
}
|
|
1390
|
-
function between(
|
|
1391
|
-
if (
|
|
1392
|
-
return nok(
|
|
2397
|
+
function between(code2) {
|
|
2398
|
+
if (code2 === null) {
|
|
2399
|
+
return nok(code2);
|
|
1393
2400
|
}
|
|
1394
|
-
if (
|
|
2401
|
+
if (code2 === 36) {
|
|
1395
2402
|
token = effects.enter("mathTextSequence");
|
|
1396
2403
|
size = 0;
|
|
1397
|
-
return sequenceClose(
|
|
2404
|
+
return sequenceClose(code2);
|
|
1398
2405
|
}
|
|
1399
|
-
if (
|
|
2406
|
+
if (code2 === 32) {
|
|
1400
2407
|
effects.enter("space");
|
|
1401
|
-
effects.consume(
|
|
2408
|
+
effects.consume(code2);
|
|
1402
2409
|
effects.exit("space");
|
|
1403
2410
|
return between;
|
|
1404
2411
|
}
|
|
1405
|
-
if (markdownLineEnding(
|
|
2412
|
+
if (markdownLineEnding(code2)) {
|
|
1406
2413
|
effects.enter("lineEnding");
|
|
1407
|
-
effects.consume(
|
|
2414
|
+
effects.consume(code2);
|
|
1408
2415
|
effects.exit("lineEnding");
|
|
1409
2416
|
return between;
|
|
1410
2417
|
}
|
|
1411
2418
|
effects.enter("mathTextData");
|
|
1412
|
-
return data(
|
|
2419
|
+
return data(code2);
|
|
1413
2420
|
}
|
|
1414
|
-
function data(
|
|
1415
|
-
if (
|
|
2421
|
+
function data(code2) {
|
|
2422
|
+
if (code2 === null || code2 === 32 || code2 === 36 || markdownLineEnding(code2)) {
|
|
1416
2423
|
effects.exit("mathTextData");
|
|
1417
|
-
return between(
|
|
2424
|
+
return between(code2);
|
|
1418
2425
|
}
|
|
1419
|
-
effects.consume(
|
|
2426
|
+
effects.consume(code2);
|
|
1420
2427
|
return data;
|
|
1421
2428
|
}
|
|
1422
|
-
function sequenceClose(
|
|
1423
|
-
if (
|
|
1424
|
-
effects.consume(
|
|
2429
|
+
function sequenceClose(code2) {
|
|
2430
|
+
if (code2 === 36) {
|
|
2431
|
+
effects.consume(code2);
|
|
1425
2432
|
size++;
|
|
1426
2433
|
return sequenceClose;
|
|
1427
2434
|
}
|
|
1428
2435
|
if (size === sizeOpen) {
|
|
1429
2436
|
effects.exit("mathTextSequence");
|
|
1430
2437
|
effects.exit("mathText");
|
|
1431
|
-
return ok3(
|
|
2438
|
+
return ok3(code2);
|
|
1432
2439
|
}
|
|
1433
2440
|
token.type = "mathTextData";
|
|
1434
|
-
return data(
|
|
2441
|
+
return data(code2);
|
|
1435
2442
|
}
|
|
1436
2443
|
}
|
|
1437
2444
|
}
|
|
@@ -1472,8 +2479,8 @@ function resolveMathText(events) {
|
|
|
1472
2479
|
}
|
|
1473
2480
|
return events;
|
|
1474
2481
|
}
|
|
1475
|
-
function previous(
|
|
1476
|
-
return
|
|
2482
|
+
function previous(code2) {
|
|
2483
|
+
return code2 !== 36 || this.events[this.events.length - 1][1].type === "characterEscape";
|
|
1477
2484
|
}
|
|
1478
2485
|
|
|
1479
2486
|
// node_modules/micromark-extension-math/lib/syntax.js
|
|
@@ -1492,30 +2499,6 @@ function math(options) {
|
|
|
1492
2499
|
function ok2() {
|
|
1493
2500
|
}
|
|
1494
2501
|
|
|
1495
|
-
// node_modules/longest-streak/index.js
|
|
1496
|
-
function longestStreak(value, substring) {
|
|
1497
|
-
const source = String(value);
|
|
1498
|
-
let index = source.indexOf(substring);
|
|
1499
|
-
let expected = index;
|
|
1500
|
-
let count = 0;
|
|
1501
|
-
let max = 0;
|
|
1502
|
-
if (typeof substring !== "string") {
|
|
1503
|
-
throw new TypeError("Expected substring");
|
|
1504
|
-
}
|
|
1505
|
-
while (index !== -1) {
|
|
1506
|
-
if (index === expected) {
|
|
1507
|
-
if (++count > max) {
|
|
1508
|
-
max = count;
|
|
1509
|
-
}
|
|
1510
|
-
} else {
|
|
1511
|
-
count = 1;
|
|
1512
|
-
}
|
|
1513
|
-
expected = index + substring.length;
|
|
1514
|
-
index = source.indexOf(substring, expected);
|
|
1515
|
-
}
|
|
1516
|
-
return max;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
2502
|
// node_modules/mdast-util-math/lib/index.js
|
|
1520
2503
|
function mathFromMarkdown() {
|
|
1521
2504
|
return {
|
|
@@ -1534,7 +2517,7 @@ function mathFromMarkdown() {
|
|
|
1534
2517
|
}
|
|
1535
2518
|
};
|
|
1536
2519
|
function enterMathFlow(token) {
|
|
1537
|
-
const
|
|
2520
|
+
const code2 = {
|
|
1538
2521
|
type: "element",
|
|
1539
2522
|
tagName: "code",
|
|
1540
2523
|
properties: { className: ["language-math", "math-display"] },
|
|
@@ -1545,7 +2528,7 @@ function mathFromMarkdown() {
|
|
|
1545
2528
|
type: "math",
|
|
1546
2529
|
meta: null,
|
|
1547
2530
|
value: "",
|
|
1548
|
-
data: { hName: "pre", hChildren: [
|
|
2531
|
+
data: { hName: "pre", hChildren: [code2] }
|
|
1549
2532
|
},
|
|
1550
2533
|
token
|
|
1551
2534
|
);
|
|
@@ -1555,9 +2538,9 @@ function mathFromMarkdown() {
|
|
|
1555
2538
|
}
|
|
1556
2539
|
function exitMathFlowMeta() {
|
|
1557
2540
|
const data = this.resume();
|
|
1558
|
-
const
|
|
1559
|
-
ok2(
|
|
1560
|
-
|
|
2541
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2542
|
+
ok2(node2.type === "math");
|
|
2543
|
+
node2.meta = data;
|
|
1561
2544
|
}
|
|
1562
2545
|
function exitMathFlowFence() {
|
|
1563
2546
|
if (this.data.mathFlowInside) return;
|
|
@@ -1566,17 +2549,17 @@ function mathFromMarkdown() {
|
|
|
1566
2549
|
}
|
|
1567
2550
|
function exitMathFlow(token) {
|
|
1568
2551
|
const data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
|
|
1569
|
-
const
|
|
1570
|
-
ok2(
|
|
2552
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2553
|
+
ok2(node2.type === "math");
|
|
1571
2554
|
this.exit(token);
|
|
1572
|
-
|
|
1573
|
-
const
|
|
2555
|
+
node2.value = data;
|
|
2556
|
+
const code2 = (
|
|
1574
2557
|
/** @type {HastElement} */
|
|
1575
|
-
|
|
2558
|
+
node2.data.hChildren[0]
|
|
1576
2559
|
);
|
|
1577
|
-
ok2(
|
|
1578
|
-
ok2(
|
|
1579
|
-
|
|
2560
|
+
ok2(code2.type === "element");
|
|
2561
|
+
ok2(code2.tagName === "code");
|
|
2562
|
+
code2.children.push({ type: "text", value: data });
|
|
1580
2563
|
this.data.mathFlowInside = void 0;
|
|
1581
2564
|
}
|
|
1582
2565
|
function enterMathText(token) {
|
|
@@ -1596,14 +2579,14 @@ function mathFromMarkdown() {
|
|
|
1596
2579
|
}
|
|
1597
2580
|
function exitMathText(token) {
|
|
1598
2581
|
const data = this.resume();
|
|
1599
|
-
const
|
|
1600
|
-
ok2(
|
|
2582
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2583
|
+
ok2(node2.type === "inlineMath");
|
|
1601
2584
|
this.exit(token);
|
|
1602
|
-
|
|
2585
|
+
node2.value = data;
|
|
1603
2586
|
const children = (
|
|
1604
2587
|
/** @type {Array<HastElementContent>} */
|
|
1605
2588
|
// @ts-expect-error: we defined it in `enterMathFlow`.
|
|
1606
|
-
|
|
2589
|
+
node2.data.hChildren
|
|
1607
2590
|
);
|
|
1608
2591
|
children.push({ type: "text", value: data });
|
|
1609
2592
|
}
|
|
@@ -1632,16 +2615,16 @@ function mathToMarkdown(options) {
|
|
|
1632
2615
|
],
|
|
1633
2616
|
handlers: { math: math2, inlineMath }
|
|
1634
2617
|
};
|
|
1635
|
-
function math2(
|
|
1636
|
-
const raw =
|
|
2618
|
+
function math2(node2, _, state, info) {
|
|
2619
|
+
const raw = node2.value || "";
|
|
1637
2620
|
const tracker = state.createTracker(info);
|
|
1638
2621
|
const sequence = "$".repeat(Math.max(longestStreak(raw, "$") + 1, 2));
|
|
1639
2622
|
const exit = state.enter("mathFlow");
|
|
1640
2623
|
let value = tracker.move(sequence);
|
|
1641
|
-
if (
|
|
2624
|
+
if (node2.meta) {
|
|
1642
2625
|
const subexit = state.enter("mathFlowMeta");
|
|
1643
2626
|
value += tracker.move(
|
|
1644
|
-
state.safe(
|
|
2627
|
+
state.safe(node2.meta, {
|
|
1645
2628
|
after: "\n",
|
|
1646
2629
|
before: value,
|
|
1647
2630
|
encode: ["$"],
|
|
@@ -1658,8 +2641,8 @@ function mathToMarkdown(options) {
|
|
|
1658
2641
|
exit();
|
|
1659
2642
|
return value;
|
|
1660
2643
|
}
|
|
1661
|
-
function inlineMath(
|
|
1662
|
-
let value =
|
|
2644
|
+
function inlineMath(node2, _, state) {
|
|
2645
|
+
let value = node2.value || "";
|
|
1663
2646
|
let size = 1;
|
|
1664
2647
|
if (!single) size++;
|
|
1665
2648
|
while (new RegExp("(^|[^$])" + "\\$".repeat(size) + "([^$]|$)").test(value)) {
|
|
@@ -1735,6 +2718,9 @@ function remarkObsidian(userOpts) {
|
|
|
1735
2718
|
data.fromMarkdownExtensions.push(mathFromMarkdown());
|
|
1736
2719
|
data.toMarkdownExtensions.push(mathToMarkdown());
|
|
1737
2720
|
}
|
|
2721
|
+
if (opts.customTaskChars) {
|
|
2722
|
+
data.toMarkdownExtensions.push(taskCharToMarkdown());
|
|
2723
|
+
}
|
|
1738
2724
|
const needsTransform = opts.comments || opts.customTaskChars;
|
|
1739
2725
|
if (!needsTransform) return void 0;
|
|
1740
2726
|
return (tree, file) => {
|
|
@@ -1768,6 +2754,7 @@ export {
|
|
|
1768
2754
|
tagFromMarkdown,
|
|
1769
2755
|
tagSyntax,
|
|
1770
2756
|
tagToMarkdown,
|
|
2757
|
+
taskCharToMarkdown,
|
|
1771
2758
|
wikilinkFromMarkdown,
|
|
1772
2759
|
wikilinkSyntax,
|
|
1773
2760
|
wikilinkToMarkdown
|