@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.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/ImageGallery-Bcpjlfh9.js +569 -0
- package/dist/Markdown-607_slPB.js +117 -0
- package/dist/assets-CqlggKr8.js +77 -0
- package/dist/base.css +1 -1
- package/dist/client/bundler.js +308 -0
- package/dist/client/chunks/{client-kVNIqHQd.js → client-CHUUETWE.js} +3 -3
- package/dist/client/chunks/{gallery-BTg1qJjd.js → gallery-Cr0TgC1h.js} +2 -2
- package/dist/client/chunks/{image-BuMCsr5L.js → image-6_o7fPkU.js} +3 -3
- package/dist/client/chunks/provider-k1N-5njv.js +1037 -0
- package/dist/client/chunks/react-runtime-DRPMrVPX.js +12062 -0
- package/dist/client/chunks/{serialized-T1PzI4rG.js → serialized-Chn9ydGA.js} +270 -220
- package/dist/client/chunks/{table-JOSJsHgy.js → table-D99-Zhc8.js} +3 -3
- package/dist/client/index.js +1 -1
- package/dist/compiler/fenceMetadata.d.ts +7 -0
- package/dist/compiler/normalizeOptions.d.ts +2 -1
- package/dist/compiler/plugins/code.d.ts +1 -1
- package/dist/compiler/prepareMarkdown.d.ts +1 -1
- package/dist/compiler/types.d.ts +3 -0
- package/dist/componentMap-CKSUGzQH.js +1483 -0
- package/dist/components/blocks/MarkdownCodeBlock.d.ts +3 -1
- package/dist/copyText-C0ZgrMnH.js +18 -0
- package/dist/{directiveValidation-BdVbgcY_.js → directiveValidation-B7LY-R5p.js} +187 -248
- package/dist/fileKinds-BPzIxbaS.js +170 -0
- package/dist/gallery-BqQ-i0TC.js +42 -0
- package/dist/image-CiPni6Az.js +38 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/plugins-CXYBB-oH.js +130 -0
- package/dist/{prepareMarkdown-D-bFl1_V.js → prepareMarkdown-CS6sALIb.js} +344 -329
- package/dist/provider-BJDHf4Z_.js +8 -0
- package/dist/serialized-DFiNQYA5.js +39 -0
- package/dist/server/analyze.js +11 -11
- package/dist/server.js +30 -28
- package/dist/table-DQSeLjVL.js +32 -0
- package/package.json +14 -9
- package/dist/Markdown-C7O01MRv.js +0 -2116
- package/dist/client/chunks/provider-DNSHvvN7.js +0 -841
- package/dist/client/chunks/react-runtime-Dzgdzn6D.js +0 -10571
- package/dist/plugins-StkCS2su.js +0 -298
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs as c, jsx as m, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import { toJsxRuntime as l } from "hast-util-to-jsx-runtime";
|
|
3
|
+
import { isValidElement as p, cloneElement as f } from "react";
|
|
4
|
+
import { d as i, c as y } from "./componentMap-CKSUGzQH.js";
|
|
5
|
+
function v(e) {
|
|
6
|
+
return !!(e && typeof e == "object" && typeof e.type == "string");
|
|
7
|
+
}
|
|
8
|
+
function d(e, r = {}, t = !0) {
|
|
9
|
+
return l(e, {
|
|
10
|
+
Fragment: u,
|
|
11
|
+
jsx: m,
|
|
12
|
+
jsxs: c,
|
|
13
|
+
components: t ? y(r.classNames, r.slots, r.components) : void 0,
|
|
14
|
+
passNode: !0
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function j(e, r = {}) {
|
|
18
|
+
try {
|
|
19
|
+
const t = i(e);
|
|
20
|
+
return t ? d(t, r) : void 0;
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function w(e, r = {}, t = !0) {
|
|
26
|
+
try {
|
|
27
|
+
const n = i(e);
|
|
28
|
+
return !n || !("children" in n) || !Array.isArray(n.children) ? void 0 : n.children.filter(v).map((a, s) => {
|
|
29
|
+
const o = a.type === "text" ? a.value : d(a, r, t);
|
|
30
|
+
return p(o) && o.key === null ? f(o, { key: `markdown-node-${s}` }) : o;
|
|
31
|
+
});
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
j as a,
|
|
38
|
+
w as r
|
|
39
|
+
};
|
package/dist/server/analyze.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { unified as I } from "unified";
|
|
1
|
+
import { d as V } from "../assets-CqlggKr8.js";
|
|
2
|
+
import w from "github-slugger";
|
|
3
|
+
import { remarkDefinitionList as x } from "remark-definition-list";
|
|
4
|
+
import b from "remark-directive";
|
|
5
|
+
import D from "remark-gfm";
|
|
6
|
+
import M from "remark-parse";
|
|
7
|
+
import { unified as E } from "unified";
|
|
9
8
|
import { visit as k } from "unist-util-visit";
|
|
10
|
-
import {
|
|
9
|
+
import { n as S, c as I } from "../directiveValidation-B7LY-R5p.js";
|
|
10
|
+
import { a as j, n as C, m as A } from "../plugins-CXYBB-oH.js";
|
|
11
11
|
import { createProcessor as L } from "@mdx-js/mdx";
|
|
12
12
|
function P(t) {
|
|
13
13
|
return "children" in t && Array.isArray(t.children);
|
|
@@ -16,7 +16,7 @@ function l(t) {
|
|
|
16
16
|
return t.type === "text" || t.type === "inlineCode" ? String(t.value ?? "") : t.type === "image" ? String(t.alt ?? "") : t.type === "code" || t.type === "html" || t.type === "definition" ? "" : P(t) ? t.children.map(l).join(" ") : "";
|
|
17
17
|
}
|
|
18
18
|
function H(t, i = {}) {
|
|
19
|
-
const n =
|
|
19
|
+
const n = E().use(M).use(x).use(D).use(b).parse(S(t)), c = new w(), f = [], s = [], o = [], m = [], y = [];
|
|
20
20
|
let g = 0;
|
|
21
21
|
const u = /* @__PURE__ */ new Map();
|
|
22
22
|
k(n, "definition", (r) => {
|
|
@@ -80,7 +80,7 @@ function H(t, i = {}) {
|
|
|
80
80
|
images: m,
|
|
81
81
|
missingCodeBlockLanguages: g,
|
|
82
82
|
directives: y,
|
|
83
|
-
directiveIssues:
|
|
83
|
+
directiveIssues: I(n, A(v)).map(
|
|
84
84
|
({ message: r, line: e, column: a }) => ({
|
|
85
85
|
message: r,
|
|
86
86
|
line: e,
|
package/dist/server.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import * as f from "react/jsx-runtime";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
3
3
|
import { evaluate as h } from "@mdx-js/mdx";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import { a as
|
|
8
|
-
import { d as
|
|
9
|
-
import {
|
|
4
|
+
import { b as k } from "./componentMap-CKSUGzQH.js";
|
|
5
|
+
import { c as M } from "./assets-CqlggKr8.js";
|
|
6
|
+
import { n as P, d as x, c as v, a as y, p as L } from "./prepareMarkdown-CS6sALIb.js";
|
|
7
|
+
import { a as N, b as S, c as b, s as C, e as T } from "./plugins-CXYBB-oH.js";
|
|
8
|
+
import { d as Z } from "./plugins-CXYBB-oH.js";
|
|
9
|
+
import { n as z } from "./directiveValidation-B7LY-R5p.js";
|
|
10
|
+
import { createHash as H } from "node:crypto";
|
|
11
|
+
import { a as O, b as R } from "./Markdown-607_slPB.js";
|
|
10
12
|
async function A(a = {}, r, s = { warnedLanguages: /* @__PURE__ */ new Set() }) {
|
|
11
|
-
const n =
|
|
12
|
-
.../* @__PURE__ */ new Set([...g.codeLanguages, ...
|
|
13
|
-
],
|
|
13
|
+
const n = P(a), e = M(), t = r ?? "", o = N(n.plugins, { source: t, mode: "mdx" }), l = S(o), d = { ...n, plugins: o }, g = x(t, l), m = [
|
|
14
|
+
.../* @__PURE__ */ new Set([...g.codeLanguages, ...b(o)])
|
|
15
|
+
], i = {
|
|
14
16
|
highlightedCode: m.length > 0,
|
|
15
17
|
codeLanguages: m
|
|
16
18
|
};
|
|
17
19
|
o.forEach((w) => e.markPluginAssets(w));
|
|
18
|
-
const p =
|
|
19
|
-
|
|
20
|
+
const p = i.highlightedCode ? await v(
|
|
21
|
+
i.codeLanguages,
|
|
20
22
|
d,
|
|
21
23
|
s.warnedLanguages,
|
|
22
24
|
l
|
|
23
|
-
) : void 0,
|
|
25
|
+
) : void 0, c = y("mdx", e, d, i, p);
|
|
24
26
|
return {
|
|
25
|
-
remarkPlugins:
|
|
26
|
-
rehypePlugins:
|
|
27
|
-
remarkRehypeOptions: { handlers:
|
|
27
|
+
remarkPlugins: c.remarkPlugins,
|
|
28
|
+
rehypePlugins: c.rehypePlugins,
|
|
29
|
+
remarkRehypeOptions: { handlers: c.handlers },
|
|
28
30
|
getAssets: () => e.snapshot()
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
function F(a, r) {
|
|
32
|
-
const { plugins: s, ...n } = r ?? {}, e =
|
|
34
|
+
const { plugins: s, ...n } = r ?? {}, e = C({ ...n, plugins: T(s) });
|
|
33
35
|
if (e !== void 0)
|
|
34
|
-
return
|
|
36
|
+
return H("sha256").update(a).update("\0").update(e).digest("hex");
|
|
35
37
|
}
|
|
36
38
|
function D(a, r, s, n) {
|
|
37
39
|
for (a.delete(r), a.set(r, s); a.size > n; ) {
|
|
@@ -61,7 +63,7 @@ function K({
|
|
|
61
63
|
return J(
|
|
62
64
|
n,
|
|
63
65
|
F(e, t),
|
|
64
|
-
() =>
|
|
66
|
+
() => L(e, t, { warnedLanguages: r }),
|
|
65
67
|
s
|
|
66
68
|
);
|
|
67
69
|
},
|
|
@@ -70,14 +72,14 @@ function K({
|
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
|
-
function
|
|
75
|
+
function V(a = {}) {
|
|
74
76
|
const r = /* @__PURE__ */ new Set(), s = K({ ...a, warningState: r });
|
|
75
77
|
return {
|
|
76
78
|
async render(n, e = {}) {
|
|
77
79
|
const t = await s.prepare(n, e.markdown);
|
|
78
80
|
return {
|
|
79
|
-
content: /* @__PURE__ */
|
|
80
|
-
|
|
81
|
+
content: /* @__PURE__ */ u(
|
|
82
|
+
R,
|
|
81
83
|
{
|
|
82
84
|
document: t.document,
|
|
83
85
|
classNames: e.classNames,
|
|
@@ -99,7 +101,7 @@ function G(a = {}) {
|
|
|
99
101
|
warnedLanguages: r
|
|
100
102
|
}), l = (await h(
|
|
101
103
|
{
|
|
102
|
-
value:
|
|
104
|
+
value: z(n),
|
|
103
105
|
data: { canofoldLocale: e.markdown?.locale?.trim() || void 0 }
|
|
104
106
|
},
|
|
105
107
|
{
|
|
@@ -116,8 +118,8 @@ function G(a = {}) {
|
|
|
116
118
|
e.urlTransform
|
|
117
119
|
);
|
|
118
120
|
return {
|
|
119
|
-
content: /* @__PURE__ */
|
|
120
|
-
|
|
121
|
+
content: /* @__PURE__ */ u(
|
|
122
|
+
O,
|
|
121
123
|
{
|
|
122
124
|
"data-cf-runtime": "static",
|
|
123
125
|
as: e.as,
|
|
@@ -125,7 +127,7 @@ function G(a = {}) {
|
|
|
125
127
|
classNames: e.classNames,
|
|
126
128
|
slots: e.slots,
|
|
127
129
|
urlTransform: e.urlTransform,
|
|
128
|
-
children: /* @__PURE__ */
|
|
130
|
+
children: /* @__PURE__ */ u(l, { components: d })
|
|
129
131
|
}
|
|
130
132
|
),
|
|
131
133
|
assets: t.getAssets()
|
|
@@ -137,6 +139,6 @@ function G(a = {}) {
|
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
141
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
V as createMarkdownRenderer,
|
|
143
|
+
Z as defineMarkdownPlugin
|
|
142
144
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { hydrateRoot as t } from "react-dom/client";
|
|
3
|
+
import { a as s } from "./componentMap-CKSUGzQH.js";
|
|
4
|
+
import { a as d } from "./serialized-DFiNQYA5.js";
|
|
5
|
+
import { w as b } from "./provider-BJDHf4Z_.js";
|
|
6
|
+
function L(a, e) {
|
|
7
|
+
return t(
|
|
8
|
+
a,
|
|
9
|
+
b(
|
|
10
|
+
/* @__PURE__ */ l(
|
|
11
|
+
s,
|
|
12
|
+
{
|
|
13
|
+
className: a.className,
|
|
14
|
+
tableTitle: a.dataset.cfTableTitle,
|
|
15
|
+
copyLabel: a.dataset.cfCopyLabel,
|
|
16
|
+
copyFailureLabel: a.dataset.cfCopyFailureLabel,
|
|
17
|
+
downloadLabel: a.dataset.cfDownloadLabel,
|
|
18
|
+
zoomLabel: a.dataset.cfZoomLabel,
|
|
19
|
+
closeLabel: a.dataset.cfCloseLabel,
|
|
20
|
+
sortLabel: a.dataset.cfSortLabel,
|
|
21
|
+
serializedTable: a.dataset.cfTable,
|
|
22
|
+
inner: !0,
|
|
23
|
+
children: d(a.dataset.cfTable, e)
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
e
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
L as hydrate
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canofold/markdown",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "An interactive, themeable Markdown renderer for knowledge and documentation sites.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Canofold Contributors",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"./client": {
|
|
31
31
|
"types": "./dist/client.d.ts",
|
|
32
|
-
"import": "./dist/client/
|
|
32
|
+
"import": "./dist/client/bundler.js",
|
|
33
33
|
"default": "./dist/client/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./server": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@shikijs/types": "^4.4.3",
|
|
71
71
|
"github-slugger": "^2.0.0",
|
|
72
72
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
73
|
-
"lucide-react": "1.
|
|
73
|
+
"lucide-react": "1.46.0",
|
|
74
74
|
"rehype-raw": "^7.0.0",
|
|
75
75
|
"rehype-sanitize": "^6.0.0",
|
|
76
76
|
"rehype-slug": "^6.0.0",
|
|
@@ -88,21 +88,26 @@
|
|
|
88
88
|
"@types/estree": "^1.0.9",
|
|
89
89
|
"@types/hast": "^3.0.5",
|
|
90
90
|
"@types/mdast": "^4.0.4",
|
|
91
|
-
"@types/node": "^22.
|
|
92
|
-
"@types/react": "^19.
|
|
93
|
-
"@types/react-dom": "^19.
|
|
91
|
+
"@types/node": "^22.20.3",
|
|
92
|
+
"@types/react": "^19.3.0",
|
|
93
|
+
"@types/react-dom": "^19.3.0",
|
|
94
94
|
"@types/unist": "^3.0.3",
|
|
95
95
|
"mdast-util-directive": "^3.1.0",
|
|
96
96
|
"mdast-util-to-hast": "^13.2.1",
|
|
97
|
-
"react": "^19.
|
|
98
|
-
"react-dom": "^19.
|
|
97
|
+
"react": "^19.3.0",
|
|
98
|
+
"react-dom": "^19.3.0",
|
|
99
99
|
"tailwindcss": "^4.3.3",
|
|
100
100
|
"typescript": "^6.0.3",
|
|
101
101
|
"vite": "^6.4.3",
|
|
102
102
|
"vitest": "^4.1.11"
|
|
103
103
|
},
|
|
104
104
|
"scripts": {
|
|
105
|
-
"build": "vite build && vite build -c vite.client.config.ts && tsc -p tsconfig.build.json && tailwindcss -i ./src/tailwind.css -o ./dist/base.css --minify
|
|
105
|
+
"build": "vite build && vite build -c vite.client.config.ts && tsc -p tsconfig.build.json && tailwindcss -i ./src/tailwind.css -o ./dist/base.css --minify",
|
|
106
|
+
"dev": "pnpm --parallel --stream run \"/^dev:.+/\"",
|
|
107
|
+
"dev:library": "vite build --watch --mode development",
|
|
108
|
+
"dev:client": "vite build --watch --mode development -c vite.client.config.ts",
|
|
109
|
+
"dev:types": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
110
|
+
"dev:styles": "tailwindcss -i ./src/tailwind.css -o ./dist/base.css --minify --watch=always --poll=250",
|
|
106
111
|
"test:browser": "node scripts/test-browser-build.mjs",
|
|
107
112
|
"typecheck": "tsc --noEmit",
|
|
108
113
|
"test": "vitest run --root ../.. packages/markdown"
|