@quartz-community/remark-obsidian 0.1.0

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.js ADDED
@@ -0,0 +1,1775 @@
1
+ // node_modules/unist-util-is/lib/index.js
2
+ var convert = (
3
+ // Note: overloads in JSDoc can’t yet use different `@template`s.
4
+ /**
5
+ * @type {(
6
+ * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
7
+ * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
8
+ * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
9
+ * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
10
+ * ((test?: Test) => Check)
11
+ * )}
12
+ */
13
+ /**
14
+ * @param {Test} [test]
15
+ * @returns {Check}
16
+ */
17
+ (function(test) {
18
+ if (test === null || test === void 0) {
19
+ return ok;
20
+ }
21
+ if (typeof test === "function") {
22
+ return castFactory(test);
23
+ }
24
+ if (typeof test === "object") {
25
+ return Array.isArray(test) ? anyFactory(test) : (
26
+ // Cast because `ReadonlyArray` goes into the above but `isArray`
27
+ // narrows to `Array`.
28
+ propertiesFactory(
29
+ /** @type {Props} */
30
+ test
31
+ )
32
+ );
33
+ }
34
+ if (typeof test === "string") {
35
+ return typeFactory(test);
36
+ }
37
+ throw new Error("Expected function, string, or object as test");
38
+ })
39
+ );
40
+ function anyFactory(tests) {
41
+ const checks = [];
42
+ let index = -1;
43
+ while (++index < tests.length) {
44
+ checks[index] = convert(tests[index]);
45
+ }
46
+ return castFactory(any);
47
+ function any(...parameters) {
48
+ let index2 = -1;
49
+ while (++index2 < checks.length) {
50
+ if (checks[index2].apply(this, parameters)) return true;
51
+ }
52
+ return false;
53
+ }
54
+ }
55
+ function propertiesFactory(check) {
56
+ const checkAsRecord = (
57
+ /** @type {Record<string, unknown>} */
58
+ check
59
+ );
60
+ return castFactory(all);
61
+ function all(node) {
62
+ const nodeAsRecord = (
63
+ /** @type {Record<string, unknown>} */
64
+ /** @type {unknown} */
65
+ node
66
+ );
67
+ let key;
68
+ for (key in check) {
69
+ if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
70
+ }
71
+ return true;
72
+ }
73
+ }
74
+ function typeFactory(check) {
75
+ return castFactory(type);
76
+ function type(node) {
77
+ return node && node.type === check;
78
+ }
79
+ }
80
+ function castFactory(testFunction) {
81
+ return check;
82
+ function check(value, index, parent) {
83
+ return Boolean(
84
+ looksLikeANode(value) && testFunction.call(
85
+ this,
86
+ value,
87
+ typeof index === "number" ? index : void 0,
88
+ parent || void 0
89
+ )
90
+ );
91
+ }
92
+ }
93
+ function ok() {
94
+ return true;
95
+ }
96
+ function looksLikeANode(value) {
97
+ return value !== null && typeof value === "object" && "type" in value;
98
+ }
99
+
100
+ // node_modules/unist-util-visit-parents/lib/color.node.js
101
+ function color(d) {
102
+ return "\x1B[33m" + d + "\x1B[39m";
103
+ }
104
+
105
+ // node_modules/unist-util-visit-parents/lib/index.js
106
+ var empty = [];
107
+ var CONTINUE = true;
108
+ var EXIT = false;
109
+ var SKIP = "skip";
110
+ function visitParents(tree, test, visitor, reverse) {
111
+ let check;
112
+ if (typeof test === "function" && typeof visitor !== "function") {
113
+ reverse = visitor;
114
+ visitor = test;
115
+ } else {
116
+ check = test;
117
+ }
118
+ const is2 = convert(check);
119
+ const step = reverse ? -1 : 1;
120
+ factory(tree, void 0, [])();
121
+ function factory(node, index, parents) {
122
+ const value = (
123
+ /** @type {Record<string, unknown>} */
124
+ node && typeof node === "object" ? node : {}
125
+ );
126
+ if (typeof value.type === "string") {
127
+ const name = (
128
+ // `hast`
129
+ typeof value.tagName === "string" ? value.tagName : (
130
+ // `xast`
131
+ typeof value.name === "string" ? value.name : void 0
132
+ )
133
+ );
134
+ Object.defineProperty(visit2, "name", {
135
+ value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
136
+ });
137
+ }
138
+ return visit2;
139
+ function visit2() {
140
+ let result = empty;
141
+ let subresult;
142
+ let offset;
143
+ let grandparents;
144
+ if (!test || is2(node, index, parents[parents.length - 1] || void 0)) {
145
+ result = toResult(visitor(node, parents));
146
+ if (result[0] === EXIT) {
147
+ return result;
148
+ }
149
+ }
150
+ if ("children" in node && node.children) {
151
+ const nodeAsParent = (
152
+ /** @type {UnistParent} */
153
+ node
154
+ );
155
+ if (nodeAsParent.children && result[0] !== SKIP) {
156
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
157
+ grandparents = parents.concat(nodeAsParent);
158
+ while (offset > -1 && offset < nodeAsParent.children.length) {
159
+ const child = nodeAsParent.children[offset];
160
+ subresult = factory(child, offset, grandparents)();
161
+ if (subresult[0] === EXIT) {
162
+ return subresult;
163
+ }
164
+ offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
165
+ }
166
+ }
167
+ }
168
+ return result;
169
+ }
170
+ }
171
+ }
172
+ function toResult(value) {
173
+ if (Array.isArray(value)) {
174
+ return value;
175
+ }
176
+ if (typeof value === "number") {
177
+ return [CONTINUE, value];
178
+ }
179
+ return value === null || value === void 0 ? empty : [value];
180
+ }
181
+
182
+ // node_modules/unist-util-visit/lib/index.js
183
+ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
184
+ let reverse;
185
+ let test;
186
+ let visitor;
187
+ if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
188
+ test = void 0;
189
+ visitor = testOrVisitor;
190
+ reverse = visitorOrReverse;
191
+ } else {
192
+ test = testOrVisitor;
193
+ visitor = visitorOrReverse;
194
+ reverse = maybeReverse;
195
+ }
196
+ visitParents(tree, test, overload, reverse);
197
+ function overload(node, parents) {
198
+ const parent = parents[parents.length - 1];
199
+ const index = parent ? parent.children.indexOf(node) : void 0;
200
+ return visitor(node, index, parent);
201
+ }
202
+ }
203
+
204
+ // node_modules/micromark-util-symbol/lib/codes.js
205
+ var codes = (
206
+ /** @type {const} */
207
+ {
208
+ carriageReturn: -5,
209
+ lineFeed: -4,
210
+ carriageReturnLineFeed: -3,
211
+ horizontalTab: -2,
212
+ virtualSpace: -1,
213
+ eof: null,
214
+ nul: 0,
215
+ soh: 1,
216
+ stx: 2,
217
+ etx: 3,
218
+ eot: 4,
219
+ enq: 5,
220
+ ack: 6,
221
+ bel: 7,
222
+ bs: 8,
223
+ ht: 9,
224
+ // `\t`
225
+ lf: 10,
226
+ // `\n`
227
+ vt: 11,
228
+ // `\v`
229
+ ff: 12,
230
+ // `\f`
231
+ cr: 13,
232
+ // `\r`
233
+ so: 14,
234
+ si: 15,
235
+ dle: 16,
236
+ dc1: 17,
237
+ dc2: 18,
238
+ dc3: 19,
239
+ dc4: 20,
240
+ nak: 21,
241
+ syn: 22,
242
+ etb: 23,
243
+ can: 24,
244
+ em: 25,
245
+ sub: 26,
246
+ esc: 27,
247
+ fs: 28,
248
+ gs: 29,
249
+ rs: 30,
250
+ us: 31,
251
+ space: 32,
252
+ exclamationMark: 33,
253
+ // `!`
254
+ quotationMark: 34,
255
+ // `"`
256
+ numberSign: 35,
257
+ // `#`
258
+ dollarSign: 36,
259
+ // `$`
260
+ percentSign: 37,
261
+ // `%`
262
+ ampersand: 38,
263
+ // `&`
264
+ apostrophe: 39,
265
+ // `'`
266
+ leftParenthesis: 40,
267
+ // `(`
268
+ rightParenthesis: 41,
269
+ // `)`
270
+ asterisk: 42,
271
+ // `*`
272
+ plusSign: 43,
273
+ // `+`
274
+ comma: 44,
275
+ // `,`
276
+ dash: 45,
277
+ // `-`
278
+ dot: 46,
279
+ // `.`
280
+ slash: 47,
281
+ // `/`
282
+ digit0: 48,
283
+ // `0`
284
+ digit1: 49,
285
+ // `1`
286
+ digit2: 50,
287
+ // `2`
288
+ digit3: 51,
289
+ // `3`
290
+ digit4: 52,
291
+ // `4`
292
+ digit5: 53,
293
+ // `5`
294
+ digit6: 54,
295
+ // `6`
296
+ digit7: 55,
297
+ // `7`
298
+ digit8: 56,
299
+ // `8`
300
+ digit9: 57,
301
+ // `9`
302
+ colon: 58,
303
+ // `:`
304
+ semicolon: 59,
305
+ // `;`
306
+ lessThan: 60,
307
+ // `<`
308
+ equalsTo: 61,
309
+ // `=`
310
+ greaterThan: 62,
311
+ // `>`
312
+ questionMark: 63,
313
+ // `?`
314
+ atSign: 64,
315
+ // `@`
316
+ uppercaseA: 65,
317
+ // `A`
318
+ uppercaseB: 66,
319
+ // `B`
320
+ uppercaseC: 67,
321
+ // `C`
322
+ uppercaseD: 68,
323
+ // `D`
324
+ uppercaseE: 69,
325
+ // `E`
326
+ uppercaseF: 70,
327
+ // `F`
328
+ uppercaseG: 71,
329
+ // `G`
330
+ uppercaseH: 72,
331
+ // `H`
332
+ uppercaseI: 73,
333
+ // `I`
334
+ uppercaseJ: 74,
335
+ // `J`
336
+ uppercaseK: 75,
337
+ // `K`
338
+ uppercaseL: 76,
339
+ // `L`
340
+ uppercaseM: 77,
341
+ // `M`
342
+ uppercaseN: 78,
343
+ // `N`
344
+ uppercaseO: 79,
345
+ // `O`
346
+ uppercaseP: 80,
347
+ // `P`
348
+ uppercaseQ: 81,
349
+ // `Q`
350
+ uppercaseR: 82,
351
+ // `R`
352
+ uppercaseS: 83,
353
+ // `S`
354
+ uppercaseT: 84,
355
+ // `T`
356
+ uppercaseU: 85,
357
+ // `U`
358
+ uppercaseV: 86,
359
+ // `V`
360
+ uppercaseW: 87,
361
+ // `W`
362
+ uppercaseX: 88,
363
+ // `X`
364
+ uppercaseY: 89,
365
+ // `Y`
366
+ uppercaseZ: 90,
367
+ // `Z`
368
+ leftSquareBracket: 91,
369
+ // `[`
370
+ backslash: 92,
371
+ // `\`
372
+ rightSquareBracket: 93,
373
+ // `]`
374
+ caret: 94,
375
+ // `^`
376
+ underscore: 95,
377
+ // `_`
378
+ graveAccent: 96,
379
+ // `` ` ``
380
+ lowercaseA: 97,
381
+ // `a`
382
+ lowercaseB: 98,
383
+ // `b`
384
+ lowercaseC: 99,
385
+ // `c`
386
+ lowercaseD: 100,
387
+ // `d`
388
+ lowercaseE: 101,
389
+ // `e`
390
+ lowercaseF: 102,
391
+ // `f`
392
+ lowercaseG: 103,
393
+ // `g`
394
+ lowercaseH: 104,
395
+ // `h`
396
+ lowercaseI: 105,
397
+ // `i`
398
+ lowercaseJ: 106,
399
+ // `j`
400
+ lowercaseK: 107,
401
+ // `k`
402
+ lowercaseL: 108,
403
+ // `l`
404
+ lowercaseM: 109,
405
+ // `m`
406
+ lowercaseN: 110,
407
+ // `n`
408
+ lowercaseO: 111,
409
+ // `o`
410
+ lowercaseP: 112,
411
+ // `p`
412
+ lowercaseQ: 113,
413
+ // `q`
414
+ lowercaseR: 114,
415
+ // `r`
416
+ lowercaseS: 115,
417
+ // `s`
418
+ lowercaseT: 116,
419
+ // `t`
420
+ lowercaseU: 117,
421
+ // `u`
422
+ lowercaseV: 118,
423
+ // `v`
424
+ lowercaseW: 119,
425
+ // `w`
426
+ lowercaseX: 120,
427
+ // `x`
428
+ lowercaseY: 121,
429
+ // `y`
430
+ lowercaseZ: 122,
431
+ // `z`
432
+ leftCurlyBrace: 123,
433
+ // `{`
434
+ verticalBar: 124,
435
+ // `|`
436
+ rightCurlyBrace: 125,
437
+ // `}`
438
+ tilde: 126,
439
+ // `~`
440
+ del: 127,
441
+ // Unicode Specials block.
442
+ byteOrderMarker: 65279,
443
+ // Unicode Specials block.
444
+ replacementCharacter: 65533
445
+ // `�`
446
+ }
447
+ );
448
+
449
+ // src/lib/syntax/wikilink.ts
450
+ var EXCLAMATION = 33;
451
+ var HASH = 35;
452
+ var LEFT_BRACKET = 91;
453
+ var BACKSLASH = 92;
454
+ var RIGHT_BRACKET = 93;
455
+ var PIPE = 124;
456
+ function isLineEnding(code) {
457
+ return code === codes.lineFeed || code === codes.carriageReturn;
458
+ }
459
+ function wikilinkSyntax() {
460
+ return {
461
+ text: {
462
+ [LEFT_BRACKET]: { name: "wikilink", tokenize },
463
+ [EXCLAMATION]: { name: "wikilink", tokenize }
464
+ }
465
+ };
466
+ }
467
+ function tokenize(effects, ok3, nok) {
468
+ let hasPath = false;
469
+ let hasHeading = false;
470
+ let hasAlias = false;
471
+ return start;
472
+ function start(code) {
473
+ if (code === EXCLAMATION) {
474
+ effects.enter("wikilink");
475
+ effects.enter("wikilinkEmbedMarker");
476
+ effects.consume(code);
477
+ effects.exit("wikilinkEmbedMarker");
478
+ return openFirst;
479
+ }
480
+ if (code === LEFT_BRACKET) {
481
+ effects.enter("wikilink");
482
+ return openFirst(code);
483
+ }
484
+ return nok(code);
485
+ }
486
+ function openFirst(code) {
487
+ if (code !== LEFT_BRACKET) return nok(code);
488
+ effects.enter("wikilinkMarker");
489
+ effects.consume(code);
490
+ return openSecond;
491
+ }
492
+ function openSecond(code) {
493
+ if (code !== LEFT_BRACKET) return nok(code);
494
+ effects.consume(code);
495
+ effects.exit("wikilinkMarker");
496
+ return pathStart;
497
+ }
498
+ function pathStart(code) {
499
+ if (code === HASH) return headingMarker(code);
500
+ if (code === PIPE) return nok(code);
501
+ if (code === RIGHT_BRACKET || code === null || isLineEnding(code))
502
+ return nok(code);
503
+ effects.enter("wikilinkPath");
504
+ hasPath = true;
505
+ return path(code);
506
+ }
507
+ function path(code) {
508
+ if (code === BACKSLASH) {
509
+ effects.consume(code);
510
+ return pathEscape;
511
+ }
512
+ if (code === HASH) {
513
+ effects.exit("wikilinkPath");
514
+ return headingMarker(code);
515
+ }
516
+ if (code === PIPE) {
517
+ effects.exit("wikilinkPath");
518
+ return aliasMarker(code);
519
+ }
520
+ if (code === RIGHT_BRACKET) {
521
+ effects.exit("wikilinkPath");
522
+ return closeFirst(code);
523
+ }
524
+ if (code === null || isLineEnding(code)) return nok(code);
525
+ effects.consume(code);
526
+ return path;
527
+ }
528
+ function pathEscape(code) {
529
+ if (code === PIPE) {
530
+ effects.exit("wikilinkPath");
531
+ return aliasMarker(code);
532
+ }
533
+ if (code === null || isLineEnding(code)) return nok(code);
534
+ effects.consume(code);
535
+ return path;
536
+ }
537
+ function headingMarker(code) {
538
+ if (code !== HASH) return nok(code);
539
+ effects.enter("wikilinkHeadingMarker");
540
+ effects.consume(code);
541
+ effects.exit("wikilinkHeadingMarker");
542
+ return headingStart;
543
+ }
544
+ function headingStart(code) {
545
+ if (code === null || isLineEnding(code)) return nok(code);
546
+ if (code === RIGHT_BRACKET) {
547
+ hasHeading = true;
548
+ return closeFirst(code);
549
+ }
550
+ if (code === PIPE) {
551
+ hasHeading = true;
552
+ return aliasMarker(code);
553
+ }
554
+ effects.enter("wikilinkHeading");
555
+ hasHeading = true;
556
+ return heading(code);
557
+ }
558
+ function heading(code) {
559
+ if (code === BACKSLASH) {
560
+ effects.consume(code);
561
+ return headingEscape;
562
+ }
563
+ if (code === PIPE) {
564
+ effects.exit("wikilinkHeading");
565
+ return aliasMarker(code);
566
+ }
567
+ if (code === RIGHT_BRACKET) {
568
+ effects.exit("wikilinkHeading");
569
+ return closeFirst(code);
570
+ }
571
+ if (code === null || isLineEnding(code)) return nok(code);
572
+ effects.consume(code);
573
+ return heading;
574
+ }
575
+ function headingEscape(code) {
576
+ if (code === PIPE) {
577
+ effects.exit("wikilinkHeading");
578
+ return aliasMarker(code);
579
+ }
580
+ if (code === null || isLineEnding(code)) return nok(code);
581
+ effects.consume(code);
582
+ return heading;
583
+ }
584
+ function aliasMarker(code) {
585
+ if (code !== PIPE) return nok(code);
586
+ effects.enter("wikilinkAliasMarker");
587
+ effects.consume(code);
588
+ effects.exit("wikilinkAliasMarker");
589
+ return aliasStart;
590
+ }
591
+ function aliasStart(code) {
592
+ if (code === RIGHT_BRACKET) return closeFirst(code);
593
+ if (code === null || isLineEnding(code)) return nok(code);
594
+ effects.enter("wikilinkAlias");
595
+ hasAlias = true;
596
+ return alias(code);
597
+ }
598
+ function alias(code) {
599
+ if (code === RIGHT_BRACKET) {
600
+ effects.exit("wikilinkAlias");
601
+ return closeFirst(code);
602
+ }
603
+ if (code === null || isLineEnding(code)) return nok(code);
604
+ effects.consume(code);
605
+ return alias;
606
+ }
607
+ function closeFirst(code) {
608
+ if (code !== RIGHT_BRACKET) return nok(code);
609
+ if (!hasPath && !hasHeading && !hasAlias) return nok(code);
610
+ effects.enter("wikilinkMarker");
611
+ effects.consume(code);
612
+ return closeSecond;
613
+ }
614
+ function closeSecond(code) {
615
+ if (code !== RIGHT_BRACKET) return nok(code);
616
+ effects.consume(code);
617
+ effects.exit("wikilinkMarker");
618
+ effects.exit("wikilink");
619
+ return ok3;
620
+ }
621
+ }
622
+
623
+ // src/lib/syntax/highlight.ts
624
+ var EQUALS = 61;
625
+ function isLineEnding2(code) {
626
+ return code === codes.lineFeed || code === codes.carriageReturn;
627
+ }
628
+ function highlightSyntax() {
629
+ return {
630
+ text: {
631
+ [EQUALS]: { name: "highlight", tokenize: tokenize2 }
632
+ }
633
+ };
634
+ }
635
+ function tokenize2(effects, ok3, nok) {
636
+ const close = { tokenize: tokenizeClose, partial: true };
637
+ let hasContent = false;
638
+ return start;
639
+ function start(code) {
640
+ if (code !== EQUALS) return nok(code);
641
+ effects.enter("highlight");
642
+ effects.enter("highlightMarker");
643
+ effects.consume(code);
644
+ return openSecond;
645
+ }
646
+ function openSecond(code) {
647
+ if (code !== EQUALS) return nok(code);
648
+ effects.consume(code);
649
+ effects.exit("highlightMarker");
650
+ effects.enter("highlightContent");
651
+ return content;
652
+ }
653
+ function content(code) {
654
+ if (code === null || isLineEnding2(code)) return nok(code);
655
+ if (!hasContent && code === EQUALS) return nok(code);
656
+ if (code === EQUALS)
657
+ return effects.attempt(close, closeAfter, contentConsume)(code);
658
+ effects.consume(code);
659
+ hasContent = true;
660
+ return content;
661
+ }
662
+ function contentConsume(code) {
663
+ if (code === null || isLineEnding2(code)) return nok(code);
664
+ effects.consume(code);
665
+ return content;
666
+ }
667
+ function tokenizeClose(closeEffects, closeOk, closeNok) {
668
+ return closeStart;
669
+ function closeStart(closeCode) {
670
+ if (closeCode !== EQUALS) return closeNok(closeCode);
671
+ closeEffects.exit("highlightContent");
672
+ closeEffects.enter("highlightMarker");
673
+ closeEffects.consume(closeCode);
674
+ return closeSecond;
675
+ }
676
+ function closeSecond(closeCode) {
677
+ if (closeCode !== EQUALS) return closeNok(closeCode);
678
+ closeEffects.consume(closeCode);
679
+ closeEffects.exit("highlightMarker");
680
+ return closeOk;
681
+ }
682
+ }
683
+ function closeAfter(code) {
684
+ effects.exit("highlight");
685
+ return ok3(code);
686
+ }
687
+ }
688
+
689
+ // src/lib/syntax/comment.ts
690
+ var PERCENT = 37;
691
+ var LINE_FEED = -4;
692
+ var CARRIAGE_RETURN = -3;
693
+ var CARRIAGE_RETURN_LINE_FEED = -5;
694
+ function isLineEnding3(code) {
695
+ return code === LINE_FEED || code === CARRIAGE_RETURN || code === CARRIAGE_RETURN_LINE_FEED;
696
+ }
697
+ var commentFlow = {
698
+ tokenize: tokenizeFlow,
699
+ concrete: true,
700
+ name: "commentFlow"
701
+ };
702
+ var nonLazyContinuation = {
703
+ tokenize: tokenizeNonLazyContinuation,
704
+ partial: true
705
+ };
706
+ function commentSyntax() {
707
+ return {
708
+ text: {
709
+ [PERCENT]: { name: "comment", tokenize: tokenizeText }
710
+ },
711
+ flow: {
712
+ [PERCENT]: commentFlow
713
+ }
714
+ };
715
+ }
716
+ function tokenizeText(effects, ok3, nok) {
717
+ const close = { tokenize: tokenizeClose, partial: true };
718
+ return start;
719
+ function start(code) {
720
+ if (code !== PERCENT) return nok(code);
721
+ effects.enter("comment");
722
+ effects.enter("commentMarker");
723
+ effects.consume(code);
724
+ return openSecond;
725
+ }
726
+ function openSecond(code) {
727
+ if (code !== PERCENT) return nok(code);
728
+ effects.consume(code);
729
+ effects.exit("commentMarker");
730
+ effects.enter("commentContent");
731
+ return content;
732
+ }
733
+ function content(code) {
734
+ if (code === null) return nok(code);
735
+ if (code === PERCENT)
736
+ return effects.attempt(close, closeAfter, contentConsume)(code);
737
+ effects.consume(code);
738
+ return content;
739
+ }
740
+ function contentConsume(code) {
741
+ if (code === null) return nok(code);
742
+ effects.consume(code);
743
+ return content;
744
+ }
745
+ function tokenizeClose(closeEffects, closeOk, closeNok) {
746
+ return closeStart;
747
+ function closeStart(closeCode) {
748
+ if (closeCode !== PERCENT) return closeNok(closeCode);
749
+ closeEffects.exit("commentContent");
750
+ closeEffects.enter("commentMarker");
751
+ closeEffects.consume(closeCode);
752
+ return closeSecond;
753
+ }
754
+ function closeSecond(closeCode) {
755
+ if (closeCode !== PERCENT) return closeNok(closeCode);
756
+ closeEffects.consume(closeCode);
757
+ closeEffects.exit("commentMarker");
758
+ return closeOk;
759
+ }
760
+ }
761
+ function closeAfter(code) {
762
+ effects.exit("comment");
763
+ return ok3(code);
764
+ }
765
+ }
766
+ function tokenizeFlow(effects, ok3, nok) {
767
+ const self = this;
768
+ const flowClose = {
769
+ tokenize: tokenizeFlowClose,
770
+ partial: true
771
+ };
772
+ return start;
773
+ function start(code) {
774
+ if (code !== PERCENT) return nok(code);
775
+ effects.enter("comment");
776
+ effects.enter("commentMarker");
777
+ effects.consume(code);
778
+ return openSecond;
779
+ }
780
+ function openSecond(code) {
781
+ if (code !== PERCENT) return nok(code);
782
+ effects.consume(code);
783
+ effects.exit("commentMarker");
784
+ return afterOpen;
785
+ }
786
+ function afterOpen(code) {
787
+ if (code === null) return nok(code);
788
+ if (isLineEnding3(code)) {
789
+ return effects.attempt(
790
+ nonLazyContinuation,
791
+ beforeContentChunk,
792
+ abandon
793
+ )(code);
794
+ }
795
+ effects.enter("commentContent");
796
+ return contentChunk(code);
797
+ }
798
+ function beforeContentChunk(code) {
799
+ if (code === null) {
800
+ return abandon(code);
801
+ }
802
+ if (isLineEnding3(code)) {
803
+ return effects.attempt(
804
+ nonLazyContinuation,
805
+ beforeContentChunk,
806
+ abandon
807
+ )(code);
808
+ }
809
+ if (code === PERCENT) {
810
+ return effects.attempt(flowClose, closeAfter, startContent)(code);
811
+ }
812
+ effects.enter("commentContent");
813
+ return contentChunk(code);
814
+ }
815
+ function startContent(code) {
816
+ effects.enter("commentContent");
817
+ effects.consume(code);
818
+ return contentChunk;
819
+ }
820
+ function contentChunk(code) {
821
+ if (code === null) return abandon(code);
822
+ if (code === PERCENT) {
823
+ return effects.attempt(flowClose, closeAfter, contentConsume)(code);
824
+ }
825
+ if (isLineEnding3(code)) {
826
+ effects.exit("commentContent");
827
+ return effects.attempt(
828
+ nonLazyContinuation,
829
+ beforeContentChunk,
830
+ abandon
831
+ )(code);
832
+ }
833
+ effects.consume(code);
834
+ return contentChunk;
835
+ }
836
+ function contentConsume(code) {
837
+ if (code === null) return abandon(code);
838
+ effects.consume(code);
839
+ return contentChunk;
840
+ }
841
+ function closeAfter(code) {
842
+ effects.exit("comment");
843
+ return ok3(code);
844
+ }
845
+ function abandon(code) {
846
+ effects.exit("comment");
847
+ return nok(code);
848
+ }
849
+ function tokenizeFlowClose(closeEffects, closeOk, closeNok) {
850
+ let inContent = false;
851
+ return closeStart;
852
+ function closeStart(closeCode) {
853
+ if (closeCode !== PERCENT) return closeNok(closeCode);
854
+ const current = self.events[self.events.length - 1];
855
+ if (current && current[0] === "enter" && current[1].type === "commentContent") {
856
+ closeEffects.exit("commentContent");
857
+ inContent = true;
858
+ }
859
+ closeEffects.enter("commentMarker");
860
+ closeEffects.consume(closeCode);
861
+ return closeSecond;
862
+ }
863
+ function closeSecond(closeCode) {
864
+ if (closeCode !== PERCENT) {
865
+ if (inContent) {
866
+ closeEffects.exit("commentMarker");
867
+ closeEffects.enter("commentContent");
868
+ }
869
+ return closeNok(closeCode);
870
+ }
871
+ closeEffects.consume(closeCode);
872
+ closeEffects.exit("commentMarker");
873
+ return closeOk;
874
+ }
875
+ }
876
+ }
877
+ function tokenizeNonLazyContinuation(effects, ok3, nok) {
878
+ const self = this;
879
+ return start;
880
+ function start(code) {
881
+ if (code === null) {
882
+ return ok3(code);
883
+ }
884
+ if (!isLineEnding3(code)) return nok(code);
885
+ effects.enter("lineEnding");
886
+ effects.consume(code);
887
+ effects.exit("lineEnding");
888
+ return lineStart;
889
+ }
890
+ function lineStart(code) {
891
+ return self.parser.lazy[self.now().line] ? nok(code) : ok3(code);
892
+ }
893
+ }
894
+
895
+ // src/lib/syntax/tag.ts
896
+ var HASH2 = 35;
897
+ var SLASH = 47;
898
+ var DASH = 45;
899
+ var UNDERSCORE = 95;
900
+ var tagCharRegex = /[\p{L}\p{M}\p{Emoji}]/u;
901
+ function isWhitespace(code) {
902
+ return code === codes.space || code === codes.horizontalTab || code === codes.lineFeed || code === codes.carriageReturn || code === codes.carriageReturnLineFeed;
903
+ }
904
+ function isTagChar(code) {
905
+ if (code === null || code < 0) return false;
906
+ if (code >= 48 && code <= 57) return true;
907
+ if (code === DASH || code === UNDERSCORE) return true;
908
+ return tagCharRegex.test(String.fromCodePoint(code));
909
+ }
910
+ function isNonDigit(code) {
911
+ if (code === null) return false;
912
+ return !(code >= 48 && code <= 57);
913
+ }
914
+ function tagSyntax() {
915
+ return {
916
+ text: {
917
+ [HASH2]: { name: "tag", tokenize: tokenize3 }
918
+ }
919
+ };
920
+ }
921
+ function tokenize3(effects, ok3, nok) {
922
+ let hasNonDigit = false;
923
+ const context = this;
924
+ return start;
925
+ function start(code) {
926
+ const previous2 = context.previous;
927
+ const allowedStart = previous2 === null || isWhitespace(previous2) || previous2 === HASH2;
928
+ if (!allowedStart) return nok(code);
929
+ if (code !== HASH2) return nok(code);
930
+ effects.enter("tag");
931
+ effects.enter("tagMarker");
932
+ effects.consume(code);
933
+ effects.exit("tagMarker");
934
+ return tagStart;
935
+ }
936
+ function tagStart(code) {
937
+ if (!isTagChar(code)) return nok(code);
938
+ effects.enter("tagContent");
939
+ if (isNonDigit(code)) hasNonDigit = true;
940
+ effects.consume(code);
941
+ return tagContent;
942
+ }
943
+ function tagContent(code) {
944
+ if (code === SLASH) {
945
+ effects.consume(code);
946
+ return afterSlash;
947
+ }
948
+ if (isTagChar(code)) {
949
+ if (isNonDigit(code)) hasNonDigit = true;
950
+ effects.consume(code);
951
+ return tagContent;
952
+ }
953
+ return end(code);
954
+ }
955
+ function afterSlash(code) {
956
+ if (!isTagChar(code)) return nok(code);
957
+ if (isNonDigit(code)) hasNonDigit = true;
958
+ effects.consume(code);
959
+ return tagContent;
960
+ }
961
+ function end(code) {
962
+ if (!hasNonDigit) return nok(code);
963
+ effects.exit("tagContent");
964
+ effects.exit("tag");
965
+ return ok3(code);
966
+ }
967
+ }
968
+
969
+ // src/lib/mdast/wikilink.ts
970
+ function wikilinkFromMarkdown() {
971
+ return {
972
+ enter: {
973
+ wikilink(token) {
974
+ this.enter(
975
+ {
976
+ type: "wikilink",
977
+ value: "",
978
+ embedded: false,
979
+ path: "",
980
+ heading: "",
981
+ alias: ""
982
+ },
983
+ token
984
+ );
985
+ },
986
+ wikilinkEmbedMarker() {
987
+ const node = this.stack[this.stack.length - 1];
988
+ node.embedded = true;
989
+ },
990
+ wikilinkPath(token) {
991
+ const node = this.stack[this.stack.length - 1];
992
+ node.path = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
993
+ },
994
+ wikilinkHeading(token) {
995
+ const node = this.stack[this.stack.length - 1];
996
+ node.heading = this.sliceSerialize(token).replace(/\\([#\[\]])/g, "$1");
997
+ },
998
+ wikilinkAlias(token) {
999
+ const node = this.stack[this.stack.length - 1];
1000
+ node.alias = this.sliceSerialize(token);
1001
+ }
1002
+ },
1003
+ exit: {
1004
+ wikilink(token) {
1005
+ const node = this.stack[this.stack.length - 1];
1006
+ if (node.alias) {
1007
+ if (node.path.endsWith("\\")) node.path = node.path.slice(0, -1);
1008
+ if (node.heading.endsWith("\\"))
1009
+ node.heading = node.heading.slice(0, -1);
1010
+ }
1011
+ this.exit(token);
1012
+ }
1013
+ }
1014
+ };
1015
+ }
1016
+
1017
+ // src/lib/mdast/highlight.ts
1018
+ function highlightFromMarkdown() {
1019
+ return {
1020
+ enter: {
1021
+ highlight(token) {
1022
+ this.enter({ type: "highlight", children: [] }, token);
1023
+ }
1024
+ },
1025
+ exit: {
1026
+ highlightContent(token) {
1027
+ const node = this.stack[this.stack.length - 1];
1028
+ node.children = [{ type: "text", value: this.sliceSerialize(token) }];
1029
+ },
1030
+ highlight(token) {
1031
+ this.exit(token);
1032
+ }
1033
+ }
1034
+ };
1035
+ }
1036
+
1037
+ // src/lib/mdast/comment.ts
1038
+ function commentFromMarkdown() {
1039
+ return {
1040
+ enter: {
1041
+ comment(token) {
1042
+ this.enter({ type: "comment", value: "" }, token);
1043
+ }
1044
+ },
1045
+ exit: {
1046
+ commentContent(token) {
1047
+ const node = this.stack[this.stack.length - 1];
1048
+ node.value += this.sliceSerialize(token);
1049
+ },
1050
+ comment(token) {
1051
+ this.exit(token);
1052
+ }
1053
+ }
1054
+ };
1055
+ }
1056
+
1057
+ // src/lib/mdast/tag.ts
1058
+ function tagFromMarkdown() {
1059
+ return {
1060
+ enter: {
1061
+ tag(token) {
1062
+ this.enter({ type: "tag", value: "" }, token);
1063
+ },
1064
+ tagContent(token) {
1065
+ const node = this.stack[this.stack.length - 1];
1066
+ if (node.type === "tag") node.value = this.sliceSerialize(token);
1067
+ }
1068
+ },
1069
+ exit: {
1070
+ tag(token) {
1071
+ this.exit(token);
1072
+ }
1073
+ }
1074
+ };
1075
+ }
1076
+
1077
+ // src/lib/mdast/wikilink-to-markdown.ts
1078
+ function wikilinkToMarkdown() {
1079
+ return {
1080
+ handlers: {
1081
+ wikilink(node) {
1082
+ const prefix = node.embedded ? "!" : "";
1083
+ const heading = node.heading ? `#${node.heading}` : "";
1084
+ const alias = node.alias ? `|${node.alias}` : "";
1085
+ return `${prefix}[[${node.path}${heading}${alias}]]`;
1086
+ }
1087
+ }
1088
+ };
1089
+ }
1090
+
1091
+ // src/lib/mdast/highlight-to-markdown.ts
1092
+ function highlightToMarkdown() {
1093
+ return {
1094
+ handlers: {
1095
+ highlight(node, _parent, state, info) {
1096
+ const exit = state.enter("highlight");
1097
+ const content = state.containerPhrasing(node, info);
1098
+ exit();
1099
+ return `==${content}==`;
1100
+ }
1101
+ }
1102
+ };
1103
+ }
1104
+
1105
+ // src/lib/mdast/comment-to-markdown.ts
1106
+ function commentToMarkdown() {
1107
+ return {
1108
+ handlers: {
1109
+ comment(node) {
1110
+ return `%%${node.value}%%`;
1111
+ }
1112
+ }
1113
+ };
1114
+ }
1115
+
1116
+ // src/lib/mdast/tag-to-markdown.ts
1117
+ function tagToMarkdown() {
1118
+ return {
1119
+ handlers: {
1120
+ tag(node) {
1121
+ return `#${node.value}`;
1122
+ }
1123
+ }
1124
+ };
1125
+ }
1126
+
1127
+ // src/lib/task-char.ts
1128
+ function customTaskCharTransform(tree, source) {
1129
+ visit(tree, "listItem", (node) => {
1130
+ if (typeof node.checked === "boolean") {
1131
+ let char = node.checked ? "x" : " ";
1132
+ if (source && node.position?.start?.offset != null) {
1133
+ const slice = source.slice(
1134
+ node.position.start.offset,
1135
+ node.position.start.offset + 20
1136
+ );
1137
+ const m = slice.match(/\[([^\]])\]/);
1138
+ if (m) {
1139
+ char = m[1];
1140
+ }
1141
+ }
1142
+ node.data ??= {};
1143
+ node.data.taskChar = char;
1144
+ node.data.hProperties ??= {};
1145
+ node.data.hProperties.dataTaskChar = char;
1146
+ return;
1147
+ }
1148
+ const firstChild = node.children?.[0];
1149
+ if (!firstChild || firstChild.type !== "paragraph") return;
1150
+ const firstText = firstChild.children?.[0];
1151
+ if (!firstText || firstText.type !== "text") return;
1152
+ const match = firstText.value.match(/^\[([^\]])\]\s/);
1153
+ if (!match) return;
1154
+ const taskChar = match[1];
1155
+ node.checked = taskChar !== " ";
1156
+ node.data ??= {};
1157
+ node.data.taskChar = taskChar;
1158
+ node.data.hProperties ??= {};
1159
+ node.data.hProperties.dataTaskChar = taskChar;
1160
+ firstText.value = firstText.value.slice(match[0].length);
1161
+ if (firstText.value.length === 0) {
1162
+ firstChild.children.shift();
1163
+ } else if (firstText.position && typeof firstText.position.start.offset === "number") {
1164
+ firstText.position.start.column += match[0].length;
1165
+ firstText.position.start.offset += match[0].length;
1166
+ }
1167
+ });
1168
+ }
1169
+
1170
+ // node_modules/micromark-util-character/index.js
1171
+ var asciiAlpha = regexCheck(/[A-Za-z]/);
1172
+ var asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
1173
+ var asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
1174
+ var asciiDigit = regexCheck(/\d/);
1175
+ var asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
1176
+ var asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
1177
+ function markdownLineEnding(code) {
1178
+ return code !== null && code < -2;
1179
+ }
1180
+ function markdownSpace(code) {
1181
+ return code === -2 || code === -1 || code === 32;
1182
+ }
1183
+ var unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
1184
+ var unicodeWhitespace = regexCheck(/\s/);
1185
+ function regexCheck(regex) {
1186
+ return check;
1187
+ function check(code) {
1188
+ return code !== null && code > -1 && regex.test(String.fromCharCode(code));
1189
+ }
1190
+ }
1191
+
1192
+ // node_modules/micromark-factory-space/index.js
1193
+ function factorySpace(effects, ok3, type, max) {
1194
+ const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
1195
+ let size = 0;
1196
+ return start;
1197
+ function start(code) {
1198
+ if (markdownSpace(code)) {
1199
+ effects.enter(type);
1200
+ return prefix(code);
1201
+ }
1202
+ return ok3(code);
1203
+ }
1204
+ function prefix(code) {
1205
+ if (markdownSpace(code) && size++ < limit) {
1206
+ effects.consume(code);
1207
+ return prefix;
1208
+ }
1209
+ effects.exit(type);
1210
+ return ok3(code);
1211
+ }
1212
+ }
1213
+
1214
+ // node_modules/micromark-extension-math/lib/math-flow.js
1215
+ var mathFlow = {
1216
+ tokenize: tokenizeMathFenced,
1217
+ concrete: true,
1218
+ name: "mathFlow"
1219
+ };
1220
+ var nonLazyContinuation2 = {
1221
+ tokenize: tokenizeNonLazyContinuation2,
1222
+ partial: true
1223
+ };
1224
+ function tokenizeMathFenced(effects, ok3, nok) {
1225
+ const self = this;
1226
+ const tail = self.events[self.events.length - 1];
1227
+ const initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
1228
+ let sizeOpen = 0;
1229
+ return start;
1230
+ function start(code) {
1231
+ effects.enter("mathFlow");
1232
+ effects.enter("mathFlowFence");
1233
+ effects.enter("mathFlowFenceSequence");
1234
+ return sequenceOpen(code);
1235
+ }
1236
+ function sequenceOpen(code) {
1237
+ if (code === 36) {
1238
+ effects.consume(code);
1239
+ sizeOpen++;
1240
+ return sequenceOpen;
1241
+ }
1242
+ if (sizeOpen < 2) {
1243
+ return nok(code);
1244
+ }
1245
+ effects.exit("mathFlowFenceSequence");
1246
+ return factorySpace(effects, metaBefore, "whitespace")(code);
1247
+ }
1248
+ function metaBefore(code) {
1249
+ if (code === null || markdownLineEnding(code)) {
1250
+ return metaAfter(code);
1251
+ }
1252
+ effects.enter("mathFlowFenceMeta");
1253
+ effects.enter("chunkString", {
1254
+ contentType: "string"
1255
+ });
1256
+ return meta(code);
1257
+ }
1258
+ function meta(code) {
1259
+ if (code === null || markdownLineEnding(code)) {
1260
+ effects.exit("chunkString");
1261
+ effects.exit("mathFlowFenceMeta");
1262
+ return metaAfter(code);
1263
+ }
1264
+ if (code === 36) {
1265
+ return nok(code);
1266
+ }
1267
+ effects.consume(code);
1268
+ return meta;
1269
+ }
1270
+ function metaAfter(code) {
1271
+ effects.exit("mathFlowFence");
1272
+ if (self.interrupt) {
1273
+ return ok3(code);
1274
+ }
1275
+ return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code);
1276
+ }
1277
+ function beforeNonLazyContinuation(code) {
1278
+ return effects.attempt({
1279
+ tokenize: tokenizeClosingFence,
1280
+ partial: true
1281
+ }, after, contentStart)(code);
1282
+ }
1283
+ function contentStart(code) {
1284
+ return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(code);
1285
+ }
1286
+ function beforeContentChunk(code) {
1287
+ if (code === null) {
1288
+ return after(code);
1289
+ }
1290
+ if (markdownLineEnding(code)) {
1291
+ return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code);
1292
+ }
1293
+ effects.enter("mathFlowValue");
1294
+ return contentChunk(code);
1295
+ }
1296
+ function contentChunk(code) {
1297
+ if (code === null || markdownLineEnding(code)) {
1298
+ effects.exit("mathFlowValue");
1299
+ return beforeContentChunk(code);
1300
+ }
1301
+ effects.consume(code);
1302
+ return contentChunk;
1303
+ }
1304
+ function after(code) {
1305
+ effects.exit("mathFlow");
1306
+ return ok3(code);
1307
+ }
1308
+ function tokenizeClosingFence(effects2, ok4, nok2) {
1309
+ let size = 0;
1310
+ return factorySpace(effects2, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
1311
+ function beforeSequenceClose(code) {
1312
+ effects2.enter("mathFlowFence");
1313
+ effects2.enter("mathFlowFenceSequence");
1314
+ return sequenceClose(code);
1315
+ }
1316
+ function sequenceClose(code) {
1317
+ if (code === 36) {
1318
+ size++;
1319
+ effects2.consume(code);
1320
+ return sequenceClose;
1321
+ }
1322
+ if (size < sizeOpen) {
1323
+ return nok2(code);
1324
+ }
1325
+ effects2.exit("mathFlowFenceSequence");
1326
+ return factorySpace(effects2, afterSequenceClose, "whitespace")(code);
1327
+ }
1328
+ function afterSequenceClose(code) {
1329
+ if (code === null || markdownLineEnding(code)) {
1330
+ effects2.exit("mathFlowFence");
1331
+ return ok4(code);
1332
+ }
1333
+ return nok2(code);
1334
+ }
1335
+ }
1336
+ }
1337
+ function tokenizeNonLazyContinuation2(effects, ok3, nok) {
1338
+ const self = this;
1339
+ return start;
1340
+ function start(code) {
1341
+ if (code === null) {
1342
+ return ok3(code);
1343
+ }
1344
+ effects.enter("lineEnding");
1345
+ effects.consume(code);
1346
+ effects.exit("lineEnding");
1347
+ return lineStart;
1348
+ }
1349
+ function lineStart(code) {
1350
+ return self.parser.lazy[self.now().line] ? nok(code) : ok3(code);
1351
+ }
1352
+ }
1353
+
1354
+ // node_modules/micromark-extension-math/lib/math-text.js
1355
+ function mathText(options) {
1356
+ const options_ = options || {};
1357
+ let single = options_.singleDollarTextMath;
1358
+ if (single === null || single === void 0) {
1359
+ single = true;
1360
+ }
1361
+ return {
1362
+ tokenize: tokenizeMathText,
1363
+ resolve: resolveMathText,
1364
+ previous,
1365
+ name: "mathText"
1366
+ };
1367
+ function tokenizeMathText(effects, ok3, nok) {
1368
+ const self = this;
1369
+ let sizeOpen = 0;
1370
+ let size;
1371
+ let token;
1372
+ return start;
1373
+ function start(code) {
1374
+ effects.enter("mathText");
1375
+ effects.enter("mathTextSequence");
1376
+ return sequenceOpen(code);
1377
+ }
1378
+ function sequenceOpen(code) {
1379
+ if (code === 36) {
1380
+ effects.consume(code);
1381
+ sizeOpen++;
1382
+ return sequenceOpen;
1383
+ }
1384
+ if (sizeOpen < 2 && !single) {
1385
+ return nok(code);
1386
+ }
1387
+ effects.exit("mathTextSequence");
1388
+ return between(code);
1389
+ }
1390
+ function between(code) {
1391
+ if (code === null) {
1392
+ return nok(code);
1393
+ }
1394
+ if (code === 36) {
1395
+ token = effects.enter("mathTextSequence");
1396
+ size = 0;
1397
+ return sequenceClose(code);
1398
+ }
1399
+ if (code === 32) {
1400
+ effects.enter("space");
1401
+ effects.consume(code);
1402
+ effects.exit("space");
1403
+ return between;
1404
+ }
1405
+ if (markdownLineEnding(code)) {
1406
+ effects.enter("lineEnding");
1407
+ effects.consume(code);
1408
+ effects.exit("lineEnding");
1409
+ return between;
1410
+ }
1411
+ effects.enter("mathTextData");
1412
+ return data(code);
1413
+ }
1414
+ function data(code) {
1415
+ if (code === null || code === 32 || code === 36 || markdownLineEnding(code)) {
1416
+ effects.exit("mathTextData");
1417
+ return between(code);
1418
+ }
1419
+ effects.consume(code);
1420
+ return data;
1421
+ }
1422
+ function sequenceClose(code) {
1423
+ if (code === 36) {
1424
+ effects.consume(code);
1425
+ size++;
1426
+ return sequenceClose;
1427
+ }
1428
+ if (size === sizeOpen) {
1429
+ effects.exit("mathTextSequence");
1430
+ effects.exit("mathText");
1431
+ return ok3(code);
1432
+ }
1433
+ token.type = "mathTextData";
1434
+ return data(code);
1435
+ }
1436
+ }
1437
+ }
1438
+ function resolveMathText(events) {
1439
+ let tailExitIndex = events.length - 4;
1440
+ let headEnterIndex = 3;
1441
+ let index;
1442
+ let enter;
1443
+ if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
1444
+ index = headEnterIndex;
1445
+ while (++index < tailExitIndex) {
1446
+ if (events[index][1].type === "mathTextData") {
1447
+ events[tailExitIndex][1].type = "mathTextPadding";
1448
+ events[headEnterIndex][1].type = "mathTextPadding";
1449
+ headEnterIndex += 2;
1450
+ tailExitIndex -= 2;
1451
+ break;
1452
+ }
1453
+ }
1454
+ }
1455
+ index = headEnterIndex - 1;
1456
+ tailExitIndex++;
1457
+ while (++index <= tailExitIndex) {
1458
+ if (enter === void 0) {
1459
+ if (index !== tailExitIndex && events[index][1].type !== "lineEnding") {
1460
+ enter = index;
1461
+ }
1462
+ } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
1463
+ events[enter][1].type = "mathTextData";
1464
+ if (index !== enter + 2) {
1465
+ events[enter][1].end = events[index - 1][1].end;
1466
+ events.splice(enter + 2, index - enter - 2);
1467
+ tailExitIndex -= index - enter - 2;
1468
+ index = enter + 2;
1469
+ }
1470
+ enter = void 0;
1471
+ }
1472
+ }
1473
+ return events;
1474
+ }
1475
+ function previous(code) {
1476
+ return code !== 36 || this.events[this.events.length - 1][1].type === "characterEscape";
1477
+ }
1478
+
1479
+ // node_modules/micromark-extension-math/lib/syntax.js
1480
+ function math(options) {
1481
+ return {
1482
+ flow: {
1483
+ [36]: mathFlow
1484
+ },
1485
+ text: {
1486
+ [36]: mathText(options)
1487
+ }
1488
+ };
1489
+ }
1490
+
1491
+ // node_modules/devlop/lib/default.js
1492
+ function ok2() {
1493
+ }
1494
+
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
+ // node_modules/mdast-util-math/lib/index.js
1520
+ function mathFromMarkdown() {
1521
+ return {
1522
+ enter: {
1523
+ mathFlow: enterMathFlow,
1524
+ mathFlowFenceMeta: enterMathFlowMeta,
1525
+ mathText: enterMathText
1526
+ },
1527
+ exit: {
1528
+ mathFlow: exitMathFlow,
1529
+ mathFlowFence: exitMathFlowFence,
1530
+ mathFlowFenceMeta: exitMathFlowMeta,
1531
+ mathFlowValue: exitMathData,
1532
+ mathText: exitMathText,
1533
+ mathTextData: exitMathData
1534
+ }
1535
+ };
1536
+ function enterMathFlow(token) {
1537
+ const code = {
1538
+ type: "element",
1539
+ tagName: "code",
1540
+ properties: { className: ["language-math", "math-display"] },
1541
+ children: []
1542
+ };
1543
+ this.enter(
1544
+ {
1545
+ type: "math",
1546
+ meta: null,
1547
+ value: "",
1548
+ data: { hName: "pre", hChildren: [code] }
1549
+ },
1550
+ token
1551
+ );
1552
+ }
1553
+ function enterMathFlowMeta() {
1554
+ this.buffer();
1555
+ }
1556
+ function exitMathFlowMeta() {
1557
+ const data = this.resume();
1558
+ const node = this.stack[this.stack.length - 1];
1559
+ ok2(node.type === "math");
1560
+ node.meta = data;
1561
+ }
1562
+ function exitMathFlowFence() {
1563
+ if (this.data.mathFlowInside) return;
1564
+ this.buffer();
1565
+ this.data.mathFlowInside = true;
1566
+ }
1567
+ function exitMathFlow(token) {
1568
+ const data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
1569
+ const node = this.stack[this.stack.length - 1];
1570
+ ok2(node.type === "math");
1571
+ this.exit(token);
1572
+ node.value = data;
1573
+ const code = (
1574
+ /** @type {HastElement} */
1575
+ node.data.hChildren[0]
1576
+ );
1577
+ ok2(code.type === "element");
1578
+ ok2(code.tagName === "code");
1579
+ code.children.push({ type: "text", value: data });
1580
+ this.data.mathFlowInside = void 0;
1581
+ }
1582
+ function enterMathText(token) {
1583
+ this.enter(
1584
+ {
1585
+ type: "inlineMath",
1586
+ value: "",
1587
+ data: {
1588
+ hName: "code",
1589
+ hProperties: { className: ["language-math", "math-inline"] },
1590
+ hChildren: []
1591
+ }
1592
+ },
1593
+ token
1594
+ );
1595
+ this.buffer();
1596
+ }
1597
+ function exitMathText(token) {
1598
+ const data = this.resume();
1599
+ const node = this.stack[this.stack.length - 1];
1600
+ ok2(node.type === "inlineMath");
1601
+ this.exit(token);
1602
+ node.value = data;
1603
+ const children = (
1604
+ /** @type {Array<HastElementContent>} */
1605
+ // @ts-expect-error: we defined it in `enterMathFlow`.
1606
+ node.data.hChildren
1607
+ );
1608
+ children.push({ type: "text", value: data });
1609
+ }
1610
+ function exitMathData(token) {
1611
+ this.config.enter.data.call(this, token);
1612
+ this.config.exit.data.call(this, token);
1613
+ }
1614
+ }
1615
+ function mathToMarkdown(options) {
1616
+ let single = (options || {}).singleDollarTextMath;
1617
+ if (single === null || single === void 0) {
1618
+ single = true;
1619
+ }
1620
+ inlineMath.peek = inlineMathPeek;
1621
+ return {
1622
+ unsafe: [
1623
+ { character: "\r", inConstruct: "mathFlowMeta" },
1624
+ { character: "\n", inConstruct: "mathFlowMeta" },
1625
+ {
1626
+ character: "$",
1627
+ after: single ? void 0 : "\\$",
1628
+ inConstruct: "phrasing"
1629
+ },
1630
+ { character: "$", inConstruct: "mathFlowMeta" },
1631
+ { atBreak: true, character: "$", after: "\\$" }
1632
+ ],
1633
+ handlers: { math: math2, inlineMath }
1634
+ };
1635
+ function math2(node, _, state, info) {
1636
+ const raw = node.value || "";
1637
+ const tracker = state.createTracker(info);
1638
+ const sequence = "$".repeat(Math.max(longestStreak(raw, "$") + 1, 2));
1639
+ const exit = state.enter("mathFlow");
1640
+ let value = tracker.move(sequence);
1641
+ if (node.meta) {
1642
+ const subexit = state.enter("mathFlowMeta");
1643
+ value += tracker.move(
1644
+ state.safe(node.meta, {
1645
+ after: "\n",
1646
+ before: value,
1647
+ encode: ["$"],
1648
+ ...tracker.current()
1649
+ })
1650
+ );
1651
+ subexit();
1652
+ }
1653
+ value += tracker.move("\n");
1654
+ if (raw) {
1655
+ value += tracker.move(raw + "\n");
1656
+ }
1657
+ value += tracker.move(sequence);
1658
+ exit();
1659
+ return value;
1660
+ }
1661
+ function inlineMath(node, _, state) {
1662
+ let value = node.value || "";
1663
+ let size = 1;
1664
+ if (!single) size++;
1665
+ while (new RegExp("(^|[^$])" + "\\$".repeat(size) + "([^$]|$)").test(value)) {
1666
+ size++;
1667
+ }
1668
+ const sequence = "$".repeat(size);
1669
+ if (
1670
+ // Contains non-space.
1671
+ /[^ \r\n]/.test(value) && // Starts with space and ends with space.
1672
+ (/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value) || // Starts or ends with dollar.
1673
+ /^\$|\$$/.test(value))
1674
+ ) {
1675
+ value = " " + value + " ";
1676
+ }
1677
+ let index = -1;
1678
+ while (++index < state.unsafe.length) {
1679
+ const pattern = state.unsafe[index];
1680
+ if (!pattern.atBreak) continue;
1681
+ const expression = state.compilePattern(pattern);
1682
+ let match;
1683
+ while (match = expression.exec(value)) {
1684
+ let position = match.index;
1685
+ if (value.codePointAt(position) === 10 && value.codePointAt(position - 1) === 13) {
1686
+ position--;
1687
+ }
1688
+ value = value.slice(0, position) + " " + value.slice(match.index + 1);
1689
+ }
1690
+ }
1691
+ return sequence + value + sequence;
1692
+ }
1693
+ function inlineMathPeek() {
1694
+ return "$";
1695
+ }
1696
+ }
1697
+
1698
+ // src/index.ts
1699
+ var defaultOptions = {
1700
+ wikilinks: true,
1701
+ highlights: true,
1702
+ comments: true,
1703
+ tags: true,
1704
+ customTaskChars: true,
1705
+ math: true
1706
+ };
1707
+ function remarkObsidian(userOpts) {
1708
+ const opts = { ...defaultOptions, ...userOpts };
1709
+ const data = this.data();
1710
+ data.micromarkExtensions ??= [];
1711
+ data.fromMarkdownExtensions ??= [];
1712
+ data.toMarkdownExtensions ??= [];
1713
+ if (opts.wikilinks) {
1714
+ data.micromarkExtensions.push(wikilinkSyntax());
1715
+ data.fromMarkdownExtensions.push(wikilinkFromMarkdown());
1716
+ data.toMarkdownExtensions.push(wikilinkToMarkdown());
1717
+ }
1718
+ if (opts.comments) {
1719
+ data.micromarkExtensions.push(commentSyntax());
1720
+ data.fromMarkdownExtensions.push(commentFromMarkdown());
1721
+ data.toMarkdownExtensions.push(commentToMarkdown());
1722
+ }
1723
+ if (opts.tags) {
1724
+ data.micromarkExtensions.push(tagSyntax());
1725
+ data.fromMarkdownExtensions.push(tagFromMarkdown());
1726
+ data.toMarkdownExtensions.push(tagToMarkdown());
1727
+ }
1728
+ if (opts.highlights) {
1729
+ data.micromarkExtensions.push(highlightSyntax());
1730
+ data.fromMarkdownExtensions.push(highlightFromMarkdown());
1731
+ data.toMarkdownExtensions.push(highlightToMarkdown());
1732
+ }
1733
+ if (opts.math) {
1734
+ data.micromarkExtensions.push(math());
1735
+ data.fromMarkdownExtensions.push(mathFromMarkdown());
1736
+ data.toMarkdownExtensions.push(mathToMarkdown());
1737
+ }
1738
+ const needsTransform = opts.comments || opts.customTaskChars;
1739
+ if (!needsTransform) return void 0;
1740
+ return (tree, file) => {
1741
+ if (opts.comments) {
1742
+ visit(
1743
+ tree,
1744
+ "comment",
1745
+ (_node, index, parent) => {
1746
+ if (parent && typeof index === "number") {
1747
+ parent.children.splice(index, 1);
1748
+ return index;
1749
+ }
1750
+ return void 0;
1751
+ }
1752
+ );
1753
+ }
1754
+ if (opts.customTaskChars) {
1755
+ customTaskCharTransform(tree, String(file));
1756
+ }
1757
+ };
1758
+ }
1759
+ export {
1760
+ commentFromMarkdown,
1761
+ commentSyntax,
1762
+ commentToMarkdown,
1763
+ customTaskCharTransform,
1764
+ remarkObsidian as default,
1765
+ highlightFromMarkdown,
1766
+ highlightSyntax,
1767
+ highlightToMarkdown,
1768
+ tagFromMarkdown,
1769
+ tagSyntax,
1770
+ tagToMarkdown,
1771
+ wikilinkFromMarkdown,
1772
+ wikilinkSyntax,
1773
+ wikilinkToMarkdown
1774
+ };
1775
+ //# sourceMappingURL=index.js.map