@canofold/markdown 0.3.0 → 0.3.2

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 (41) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dist/ImageGallery-Bcpjlfh9.js +569 -0
  4. package/dist/Markdown-607_slPB.js +117 -0
  5. package/dist/assets-CqlggKr8.js +77 -0
  6. package/dist/base.css +1 -1
  7. package/dist/client/bundler.js +308 -0
  8. package/dist/client/chunks/{client-kVNIqHQd.js → client-CHUUETWE.js} +3 -3
  9. package/dist/client/chunks/{gallery-BTg1qJjd.js → gallery-Cr0TgC1h.js} +2 -2
  10. package/dist/client/chunks/{image-BuMCsr5L.js → image-6_o7fPkU.js} +3 -3
  11. package/dist/client/chunks/provider-k1N-5njv.js +1037 -0
  12. package/dist/client/chunks/react-runtime-DRPMrVPX.js +12062 -0
  13. package/dist/client/chunks/{serialized-T1PzI4rG.js → serialized-Chn9ydGA.js} +270 -220
  14. package/dist/client/chunks/{table-JOSJsHgy.js → table-D99-Zhc8.js} +3 -3
  15. package/dist/client/index.js +1 -1
  16. package/dist/compiler/fenceMetadata.d.ts +7 -0
  17. package/dist/compiler/normalizeOptions.d.ts +2 -1
  18. package/dist/compiler/plugins/code.d.ts +1 -1
  19. package/dist/compiler/prepareMarkdown.d.ts +1 -1
  20. package/dist/compiler/types.d.ts +3 -0
  21. package/dist/componentMap-CKSUGzQH.js +1483 -0
  22. package/dist/components/blocks/MarkdownCodeBlock.d.ts +3 -1
  23. package/dist/copyText-C0ZgrMnH.js +18 -0
  24. package/dist/{directiveValidation-BdVbgcY_.js → directiveValidation-B7LY-R5p.js} +187 -248
  25. package/dist/fileKinds-BPzIxbaS.js +170 -0
  26. package/dist/gallery-BqQ-i0TC.js +42 -0
  27. package/dist/image-CiPni6Az.js +38 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/plugins-CXYBB-oH.js +130 -0
  31. package/dist/{prepareMarkdown-D-bFl1_V.js → prepareMarkdown-CS6sALIb.js} +344 -329
  32. package/dist/provider-BJDHf4Z_.js +8 -0
  33. package/dist/serialized-DFiNQYA5.js +39 -0
  34. package/dist/server/analyze.js +11 -11
  35. package/dist/server.js +30 -28
  36. package/dist/table-DQSeLjVL.js +32 -0
  37. package/package.json +14 -9
  38. package/dist/Markdown-C7O01MRv.js +0 -2116
  39. package/dist/client/chunks/provider-DNSHvvN7.js +0 -841
  40. package/dist/client/chunks/react-runtime-Dzgdzn6D.js +0 -10571
  41. package/dist/plugins-StkCS2su.js +0 -298
@@ -1,298 +0,0 @@
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 h(e, t = "") {
97
- const r = e.split(/[\\/]/).pop()?.toLowerCase() || "", n = w[r];
98
- if (n) return n;
99
- if (/^\.env(?:\..+)?$/.test(r)) return "environment";
100
- if (/(^|\.)config\.[^.]+$/.test(r) || /^\.[a-z0-9-]+rc(?:\.[^.]+)?$/.test(r))
101
- return "config";
102
- const o = r.includes(".") && r.split(".").pop() || "";
103
- return y[o] || k[t.toLowerCase()] || "file";
104
- }
105
- const l = {
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 r = e.replace(/\\/g, "/").toLowerCase(), n = r.split("/").pop() || "";
142
- if (/^canofold\.config\.(?:[cm]?[jt]s)$/.test(n)) return "canofold";
143
- if (/^(?:.*\/)?\.github\/workflows\/[^/]+\.ya?ml$/.test(r)) 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 o = h(n, t);
159
- if (o === "config") return "config";
160
- if (o === "database") return "database";
161
- if (o === "diff") return "diff";
162
- if (o === "shell") return "console";
163
- if (o === "container") return "docker";
164
- const a = n.includes(".") && n.split(".").pop() || "";
165
- return l[a] || l[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 r = Object.getPrototypeOf(e);
176
- if (!Array.isArray(e) && r !== Object.prototype && r !== 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 p(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]+)*$/, b = /^[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 && p(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" || !b.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 && p(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 r = t.trim().toLowerCase();
223
- if (t !== r || !m.test(r))
224
- throw new Error(
225
- `Markdown plugin "${e.name}" directive names must be lowercase kebab-case slugs, got ${JSON.stringify(t)}`
226
- );
227
- return r;
228
- });
229
- }
230
- function $(e = []) {
231
- const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
232
- for (const o of e) {
233
- if (d(o?.name), u(o), g(o), t.has(o.name))
234
- throw new Error(`Markdown plugins must have unique names, got "${o.name}" twice`);
235
- t.add(o.name);
236
- for (const a of o.fenceLanguages ?? []) {
237
- const s = a.trim().toLowerCase();
238
- if (!s) continue;
239
- const i = r.get(s);
240
- if (i && i !== o.name)
241
- throw new Error(`Fence language "${s}" is owned by both "${i}" and "${o.name}"`);
242
- r.set(s, o.name);
243
- }
244
- for (const a of f(o)) {
245
- const s = n.get(a);
246
- if (s && s !== o.name)
247
- throw new Error(`Directive "${a}" is owned by both "${s}" and "${o.name}"`);
248
- n.set(a, o.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((r) => r.appliesTo?.(t) !== !1);
265
- }
266
- function z(e) {
267
- const t = /* @__PURE__ */ new Set();
268
- for (const r of e)
269
- for (const n of r.fenceLanguages ?? []) {
270
- const o = n.trim().toLowerCase();
271
- o && t.add(o);
272
- }
273
- return t;
274
- }
275
- function E(e) {
276
- const t = /* @__PURE__ */ new Set();
277
- for (const r of e)
278
- for (const n of r.highlightLanguages ?? []) {
279
- const o = n.trim().toLowerCase();
280
- o && t.add(o);
281
- }
282
- return [...t];
283
- }
284
- function O(e) {
285
- return new Set(e.flatMap((t) => f(t)));
286
- }
287
- export {
288
- x as a,
289
- z as b,
290
- E as c,
291
- N as d,
292
- v as e,
293
- h as f,
294
- j as g,
295
- O as m,
296
- $ as n,
297
- p as s
298
- };