@p-buddy/parkdown 0.0.27 → 0.0.28
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/cli.js +1 -1
- package/dist/index.js +52 -51
- package/dist/index.umd.cjs +7 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Command as r } from "@commander-js/extra-typings";
|
|
3
3
|
import { populateMarkdownInclusions as l, depopulateMarkdownInclusions as a } from "@p-buddy/parkdown";
|
|
4
4
|
import f from "chokidar";
|
|
5
|
-
const c = "0.0.
|
|
5
|
+
const c = "0.0.28", p = new r().version(c).option("--nw, --no-write", "Do NOT write result to file (defaults to false)", !1).option("--ni, --no-inclusions", "Do NOT process file inclusions (defaults to false)", !1).option("-d, --depopulate", "Remove populated inclusions from the file", !1).option("-f, --file <flag>", "The file(s) to process", (e, o) => (o.push(e), o), new Array()).option("-w, --watch", "Watch the file(s) for changes and update automatically", !1).parse(), { inclusions: u, depopulate: d, file: t, write: n, watch: h } = p.opts();
|
|
6
6
|
t.length === 0 && t.push("README.md");
|
|
7
7
|
const m = [
|
|
8
8
|
[l, !u],
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,17 @@ var Ce = Object.defineProperty;
|
|
|
2
2
|
var Ee = (e, t, n) => t in e ? Ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var _ = (e, t, n) => Ee(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { writeFileSync as ae, readFileSync as Se } from "node:fs";
|
|
5
|
-
import { basename as xe, dirname as Q, join as
|
|
5
|
+
import { basename as xe, dirname as Q, join as T, resolve as ce } from "node:path";
|
|
6
6
|
import { URLSearchParams as _e } from "node:url";
|
|
7
7
|
import { unified as Ne } from "unified";
|
|
8
8
|
import ke from "remark-parse";
|
|
9
9
|
import { visit as Me } from "unist-util-visit";
|
|
10
|
-
import { dedent as
|
|
10
|
+
import { dedent as Te } from "ts-dedent";
|
|
11
11
|
const f = (e, t) => e.position.start.offset - t.position.start.offset;
|
|
12
12
|
f.reverse = (e, t) => f(t, e);
|
|
13
|
-
const G = (e) => e.position !== void 0 && e.position.start.offset !== void 0 && e.position.end.offset !== void 0,
|
|
14
|
-
md: (e) =>
|
|
15
|
-
},
|
|
13
|
+
const G = (e) => e.position !== void 0 && e.position.start.offset !== void 0 && e.position.end.offset !== void 0, Ae = Ne().use(ke), z = {
|
|
14
|
+
md: (e) => Ae.parse(e)
|
|
15
|
+
}, A = (e, t) => {
|
|
16
16
|
const n = [];
|
|
17
17
|
return Me(e, (s, r, o) => {
|
|
18
18
|
if (s.type !== "root") {
|
|
@@ -23,12 +23,12 @@ const G = (e) => e.position !== void 0 && e.position.start.offset !== void 0 &&
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}), n;
|
|
26
|
-
},
|
|
26
|
+
}, Oe = (e) => e.children.length === 0, pe = (e, t, ...n) => {
|
|
27
27
|
if (n.length === 0) throw new Error("No nodes to replace content from");
|
|
28
28
|
n.sort(f);
|
|
29
29
|
const s = n.at(0), r = n.at(-1);
|
|
30
30
|
return e.slice(0, s.position.start.offset) + t + e.slice(r.position.end.offset);
|
|
31
|
-
},
|
|
31
|
+
}, Re = (e, t, n) => {
|
|
32
32
|
const s = Math.min(t.position.end.offset, n.position.end.offset), r = Math.max(t.position.start.offset, n.position.start.offset);
|
|
33
33
|
return e.slice(s, r);
|
|
34
34
|
}, M = (...e) => e.join(" "), We = (...e) => e.join(`
|
|
@@ -115,7 +115,7 @@ const G = (e) => e.position !== void 0 && e.position.start.offset !== void 0 &&
|
|
|
115
115
|
i.push({ name: c, optional: a === "?", type: p });
|
|
116
116
|
}
|
|
117
117
|
return { name: s, parameters: i };
|
|
118
|
-
},
|
|
118
|
+
}, O = (e) => {
|
|
119
119
|
const t = e.map(Qe).reduce(
|
|
120
120
|
(n, { name: s, parameters: r }) => n.set(s, r),
|
|
121
121
|
/* @__PURE__ */ new Map()
|
|
@@ -181,7 +181,7 @@ const G = (e) => e.position !== void 0 && e.position.start.offset !== void 0 &&
|
|
|
181
181
|
* @example [](<url>?wrap=dropdown(hello_world,,_))
|
|
182
182
|
*/
|
|
183
183
|
"dropdown(summary: string, open?: boolean, space?: string)"
|
|
184
|
-
], ze =
|
|
184
|
+
], ze = O(Ge), E = (e, t = 1) => `
|
|
185
185
|
`.repeat(t) + e + `
|
|
186
186
|
`.repeat(t), B = (e, t, n) => `<${t}${n ? ` ${n}` : ""}>${E(e)}</${t}>`, ee = (e, t, n) => {
|
|
187
187
|
const s = ze(t);
|
|
@@ -409,12 +409,12 @@ const I = (e) => {
|
|
|
409
409
|
* Helpful when trying to determine fine-grained edits (e.g. trimming, splicing, etc.).
|
|
410
410
|
*/
|
|
411
411
|
"debug()"
|
|
412
|
-
], Ze =
|
|
412
|
+
], Ze = O(Je), $ = (e, t, n) => {
|
|
413
413
|
const s = X(e, t, n), r = [];
|
|
414
414
|
for (let o = 0; o < s.length - 1; o += 2)
|
|
415
415
|
r.push([s[o], s[o + 1]]);
|
|
416
416
|
return r;
|
|
417
|
-
}, Ke = (e, t, n) => new d(...X(e, t, n).map(({ range: s }) => s)), P = (e) =>
|
|
417
|
+
}, Ke = (e, t, n) => new d(...X(e, t, n).map(({ range: s }) => s)), P = (e) => Te(e).trim(), se = (e, t) => e[t] !== void 0 && /[^\S\r\n]/.test(e[t]), re = (e, t) => Math.max(0, Math.min(e.length, t)), Ye = (e, ...t) => {
|
|
418
418
|
if (t.length === 0) return e;
|
|
419
419
|
const n = I(e);
|
|
420
420
|
return P(
|
|
@@ -511,13 +511,14 @@ const I = (e) => {
|
|
|
511
511
|
}
|
|
512
512
|
case "trim-start":
|
|
513
513
|
case "trim-end": {
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
s.left ?? (s.left = !0), s.right ?? (s.right = !0);
|
|
515
|
+
const r = s.name === "trim-start" ? "start" : "end", { length: o } = e;
|
|
516
|
+
e = oe(e, s.id, { [r]: s }), console.log(`Trimmed ${o - e.length} characters from ${r} of "${s.id}" region`);
|
|
516
517
|
break;
|
|
517
518
|
}
|
|
518
519
|
case "trim": {
|
|
519
|
-
const { inside: r, outside: o, id: i } = s;
|
|
520
|
-
e = oe(e, i, { start:
|
|
520
|
+
const { inside: r, outside: o, id: i } = s, l = { left: o ?? !0, right: r ?? !0 }, c = { left: r ?? !0, right: o ?? !0 }, { length: a } = e;
|
|
521
|
+
e = oe(e, i, { start: l, end: c }), console.log(`Trimmed ${a - e.length} characters around "${s.id}" region`);
|
|
521
522
|
break;
|
|
522
523
|
}
|
|
523
524
|
case "single-line":
|
|
@@ -533,8 +534,8 @@ const I = (e) => {
|
|
|
533
534
|
], lt = [
|
|
534
535
|
"recipe(id: string, 0?: string, 1?: string, 2?: string)"
|
|
535
536
|
], ie = {
|
|
536
|
-
register:
|
|
537
|
-
apply:
|
|
537
|
+
register: O(it),
|
|
538
|
+
apply: O(lt)
|
|
538
539
|
}, N = class N {
|
|
539
540
|
constructor() {
|
|
540
541
|
_(this, "recipes", /* @__PURE__ */ new Map());
|
|
@@ -577,29 +578,29 @@ const I = (e) => {
|
|
|
577
578
|
};
|
|
578
579
|
_(N, "Entries", (t) => Array.from(new URLSearchParams(t).entries()));
|
|
579
580
|
let H = N;
|
|
580
|
-
const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.startsWith(t)), pt = (e) => G(e) &&
|
|
581
|
+
const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.startsWith(t)), pt = (e) => G(e) && Oe(e) && ct(e), me = ({ url: e }, t) => `[](${t ? T(t, e) : e})`, g = {
|
|
581
582
|
_open: "<!--",
|
|
582
583
|
_close: "-->",
|
|
583
584
|
_flag: "p↓",
|
|
584
585
|
get begin() {
|
|
585
|
-
return M(
|
|
586
|
+
return M(g._open, g._flag, "BEGIN", g._close);
|
|
586
587
|
},
|
|
587
588
|
get end() {
|
|
588
|
-
return M(
|
|
589
|
+
return M(g._open, g._flag, "END", g._close);
|
|
589
590
|
},
|
|
590
591
|
lengthOf(e) {
|
|
591
592
|
const t = `lines: ${e.split(`
|
|
592
593
|
`).length}`, n = `chars: ${e.length}`;
|
|
593
|
-
return M(
|
|
594
|
+
return M(g._open, g._flag, "length", t, n, g._close);
|
|
594
595
|
}
|
|
595
|
-
}, le = (e) => (t) => G(t) && t.value ===
|
|
596
|
+
}, le = (e) => (t) => G(t) && t.value === g[e], ut = ({ position: e, url: t, siblingCount: n }, s) => ({ position: e, url: t, headingDepth: s, inline: n >= 1 }), mt = ({ position: { start: e }, url: t, siblingCount: n }, { position: { end: s } }, r) => ({ position: { start: e, end: s }, url: t, headingDepth: r, inline: n >= 1 }), gt = (e, t, n) => (e.inline ? M : We)(
|
|
596
597
|
me(e, n),
|
|
597
|
-
|
|
598
|
-
|
|
598
|
+
g.begin,
|
|
599
|
+
g.lengthOf(t),
|
|
599
600
|
t,
|
|
600
|
-
|
|
601
|
-
),
|
|
602
|
-
const t =
|
|
601
|
+
g.end
|
|
602
|
+
), ht = (e) => {
|
|
603
|
+
const t = A(e, "heading").reduce((n, { position: s, depth: r }) => n.set(s.start.line, r), /* @__PURE__ */ new Map());
|
|
603
604
|
return (n) => {
|
|
604
605
|
for (let s = n.position.start.line; s >= 1; s--) {
|
|
605
606
|
const r = t.get(s);
|
|
@@ -607,7 +608,7 @@ const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.sta
|
|
|
607
608
|
}
|
|
608
609
|
return 0;
|
|
609
610
|
};
|
|
610
|
-
},
|
|
611
|
+
}, R = {
|
|
611
612
|
openingCommentDoesNotFollowLink: ({ position: { start: e } }) => new Error(`Opening comment (@${e.line}:${e.column}) does not follow link`),
|
|
612
613
|
closingCommentNotMatchedToOpening: ({ position: { start: e } }) => new Error(`Closing comment (@${e.line}:${e.column}) does not match to opening comment`),
|
|
613
614
|
openingCommentNotClosed: ({ position: { start: e } }) => new Error(`Opening comment (@${e.line}:${e.column}) is not followed by a closing comment`)
|
|
@@ -621,13 +622,13 @@ const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.sta
|
|
|
621
622
|
else {
|
|
622
623
|
const i = o.node;
|
|
623
624
|
if (r.length === 0)
|
|
624
|
-
throw
|
|
625
|
+
throw R.closingCommentNotMatchedToOpening(i);
|
|
625
626
|
const l = r.pop().node;
|
|
626
627
|
if (r.length > 0) continue;
|
|
627
628
|
n.push({ open: l, close: i });
|
|
628
629
|
}
|
|
629
630
|
if (r.length > 0)
|
|
630
|
-
throw
|
|
631
|
+
throw R.openingCommentNotClosed(r[0].node);
|
|
631
632
|
return n;
|
|
632
633
|
}, ft = (e, t, n) => {
|
|
633
634
|
const s = [...t].sort(f), r = [];
|
|
@@ -635,58 +636,58 @@ const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.sta
|
|
|
635
636
|
for (; s.length > 0; ) {
|
|
636
637
|
const i = s.pop();
|
|
637
638
|
if (i.position.start.offset < o.open.position.start.offset) {
|
|
638
|
-
if (
|
|
639
|
-
throw
|
|
639
|
+
if (Re(e, i, o.open).trim() !== "")
|
|
640
|
+
throw R.openingCommentDoesNotFollowLink(o.open);
|
|
640
641
|
return r.push([i, o]);
|
|
641
642
|
}
|
|
642
643
|
r.push(i);
|
|
643
644
|
}
|
|
644
|
-
throw
|
|
645
|
+
throw R.openingCommentDoesNotFollowLink(o.open);
|
|
645
646
|
}), r.push(...s.reverse()), r.reverse();
|
|
646
|
-
},
|
|
647
|
+
}, ge = (e, t) => {
|
|
647
648
|
t ?? (t = z.md(e));
|
|
648
|
-
const n =
|
|
649
|
+
const n = ht(t), s = A(t, "link").filter(pt), r = A(t, "html").sort(f), o = r.filter(le("begin")), i = r.filter(le("end")), l = dt(o, i);
|
|
649
650
|
return ft(e, s, l).map((a) => Array.isArray(a) ? mt(a[0], a[1].close, n(a[0])) : ut(a, n(a)));
|
|
650
|
-
}, vt = (e, { url: t }) => (n) => e(
|
|
651
|
+
}, vt = (e, { url: t }) => (n) => e(T(Q(t), n)), he = (...e) => {
|
|
651
652
|
const t = e.reduce((n, s) => n + s, 0);
|
|
652
653
|
return Math.min(Math.max(t, 1), 6);
|
|
653
654
|
}, wt = (e, t, n) => {
|
|
654
655
|
if (t === 0) return e;
|
|
655
656
|
n ?? (n = z.md(e));
|
|
656
|
-
const s =
|
|
657
|
+
const s = A(n, "heading"), r = e.split(`
|
|
657
658
|
`);
|
|
658
659
|
for (const o of s) {
|
|
659
|
-
const { depth: i, position: { start: l, end: c } } = o, a =
|
|
660
|
+
const { depth: i, position: { start: l, end: c } } = o, a = he(i, t), u = r[l.line - 1].slice(i, c.column), p = "#".repeat(a) + u;
|
|
660
661
|
r[l.line - 1] = p, o.depth = a;
|
|
661
662
|
}
|
|
662
663
|
return r.join(`
|
|
663
664
|
`);
|
|
664
|
-
}, de = (e) =>
|
|
665
|
+
}, de = (e) => ge(e).reverse().sort(f.reverse).reduce((t, n) => pe(t, me(n), n), e), fe = (e, t, n, s, r) => {
|
|
665
666
|
try {
|
|
666
667
|
e = de(e), e = wt(e, t);
|
|
667
|
-
const o = z.md(e), i = new H(), l =
|
|
668
|
+
const o = z.md(e), i = new H(), l = ge(e, o).sort(f);
|
|
668
669
|
return l.filter(({ url: c }) => c.startsWith("?")).forEach(({ url: c }) => i.tryStore(c)), l.reverse().map((c) => {
|
|
669
670
|
var k, S;
|
|
670
671
|
const { url: a, headingDepth: u } = c, [p, ...b] = xe(a).split("?"), y = i.apply(b.join("?"));
|
|
671
672
|
if (!a.startsWith("?"))
|
|
672
673
|
if (a.startsWith("./") || a.startsWith("../")) {
|
|
673
|
-
const m = p.split(".").pop() ?? "", j = Q(a), V =
|
|
674
|
-
let
|
|
674
|
+
const m = p.split(".").pop() ?? "", j = Q(a), V = T(j, p);
|
|
675
|
+
let h = n(V);
|
|
675
676
|
const x = new _e(y), D = (k = ((w) => {
|
|
676
677
|
const v = Array.from(x.entries()).filter(([C]) => C === w).map(([C, q]) => q);
|
|
677
678
|
return v.length >= 1 ? v.join(",") : void 0;
|
|
678
679
|
})("region")) == null ? void 0 : k.split(J);
|
|
679
|
-
|
|
680
|
+
h = (D == null ? void 0 : D.reduce(
|
|
680
681
|
(w, v, C, { length: q }) => ot(w, v, C === q - 1),
|
|
681
|
-
|
|
682
|
-
)) ??
|
|
682
|
+
h
|
|
683
|
+
)) ?? h;
|
|
683
684
|
const $e = x.has("skip"), be = x.get("heading") ?? 0, ye = x.has("inline");
|
|
684
685
|
let { inline: L } = c;
|
|
685
686
|
if (ye && (L = !0), !$e)
|
|
686
687
|
if (m === "md") {
|
|
687
|
-
const w = vt(n, c), v = r ?
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
const w = vt(n, c), v = r ? T(r, j) : j, C = he(u, Number(be));
|
|
689
|
+
h = fe(
|
|
690
|
+
h,
|
|
690
691
|
/** p↓: ... */
|
|
691
692
|
C,
|
|
692
693
|
w,
|
|
@@ -694,15 +695,15 @@ const at = ["http", "./", "../", "?"], ct = ({ url: e }) => at.some((t) => e.sta
|
|
|
694
695
|
v
|
|
695
696
|
/** p↓: ... */
|
|
696
697
|
);
|
|
697
|
-
} else /^(js|ts)x?|svelte$/i.test(m) && (
|
|
698
|
-
|
|
698
|
+
} else /^(js|ts)x?|svelte$/i.test(m) && (h = ee(
|
|
699
|
+
h,
|
|
699
700
|
"code",
|
|
700
701
|
/** p↓: ... */
|
|
701
702
|
{ extension: m, inline: L }
|
|
702
703
|
/** p↓: ... */
|
|
703
704
|
));
|
|
704
705
|
const U = (S = x.get("wrap")) == null ? void 0 : S.split(J);
|
|
705
|
-
return
|
|
706
|
+
return h = (U == null ? void 0 : U.reduce((w, v) => ee(w, v, { extension: m, inline: L }), h)) ?? h, { target: c, content: gt(c, h, r) };
|
|
706
707
|
} else throw a.startsWith("http") ? new Error("External web links are not implemented yet") : new Error(`Unsupported link type: ${a}`);
|
|
707
708
|
}).filter(Boolean).reduce((c, { target: a, content: u }) => pe(c, u, a), e);
|
|
708
709
|
} catch (o) {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(u,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("node:fs"),require("node:path"),require("node:url"),require("unified"),require("remark-parse"),require("unist-util-visit"),require("ts-dedent")):typeof define=="function"&&define.amd?define(["exports","node:fs","node:path","node:url","unified","remark-parse","unist-util-visit","ts-dedent"],d):(u=typeof globalThis<"u"?globalThis:u||self,d(u.index={},u.node_fs,u.node_path,u.node_url,u.unified,u.remarkParse,u.unistUtilVisit,u.tsDedent))})(this,function(u,d,h
|
|
2
|
-
`),Me=e=>{const t=e.split("?");return t.length>1?[t.slice(0,-1).join("?"),t.at(-1)]:[e,""]},
|
|
3
|
-
`}},
|
|
1
|
+
(function(u,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("node:fs"),require("node:path"),require("node:url"),require("unified"),require("remark-parse"),require("unist-util-visit"),require("ts-dedent")):typeof define=="function"&&define.amd?define(["exports","node:fs","node:path","node:url","unified","remark-parse","unist-util-visit","ts-dedent"],d):(u=typeof globalThis<"u"?globalThis:u||self,d(u.index={},u.node_fs,u.node_path,u.node_url,u.unified,u.remarkParse,u.unistUtilVisit,u.tsDedent))})(this,function(u,d,h,$e,ye,Ce,be,Ee){"use strict";var ht=Object.defineProperty;var gt=(u,d,h)=>d in u?ht(u,d,{enumerable:!0,configurable:!0,writable:!0,value:h}):u[d]=h;var _=(u,d,h)=>gt(u,typeof d!="symbol"?d+"":d,h);const $=(e,t)=>e.position.start.offset-t.position.start.offset;$.reverse=(e,t)=>$(t,e);const D=e=>e.position!==void 0&&e.position.start.offset!==void 0&&e.position.end.offset!==void 0,Se=ye.unified().use(Ce),L={md:e=>Se.parse(e)},j=(e,t)=>{const n=[];return be.visit(e,(s,r,i)=>{if(s.type!=="root"){if(t&&s.type!==t)return;if(D(s)){const o=((i==null?void 0:i.children.length)??0)-1;n.push({...s,siblingIndex:r,siblingCount:o})}}}),n},ke=e=>e.children.length===0,J=(e,t,...n)=>{if(n.length===0)throw new Error("No nodes to replace content from");n.sort($);const s=n.at(0),r=n.at(-1);return e.slice(0,s.position.start.offset)+t+e.slice(r.position.end.offset)},xe=(e,t,n)=>{const s=Math.min(t.position.end.offset,n.position.end.offset),r=Math.max(t.position.start.offset,n.position.start.offset);return e.slice(s,r)},A=(...e)=>e.join(" "),Ne=(...e)=>e.join(`
|
|
2
|
+
`),Me=e=>{const t=e.split("?");return t.length>1?[t.slice(0,-1).join("?"),t.at(-1)]:[e,""]},Te=e=>Me(e)[0],Z=/,\s*(?![^()]*\))/,K={reserved:{semi:";",slash:"/",question:"?",colon:":",at:"@",equal:"=",and:"&"},unsafe:{quote:'"',angle:"<",unangle:">",hash:"#",percent:"%",curly:"{",uncurly:"}",pipe:"|",back:"\\",carrot:"^",tilde:"~",square:"[",unsquare:"]",tick:"`",line:`
|
|
3
|
+
`}},_e="-",Y={static:[["'''",'"'],["''","'"],[/parkdown:\s+/g,""],[/p↓:\s+/g,""]],url:[...Object.entries(K.unsafe),...Object.entries(K.reserved)]},ee=(e,[t,n])=>e.replaceAll(t,n),O=(e,t=_e)=>{const n=Y.static.reduce(ee,e);return Y.url.map(([s,r])=>[t+s+t,r]).reduce(ee,n).replaceAll(t," ")},je=["string","number","boolean"],Ae=e=>je.includes(e),Oe=/^([a-zA-Z0-9_-]+)(?:\(([^)]*)\))?$/,Ie=e=>{const t=e.match(Oe);if(!t)throw new Error(`Invalid invocation: ${e}`);const[,n,s=""]=t;if(!s.trim())return{name:n,parameters:[]};const r=Re(s);return{name:n,parameters:r}},qe=(e,t)=>{for(let n=t+1;n<e.length;n++)if(e[n]!==void 0)return!1;return!0},Re=e=>{const t=[];let n="",s=!1;for(let r=0;r<e.length;r++){const i=e[r],o=i==="'";if(o&&e.at(r+1)==="'"){const l=e.at(r+2)==="'";s=!s,n+=l?"'''":"''",r+=l?2:1}else o?(s=!s,n+=i):i===","&&!s?(t.push(n.trim()),n=""):n+=i}return t.push(n.trim()),t.map(r=>r===""?void 0:r?We(r):void 0).filter((r,i,o)=>r!==void 0||!qe(o,i))},We=e=>{const t=e.length>=2&&e[0]==="'"&&e.at(-1)==="'",n=t&&e.length>=4&&e[1]==="'"&&e.at(-2)==="'";return!t||n?e:e.slice(1,-1)},Pe=e=>{const t=/^([\w-_]+)(?:\(([^)]*)\))?/,n=e.match(t);if(!n)return{name:e};const[,s,r]=n;if(!r)return{name:s};const i=/([\w-_]+)(\?)?:\s*([^,]+)/g,o=[];let l;for(;(l=i.exec(r))!==null;){const[,c,a,m]=l,p=m.trim();if(!Ae(p))throw new Error(`Unsupported type: ${p}`);o.push({name:c,optional:a==="?",type:p})}return{name:s,parameters:o}},I=e=>{const t=e.map(Pe).reduce((n,{name:s,parameters:r})=>n.set(s,r),new Map);return n=>{const{name:s,parameters:r}=Ie(n);if(!t.has(s))throw new Error(`Unknown method: ${s}`);const i=t.get(s);if(i===void 0)return{name:s};if(r.length>i.length){const o=i.filter(({optional:c})=>!c).length,l=o===i.length?o.toString():`${o} - ${i.length}`;throw new Error(`Too many parameters: ${r.length} for method '${s}' (expected: ${l})`)}return i.reduce((o,{name:l,optional:c,type:a},m)=>{const p=r[m];if(p===void 0){if(c)return o;throw new Error(`Missing required parameter: ${l} for method '${s}'`)}switch(a){case"string":o[l]=p;break;case"number":case"boolean":o[l]=JSON.parse(p);break}if(typeof o[l]!==a)throw new Error(`Invalid type: ${l} must be ${a}, got ${typeof o[l]} for method '${s}'`);return o},{name:s})}},U=e=>Object.entries(e).filter(([t])=>t!=="name"&&!isNaN(Number(t))).map(([t,n])=>n),De=I(["code(lang?: string, meta?: string)","quote()","dropdown(summary: string, open?: boolean, space?: string)"]),E=(e,t=1)=>`
|
|
4
4
|
`.repeat(t)+e+`
|
|
5
5
|
`.repeat(t),B=(e,t,n)=>`<${t}${n?` ${n}`:""}>${E(e)}</${t}>`,te=(e,t,n)=>{const s=De(t);switch(s.name){case"code":if(!s.lang&&!s.meta&&(n==null?void 0:n.inline)&&!e.includes(`
|
|
6
6
|
`))return`\`${e}\``;const i=s.lang??(n==null?void 0:n.extension)??"",o=s.meta?` ${s.meta}`:"";return E(`\`\`\`${i}${o}${E(e)}\`\`\``);case"quote":return n!=null&&n.inline&&!e.includes(`
|
|
7
7
|
|
|
8
8
|
`)?`> ${e}`:E(B(E(e),"blockquote"));case"dropdown":const l=B(O(s.summary),"summary");return E(B([l,e].join(`
|
|
9
|
-
`),"details",s.open?"open":void 0))}};class w{constructor(...t){
|
|
9
|
+
`),"details",s.open?"open":void 0))}};class w{constructor(...t){_(this,"_intervals",[]);_(this,"collapsed",!0);for(const[n,s]of t)this.push(n,s)}get intervals(){return this._intervals}push(t,n){return n??(n=t+1),this._intervals.push([Math.min(t,n),Math.max(t,n)]),this.collapsed=!1,this}combine(t){for(const[n,s]of t.intervals)this.push(n,s);return this}collapse(t=!1){const{_intervals:n,collapsed:s}=this;if(s&&!t||!n.length)return this;n.sort((l,c)=>l[0]-c[0]);const r=[];let[i,o]=n[0];for(let l=1;l<n.length;l++){const[c,a]=n[l];c<=o?o=Math.max(o,a):(r.push([i,o]),i=c,o=a)}return r.push([i,o]),this._intervals=r,this.collapsed=!0,this}subtract(t){this.collapse(),t.collapse();const{_intervals:n}=this,{_intervals:s}=t;if(!n.length||!s.length)return this;let r=[...n];for(const[i,o]of s){const l=[];for(const[c,a]of r){if(o<=c||i>=a){l.push([c,a]);continue}i>c&&l.push([c,i]),o<a&&l.push([o,a])}r=l}return this._intervals=r,this.collapse(!0),this}test(t,n="head"){const{_intervals:s}=this;switch(n){case"head":return s.some(([r,i])=>t>=r&&t<i);case"tail":return s.some(([r,i])=>t>r&&t<=i);case"both":return s.some(([r,i])=>t>=r&&t<=i);case"none":return s.some(([r,i])=>t>r&&t<i)}}slice(t){this.collapse();const n=[];for(const[s,r]of this._intervals)n.push(t.slice(s,r));return n.filter(Boolean).join("")}offset(t){for(const n of this._intervals)n[0]+=t,n[1]+=t;return this}}const q=e=>{const t=/(\/\/[^\n]*|\/\*[\s\S]*?\*\/|<!--[\s\S]*?-->)/gm,n=[];let s;for(;(s=t.exec(e))!==null;){const r=[s.index,s.index+s[0].length],i=Le(s[0]).trim();n.push({range:r,value:i})}return n},Le=e=>e.startsWith("//")?e.slice(2):e.startsWith("/*")?e.slice(2,-2):e.startsWith("<!--")?e.slice(4,-3):e,Ue=["(pd)","(p↓)","(parkdown)","pd:","p↓:","parkdown:"],ne=(e,t)=>e.range[0]-t.range[0],F=(e,t,n)=>(n??q(e)).filter(({value:s})=>s.split(" ").includes(t)).sort(ne),se=e=>({isSpace:e===" ",isNewline:e===`
|
|
10
10
|
`||e===void 0}),re=e=>Ue.flatMap(t=>F(e,t)).sort((t,n)=>t.range[0]-n.range[0]).reverse().reduce((t,{range:[n,s],value:r})=>{const i=(S,k)=>t.slice(0,S)+t.slice(k),o=se(t[n-1]),l=se(t[s]),c=s===t.length;let a=n;for(;a>0&&t[a-1]!==`
|
|
11
11
|
`;)a--;let m=s;for(;m<t.length&&t[m]!==`
|
|
12
|
-
`;)m++;const p=t.slice(a,n).trim()===""&&t.slice(s,m).trim()==="";return o.isNewline&&l.isNewline?i(n-(c?1:0),s+1):o.isNewline||p?i(a,s+(l.isSpace||l.isNewline?1:0)):i(n-(o.isSpace?1:0),s)},e),Be=I(["extract(id: string, 0?: string, 1?: string, 2?: string)","remove(id: string, 0?: string, 1?: string, 2?: string)","replace(id: string, with?: string, space?: string)","remap(id?: string, from: string, to?: string, space?: string)","single-line(id: string, includeBoundaries?: boolean)","trim(id: string, inside?: boolean, outside?: boolean)","trim-start(id: string, left?: boolean, right?: boolean)","trim-end(id: string, left?: boolean, right?: boolean)","splice-start(id: string, deleteCount?: number, insert?: string, space?: string)","splice-end(id: string, deleteCount?: number, insert?: string, space?: string)","debug()"]),C=(e,t,n)=>{const s=F(e,t,n),r=[];for(let i=0;i<s.length-1;i+=2)r.push([s[i],s[i+1]]);return r},Fe=(e,t,n)=>new w(...F(e,t,n).map(({range:s})=>s)),R=e=>Ee.dedent(e).trim(),ie=(e,t)=>e[t]!==void 0&&/[^\S\r\n]/.test(e[t]),oe=(e,t)=>Math.max(0,Math.min(e.length,t)),He=(e,...t)=>{if(t.length===0)return e;const n=q(e);return R(new w(...t.flatMap(s=>C(e,s,n).map(([{range:[r]},{range:[,i]}])=>{for(;ie(e,r);)r--;for(;ie(e,i);)i++;return[oe(e,r),oe(e,i)]}))).slice(e))},Qe=(e,...t)=>{if(t.length===0)return e;const n=q(e);return R(new w([0,e.length]).subtract(new w(...t.flatMap(s=>C(e,s,n).map(([{range:[,r]},{range:[i]}])=>[r,i])))).slice(e))},Ge=(e,t,n,s)=>{if(!t)return e;let r="",i=0;for(const[o,l]of C(e,t))r+=e.slice(i,o.range[1]),r+=O(n??o.value,s),i=l.range[0];return r+=e.slice(i),R(new w([0,r.length]).subtract(Fe(r,t)).slice(r))},ze=(e,t,n,s,r,i)=>{if(!t)return e;const o=!(s===void 0||s<0),l=r?O(r,i):"",c=s??0,a=q(e),m=new w(...a.map(({range:p})=>p));return C(e,t,a).map(p=>p[n==="start"?0:1]).sort(ne).reverse().reduce((p,{range:S})=>{const k=new w,P=o?1:-1;let M=Math.abs(c),g=o?S[1]:S[0];for(;M>0&&g<p.length&&g>=0;)m.test(g)||(k.push(g),M--),g+=P;return g=Math.min(Math.max(0,g),p.length),p=p.slice(0,g)+l+p.slice(g),new w([0,p.length]).subtract(k.offset(o?0:l.length)).slice(p)},e)},Ve=(e,t,n,s,r)=>{let i="",o=0;[n,s]=[n,s??""].map(c=>O(c,r));const l=t?C(e,t):[[{range:[0,0]},{range:[e.length,e.length]}]];for(const[c,a]of l)i+=e.slice(o,c.range[1]),i+=e.slice(c.range[1],a.range[0]).replaceAll(n,s),o=a.range[0];return i+=e.slice(o),i},Xe=(e,t)=>{if(!t)return e;let n="",s=0;for(const[r,i]of C(e,t))n+=e.slice(s,r.range[1]),n+=e.slice(r.range[1],i.range[0]).replaceAll(/[\s\n]+/g," "),s=i.range[0];return n+=e.slice(s),n},le=(e,t,n)=>{var i,o,l,c;if(!t)return e;const s=a=>/\s/.test(e[a]),r=new w;for(const[a,m]of C(e,t)){if((i=n.start)!=null&&i.left){let p=a.range[0]-1;for(;s(p);)r.push(p--)}if((o=n.start)!=null&&o.right){let p=a.range[1];for(;s(p);)r.push(p++)}if((l=n.end)!=null&&l.left){let p=m.range[0]-1;for(;s(p);)r.push(p--)}if((c=n.end)!=null&&c.right){let p=m.range[1];for(;s(p);)r.push(p++)}}return new w([0,e.length]).subtract(r).slice(e)},Je=(e,t,n)=>{if(!t)return re(e);const s=Be(t);switch(s.name){case"extract":e=He(e,s.id,...U(s));break;case"remove":e=Qe(e,s.id,...U(s));break;case"replace":e=Ge(e,s.id,s.with,s.space);break;case"splice-start":case"splice-end":{const{deleteCount:r,insert:i,space:o,id:l}=s,c=s.name==="splice-start"?"start":"end";e=ze(e,l,c,r,i,o);break}case"trim-start":case"trim-end":{
|
|
13
|
-
`).length}`,n=`chars: ${e.length}`;return A(f._open,f._flag,"length",t,n,f._close)}},pe=e=>t=>D(t)&&t.value===f[e],nt=({position:e,url:t,siblingCount:n},s)=>({position:e,url:t,headingDepth:s,inline:n>=1}),st=({position:{start:e},url:t,siblingCount:n},{position:{end:s}},r)=>({position:{start:e,end:s},url:t,headingDepth:r,inline:n>=1}),rt=(e,t,n)=>(e.inline?A:Ne)(ce(e,n),f.begin,f.lengthOf(t),t,f.end),it=e=>{const t=j(e,"heading").reduce((n,{position:s,depth:r})=>n.set(s.start.line,r),new Map);return n=>{for(let s=n.position.start.line;s>=1;s--){const r=t.get(s);if(r)return r}return 0}},W={openingCommentDoesNotFollowLink:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) does not follow link`),closingCommentNotMatchedToOpening:({position:{start:e}})=>new Error(`Closing comment (@${e.line}:${e.column}) does not match to opening comment`),openingCommentNotClosed:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) is not followed by a closing comment`)},ot=(e,t)=>{const n=[],s=[...e.map(i=>({node:i,type:"open"})),...t.map(i=>({node:i,type:"close"}))].sort((i,o)
|
|
12
|
+
`;)m++;const p=t.slice(a,n).trim()===""&&t.slice(s,m).trim()==="";return o.isNewline&&l.isNewline?i(n-(c?1:0),s+1):o.isNewline||p?i(a,s+(l.isSpace||l.isNewline?1:0)):i(n-(o.isSpace?1:0),s)},e),Be=I(["extract(id: string, 0?: string, 1?: string, 2?: string)","remove(id: string, 0?: string, 1?: string, 2?: string)","replace(id: string, with?: string, space?: string)","remap(id?: string, from: string, to?: string, space?: string)","single-line(id: string, includeBoundaries?: boolean)","trim(id: string, inside?: boolean, outside?: boolean)","trim-start(id: string, left?: boolean, right?: boolean)","trim-end(id: string, left?: boolean, right?: boolean)","splice-start(id: string, deleteCount?: number, insert?: string, space?: string)","splice-end(id: string, deleteCount?: number, insert?: string, space?: string)","debug()"]),C=(e,t,n)=>{const s=F(e,t,n),r=[];for(let i=0;i<s.length-1;i+=2)r.push([s[i],s[i+1]]);return r},Fe=(e,t,n)=>new w(...F(e,t,n).map(({range:s})=>s)),R=e=>Ee.dedent(e).trim(),ie=(e,t)=>e[t]!==void 0&&/[^\S\r\n]/.test(e[t]),oe=(e,t)=>Math.max(0,Math.min(e.length,t)),He=(e,...t)=>{if(t.length===0)return e;const n=q(e);return R(new w(...t.flatMap(s=>C(e,s,n).map(([{range:[r]},{range:[,i]}])=>{for(;ie(e,r);)r--;for(;ie(e,i);)i++;return[oe(e,r),oe(e,i)]}))).slice(e))},Qe=(e,...t)=>{if(t.length===0)return e;const n=q(e);return R(new w([0,e.length]).subtract(new w(...t.flatMap(s=>C(e,s,n).map(([{range:[,r]},{range:[i]}])=>[r,i])))).slice(e))},Ge=(e,t,n,s)=>{if(!t)return e;let r="",i=0;for(const[o,l]of C(e,t))r+=e.slice(i,o.range[1]),r+=O(n??o.value,s),i=l.range[0];return r+=e.slice(i),R(new w([0,r.length]).subtract(Fe(r,t)).slice(r))},ze=(e,t,n,s,r,i)=>{if(!t)return e;const o=!(s===void 0||s<0),l=r?O(r,i):"",c=s??0,a=q(e),m=new w(...a.map(({range:p})=>p));return C(e,t,a).map(p=>p[n==="start"?0:1]).sort(ne).reverse().reduce((p,{range:S})=>{const k=new w,P=o?1:-1;let M=Math.abs(c),g=o?S[1]:S[0];for(;M>0&&g<p.length&&g>=0;)m.test(g)||(k.push(g),M--),g+=P;return g=Math.min(Math.max(0,g),p.length),p=p.slice(0,g)+l+p.slice(g),new w([0,p.length]).subtract(k.offset(o?0:l.length)).slice(p)},e)},Ve=(e,t,n,s,r)=>{let i="",o=0;[n,s]=[n,s??""].map(c=>O(c,r));const l=t?C(e,t):[[{range:[0,0]},{range:[e.length,e.length]}]];for(const[c,a]of l)i+=e.slice(o,c.range[1]),i+=e.slice(c.range[1],a.range[0]).replaceAll(n,s),o=a.range[0];return i+=e.slice(o),i},Xe=(e,t)=>{if(!t)return e;let n="",s=0;for(const[r,i]of C(e,t))n+=e.slice(s,r.range[1]),n+=e.slice(r.range[1],i.range[0]).replaceAll(/[\s\n]+/g," "),s=i.range[0];return n+=e.slice(s),n},le=(e,t,n)=>{var i,o,l,c;if(!t)return e;const s=a=>/\s/.test(e[a]),r=new w;for(const[a,m]of C(e,t)){if((i=n.start)!=null&&i.left){let p=a.range[0]-1;for(;s(p);)r.push(p--)}if((o=n.start)!=null&&o.right){let p=a.range[1];for(;s(p);)r.push(p++)}if((l=n.end)!=null&&l.left){let p=m.range[0]-1;for(;s(p);)r.push(p--)}if((c=n.end)!=null&&c.right){let p=m.range[1];for(;s(p);)r.push(p++)}}return new w([0,e.length]).subtract(r).slice(e)},Je=(e,t,n)=>{if(!t)return re(e);const s=Be(t);switch(s.name){case"extract":e=He(e,s.id,...U(s));break;case"remove":e=Qe(e,s.id,...U(s));break;case"replace":e=Ge(e,s.id,s.with,s.space);break;case"splice-start":case"splice-end":{const{deleteCount:r,insert:i,space:o,id:l}=s,c=s.name==="splice-start"?"start":"end";e=ze(e,l,c,r,i,o);break}case"trim-start":case"trim-end":{s.left??(s.left=!0),s.right??(s.right=!0);const r=s.name==="trim-start"?"start":"end",{length:i}=e;e=le(e,s.id,{[r]:s}),console.log(`Trimmed ${i-e.length} characters from ${r} of "${s.id}" region`);break}case"trim":{const{inside:r,outside:i,id:o}=s,l={left:i??!0,right:r??!0},c={left:r??!0,right:i??!0},{length:a}=e;e=le(e,o,{start:l,end:c}),console.log(`Trimmed ${a-e.length} characters around "${s.id}" region`);break}case"single-line":e=Xe(e,s.id);break;case"remap":e=Ve(e,s.id,s.from,s.to,s.space);break}return s.name==="debug"&&console.log("debug!!!",s),e=n&&s.name!=="debug"?re(e):e,n?R(e):e},Ze=["recipe(id: string)"],Ke=["recipe(id: string, 0?: string, 1?: string, 2?: string)"],ae={register:I(Ze),apply:I(Ke)},N=class N{constructor(){_(this,"recipes",new Map)}tryStore(t){const n=N.Entries(this.apply(t));for(let s=0;s<n.length;s++){const[r,i]=n[s];if(r!=="register")continue;const o=ae.register(i);switch(o.name){case"recipe":const l=n.slice(s+1).filter(([c])=>c!=="register").map(([c,a])=>`${c}=${a}`).join("&");this.recipes.set(o.id,l);break;default:throw new Error(`Unknown registration: ${o.name}`)}}}apply(t){const n=N.Entries(t),s=[];for(let r=0;r<n.length;r++){const[i,o]=n[r];if(i!=="apply"){s.push(`${i}=${o}`);continue}const l=ae.apply(o);switch(l.name){case"recipe":s.push(this.recipes.get(l.id)),s.push(...U(l).map(c=>this.recipes.get(c)));break;default:throw new Error(`Unknown registration: ${l.name}`)}}return s.join("&")}};_(N,"Entries",t=>Array.from(new URLSearchParams(t).entries()));let H=N;const Ye=["http","./","../","?"],et=({url:e})=>Ye.some(t=>e.startsWith(t)),tt=e=>D(e)&&ke(e)&&et(e),ce=({url:e},t)=>`[](${t?h.join(t,e):e})`,f={_open:"<!--",_close:"-->",_flag:"p↓",get begin(){return A(f._open,f._flag,"BEGIN",f._close)},get end(){return A(f._open,f._flag,"END",f._close)},lengthOf(e){const t=`lines: ${e.split(`
|
|
13
|
+
`).length}`,n=`chars: ${e.length}`;return A(f._open,f._flag,"length",t,n,f._close)}},pe=e=>t=>D(t)&&t.value===f[e],nt=({position:e,url:t,siblingCount:n},s)=>({position:e,url:t,headingDepth:s,inline:n>=1}),st=({position:{start:e},url:t,siblingCount:n},{position:{end:s}},r)=>({position:{start:e,end:s},url:t,headingDepth:r,inline:n>=1}),rt=(e,t,n)=>(e.inline?A:Ne)(ce(e,n),f.begin,f.lengthOf(t),t,f.end),it=e=>{const t=j(e,"heading").reduce((n,{position:s,depth:r})=>n.set(s.start.line,r),new Map);return n=>{for(let s=n.position.start.line;s>=1;s--){const r=t.get(s);if(r)return r}return 0}},W={openingCommentDoesNotFollowLink:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) does not follow link`),closingCommentNotMatchedToOpening:({position:{start:e}})=>new Error(`Closing comment (@${e.line}:${e.column}) does not match to opening comment`),openingCommentNotClosed:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) is not followed by a closing comment`)},ot=(e,t)=>{const n=[],s=[...e.map(i=>({node:i,type:"open"})),...t.map(i=>({node:i,type:"close"}))].sort((i,o)=>$(i.node,o.node)),r=[];for(const i of s)if(i.type==="open")r.push(i);else{const o=i.node;if(r.length===0)throw W.closingCommentNotMatchedToOpening(o);const l=r.pop().node;if(r.length>0)continue;n.push({open:l,close:o})}if(r.length>0)throw W.openingCommentNotClosed(r[0].node);return n},lt=(e,t,n)=>{const s=[...t].sort($),r=[];return[...n].sort((i,o)=>$.reverse(i.open,o.open)).forEach(i=>{for(;s.length>0;){const o=s.pop();if(o.position.start.offset<i.open.position.start.offset){if(xe(e,o,i.open).trim()!=="")throw W.openingCommentDoesNotFollowLink(i.open);return r.push([o,i])}r.push(o)}throw W.openingCommentDoesNotFollowLink(i.open)}),r.push(...s.reverse()),r.reverse()},ue=(e,t)=>{t??(t=L.md(e));const n=it(t),s=j(t,"link").filter(tt),r=j(t,"html").sort($),i=r.filter(pe("begin")),o=r.filter(pe("end")),l=ot(i,o);return lt(e,s,l).map(a=>Array.isArray(a)?st(a[0],a[1].close,n(a[0])):nt(a,n(a)))},at=(e,{url:t})=>n=>e(h.join(h.dirname(t),n)),me=(...e)=>{const t=e.reduce((n,s)=>n+s,0);return Math.min(Math.max(t,1),6)},ct=(e,t,n)=>{if(t===0)return e;n??(n=L.md(e));const s=j(n,"heading"),r=e.split(`
|
|
14
14
|
`);for(const i of s){const{depth:o,position:{start:l,end:c}}=i,a=me(o,t),m=r[l.line-1].slice(o,c.column),p="#".repeat(a)+m;r[l.line-1]=p,i.depth=a}return r.join(`
|
|
15
|
-
`)},de=e=>ue(e).reverse().sort(
|
|
15
|
+
`)},de=e=>ue(e).reverse().sort($.reverse).reduce((t,n)=>J(t,ce(n),n),e),he=(e,t,n,s,r)=>{try{e=de(e),e=ct(e,t);const i=L.md(e),o=new H,l=ue(e,i).sort($);return l.filter(({url:c})=>c.startsWith("?")).forEach(({url:c})=>o.tryStore(c)),l.reverse().map(c=>{var P,M;const{url:a,headingDepth:m}=c,[p,...S]=h.basename(a).split("?"),k=o.apply(S.join("?"));if(!a.startsWith("?"))if(a.startsWith("./")||a.startsWith("../")){const g=p.split(".").pop()??"",Q=h.dirname(a),we=h.join(Q,p);let v=n(we);const T=new $e.URLSearchParams(k),G=(P=(b=>{const y=Array.from(T.entries()).filter(([x])=>x===b).map(([x,X])=>X);return y.length>=1?y.join(","):void 0})("region"))==null?void 0:P.split(Z);v=(G==null?void 0:G.reduce((b,y,x,{length:X})=>Je(b,y,x===X-1),v))??v;const ut=T.has("skip"),mt=T.get("heading")??0,dt=T.has("inline");let{inline:z}=c;if(dt&&(z=!0),!ut)if(g==="md"){const b=at(n,c),y=r?h.join(r,Q):Q,x=me(m,Number(mt));v=he(v,x,b,we,y)}else/^(js|ts)x?|svelte$/i.test(g)&&(v=te(v,"code",{extension:g,inline:z}));const V=(M=T.get("wrap"))==null?void 0:M.split(Z);return v=(V==null?void 0:V.reduce((b,y)=>te(b,y,{extension:g,inline:z}),v))??v,{target:c,content:rt(c,v,r)}}else throw a.startsWith("http")?new Error("External web links are not implemented yet"):new Error(`Unsupported link type: ${a}`)}).filter(Boolean).reduce((c,{target:a,content:m})=>J(c,m,a),e)}catch(i){throw new Error(`Error populating inclusions in file ${s??"(unknown)"}: ${i}`)}},ge=e=>d.readFileSync(e,"utf-8"),fe=e=>{const t=h.resolve(e),n=h.dirname(t);return{content:ge(t),dir:n,path:t}},ve=(e,t=!0,n)=>{const{dir:s,path:r,content:i}=fe(e);n==null||n.unwatch(r),n==null||n.once("change",(c,a)=>{console.log(`Change detected in "${c}". Regenerating "${r}"...`),ve(e,t,n)});const l=he(i,0,c=>{const a=h.resolve(s,Te(c));return n==null||n.add(a),ge(a)},r);return t&&d.writeFileSync(r,l),n==null||n.add(r),l},pt=(e,t=!0,n)=>{const{path:s,content:r}=fe(e),i=de(r);return t&&d.writeFileSync(s,i),i};u.depopulateMarkdownInclusions=pt,u.populateMarkdownInclusions=ve,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|