@quartz-community/remark-obsidian 0.2.3 → 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 +1373 -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,93 +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 (
|
|
786
|
+
function afterOpen(code2) {
|
|
787
|
+
if (code2 === null) {
|
|
788
788
|
effects.exit("comment");
|
|
789
|
-
return ok3(
|
|
789
|
+
return ok3(code2);
|
|
790
790
|
}
|
|
791
|
-
if (isLineEnding3(
|
|
791
|
+
if (isLineEnding3(code2)) {
|
|
792
792
|
return effects.attempt(
|
|
793
793
|
nonLazyContinuation,
|
|
794
794
|
beforeContentChunk,
|
|
795
795
|
afterLazy
|
|
796
|
-
)(
|
|
796
|
+
)(code2);
|
|
797
797
|
}
|
|
798
798
|
effects.enter("commentContent");
|
|
799
|
-
return contentChunk(
|
|
799
|
+
return contentChunk(code2);
|
|
800
800
|
}
|
|
801
|
-
function beforeContentChunk(
|
|
802
|
-
if (
|
|
801
|
+
function beforeContentChunk(code2) {
|
|
802
|
+
if (code2 === null) {
|
|
803
803
|
effects.exit("comment");
|
|
804
|
-
return ok3(
|
|
804
|
+
return ok3(code2);
|
|
805
805
|
}
|
|
806
|
-
if (isLineEnding3(
|
|
806
|
+
if (isLineEnding3(code2)) {
|
|
807
807
|
return effects.attempt(
|
|
808
808
|
nonLazyContinuation,
|
|
809
809
|
beforeContentChunk,
|
|
810
810
|
afterLazy
|
|
811
|
-
)(
|
|
811
|
+
)(code2);
|
|
812
812
|
}
|
|
813
|
-
if (
|
|
814
|
-
return effects.attempt(flowClose, closeAfter, startContent)(
|
|
813
|
+
if (code2 === PERCENT) {
|
|
814
|
+
return effects.attempt(flowClose, closeAfter, startContent)(code2);
|
|
815
815
|
}
|
|
816
816
|
effects.enter("commentContent");
|
|
817
|
-
return contentChunk(
|
|
817
|
+
return contentChunk(code2);
|
|
818
818
|
}
|
|
819
|
-
function startContent(
|
|
819
|
+
function startContent(code2) {
|
|
820
820
|
effects.enter("commentContent");
|
|
821
|
-
effects.consume(
|
|
821
|
+
effects.consume(code2);
|
|
822
822
|
return contentChunk;
|
|
823
823
|
}
|
|
824
|
-
function contentChunk(
|
|
825
|
-
if (
|
|
824
|
+
function contentChunk(code2) {
|
|
825
|
+
if (code2 === null) {
|
|
826
826
|
effects.exit("commentContent");
|
|
827
827
|
effects.exit("comment");
|
|
828
|
-
return ok3(
|
|
828
|
+
return ok3(code2);
|
|
829
829
|
}
|
|
830
|
-
if (
|
|
831
|
-
return effects.attempt(flowClose, closeAfter, contentConsume)(
|
|
830
|
+
if (code2 === PERCENT) {
|
|
831
|
+
return effects.attempt(flowClose, closeAfter, contentConsume)(code2);
|
|
832
832
|
}
|
|
833
|
-
if (isLineEnding3(
|
|
833
|
+
if (isLineEnding3(code2)) {
|
|
834
834
|
effects.exit("commentContent");
|
|
835
835
|
return effects.attempt(
|
|
836
836
|
nonLazyContinuation,
|
|
837
837
|
beforeContentChunk,
|
|
838
838
|
afterLazy
|
|
839
|
-
)(
|
|
839
|
+
)(code2);
|
|
840
840
|
}
|
|
841
|
-
effects.consume(
|
|
841
|
+
effects.consume(code2);
|
|
842
842
|
return contentChunk;
|
|
843
843
|
}
|
|
844
|
-
function contentConsume(
|
|
845
|
-
if (
|
|
844
|
+
function contentConsume(code2) {
|
|
845
|
+
if (code2 === null) {
|
|
846
846
|
effects.exit("commentContent");
|
|
847
847
|
effects.exit("comment");
|
|
848
|
-
return ok3(
|
|
848
|
+
return ok3(code2);
|
|
849
849
|
}
|
|
850
|
-
effects.consume(
|
|
850
|
+
effects.consume(code2);
|
|
851
851
|
return contentChunk;
|
|
852
852
|
}
|
|
853
|
-
function closeAfter(
|
|
853
|
+
function closeAfter(code2) {
|
|
854
854
|
effects.exit("comment");
|
|
855
|
-
return ok3(
|
|
855
|
+
return ok3(code2);
|
|
856
856
|
}
|
|
857
|
-
function afterLazy(
|
|
857
|
+
function afterLazy(code2) {
|
|
858
858
|
effects.exit("comment");
|
|
859
|
-
return ok3(
|
|
859
|
+
return ok3(code2);
|
|
860
860
|
}
|
|
861
861
|
function tokenizeFlowClose(closeEffects, closeOk, closeNok) {
|
|
862
862
|
let inContent = false;
|
|
@@ -889,18 +889,18 @@ function tokenizeFlow(effects, ok3, nok) {
|
|
|
889
889
|
function tokenizeNonLazyContinuation(effects, ok3, nok) {
|
|
890
890
|
const self = this;
|
|
891
891
|
return start;
|
|
892
|
-
function start(
|
|
893
|
-
if (
|
|
894
|
-
return ok3(
|
|
892
|
+
function start(code2) {
|
|
893
|
+
if (code2 === null) {
|
|
894
|
+
return ok3(code2);
|
|
895
895
|
}
|
|
896
|
-
if (!isLineEnding3(
|
|
896
|
+
if (!isLineEnding3(code2)) return nok(code2);
|
|
897
897
|
effects.enter("lineEnding");
|
|
898
|
-
effects.consume(
|
|
898
|
+
effects.consume(code2);
|
|
899
899
|
effects.exit("lineEnding");
|
|
900
900
|
return lineStart;
|
|
901
901
|
}
|
|
902
|
-
function lineStart(
|
|
903
|
-
return self.parser.lazy[self.now().line] ? nok(
|
|
902
|
+
function lineStart(code2) {
|
|
903
|
+
return self.parser.lazy[self.now().line] ? nok(code2) : ok3(code2);
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
906
|
|
|
@@ -910,18 +910,18 @@ var SLASH = 47;
|
|
|
910
910
|
var DASH = 45;
|
|
911
911
|
var UNDERSCORE = 95;
|
|
912
912
|
var tagCharRegex = /[\p{L}\p{M}\p{Emoji}]/u;
|
|
913
|
-
function isWhitespace(
|
|
914
|
-
return
|
|
913
|
+
function isWhitespace(code2) {
|
|
914
|
+
return code2 === codes.space || code2 === codes.horizontalTab || code2 === codes.lineFeed || code2 === codes.carriageReturn || code2 === codes.carriageReturnLineFeed;
|
|
915
915
|
}
|
|
916
|
-
function isTagChar(
|
|
917
|
-
if (
|
|
918
|
-
if (
|
|
919
|
-
if (
|
|
920
|
-
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));
|
|
921
921
|
}
|
|
922
|
-
function isNonDigit(
|
|
923
|
-
if (
|
|
924
|
-
return !(
|
|
922
|
+
function isNonDigit(code2) {
|
|
923
|
+
if (code2 === null) return false;
|
|
924
|
+
return !(code2 >= 48 && code2 <= 57);
|
|
925
925
|
}
|
|
926
926
|
function tagSyntax() {
|
|
927
927
|
return {
|
|
@@ -934,47 +934,47 @@ function tokenize3(effects, ok3, nok) {
|
|
|
934
934
|
let hasNonDigit = false;
|
|
935
935
|
const context = this;
|
|
936
936
|
return start;
|
|
937
|
-
function start(
|
|
937
|
+
function start(code2) {
|
|
938
938
|
const previous2 = context.previous;
|
|
939
939
|
const allowedStart = previous2 === null || isWhitespace(previous2) || previous2 === HASH2;
|
|
940
|
-
if (!allowedStart) return nok(
|
|
941
|
-
if (
|
|
940
|
+
if (!allowedStart) return nok(code2);
|
|
941
|
+
if (code2 !== HASH2) return nok(code2);
|
|
942
942
|
effects.enter("tag");
|
|
943
943
|
effects.enter("tagMarker");
|
|
944
|
-
effects.consume(
|
|
944
|
+
effects.consume(code2);
|
|
945
945
|
effects.exit("tagMarker");
|
|
946
946
|
return tagStart;
|
|
947
947
|
}
|
|
948
|
-
function tagStart(
|
|
949
|
-
if (!isTagChar(
|
|
948
|
+
function tagStart(code2) {
|
|
949
|
+
if (!isTagChar(code2)) return nok(code2);
|
|
950
950
|
effects.enter("tagContent");
|
|
951
|
-
if (isNonDigit(
|
|
952
|
-
effects.consume(
|
|
951
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
952
|
+
effects.consume(code2);
|
|
953
953
|
return tagContent;
|
|
954
954
|
}
|
|
955
|
-
function tagContent(
|
|
956
|
-
if (
|
|
957
|
-
effects.consume(
|
|
955
|
+
function tagContent(code2) {
|
|
956
|
+
if (code2 === SLASH) {
|
|
957
|
+
effects.consume(code2);
|
|
958
958
|
return afterSlash;
|
|
959
959
|
}
|
|
960
|
-
if (isTagChar(
|
|
961
|
-
if (isNonDigit(
|
|
962
|
-
effects.consume(
|
|
960
|
+
if (isTagChar(code2)) {
|
|
961
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
962
|
+
effects.consume(code2);
|
|
963
963
|
return tagContent;
|
|
964
964
|
}
|
|
965
|
-
return end(
|
|
965
|
+
return end(code2);
|
|
966
966
|
}
|
|
967
|
-
function afterSlash(
|
|
968
|
-
if (!isTagChar(
|
|
969
|
-
if (isNonDigit(
|
|
970
|
-
effects.consume(
|
|
967
|
+
function afterSlash(code2) {
|
|
968
|
+
if (!isTagChar(code2)) return nok(code2);
|
|
969
|
+
if (isNonDigit(code2)) hasNonDigit = true;
|
|
970
|
+
effects.consume(code2);
|
|
971
971
|
return tagContent;
|
|
972
972
|
}
|
|
973
|
-
function end(
|
|
974
|
-
if (!hasNonDigit) return nok(
|
|
973
|
+
function end(code2) {
|
|
974
|
+
if (!hasNonDigit) return nok(code2);
|
|
975
975
|
effects.exit("tagContent");
|
|
976
976
|
effects.exit("tag");
|
|
977
|
-
return ok3(
|
|
977
|
+
return ok3(code2);
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
980
|
|
|
@@ -996,29 +996,29 @@ function wikilinkFromMarkdown() {
|
|
|
996
996
|
);
|
|
997
997
|
},
|
|
998
998
|
wikilinkEmbedMarker() {
|
|
999
|
-
const
|
|
1000
|
-
|
|
999
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1000
|
+
node2.embedded = true;
|
|
1001
1001
|
},
|
|
1002
1002
|
wikilinkPath(token) {
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1003
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1004
|
+
node2.path = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
|
|
1005
1005
|
},
|
|
1006
1006
|
wikilinkHeading(token) {
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1007
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1008
|
+
node2.heading = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
|
|
1009
1009
|
},
|
|
1010
1010
|
wikilinkAlias(token) {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1011
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1012
|
+
node2.alias = this.sliceSerialize(token);
|
|
1013
1013
|
}
|
|
1014
1014
|
},
|
|
1015
1015
|
exit: {
|
|
1016
1016
|
wikilink(token) {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
if (
|
|
1020
|
-
if (
|
|
1021
|
-
|
|
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);
|
|
1022
1022
|
}
|
|
1023
1023
|
this.exit(token);
|
|
1024
1024
|
}
|
|
@@ -1036,8 +1036,8 @@ function highlightFromMarkdown() {
|
|
|
1036
1036
|
},
|
|
1037
1037
|
exit: {
|
|
1038
1038
|
highlightContent(token) {
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1039
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1040
|
+
node2.children = [{ type: "text", value: this.sliceSerialize(token) }];
|
|
1041
1041
|
},
|
|
1042
1042
|
highlight(token) {
|
|
1043
1043
|
this.exit(token);
|
|
@@ -1056,8 +1056,8 @@ function commentFromMarkdown() {
|
|
|
1056
1056
|
},
|
|
1057
1057
|
exit: {
|
|
1058
1058
|
commentContent(token) {
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1059
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1060
|
+
node2.value += this.sliceSerialize(token);
|
|
1061
1061
|
},
|
|
1062
1062
|
comment(token) {
|
|
1063
1063
|
this.exit(token);
|
|
@@ -1074,8 +1074,8 @@ function tagFromMarkdown() {
|
|
|
1074
1074
|
this.enter({ type: "tag", value: "" }, token);
|
|
1075
1075
|
},
|
|
1076
1076
|
tagContent(token) {
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1077
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
1078
|
+
if (node2.type === "tag") node2.value = this.sliceSerialize(token);
|
|
1079
1079
|
}
|
|
1080
1080
|
},
|
|
1081
1081
|
exit: {
|
|
@@ -1090,11 +1090,11 @@ function tagFromMarkdown() {
|
|
|
1090
1090
|
function wikilinkToMarkdown() {
|
|
1091
1091
|
return {
|
|
1092
1092
|
handlers: {
|
|
1093
|
-
wikilink(
|
|
1094
|
-
const prefix =
|
|
1095
|
-
const
|
|
1096
|
-
const alias =
|
|
1097
|
-
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}]]`;
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
};
|
|
@@ -1104,9 +1104,9 @@ function wikilinkToMarkdown() {
|
|
|
1104
1104
|
function highlightToMarkdown() {
|
|
1105
1105
|
return {
|
|
1106
1106
|
handlers: {
|
|
1107
|
-
highlight(
|
|
1107
|
+
highlight(node2, _parent, state, info) {
|
|
1108
1108
|
const exit = state.enter("highlight");
|
|
1109
|
-
const content = state.containerPhrasing(
|
|
1109
|
+
const content = state.containerPhrasing(node2, info);
|
|
1110
1110
|
exit();
|
|
1111
1111
|
return `==${content}==`;
|
|
1112
1112
|
}
|
|
@@ -1118,8 +1118,8 @@ function highlightToMarkdown() {
|
|
|
1118
1118
|
function commentToMarkdown() {
|
|
1119
1119
|
return {
|
|
1120
1120
|
handlers: {
|
|
1121
|
-
comment(
|
|
1122
|
-
return `%%${
|
|
1121
|
+
comment(node2) {
|
|
1122
|
+
return `%%${node2.value}%%`;
|
|
1123
1123
|
}
|
|
1124
1124
|
}
|
|
1125
1125
|
};
|
|
@@ -1129,8 +1129,8 @@ function commentToMarkdown() {
|
|
|
1129
1129
|
function tagToMarkdown() {
|
|
1130
1130
|
return {
|
|
1131
1131
|
handlers: {
|
|
1132
|
-
tag(
|
|
1133
|
-
return `#${
|
|
1132
|
+
tag(node2) {
|
|
1133
|
+
return `#${node2.value}`;
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
};
|
|
@@ -1138,37 +1138,37 @@ function tagToMarkdown() {
|
|
|
1138
1138
|
|
|
1139
1139
|
// src/lib/task-char.ts
|
|
1140
1140
|
function customTaskCharTransform(tree, source) {
|
|
1141
|
-
visit(tree, "listItem", (
|
|
1142
|
-
if (typeof
|
|
1143
|
-
let char =
|
|
1144
|
-
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) {
|
|
1145
1145
|
const slice = source.slice(
|
|
1146
|
-
|
|
1147
|
-
|
|
1146
|
+
node2.position.start.offset,
|
|
1147
|
+
node2.position.start.offset + 20
|
|
1148
1148
|
);
|
|
1149
1149
|
const m = slice.match(/\[([^\]])\]/);
|
|
1150
1150
|
if (m) {
|
|
1151
1151
|
char = m[1];
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1154
|
+
node2.data ??= {};
|
|
1155
|
+
node2.data.taskChar = char;
|
|
1156
|
+
node2.data.hProperties ??= {};
|
|
1157
|
+
node2.data.hProperties.dataTaskChar = char;
|
|
1158
1158
|
return;
|
|
1159
1159
|
}
|
|
1160
|
-
const firstChild =
|
|
1160
|
+
const firstChild = node2.children?.[0];
|
|
1161
1161
|
if (!firstChild || firstChild.type !== "paragraph") return;
|
|
1162
1162
|
const firstText = firstChild.children?.[0];
|
|
1163
1163
|
if (!firstText || firstText.type !== "text") return;
|
|
1164
1164
|
const match = firstText.value.match(/^\[([^\]])\]\s/);
|
|
1165
1165
|
if (!match) return;
|
|
1166
1166
|
const taskChar = match[1];
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1167
|
+
node2.checked = taskChar !== " ";
|
|
1168
|
+
node2.data ??= {};
|
|
1169
|
+
node2.data.taskChar = taskChar;
|
|
1170
|
+
node2.data.hProperties ??= {};
|
|
1171
|
+
node2.data.hProperties.dataTaskChar = taskChar;
|
|
1172
1172
|
firstText.value = firstText.value.slice(match[0].length);
|
|
1173
1173
|
if (firstText.value.length === 0) {
|
|
1174
1174
|
firstChild.children.shift();
|
|
@@ -1179,6 +1179,234 @@ function customTaskCharTransform(tree, source) {
|
|
|
1179
1179
|
});
|
|
1180
1180
|
}
|
|
1181
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
|
+
|
|
1182
1410
|
// node_modules/micromark-util-character/index.js
|
|
1183
1411
|
var asciiAlpha = regexCheck(/[A-Za-z]/);
|
|
1184
1412
|
var asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
|
|
@@ -1186,19 +1414,786 @@ var asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
|
|
1186
1414
|
var asciiDigit = regexCheck(/\d/);
|
|
1187
1415
|
var asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
|
|
1188
1416
|
var asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
|
|
1189
|
-
function markdownLineEnding(
|
|
1190
|
-
return
|
|
1417
|
+
function markdownLineEnding(code2) {
|
|
1418
|
+
return code2 !== null && code2 < -2;
|
|
1191
1419
|
}
|
|
1192
|
-
function
|
|
1193
|
-
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;
|
|
1194
1425
|
}
|
|
1195
1426
|
var unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
1196
1427
|
var unicodeWhitespace = regexCheck(/\s/);
|
|
1197
1428
|
function regexCheck(regex) {
|
|
1198
1429
|
return check;
|
|
1199
|
-
function check(
|
|
1200
|
-
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);
|
|
1201
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();
|
|
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
|
+
};
|
|
1202
2197
|
}
|
|
1203
2198
|
|
|
1204
2199
|
// node_modules/micromark-factory-space/index.js
|
|
@@ -1206,20 +2201,20 @@ function factorySpace(effects, ok3, type, max) {
|
|
|
1206
2201
|
const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
|
|
1207
2202
|
let size = 0;
|
|
1208
2203
|
return start;
|
|
1209
|
-
function start(
|
|
1210
|
-
if (markdownSpace(
|
|
2204
|
+
function start(code2) {
|
|
2205
|
+
if (markdownSpace(code2)) {
|
|
1211
2206
|
effects.enter(type);
|
|
1212
|
-
return prefix(
|
|
2207
|
+
return prefix(code2);
|
|
1213
2208
|
}
|
|
1214
|
-
return ok3(
|
|
2209
|
+
return ok3(code2);
|
|
1215
2210
|
}
|
|
1216
|
-
function prefix(
|
|
1217
|
-
if (markdownSpace(
|
|
1218
|
-
effects.consume(
|
|
2211
|
+
function prefix(code2) {
|
|
2212
|
+
if (markdownSpace(code2) && size++ < limit) {
|
|
2213
|
+
effects.consume(code2);
|
|
1219
2214
|
return prefix;
|
|
1220
2215
|
}
|
|
1221
2216
|
effects.exit(type);
|
|
1222
|
-
return ok3(
|
|
2217
|
+
return ok3(code2);
|
|
1223
2218
|
}
|
|
1224
2219
|
}
|
|
1225
2220
|
|
|
@@ -1239,127 +2234,127 @@ function tokenizeMathFenced(effects, ok3, nok) {
|
|
|
1239
2234
|
const initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
|
|
1240
2235
|
let sizeOpen = 0;
|
|
1241
2236
|
return start;
|
|
1242
|
-
function start(
|
|
2237
|
+
function start(code2) {
|
|
1243
2238
|
effects.enter("mathFlow");
|
|
1244
2239
|
effects.enter("mathFlowFence");
|
|
1245
2240
|
effects.enter("mathFlowFenceSequence");
|
|
1246
|
-
return sequenceOpen(
|
|
2241
|
+
return sequenceOpen(code2);
|
|
1247
2242
|
}
|
|
1248
|
-
function sequenceOpen(
|
|
1249
|
-
if (
|
|
1250
|
-
effects.consume(
|
|
2243
|
+
function sequenceOpen(code2) {
|
|
2244
|
+
if (code2 === 36) {
|
|
2245
|
+
effects.consume(code2);
|
|
1251
2246
|
sizeOpen++;
|
|
1252
2247
|
return sequenceOpen;
|
|
1253
2248
|
}
|
|
1254
2249
|
if (sizeOpen < 2) {
|
|
1255
|
-
return nok(
|
|
2250
|
+
return nok(code2);
|
|
1256
2251
|
}
|
|
1257
2252
|
effects.exit("mathFlowFenceSequence");
|
|
1258
|
-
return factorySpace(effects, metaBefore, "whitespace")(
|
|
2253
|
+
return factorySpace(effects, metaBefore, "whitespace")(code2);
|
|
1259
2254
|
}
|
|
1260
|
-
function metaBefore(
|
|
1261
|
-
if (
|
|
1262
|
-
return metaAfter(
|
|
2255
|
+
function metaBefore(code2) {
|
|
2256
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
2257
|
+
return metaAfter(code2);
|
|
1263
2258
|
}
|
|
1264
2259
|
effects.enter("mathFlowFenceMeta");
|
|
1265
2260
|
effects.enter("chunkString", {
|
|
1266
2261
|
contentType: "string"
|
|
1267
2262
|
});
|
|
1268
|
-
return meta(
|
|
2263
|
+
return meta(code2);
|
|
1269
2264
|
}
|
|
1270
|
-
function meta(
|
|
1271
|
-
if (
|
|
2265
|
+
function meta(code2) {
|
|
2266
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1272
2267
|
effects.exit("chunkString");
|
|
1273
2268
|
effects.exit("mathFlowFenceMeta");
|
|
1274
|
-
return metaAfter(
|
|
2269
|
+
return metaAfter(code2);
|
|
1275
2270
|
}
|
|
1276
|
-
if (
|
|
1277
|
-
return nok(
|
|
2271
|
+
if (code2 === 36) {
|
|
2272
|
+
return nok(code2);
|
|
1278
2273
|
}
|
|
1279
|
-
effects.consume(
|
|
2274
|
+
effects.consume(code2);
|
|
1280
2275
|
return meta;
|
|
1281
2276
|
}
|
|
1282
|
-
function metaAfter(
|
|
2277
|
+
function metaAfter(code2) {
|
|
1283
2278
|
effects.exit("mathFlowFence");
|
|
1284
2279
|
if (self.interrupt) {
|
|
1285
|
-
return ok3(
|
|
2280
|
+
return ok3(code2);
|
|
1286
2281
|
}
|
|
1287
|
-
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(
|
|
2282
|
+
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
|
|
1288
2283
|
}
|
|
1289
|
-
function beforeNonLazyContinuation(
|
|
2284
|
+
function beforeNonLazyContinuation(code2) {
|
|
1290
2285
|
return effects.attempt({
|
|
1291
2286
|
tokenize: tokenizeClosingFence,
|
|
1292
2287
|
partial: true
|
|
1293
|
-
}, after, contentStart)(
|
|
2288
|
+
}, after, contentStart)(code2);
|
|
1294
2289
|
}
|
|
1295
|
-
function contentStart(
|
|
1296
|
-
return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(
|
|
2290
|
+
function contentStart(code2) {
|
|
2291
|
+
return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(code2);
|
|
1297
2292
|
}
|
|
1298
|
-
function beforeContentChunk(
|
|
1299
|
-
if (
|
|
1300
|
-
return after(
|
|
2293
|
+
function beforeContentChunk(code2) {
|
|
2294
|
+
if (code2 === null) {
|
|
2295
|
+
return after(code2);
|
|
1301
2296
|
}
|
|
1302
|
-
if (markdownLineEnding(
|
|
1303
|
-
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(
|
|
2297
|
+
if (markdownLineEnding(code2)) {
|
|
2298
|
+
return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
|
|
1304
2299
|
}
|
|
1305
2300
|
effects.enter("mathFlowValue");
|
|
1306
|
-
return contentChunk(
|
|
2301
|
+
return contentChunk(code2);
|
|
1307
2302
|
}
|
|
1308
|
-
function contentChunk(
|
|
1309
|
-
if (
|
|
2303
|
+
function contentChunk(code2) {
|
|
2304
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1310
2305
|
effects.exit("mathFlowValue");
|
|
1311
|
-
return beforeContentChunk(
|
|
2306
|
+
return beforeContentChunk(code2);
|
|
1312
2307
|
}
|
|
1313
|
-
effects.consume(
|
|
2308
|
+
effects.consume(code2);
|
|
1314
2309
|
return contentChunk;
|
|
1315
2310
|
}
|
|
1316
|
-
function after(
|
|
2311
|
+
function after(code2) {
|
|
1317
2312
|
effects.exit("mathFlow");
|
|
1318
|
-
return ok3(
|
|
2313
|
+
return ok3(code2);
|
|
1319
2314
|
}
|
|
1320
2315
|
function tokenizeClosingFence(effects2, ok4, nok2) {
|
|
1321
2316
|
let size = 0;
|
|
1322
2317
|
return factorySpace(effects2, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
|
|
1323
|
-
function beforeSequenceClose(
|
|
2318
|
+
function beforeSequenceClose(code2) {
|
|
1324
2319
|
effects2.enter("mathFlowFence");
|
|
1325
2320
|
effects2.enter("mathFlowFenceSequence");
|
|
1326
|
-
return sequenceClose(
|
|
2321
|
+
return sequenceClose(code2);
|
|
1327
2322
|
}
|
|
1328
|
-
function sequenceClose(
|
|
1329
|
-
if (
|
|
2323
|
+
function sequenceClose(code2) {
|
|
2324
|
+
if (code2 === 36) {
|
|
1330
2325
|
size++;
|
|
1331
|
-
effects2.consume(
|
|
2326
|
+
effects2.consume(code2);
|
|
1332
2327
|
return sequenceClose;
|
|
1333
2328
|
}
|
|
1334
2329
|
if (size < sizeOpen) {
|
|
1335
|
-
return nok2(
|
|
2330
|
+
return nok2(code2);
|
|
1336
2331
|
}
|
|
1337
2332
|
effects2.exit("mathFlowFenceSequence");
|
|
1338
|
-
return factorySpace(effects2, afterSequenceClose, "whitespace")(
|
|
2333
|
+
return factorySpace(effects2, afterSequenceClose, "whitespace")(code2);
|
|
1339
2334
|
}
|
|
1340
|
-
function afterSequenceClose(
|
|
1341
|
-
if (
|
|
2335
|
+
function afterSequenceClose(code2) {
|
|
2336
|
+
if (code2 === null || markdownLineEnding(code2)) {
|
|
1342
2337
|
effects2.exit("mathFlowFence");
|
|
1343
|
-
return ok4(
|
|
2338
|
+
return ok4(code2);
|
|
1344
2339
|
}
|
|
1345
|
-
return nok2(
|
|
2340
|
+
return nok2(code2);
|
|
1346
2341
|
}
|
|
1347
2342
|
}
|
|
1348
2343
|
}
|
|
1349
2344
|
function tokenizeNonLazyContinuation2(effects, ok3, nok) {
|
|
1350
2345
|
const self = this;
|
|
1351
2346
|
return start;
|
|
1352
|
-
function start(
|
|
1353
|
-
if (
|
|
1354
|
-
return ok3(
|
|
2347
|
+
function start(code2) {
|
|
2348
|
+
if (code2 === null) {
|
|
2349
|
+
return ok3(code2);
|
|
1355
2350
|
}
|
|
1356
2351
|
effects.enter("lineEnding");
|
|
1357
|
-
effects.consume(
|
|
2352
|
+
effects.consume(code2);
|
|
1358
2353
|
effects.exit("lineEnding");
|
|
1359
2354
|
return lineStart;
|
|
1360
2355
|
}
|
|
1361
|
-
function lineStart(
|
|
1362
|
-
return self.parser.lazy[self.now().line] ? nok(
|
|
2356
|
+
function lineStart(code2) {
|
|
2357
|
+
return self.parser.lazy[self.now().line] ? nok(code2) : ok3(code2);
|
|
1363
2358
|
}
|
|
1364
2359
|
}
|
|
1365
2360
|
|
|
@@ -1382,68 +2377,68 @@ function mathText(options) {
|
|
|
1382
2377
|
let size;
|
|
1383
2378
|
let token;
|
|
1384
2379
|
return start;
|
|
1385
|
-
function start(
|
|
2380
|
+
function start(code2) {
|
|
1386
2381
|
effects.enter("mathText");
|
|
1387
2382
|
effects.enter("mathTextSequence");
|
|
1388
|
-
return sequenceOpen(
|
|
2383
|
+
return sequenceOpen(code2);
|
|
1389
2384
|
}
|
|
1390
|
-
function sequenceOpen(
|
|
1391
|
-
if (
|
|
1392
|
-
effects.consume(
|
|
2385
|
+
function sequenceOpen(code2) {
|
|
2386
|
+
if (code2 === 36) {
|
|
2387
|
+
effects.consume(code2);
|
|
1393
2388
|
sizeOpen++;
|
|
1394
2389
|
return sequenceOpen;
|
|
1395
2390
|
}
|
|
1396
2391
|
if (sizeOpen < 2 && !single) {
|
|
1397
|
-
return nok(
|
|
2392
|
+
return nok(code2);
|
|
1398
2393
|
}
|
|
1399
2394
|
effects.exit("mathTextSequence");
|
|
1400
|
-
return between(
|
|
2395
|
+
return between(code2);
|
|
1401
2396
|
}
|
|
1402
|
-
function between(
|
|
1403
|
-
if (
|
|
1404
|
-
return nok(
|
|
2397
|
+
function between(code2) {
|
|
2398
|
+
if (code2 === null) {
|
|
2399
|
+
return nok(code2);
|
|
1405
2400
|
}
|
|
1406
|
-
if (
|
|
2401
|
+
if (code2 === 36) {
|
|
1407
2402
|
token = effects.enter("mathTextSequence");
|
|
1408
2403
|
size = 0;
|
|
1409
|
-
return sequenceClose(
|
|
2404
|
+
return sequenceClose(code2);
|
|
1410
2405
|
}
|
|
1411
|
-
if (
|
|
2406
|
+
if (code2 === 32) {
|
|
1412
2407
|
effects.enter("space");
|
|
1413
|
-
effects.consume(
|
|
2408
|
+
effects.consume(code2);
|
|
1414
2409
|
effects.exit("space");
|
|
1415
2410
|
return between;
|
|
1416
2411
|
}
|
|
1417
|
-
if (markdownLineEnding(
|
|
2412
|
+
if (markdownLineEnding(code2)) {
|
|
1418
2413
|
effects.enter("lineEnding");
|
|
1419
|
-
effects.consume(
|
|
2414
|
+
effects.consume(code2);
|
|
1420
2415
|
effects.exit("lineEnding");
|
|
1421
2416
|
return between;
|
|
1422
2417
|
}
|
|
1423
2418
|
effects.enter("mathTextData");
|
|
1424
|
-
return data(
|
|
2419
|
+
return data(code2);
|
|
1425
2420
|
}
|
|
1426
|
-
function data(
|
|
1427
|
-
if (
|
|
2421
|
+
function data(code2) {
|
|
2422
|
+
if (code2 === null || code2 === 32 || code2 === 36 || markdownLineEnding(code2)) {
|
|
1428
2423
|
effects.exit("mathTextData");
|
|
1429
|
-
return between(
|
|
2424
|
+
return between(code2);
|
|
1430
2425
|
}
|
|
1431
|
-
effects.consume(
|
|
2426
|
+
effects.consume(code2);
|
|
1432
2427
|
return data;
|
|
1433
2428
|
}
|
|
1434
|
-
function sequenceClose(
|
|
1435
|
-
if (
|
|
1436
|
-
effects.consume(
|
|
2429
|
+
function sequenceClose(code2) {
|
|
2430
|
+
if (code2 === 36) {
|
|
2431
|
+
effects.consume(code2);
|
|
1437
2432
|
size++;
|
|
1438
2433
|
return sequenceClose;
|
|
1439
2434
|
}
|
|
1440
2435
|
if (size === sizeOpen) {
|
|
1441
2436
|
effects.exit("mathTextSequence");
|
|
1442
2437
|
effects.exit("mathText");
|
|
1443
|
-
return ok3(
|
|
2438
|
+
return ok3(code2);
|
|
1444
2439
|
}
|
|
1445
2440
|
token.type = "mathTextData";
|
|
1446
|
-
return data(
|
|
2441
|
+
return data(code2);
|
|
1447
2442
|
}
|
|
1448
2443
|
}
|
|
1449
2444
|
}
|
|
@@ -1484,8 +2479,8 @@ function resolveMathText(events) {
|
|
|
1484
2479
|
}
|
|
1485
2480
|
return events;
|
|
1486
2481
|
}
|
|
1487
|
-
function previous(
|
|
1488
|
-
return
|
|
2482
|
+
function previous(code2) {
|
|
2483
|
+
return code2 !== 36 || this.events[this.events.length - 1][1].type === "characterEscape";
|
|
1489
2484
|
}
|
|
1490
2485
|
|
|
1491
2486
|
// node_modules/micromark-extension-math/lib/syntax.js
|
|
@@ -1504,30 +2499,6 @@ function math(options) {
|
|
|
1504
2499
|
function ok2() {
|
|
1505
2500
|
}
|
|
1506
2501
|
|
|
1507
|
-
// node_modules/longest-streak/index.js
|
|
1508
|
-
function longestStreak(value, substring) {
|
|
1509
|
-
const source = String(value);
|
|
1510
|
-
let index = source.indexOf(substring);
|
|
1511
|
-
let expected = index;
|
|
1512
|
-
let count = 0;
|
|
1513
|
-
let max = 0;
|
|
1514
|
-
if (typeof substring !== "string") {
|
|
1515
|
-
throw new TypeError("Expected substring");
|
|
1516
|
-
}
|
|
1517
|
-
while (index !== -1) {
|
|
1518
|
-
if (index === expected) {
|
|
1519
|
-
if (++count > max) {
|
|
1520
|
-
max = count;
|
|
1521
|
-
}
|
|
1522
|
-
} else {
|
|
1523
|
-
count = 1;
|
|
1524
|
-
}
|
|
1525
|
-
expected = index + substring.length;
|
|
1526
|
-
index = source.indexOf(substring, expected);
|
|
1527
|
-
}
|
|
1528
|
-
return max;
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
2502
|
// node_modules/mdast-util-math/lib/index.js
|
|
1532
2503
|
function mathFromMarkdown() {
|
|
1533
2504
|
return {
|
|
@@ -1546,7 +2517,7 @@ function mathFromMarkdown() {
|
|
|
1546
2517
|
}
|
|
1547
2518
|
};
|
|
1548
2519
|
function enterMathFlow(token) {
|
|
1549
|
-
const
|
|
2520
|
+
const code2 = {
|
|
1550
2521
|
type: "element",
|
|
1551
2522
|
tagName: "code",
|
|
1552
2523
|
properties: { className: ["language-math", "math-display"] },
|
|
@@ -1557,7 +2528,7 @@ function mathFromMarkdown() {
|
|
|
1557
2528
|
type: "math",
|
|
1558
2529
|
meta: null,
|
|
1559
2530
|
value: "",
|
|
1560
|
-
data: { hName: "pre", hChildren: [
|
|
2531
|
+
data: { hName: "pre", hChildren: [code2] }
|
|
1561
2532
|
},
|
|
1562
2533
|
token
|
|
1563
2534
|
);
|
|
@@ -1567,9 +2538,9 @@ function mathFromMarkdown() {
|
|
|
1567
2538
|
}
|
|
1568
2539
|
function exitMathFlowMeta() {
|
|
1569
2540
|
const data = this.resume();
|
|
1570
|
-
const
|
|
1571
|
-
ok2(
|
|
1572
|
-
|
|
2541
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2542
|
+
ok2(node2.type === "math");
|
|
2543
|
+
node2.meta = data;
|
|
1573
2544
|
}
|
|
1574
2545
|
function exitMathFlowFence() {
|
|
1575
2546
|
if (this.data.mathFlowInside) return;
|
|
@@ -1578,17 +2549,17 @@ function mathFromMarkdown() {
|
|
|
1578
2549
|
}
|
|
1579
2550
|
function exitMathFlow(token) {
|
|
1580
2551
|
const data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
|
|
1581
|
-
const
|
|
1582
|
-
ok2(
|
|
2552
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2553
|
+
ok2(node2.type === "math");
|
|
1583
2554
|
this.exit(token);
|
|
1584
|
-
|
|
1585
|
-
const
|
|
2555
|
+
node2.value = data;
|
|
2556
|
+
const code2 = (
|
|
1586
2557
|
/** @type {HastElement} */
|
|
1587
|
-
|
|
2558
|
+
node2.data.hChildren[0]
|
|
1588
2559
|
);
|
|
1589
|
-
ok2(
|
|
1590
|
-
ok2(
|
|
1591
|
-
|
|
2560
|
+
ok2(code2.type === "element");
|
|
2561
|
+
ok2(code2.tagName === "code");
|
|
2562
|
+
code2.children.push({ type: "text", value: data });
|
|
1592
2563
|
this.data.mathFlowInside = void 0;
|
|
1593
2564
|
}
|
|
1594
2565
|
function enterMathText(token) {
|
|
@@ -1608,14 +2579,14 @@ function mathFromMarkdown() {
|
|
|
1608
2579
|
}
|
|
1609
2580
|
function exitMathText(token) {
|
|
1610
2581
|
const data = this.resume();
|
|
1611
|
-
const
|
|
1612
|
-
ok2(
|
|
2582
|
+
const node2 = this.stack[this.stack.length - 1];
|
|
2583
|
+
ok2(node2.type === "inlineMath");
|
|
1613
2584
|
this.exit(token);
|
|
1614
|
-
|
|
2585
|
+
node2.value = data;
|
|
1615
2586
|
const children = (
|
|
1616
2587
|
/** @type {Array<HastElementContent>} */
|
|
1617
2588
|
// @ts-expect-error: we defined it in `enterMathFlow`.
|
|
1618
|
-
|
|
2589
|
+
node2.data.hChildren
|
|
1619
2590
|
);
|
|
1620
2591
|
children.push({ type: "text", value: data });
|
|
1621
2592
|
}
|
|
@@ -1644,16 +2615,16 @@ function mathToMarkdown(options) {
|
|
|
1644
2615
|
],
|
|
1645
2616
|
handlers: { math: math2, inlineMath }
|
|
1646
2617
|
};
|
|
1647
|
-
function math2(
|
|
1648
|
-
const raw =
|
|
2618
|
+
function math2(node2, _, state, info) {
|
|
2619
|
+
const raw = node2.value || "";
|
|
1649
2620
|
const tracker = state.createTracker(info);
|
|
1650
2621
|
const sequence = "$".repeat(Math.max(longestStreak(raw, "$") + 1, 2));
|
|
1651
2622
|
const exit = state.enter("mathFlow");
|
|
1652
2623
|
let value = tracker.move(sequence);
|
|
1653
|
-
if (
|
|
2624
|
+
if (node2.meta) {
|
|
1654
2625
|
const subexit = state.enter("mathFlowMeta");
|
|
1655
2626
|
value += tracker.move(
|
|
1656
|
-
state.safe(
|
|
2627
|
+
state.safe(node2.meta, {
|
|
1657
2628
|
after: "\n",
|
|
1658
2629
|
before: value,
|
|
1659
2630
|
encode: ["$"],
|
|
@@ -1670,8 +2641,8 @@ function mathToMarkdown(options) {
|
|
|
1670
2641
|
exit();
|
|
1671
2642
|
return value;
|
|
1672
2643
|
}
|
|
1673
|
-
function inlineMath(
|
|
1674
|
-
let value =
|
|
2644
|
+
function inlineMath(node2, _, state) {
|
|
2645
|
+
let value = node2.value || "";
|
|
1675
2646
|
let size = 1;
|
|
1676
2647
|
if (!single) size++;
|
|
1677
2648
|
while (new RegExp("(^|[^$])" + "\\$".repeat(size) + "([^$]|$)").test(value)) {
|
|
@@ -1747,6 +2718,9 @@ function remarkObsidian(userOpts) {
|
|
|
1747
2718
|
data.fromMarkdownExtensions.push(mathFromMarkdown());
|
|
1748
2719
|
data.toMarkdownExtensions.push(mathToMarkdown());
|
|
1749
2720
|
}
|
|
2721
|
+
if (opts.customTaskChars) {
|
|
2722
|
+
data.toMarkdownExtensions.push(taskCharToMarkdown());
|
|
2723
|
+
}
|
|
1750
2724
|
const needsTransform = opts.comments || opts.customTaskChars;
|
|
1751
2725
|
if (!needsTransform) return void 0;
|
|
1752
2726
|
return (tree, file) => {
|
|
@@ -1780,6 +2754,7 @@ export {
|
|
|
1780
2754
|
tagFromMarkdown,
|
|
1781
2755
|
tagSyntax,
|
|
1782
2756
|
tagToMarkdown,
|
|
2757
|
+
taskCharToMarkdown,
|
|
1783
2758
|
wikilinkFromMarkdown,
|
|
1784
2759
|
wikilinkSyntax,
|
|
1785
2760
|
wikilinkToMarkdown
|