@vx-oss/docs-satteri 1.0.3

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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/dist/compile-SBpZsgmI.d.ts +42 -0
  3. package/dist/compile.d.ts +2 -0
  4. package/dist/compile.js +63 -0
  5. package/dist/index-AvS9vC2S.d.ts +29 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +1 -0
  8. package/dist/local-md/client.d.ts +2 -0
  9. package/dist/local-md/client.js +2 -0
  10. package/dist/local-md/dev/react-client.d.ts +2 -0
  11. package/dist/local-md/dev/react-client.js +2 -0
  12. package/dist/local-md/dev/vite.d.ts +2 -0
  13. package/dist/local-md/dev/vite.js +2 -0
  14. package/dist/local-md/dev/ws.d.ts +2 -0
  15. package/dist/local-md/dev/ws.js +2 -0
  16. package/dist/local-md/index.d.ts +70 -0
  17. package/dist/local-md/index.js +104 -0
  18. package/dist/preset-DdTDKnqd.js +104 -0
  19. package/dist/preset-DzMkd76i.d.ts +35 -0
  20. package/dist/preset.d.ts +2 -0
  21. package/dist/preset.js +2 -0
  22. package/dist/rehype-code-CLGqDUSe.d.ts +13 -0
  23. package/dist/rehype-code.d.ts +2 -0
  24. package/dist/rehype-code.js +79 -0
  25. package/dist/rehype-katex-h_E-WUwT.d.ts +15 -0
  26. package/dist/rehype-katex.d.ts +2 -0
  27. package/dist/rehype-katex.js +52 -0
  28. package/dist/rehype-toc-wT8IcPFi.d.ts +33 -0
  29. package/dist/rehype-toc.d.ts +2 -0
  30. package/dist/rehype-toc.js +84 -0
  31. package/dist/remark-admonition.d.ts +13 -0
  32. package/dist/remark-admonition.js +79 -0
  33. package/dist/remark-auto-type-table.d.ts +9 -0
  34. package/dist/remark-auto-type-table.js +189 -0
  35. package/dist/remark-block-id.d.ts +18 -0
  36. package/dist/remark-block-id.js +46 -0
  37. package/dist/remark-code-tab-BYruQJUs.d.ts +15 -0
  38. package/dist/remark-code-tab.d.ts +2 -0
  39. package/dist/remark-code-tab.js +170 -0
  40. package/dist/remark-directive-admonition.d.ts +13 -0
  41. package/dist/remark-directive-admonition.js +54 -0
  42. package/dist/remark-feedback-block.d.ts +18 -0
  43. package/dist/remark-feedback-block.js +51 -0
  44. package/dist/remark-heading-CYhI2Dkg.d.ts +15 -0
  45. package/dist/remark-heading.d.ts +2 -0
  46. package/dist/remark-heading.js +43 -0
  47. package/dist/remark-image-C28nbosW.d.ts +29 -0
  48. package/dist/remark-image.d.ts +2 -0
  49. package/dist/remark-image.js +141 -0
  50. package/dist/remark-include.d.ts +22 -0
  51. package/dist/remark-include.js +336 -0
  52. package/dist/remark-llms.d.ts +36 -0
  53. package/dist/remark-llms.js +191 -0
  54. package/dist/remark-mdx-mermaid.d.ts +10 -0
  55. package/dist/remark-mdx-mermaid.js +22 -0
  56. package/dist/remark-npm-DdmTKhyi.d.ts +18 -0
  57. package/dist/remark-npm.d.ts +2 -0
  58. package/dist/remark-npm.js +72 -0
  59. package/dist/remark-steps.d.ts +14 -0
  60. package/dist/remark-steps.js +127 -0
  61. package/dist/remark-structure.d.ts +29 -0
  62. package/dist/remark-structure.js +94 -0
  63. package/dist/remark-ts2js.d.ts +25 -0
  64. package/dist/remark-ts2js.js +56 -0
  65. package/dist/renderer-BtFWPZB8.js +54 -0
  66. package/dist/renderer-E5KzV19n.d.ts +30 -0
  67. package/dist/stringifier-COIWcXys.js +130 -0
  68. package/dist/utils-I3DkmAkd.js +27 -0
  69. package/package.json +124 -0
@@ -0,0 +1,52 @@
1
+ import { defineHastPlugin, htmlToHast } from "satteri";
2
+ //#region src/rehype-katex.ts
3
+ let katexPromise;
4
+ function loadKatex() {
5
+ katexPromise ??= import("katex").then((katex) => katex.default.renderToString);
6
+ return katexPromise;
7
+ }
8
+ function classList(node) {
9
+ const raw = node.properties?.className;
10
+ if (Array.isArray(raw)) return raw.map(String);
11
+ if (typeof raw === "string") return raw.split(/\s+/);
12
+ return [];
13
+ }
14
+ function replace(target, nodes, ctx) {
15
+ if (nodes.length === 0) {
16
+ ctx.removeNode(target);
17
+ return;
18
+ }
19
+ ctx.replaceNode(target, nodes[0]);
20
+ if (nodes.length > 1) ctx.insertAfter(target, nodes.slice(1));
21
+ }
22
+ /**
23
+ * Render `$…$`, `$$…$$`, and ```` ```math ```` blocks to KaTeX markup — the
24
+ * Satteri counterpart of `rehype-katex`. Satteri's `math` feature parses the
25
+ * syntax into `<code class="language-math …">` elements (raw TeX); this renders
26
+ * them.
27
+ *
28
+ * The preset adds this to the hast pipeline when `math` is enabled.
29
+ */
30
+ function rehypeKatex(options = {}) {
31
+ return () => defineHastPlugin({
32
+ name: "rehype-katex",
33
+ element: {
34
+ filter: ["code"],
35
+ async visit(node, ctx) {
36
+ const classes = classList(node);
37
+ if (!classes.includes("language-math")) return;
38
+ const displayMode = !classes.includes("math-inline");
39
+ const html = (await loadKatex())(ctx.textContent(node), {
40
+ ...options,
41
+ displayMode,
42
+ throwOnError: false
43
+ });
44
+ const rendered = htmlToHast(html, { fragment: true }).children;
45
+ const parent = ctx.parent(node);
46
+ replace(displayMode && parent?.type === "element" && parent.tagName === "pre" ? parent : node, rendered, ctx);
47
+ }
48
+ }
49
+ });
50
+ }
51
+ //#endregion
52
+ export { rehypeKatex };
@@ -0,0 +1,33 @@
1
+ import { o as ExtraPluginHooks } from "./compile-SBpZsgmI.js";
2
+ import { HastPluginInput } from "satteri";
3
+ import { Element } from "hast";
4
+ //#region src/rehype-toc.d.ts
5
+ interface RehypeTocOptions {
6
+ exportToc?: boolean | {
7
+ as: 'data';
8
+ } | {
9
+ as: 'esm';
10
+ name: string;
11
+ };
12
+ }
13
+ interface RehypeTocItemType {
14
+ title: string;
15
+ url: string;
16
+ depth: number;
17
+ _step?: number;
18
+ }
19
+ interface RehypeTocESMItemType {
20
+ title: Element;
21
+ url: string;
22
+ depth: number;
23
+ _step?: number;
24
+ }
25
+ declare module 'satteri' {
26
+ interface DataMap {
27
+ /** serialized items, exported by `compileMdx` */
28
+ _rehypeTocItems?: string[];
29
+ }
30
+ }
31
+ declare function rehypeToc({ exportToc }?: RehypeTocOptions): HastPluginInput & ExtraPluginHooks;
32
+ //#endregion
33
+ export { rehypeToc as i, RehypeTocItemType as n, RehypeTocOptions as r, RehypeTocESMItemType as t };
@@ -0,0 +1,2 @@
1
+ import { i as rehypeToc, n as RehypeTocItemType, r as RehypeTocOptions, t as RehypeTocESMItemType } from "./rehype-toc-wT8IcPFi.js";
2
+ export { RehypeTocESMItemType, RehypeTocItemType, RehypeTocOptions, rehypeToc };
@@ -0,0 +1,84 @@
1
+ import { n as handleTag, r as jsxToSource } from "./utils-I3DkmAkd.js";
2
+ import { defineHastPlugin } from "satteri";
3
+ //#region src/rehype-toc.ts
4
+ const TocOnlyTag = "[toc]";
5
+ const NoTocTag = "[!toc]";
6
+ const HeadingTags = [
7
+ "h1",
8
+ "h2",
9
+ "h3",
10
+ "h4",
11
+ "h5",
12
+ "h6"
13
+ ];
14
+ function rehypeToc({ exportToc = true } = {}) {
15
+ if (exportToc === false) return defineHastPlugin({ name: "rehype-toc" });
16
+ const resolved = exportToc === true ? {
17
+ as: "esm",
18
+ name: "toc"
19
+ } : exportToc;
20
+ const plugin = () => {
21
+ return {
22
+ name: "rehype-toc",
23
+ before(_root, ctx) {
24
+ if (resolved.as === "data") ctx.data.rehypeToc ??= [];
25
+ },
26
+ element: {
27
+ filter: HeadingTags,
28
+ visit(node, ctx) {
29
+ const element = node;
30
+ if (element.children.length === 0) return;
31
+ const id = element.properties.id;
32
+ if (typeof id !== "string") return;
33
+ let isTocOnly = false;
34
+ let title = ctx.textContent(element);
35
+ let titleChildren = element.children;
36
+ const last = element.children[element.children.length - 1];
37
+ if (last?.type === "text") {
38
+ const noToc = handleTag(last.value, NoTocTag);
39
+ if (noToc !== false) {
40
+ ctx.setProperty(last, "value", noToc);
41
+ return;
42
+ }
43
+ const tocOnly = handleTag(last.value, TocOnlyTag);
44
+ if (tocOnly !== false) {
45
+ isTocOnly = true;
46
+ title = title.slice(0, title.length - last.value.length) + tocOnly;
47
+ titleChildren = [...element.children.slice(0, -1), {
48
+ ...last,
49
+ value: tocOnly
50
+ }];
51
+ }
52
+ }
53
+ if (isTocOnly) ctx.removeNode(element);
54
+ const step = typeof element.properties["data-fd-step"] === "number" ? element.properties["data-fd-step"] : void 0;
55
+ if (resolved.as === "esm") {
56
+ let obj = "{";
57
+ obj += `title: ${jsxToSource({
58
+ type: "root",
59
+ children: titleChildren
60
+ })},`;
61
+ obj += `url: ${JSON.stringify(`#${id}`)},`;
62
+ obj += `depth: ${JSON.stringify(Number(element.tagName[1]))},`;
63
+ if (step !== void 0) obj += `_step: ${JSON.stringify(step)},`;
64
+ obj += "}";
65
+ (ctx.data._rehypeTocItems ??= []).push(obj);
66
+ return;
67
+ }
68
+ (ctx.data.rehypeToc ??= []).push({
69
+ title,
70
+ depth: Number(element.tagName[1]),
71
+ url: `#${id}`,
72
+ _step: step
73
+ });
74
+ }
75
+ }
76
+ };
77
+ };
78
+ plugin.collectExports = ({ data, addExport }) => {
79
+ if (resolved.as === "esm") addExport(resolved.name, `[${(data._rehypeTocItems ?? []).join(",")}]`);
80
+ };
81
+ return plugin;
82
+ }
83
+ //#endregion
84
+ export { rehypeToc };
@@ -0,0 +1,13 @@
1
+ import { MdastVisitorContext } from "satteri";
2
+ //#region src/remark-admonition.d.ts
3
+ interface RemarkAdmonitionOptions {
4
+ tag?: string;
5
+ typeMap?: Record<string, string>;
6
+ }
7
+ declare function remarkAdmonition(options?: RemarkAdmonitionOptions): () => {
8
+ name: string;
9
+ paragraph(node: Readonly<import("mdast").Paragraph>, ctx: MdastVisitorContext): undefined;
10
+ after(_root: Readonly<import("mdast").Root>, ctx: MdastVisitorContext): void;
11
+ };
12
+ //#endregion
13
+ export { RemarkAdmonitionOptions, remarkAdmonition };
@@ -0,0 +1,79 @@
1
+ import { defineMdastPlugin } from "satteri";
2
+ //#region src/remark-admonition.ts
3
+ function remarkAdmonition(options = {}) {
4
+ const tag = options.tag ?? ":::";
5
+ const typeMap = options.typeMap ?? {
6
+ info: "info",
7
+ warn: "warn",
8
+ note: "info",
9
+ tip: "info",
10
+ warning: "warn",
11
+ danger: "error"
12
+ };
13
+ const typeKeys = Object.keys(typeMap).sort((a, b) => b.length - a.length);
14
+ function replaceNodes(nodes, ctx) {
15
+ let found = false;
16
+ let open = -1;
17
+ let attributes = [];
18
+ let hasIntercept = false;
19
+ for (let i = 0; i < nodes.length; i++) {
20
+ const node = nodes[i];
21
+ if (node.type !== "paragraph") continue;
22
+ const text = ctx.textContent(node, { includeImageAlt: false });
23
+ const typeName = typeKeys.find((type) => text.startsWith(`${tag}${type}`));
24
+ if (typeName) {
25
+ if (open !== -1) {
26
+ hasIntercept = true;
27
+ continue;
28
+ }
29
+ open = i;
30
+ attributes.push({
31
+ type: "mdxJsxAttribute",
32
+ name: "type",
33
+ value: typeMap[typeName]
34
+ });
35
+ const meta = text.slice(`${tag}${typeName}`.length);
36
+ if (meta.startsWith("[") && meta.endsWith("]")) attributes.push({
37
+ type: "mdxJsxAttribute",
38
+ name: "title",
39
+ value: meta.slice(1, -1)
40
+ });
41
+ }
42
+ if (open !== -1 && text === tag) {
43
+ const children = nodes.slice(open + 1, i);
44
+ if (hasIntercept) replaceNodes(children, ctx);
45
+ nodes.splice(open, i - open + 1, {
46
+ type: "mdxJsxFlowElement",
47
+ name: "Callout",
48
+ attributes,
49
+ children
50
+ });
51
+ found = true;
52
+ i = open;
53
+ open = -1;
54
+ hasIntercept = false;
55
+ attributes = [];
56
+ }
57
+ }
58
+ return found;
59
+ }
60
+ return () => {
61
+ const parents = /* @__PURE__ */ new Set();
62
+ return defineMdastPlugin({
63
+ name: "remark-admonition",
64
+ paragraph(node, ctx) {
65
+ if (!ctx.textContent(node, { includeImageAlt: false }).startsWith(tag)) return;
66
+ const parent = ctx.parent(node);
67
+ if (parent && "children" in parent) parents.add(parent);
68
+ },
69
+ after(_root, ctx) {
70
+ for (const parent of parents) {
71
+ const copy = [...parent.children];
72
+ if (replaceNodes(copy, ctx)) ctx.setProperty(parent, "children", copy);
73
+ }
74
+ }
75
+ });
76
+ };
77
+ }
78
+ //#endregion
79
+ export { remarkAdmonition };
@@ -0,0 +1,9 @@
1
+ import { MdxJsxFlowElement } from "satteri";
2
+ import { RemarkAutoTypeTableOptions, RemarkAutoTypeTableOptions as RemarkAutoTypeTableOptions$1 } from "@vx-oss/docs-typescript";
3
+ //#region src/remark-auto-type-table.d.ts
4
+ declare function remarkAutoTypeTable(config?: RemarkAutoTypeTableOptions$1): {
5
+ name: string;
6
+ mdxJsxFlowElement(node: Readonly<MdxJsxFlowElement>, ctx: import("satteri").MdastVisitorContext): Promise<undefined>;
7
+ };
8
+ //#endregion
9
+ export { type RemarkAutoTypeTableOptions, remarkAutoTypeTable };
@@ -0,0 +1,189 @@
1
+ import { i as replaceSource, n as formatTable } from "./stringifier-COIWcXys.js";
2
+ import { r as jsxToSource } from "./utils-I3DkmAkd.js";
3
+ import { defineMdastPlugin, markdownToHast } from "satteri";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { highlightHast } from "@vx-oss/docs-core/highlight";
7
+ import { createGenerator } from "@vx-oss/docs-typescript";
8
+ //#region src/remark-auto-type-table.ts
9
+ function sanitizeHast(node) {
10
+ if (node.type === "raw") return {
11
+ type: "text",
12
+ value: node.value
13
+ };
14
+ if ("children" in node && Array.isArray(node.children)) return {
15
+ ...node,
16
+ children: node.children.map((child) => sanitizeHast(child))
17
+ };
18
+ return node;
19
+ }
20
+ function parseTags(tags) {
21
+ const typed = {};
22
+ for (const { name: key, text } of tags) {
23
+ if (key === "default" || key === "defaultValue") {
24
+ typed.default = text;
25
+ continue;
26
+ }
27
+ if (key === "param") {
28
+ const sepIdx = text.indexOf("-");
29
+ typed.params ??= [];
30
+ typed.params.push({
31
+ name: sepIdx === -1 ? text.trim() : text.slice(0, sepIdx).trim(),
32
+ description: sepIdx === -1 ? "" : text.slice(sepIdx + 1).trim()
33
+ });
34
+ continue;
35
+ }
36
+ if (key === "returns") typed.returns = text;
37
+ }
38
+ return typed;
39
+ }
40
+ async function buildTypeProp(entries, renderType, renderMarkdown) {
41
+ async function onItem(entry) {
42
+ let node = "{";
43
+ const tags = parseTags(entry.tags);
44
+ node += `type: ${jsxToSource(await renderType(entry.simplifiedType))},`;
45
+ node += `typeDescription: ${jsxToSource(await renderType(entry.type))},`;
46
+ node += `required: ${JSON.stringify(entry.required)},`;
47
+ if (entry.typeHref) node += `typeDescriptionLink: ${JSON.stringify(entry.typeHref)},`;
48
+ if (tags.default) node += `default: ${jsxToSource(await renderType(tags.default))},`;
49
+ if (tags.returns) node += `returns: ${jsxToSource(await renderMarkdown(tags.returns))},`;
50
+ if (tags.params) {
51
+ const params = await Promise.all(tags.params.map(async ({ name, description }) => {
52
+ let param = "{";
53
+ param += `name: ${JSON.stringify(name)},`;
54
+ if (description) param += `description: ${jsxToSource(await renderMarkdown(description))},`;
55
+ param += "}";
56
+ return param;
57
+ }));
58
+ node += `parameters: [${params.join(", ")}],`;
59
+ }
60
+ if (entry.description) node += `description: ${jsxToSource(await renderMarkdown(entry.description))},`;
61
+ if (entry.deprecated) node += `deprecated: true,`;
62
+ node += "}";
63
+ return node;
64
+ }
65
+ let prop = "{";
66
+ for (const entry of entries) prop += `${JSON.stringify(entry.name)}: ${await onItem(entry)},`;
67
+ prop += "}";
68
+ return prop;
69
+ }
70
+ /** the generated type table as a Markdown table, for source-based Markdown output */
71
+ function docToMarkdown(doc) {
72
+ const rows = [[
73
+ "Prop",
74
+ "Type",
75
+ "Description"
76
+ ]];
77
+ for (const entry of doc.entries) {
78
+ const tags = parseTags(entry.tags);
79
+ let description = entry.description.replace(/{@link (?<link>[^}]*)}/g, "$1").trim();
80
+ if (tags.default) description += `${description ? " " : ""}Default: \`${tags.default}\``;
81
+ if (entry.deprecated) description = `**Deprecated.** ${description}`;
82
+ rows.push([
83
+ `\`${entry.name}${entry.required ? "" : "?"}\``,
84
+ `\`${entry.simplifiedType}\``,
85
+ description
86
+ ]);
87
+ }
88
+ let out = `### ${doc.name}\n\n`;
89
+ if (doc.description) out += `${doc.description.trim()}\n\n`;
90
+ return out + formatTable(rows);
91
+ }
92
+ function remarkAutoTypeTable(config = {}) {
93
+ const { name = "auto-type-table", outputName = "TypeTable", options: generateOptions = {}, generator = createGenerator(), renderMarkdown: renderMarkdownOption, renderType: renderTypeOption, shiki } = config;
94
+ const renderType = renderTypeOption ?? (async (type) => {
95
+ return {
96
+ type: "element",
97
+ tagName: "span",
98
+ properties: { class: "shiki" },
99
+ children: [{
100
+ type: "element",
101
+ tagName: "code",
102
+ properties: {},
103
+ children: (await highlightHast(type, {
104
+ lang: "ts",
105
+ structure: "inline",
106
+ defaultColor: false,
107
+ ...shiki
108
+ })).children
109
+ }]
110
+ };
111
+ });
112
+ const renderMarkdown = renderMarkdownOption ?? ((md) => {
113
+ md = md.replace(/{@link (?<link>[^}]*)}/g, "$1");
114
+ return sanitizeHast(markdownToHast(md, { features: { gfm: true } }));
115
+ });
116
+ return defineMdastPlugin({
117
+ name: "remark-auto-type-table",
118
+ async mdxJsxFlowElement(node, ctx) {
119
+ if (node.name !== name) return;
120
+ const props = {};
121
+ const attributes = [];
122
+ for (const attr of node.attributes) {
123
+ if (attr.type !== "mdxJsxAttribute") {
124
+ attributes.push(attr);
125
+ continue;
126
+ }
127
+ switch (attr.name) {
128
+ case "cwd":
129
+ props.cwd = true;
130
+ break;
131
+ case "path":
132
+ case "name":
133
+ case "type":
134
+ if (typeof attr.value === "string") props[attr.name] = attr.value;
135
+ break;
136
+ default: attributes.push(attr);
137
+ }
138
+ }
139
+ const filePath = ctx.fileURL ? fileURLToPath(ctx.fileURL) : void 0;
140
+ let basePath = props.cwd ? ctx.data._cwd : generateOptions.basePath;
141
+ if (filePath) basePath ??= path.dirname(filePath);
142
+ const output = await generator.generateTypeTable(props, {
143
+ ...generateOptions,
144
+ basePath
145
+ });
146
+ const children = [];
147
+ for (const doc of output) children.push({
148
+ type: "mdxJsxFlowElement",
149
+ name: outputName,
150
+ attributes: [
151
+ {
152
+ type: "mdxJsxAttribute",
153
+ name: "id",
154
+ value: `type-table-${doc.id}`
155
+ },
156
+ {
157
+ type: "mdxJsxAttribute",
158
+ name: "type",
159
+ value: {
160
+ type: "mdxJsxAttributeValueExpression",
161
+ value: await buildTypeProp(doc.entries, renderType, renderMarkdown)
162
+ }
163
+ },
164
+ ...attributes
165
+ ],
166
+ children: []
167
+ });
168
+ const parent = ctx.parent(node);
169
+ const index = ctx.indexOf(node);
170
+ if (!parent || index === void 0) return;
171
+ replaceSource(ctx, node, () => {
172
+ let markdown = "";
173
+ for (const doc of output) {
174
+ if (markdown) markdown += "\n";
175
+ markdown += docToMarkdown(doc);
176
+ }
177
+ return markdown;
178
+ });
179
+ if (children.length === 0) ctx.removeNode(node);
180
+ else if (children.length === 1) ctx.replaceNode(node, children[0]);
181
+ else {
182
+ ctx.replaceNode(node, children[0]);
183
+ ctx.insertChildAt(parent, index + 1, children.slice(1));
184
+ }
185
+ }
186
+ });
187
+ }
188
+ //#endregion
189
+ export { remarkAutoTypeTable };
@@ -0,0 +1,18 @@
1
+ import { MdastNode, MdastVisitorContext } from "satteri";
2
+ //#region src/remark-block-id.d.ts
3
+ interface RemarkBlockIdOptions {
4
+ generateId?: (ctx: {
5
+ node: MdastNode;
6
+ text: string;
7
+ }) => string;
8
+ shouldGenerate?: (node: MdastNode) => boolean | 'skip';
9
+ addDataAttribute?: string | null;
10
+ }
11
+ declare function remarkBlockId({ generateId, addDataAttribute, shouldGenerate }?: RemarkBlockIdOptions): () => {
12
+ name: string;
13
+ paragraph: (node: MdastNode, ctx: MdastVisitorContext) => void;
14
+ image: (node: MdastNode, ctx: MdastVisitorContext) => void;
15
+ listItem: (node: MdastNode, ctx: MdastVisitorContext) => void;
16
+ };
17
+ //#endregion
18
+ export { RemarkBlockIdOptions, remarkBlockId };
@@ -0,0 +1,46 @@
1
+ import Slugger from "github-slugger";
2
+ import { defineMdastPlugin } from "satteri";
3
+ import { createHash } from "node:crypto";
4
+ //#region src/remark-block-id.ts
5
+ function remarkBlockId({ generateId, addDataAttribute = "default", shouldGenerate = (node) => {
6
+ switch (node.type) {
7
+ case "mdxJsxFlowElement": return "skip";
8
+ case "paragraph":
9
+ case "image":
10
+ case "listItem": return true;
11
+ default: return false;
12
+ }
13
+ } } = {}) {
14
+ return () => {
15
+ const slugger = new Slugger();
16
+ function visit(node, ctx) {
17
+ const existing = node.data;
18
+ if (existing?.hProperties?.id) return;
19
+ const resolved = shouldGenerate(node);
20
+ if (resolved === false || resolved === "skip") return;
21
+ const text = ctx.textContent(node, { includeImageAlt: false }).trim();
22
+ if (text.length === 0) return;
23
+ const id = generateId ? slugger.slug(generateId({
24
+ node,
25
+ text
26
+ })) : slugger.slug(createHash("sha256").update(text).digest("base64url"));
27
+ const hProperties = {
28
+ ...existing?.hProperties,
29
+ id
30
+ };
31
+ if (addDataAttribute) hProperties["data-block"] = addDataAttribute;
32
+ ctx.setProperty(node, "data", {
33
+ ...existing,
34
+ hProperties
35
+ });
36
+ }
37
+ return defineMdastPlugin({
38
+ name: "remark-block-id",
39
+ paragraph: visit,
40
+ image: visit,
41
+ listItem: visit
42
+ });
43
+ };
44
+ }
45
+ //#endregion
46
+ export { remarkBlockId };
@@ -0,0 +1,15 @@
1
+ import { MdastVisitorContext } from "satteri";
2
+ import { Code, Root } from "mdast";
3
+ //#region src/remark-code-tab.d.ts
4
+ type TabType = 'CodeBlockTabs' | 'Tabs';
5
+ interface RemarkCodeTabOptions {
6
+ Tabs?: TabType;
7
+ parseMdx?: boolean;
8
+ }
9
+ declare function remarkCodeTab({ parseMdx, Tabs }?: RemarkCodeTabOptions): () => {
10
+ name: string;
11
+ code(node: Readonly<Code>, ctx: MdastVisitorContext): undefined;
12
+ after(_root: Readonly<Root>, ctx: MdastVisitorContext): void;
13
+ };
14
+ //#endregion
15
+ export { remarkCodeTab as n, RemarkCodeTabOptions as t };
@@ -0,0 +1,2 @@
1
+ import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "./remark-code-tab-BYruQJUs.js";
2
+ export { RemarkCodeTabOptions, remarkCodeTab };