@canofold/markdown 0.2.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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/README.zh-CN.md +50 -0
  4. package/dist/Markdown-DgolXL7g.js +2116 -0
  5. package/dist/Markdown-iU2W4KgV.js +2116 -0
  6. package/dist/base.css +2 -0
  7. package/dist/client/chunks/client-BkvCIcoZ.js +334 -0
  8. package/dist/client/chunks/client-kVNIqHQd.js +334 -0
  9. package/dist/client/chunks/gallery-BTg1qJjd.js +40 -0
  10. package/dist/client/chunks/gallery-q0WKbDeW.js +40 -0
  11. package/dist/client/chunks/image-BuMCsr5L.js +36 -0
  12. package/dist/client/chunks/image-_I24969q.js +36 -0
  13. package/dist/client/chunks/provider-DNSHvvN7.js +841 -0
  14. package/dist/client/chunks/provider-SSQfNDJA.js +841 -0
  15. package/dist/client/chunks/react-runtime-Dzgdzn6D.js +10571 -0
  16. package/dist/client/chunks/serialized-DajnRKXi.js +3464 -0
  17. package/dist/client/chunks/serialized-T1PzI4rG.js +3464 -0
  18. package/dist/client/chunks/table-JOSJsHgy.js +30 -0
  19. package/dist/client/chunks/table-PQvrpt1p.js +30 -0
  20. package/dist/client/index.js +4 -0
  21. package/dist/client/nativeBehaviors.d.ts +4 -0
  22. package/dist/client.d.ts +15 -0
  23. package/dist/compiler/analyze.d.ts +27 -0
  24. package/dist/compiler/assets.d.ts +29 -0
  25. package/dist/compiler/ast.d.ts +68 -0
  26. package/dist/compiler/createPipeline.d.ts +18 -0
  27. package/dist/compiler/defaultLabels.d.ts +28 -0
  28. package/dist/compiler/directiveValidation.d.ts +17 -0
  29. package/dist/compiler/highlighter.d.ts +3 -0
  30. package/dist/compiler/mdxModules.d.ts +19 -0
  31. package/dist/compiler/mdxPlugins.d.ts +16 -0
  32. package/dist/compiler/normalizeOptions.d.ts +16 -0
  33. package/dist/compiler/pluginPlan.d.ts +18 -0
  34. package/dist/compiler/plugins/code.d.ts +16 -0
  35. package/dist/compiler/plugins/directives.d.ts +24 -0
  36. package/dist/compiler/plugins/documentBlocks.d.ts +5 -0
  37. package/dist/compiler/plugins/tables.d.ts +5 -0
  38. package/dist/compiler/plugins.d.ts +24 -0
  39. package/dist/compiler/prepareMarkdown.d.ts +11 -0
  40. package/dist/compiler/sanitizeBoundary.d.ts +18 -0
  41. package/dist/compiler/stableJson.d.ts +2 -0
  42. package/dist/compiler/syntaxFeatures.d.ts +10 -0
  43. package/dist/compiler/types.d.ts +177 -0
  44. package/dist/components/blocks/MarkdownCodeBlock.d.ts +10 -0
  45. package/dist/components/blocks/MarkdownCopySnippet.d.ts +10 -0
  46. package/dist/components/blocks/MarkdownHeading.d.ts +13 -0
  47. package/dist/components/blocks/MarkdownImage.d.ts +16 -0
  48. package/dist/components/blocks/MarkdownTable.d.ts +12 -0
  49. package/dist/components/blocks/MarkdownTerminal.d.ts +9 -0
  50. package/dist/components/composite/MarkdownComposite.d.ts +37 -0
  51. package/dist/components/composite/MarkdownFileTree.d.ts +5 -0
  52. package/dist/components/composite/MarkdownTabs.d.ts +6 -0
  53. package/dist/components/gallery/ImageGallery.d.ts +25 -0
  54. package/dist/components/shared/MarkdownActions.d.ts +18 -0
  55. package/dist/components/shared/MarkdownDialog.d.ts +11 -0
  56. package/dist/components/shared/MarkdownFileIcon.d.ts +4 -0
  57. package/dist/components/shared/MarkdownIcon.d.ts +8 -0
  58. package/dist/components/shared/interactionConstants.d.ts +1 -0
  59. package/dist/components/shared/reactText.d.ts +14 -0
  60. package/dist/directiveValidation-CwXRsn5k.js +741 -0
  61. package/dist/directiveValidation-KWUIIjKw.js +741 -0
  62. package/dist/file-icons/LICENSE +21 -0
  63. package/dist/file-icons/astro.svg +1 -0
  64. package/dist/file-icons/bun.svg +1 -0
  65. package/dist/file-icons/bun_light.svg +1 -0
  66. package/dist/file-icons/config.svg +1 -0
  67. package/dist/file-icons/console.svg +1 -0
  68. package/dist/file-icons/css.svg +1 -0
  69. package/dist/file-icons/database.svg +1 -0
  70. package/dist/file-icons/deno.svg +1 -0
  71. package/dist/file-icons/deno_light.svg +1 -0
  72. package/dist/file-icons/diff.svg +1 -0
  73. package/dist/file-icons/docker.svg +1 -0
  74. package/dist/file-icons/document.svg +1 -0
  75. package/dist/file-icons/download.svg +1 -0
  76. package/dist/file-icons/environment.svg +1 -0
  77. package/dist/file-icons/excel.svg +1 -0
  78. package/dist/file-icons/git.svg +1 -0
  79. package/dist/file-icons/github-actions.svg +1 -0
  80. package/dist/file-icons/go.svg +1 -0
  81. package/dist/file-icons/javascript.svg +1 -0
  82. package/dist/file-icons/json.svg +1 -0
  83. package/dist/file-icons/markdown.svg +1 -0
  84. package/dist/file-icons/nodejs.svg +1 -0
  85. package/dist/file-icons/npm.svg +1 -0
  86. package/dist/file-icons/pdf.svg +1 -0
  87. package/dist/file-icons/pnpm.svg +1 -0
  88. package/dist/file-icons/pnpm_light.svg +1 -0
  89. package/dist/file-icons/powerpoint.svg +1 -0
  90. package/dist/file-icons/python.svg +1 -0
  91. package/dist/file-icons/react.svg +1 -0
  92. package/dist/file-icons/rust.svg +1 -0
  93. package/dist/file-icons/sass.svg +1 -0
  94. package/dist/file-icons/settings.svg +1 -0
  95. package/dist/file-icons/svelte.svg +1 -0
  96. package/dist/file-icons/typescript.svg +1 -0
  97. package/dist/file-icons/vue.svg +1 -0
  98. package/dist/file-icons/word.svg +1 -0
  99. package/dist/file-icons/yaml.svg +1 -0
  100. package/dist/file-icons/yarn.svg +1 -0
  101. package/dist/index.d.ts +7 -0
  102. package/dist/index.js +6 -0
  103. package/dist/islands/gallery.d.ts +2 -0
  104. package/dist/islands/image.d.ts +2 -0
  105. package/dist/islands/options.d.ts +8 -0
  106. package/dist/islands/provider.d.ts +4 -0
  107. package/dist/islands/serialized.d.ts +4 -0
  108. package/dist/islands/table.d.ts +2 -0
  109. package/dist/islands.d.ts +13 -0
  110. package/dist/plugins-CeQ-Bo89.js +288 -0
  111. package/dist/plugins-DQ-VUuCT.js +288 -0
  112. package/dist/prepareMarkdown-8N-OdLDS.js +852 -0
  113. package/dist/prepareMarkdown-Bug1ncYk.js +852 -0
  114. package/dist/protocol/serializedNode.d.ts +3 -0
  115. package/dist/react/Markdown.d.ts +54 -0
  116. package/dist/react/componentMap.d.ts +172 -0
  117. package/dist/react/semanticOverrideProps.d.ts +4 -0
  118. package/dist/react/slots.d.ts +39 -0
  119. package/dist/react/urlTransform.d.ts +12 -0
  120. package/dist/server/analyze.d.ts +6 -0
  121. package/dist/server/analyze.js +132 -0
  122. package/dist/server/cache.d.ts +16 -0
  123. package/dist/server/createMarkdownRenderer.d.ts +39 -0
  124. package/dist/server.d.ts +5 -0
  125. package/dist/server.js +137 -0
  126. package/dist/shared/copyText.d.ts +2 -0
  127. package/dist/shared/fileKinds.d.ts +6 -0
  128. package/dist/theme.css +183 -0
  129. package/dist/theme.d.ts +167 -0
  130. package/dist/theme.js +228 -0
  131. package/package.json +110 -0
@@ -0,0 +1,288 @@
1
+ const w = {
2
+ "package.json": "package",
3
+ "package-lock.json": "package",
4
+ "pnpm-lock.yaml": "package",
5
+ "yarn.lock": "package",
6
+ "bun.lock": "package",
7
+ "bun.lockb": "package",
8
+ "deno.json": "package",
9
+ "deno.jsonc": "package",
10
+ "pnpm-workspace.yaml": "package",
11
+ ".gitignore": "config",
12
+ ".editorconfig": "config",
13
+ ".npmrc": "config",
14
+ ".nvmrc": "config",
15
+ ".prettierrc": "config",
16
+ "biome.json": "config",
17
+ dockerfile: "container",
18
+ containerfile: "container",
19
+ "tsconfig.json": "config",
20
+ "jsconfig.json": "config",
21
+ "turbo.json": "config",
22
+ "vite.config.ts": "config",
23
+ "vite.config.js": "config"
24
+ }, y = {
25
+ ts: "typescript",
26
+ tsx: "typescript",
27
+ mts: "typescript",
28
+ cts: "typescript",
29
+ js: "javascript",
30
+ jsx: "javascript",
31
+ mjs: "javascript",
32
+ cjs: "javascript",
33
+ md: "markdown",
34
+ mdx: "markdown",
35
+ css: "style",
36
+ conf: "config",
37
+ scss: "style",
38
+ sass: "style",
39
+ less: "style",
40
+ json: "data",
41
+ jsonc: "data",
42
+ yaml: "data",
43
+ yml: "data",
44
+ toml: "data",
45
+ sql: "database",
46
+ diff: "diff",
47
+ patch: "diff",
48
+ sh: "shell",
49
+ bash: "shell",
50
+ zsh: "shell",
51
+ fish: "shell",
52
+ vue: "component",
53
+ svelte: "component",
54
+ astro: "component",
55
+ py: "source",
56
+ go: "source",
57
+ rs: "source"
58
+ }, k = {
59
+ typescript: "typescript",
60
+ ts: "typescript",
61
+ tsx: "typescript",
62
+ javascript: "javascript",
63
+ js: "javascript",
64
+ jsx: "javascript",
65
+ markdown: "markdown",
66
+ md: "markdown",
67
+ mdx: "markdown",
68
+ css: "style",
69
+ scss: "style",
70
+ sass: "style",
71
+ less: "style",
72
+ json: "data",
73
+ jsonc: "data",
74
+ yaml: "data",
75
+ yml: "data",
76
+ toml: "data",
77
+ sql: "database",
78
+ diff: "diff",
79
+ docker: "container",
80
+ dockerfile: "container",
81
+ nginx: "config",
82
+ shell: "shell",
83
+ sh: "shell",
84
+ bash: "shell",
85
+ zsh: "shell",
86
+ terminal: "shell",
87
+ vue: "component",
88
+ svelte: "component",
89
+ astro: "component",
90
+ python: "source",
91
+ py: "source",
92
+ go: "source",
93
+ rust: "source",
94
+ rs: "source"
95
+ };
96
+ function b(e, t = "") {
97
+ const o = e.split(/[\\/]/).pop()?.toLowerCase() || "", n = w[o];
98
+ if (n) return n;
99
+ if (/^\.env(?:\..+)?$/.test(o)) return "environment";
100
+ if (/(^|\.)config\.[^.]+$/.test(o) || /^\.[a-z0-9-]+rc(?:\.[^.]+)?$/.test(o))
101
+ return "config";
102
+ const r = o.includes(".") && o.split(".").pop() || "";
103
+ return y[r] || k[t.toLowerCase()] || "file";
104
+ }
105
+ const p = {
106
+ astro: "astro",
107
+ bash: "console",
108
+ css: "css",
109
+ diff: "diff",
110
+ docker: "docker",
111
+ dockerfile: "docker",
112
+ go: "go",
113
+ javascript: "javascript",
114
+ js: "javascript",
115
+ jsx: "javascript",
116
+ json: "json",
117
+ jsonc: "json",
118
+ markdown: "markdown",
119
+ md: "markdown",
120
+ mdx: "markdown",
121
+ python: "python",
122
+ py: "python",
123
+ rust: "rust",
124
+ rs: "rust",
125
+ sass: "sass",
126
+ scss: "sass",
127
+ shell: "console",
128
+ sh: "console",
129
+ sql: "database",
130
+ svelte: "svelte",
131
+ terminal: "console",
132
+ typescript: "typescript",
133
+ ts: "typescript",
134
+ tsx: "typescript",
135
+ vue: "vue",
136
+ yaml: "yaml",
137
+ yml: "yaml",
138
+ zsh: "console"
139
+ };
140
+ function j(e, t = "") {
141
+ const o = e.replace(/\\/g, "/").toLowerCase(), n = o.split("/").pop() || "";
142
+ if (/^docfuse\.config\.(?:[cm]?[jt]s)$/.test(n)) return "docfuse";
143
+ if (/^(?:.*\/)?\.github\/workflows\/[^/]+\.ya?ml$/.test(o)) return "github-actions";
144
+ if (["npm", "pnpm", "yarn", "bun", "deno"].includes(n))
145
+ return n;
146
+ if (n === "package.json") return "nodejs";
147
+ if (n.startsWith("pnpm-") || n === "pnpm-lock.yaml") return "pnpm";
148
+ if (n === "package-lock.json" || n === ".npmrc") return "npm";
149
+ if (n === "yarn.lock") return "yarn";
150
+ if (n === "bun.lock" || n === "bun.lockb") return "bun";
151
+ if (n === "deno.json" || n === "deno.jsonc") return "deno";
152
+ if (n === "dockerfile" || n === "containerfile") return "docker";
153
+ if (n === ".gitignore" || n === ".gitattributes" || n === ".gitmodules")
154
+ return "git";
155
+ if (/^\.env(?:\.|$)/.test(n)) return "environment";
156
+ if (n === "tsconfig.json" || n === "jsconfig.json") return "typescript";
157
+ if (/\.(?:jsx|tsx)$/.test(n)) return "react";
158
+ const r = b(n, t);
159
+ if (r === "config") return "config";
160
+ if (r === "database") return "database";
161
+ if (r === "diff") return "diff";
162
+ if (r === "shell") return "console";
163
+ if (r === "container") return "docker";
164
+ const a = n.includes(".") && n.split(".").pop() || "";
165
+ return p[a] || p[t.toLowerCase()] || "document";
166
+ }
167
+ function c(e, t) {
168
+ if (e === null || typeof e == "string" || typeof e == "boolean") return JSON.stringify(e);
169
+ if (typeof e == "number") {
170
+ if (!Number.isFinite(e)) throw new TypeError("Numbers must be finite");
171
+ return String(e);
172
+ }
173
+ if (typeof e != "object") throw new TypeError("Value is not JSON serializable");
174
+ if (t.has(e)) throw new TypeError("Circular JSON value");
175
+ const o = Object.getPrototypeOf(e);
176
+ if (!Array.isArray(e) && o !== Object.prototype && o !== null)
177
+ throw new TypeError("Only plain objects are JSON serializable");
178
+ t.add(e);
179
+ try {
180
+ if (Array.isArray(e)) {
181
+ if (Object.keys(e).length !== e.length) throw new TypeError("Sparse arrays are not supported");
182
+ return `[${e.map((n) => c(n, t)).join(",")}]`;
183
+ }
184
+ return `{${Object.keys(e).sort().map((n) => `${JSON.stringify(n)}:${c(e[n], t)}`).join(",")}}`;
185
+ } finally {
186
+ t.delete(e);
187
+ }
188
+ }
189
+ function l(e) {
190
+ try {
191
+ return c(e, /* @__PURE__ */ new WeakSet());
192
+ } catch {
193
+ return;
194
+ }
195
+ }
196
+ const m = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, h = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
197
+ function d(e) {
198
+ if (typeof e != "string" || !m.test(e))
199
+ throw new Error(
200
+ `Markdown plugin names must be lowercase kebab-case slugs (e.g. "external-links"), got ${JSON.stringify(e)}`
201
+ );
202
+ }
203
+ function u(e) {
204
+ if (e.cacheKey !== void 0 && l(e.cacheKey) === void 0)
205
+ throw new Error(`Markdown plugin "${e.name}" cacheKey must be JSON-serializable`);
206
+ }
207
+ function g(e) {
208
+ const t = e.browserCompiler;
209
+ if (t) {
210
+ if (typeof t.module != "string" || t.module.trim() === "")
211
+ throw new Error(`Markdown plugin "${e.name}" browserCompiler.module must be a non-empty string`);
212
+ if (typeof t.exportName != "string" || !h.test(t.exportName))
213
+ throw new Error(
214
+ `Markdown plugin "${e.name}" browserCompiler.exportName must be a named JavaScript export`
215
+ );
216
+ if (t.options !== void 0 && l(t.options) === void 0)
217
+ throw new Error(`Markdown plugin "${e.name}" browserCompiler.options must be JSON-serializable`);
218
+ }
219
+ }
220
+ function f(e) {
221
+ return (e.directiveNames ?? []).map((t) => {
222
+ const o = t.trim().toLowerCase();
223
+ if (t !== o || !m.test(o))
224
+ throw new Error(
225
+ `Markdown plugin "${e.name}" directive names must be lowercase kebab-case slugs, got ${JSON.stringify(t)}`
226
+ );
227
+ return o;
228
+ });
229
+ }
230
+ function $(e = []) {
231
+ const t = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
232
+ for (const r of e) {
233
+ if (d(r?.name), u(r), g(r), t.has(r.name))
234
+ throw new Error(`Markdown plugins must have unique names, got "${r.name}" twice`);
235
+ t.add(r.name);
236
+ for (const a of r.fenceLanguages ?? []) {
237
+ const s = a.trim().toLowerCase();
238
+ if (!s) continue;
239
+ const i = o.get(s);
240
+ if (i && i !== r.name)
241
+ throw new Error(`Fence language "${s}" is owned by both "${i}" and "${r.name}"`);
242
+ o.set(s, r.name);
243
+ }
244
+ for (const a of f(r)) {
245
+ const s = n.get(a);
246
+ if (s && s !== r.name)
247
+ throw new Error(`Directive "${a}" is owned by both "${s}" and "${r.name}"`);
248
+ n.set(a, r.name);
249
+ }
250
+ }
251
+ return e;
252
+ }
253
+ function v(e = []) {
254
+ return e.map((t) => ({
255
+ name: t.name,
256
+ version: t.version ?? "",
257
+ cacheKey: t.cacheKey ?? null
258
+ }));
259
+ }
260
+ function N(e) {
261
+ return d(e?.name), u(e), g(e), f(e), e;
262
+ }
263
+ function x(e, t) {
264
+ return e.filter((o) => o.appliesTo?.(t) !== !1);
265
+ }
266
+ function z(e) {
267
+ const t = /* @__PURE__ */ new Set();
268
+ for (const o of e)
269
+ for (const n of o.fenceLanguages ?? []) {
270
+ const r = n.trim().toLowerCase();
271
+ r && t.add(r);
272
+ }
273
+ return t;
274
+ }
275
+ function E(e) {
276
+ return new Set(e.flatMap((t) => f(t)));
277
+ }
278
+ export {
279
+ x as a,
280
+ z as b,
281
+ v as c,
282
+ N as d,
283
+ b as e,
284
+ j as f,
285
+ E as m,
286
+ $ as n,
287
+ l as s
288
+ };