@cocoar/vue-markdown-core 1.6.4 → 1.6.6
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/index.js +404 -460
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,483 +1,427 @@
|
|
|
1
|
-
import { unified as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { unified as e } from "unified";
|
|
2
|
+
import t from "remark-parse";
|
|
3
|
+
import n from "remark-gfm";
|
|
4
|
+
import r from "remark-stringify";
|
|
5
|
+
//#region src/lib/id.ts
|
|
6
|
+
var i = 2166136261, a = 16777619;
|
|
7
|
+
function o(e) {
|
|
8
|
+
let t = i;
|
|
9
|
+
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, a);
|
|
10
|
+
return t >>> 0;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
function s(e) {
|
|
13
|
+
return o(e).toString(36);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/lib/parse.ts
|
|
17
|
+
function c(r, i = {}) {
|
|
18
|
+
let a = e().use(t);
|
|
19
|
+
return (i.gfm ?? !0) && a.use(n), l(a.parse(r));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
function l(e) {
|
|
22
|
+
let t = b(), n = u(e);
|
|
23
|
+
return { nodes: e.children.map((e, r) => f(e, void 0, r, t, n)).filter(d) };
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
function u(e) {
|
|
26
|
+
let t = /* @__PURE__ */ new Map();
|
|
27
|
+
for (let n of e.children) {
|
|
28
|
+
if (n.type !== "definition") continue;
|
|
29
|
+
let e = n, r = typeof e.identifier == "string" ? e.identifier : "", i = typeof e.url == "string" ? e.url : "", a = typeof e.title == "string" ? e.title : void 0;
|
|
30
|
+
r.length === 0 || i.length === 0 || t.set(r, {
|
|
31
|
+
url: i,
|
|
32
|
+
title: a
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
33
36
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
37
|
+
function d(e) {
|
|
38
|
+
return e !== null;
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
]
|
|
210
|
-
}, x = Array.isArray(a.children) ? a.children : [];
|
|
211
|
-
return {
|
|
212
|
-
id: s,
|
|
213
|
-
type: "blockquote",
|
|
214
|
-
position: r,
|
|
215
|
-
children: [
|
|
216
|
-
m,
|
|
217
|
-
...x.map(($, w) => u($, s, w, n, l)).filter(o)
|
|
218
|
-
]
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
// Raw HTML is intentionally unsupported in v1.
|
|
222
|
-
case "html":
|
|
223
|
-
return {
|
|
224
|
-
id: s,
|
|
225
|
-
type: "unsupported",
|
|
226
|
-
position: r,
|
|
227
|
-
attrs: { originalType: "html" },
|
|
228
|
-
text: t.value
|
|
229
|
-
};
|
|
230
|
-
default:
|
|
231
|
-
return {
|
|
232
|
-
id: s,
|
|
233
|
-
// Preserve the original type string for better diagnostics.
|
|
234
|
-
type: "unsupported",
|
|
235
|
-
position: r,
|
|
236
|
-
attrs: { originalType: t.type }
|
|
237
|
-
};
|
|
238
|
-
}
|
|
40
|
+
function f(e, t, n, r, i) {
|
|
41
|
+
let a = C(e.position), o = `${e.type}|${a?.start ?? "na"}-${a?.end ?? "na"}|${t ?? "root"}|${n}`, c = s(o);
|
|
42
|
+
switch (e.type) {
|
|
43
|
+
case "heading": return p(e, c, a, r, i);
|
|
44
|
+
case "paragraph": return {
|
|
45
|
+
id: c,
|
|
46
|
+
type: "paragraph",
|
|
47
|
+
position: a,
|
|
48
|
+
children: (e.children ?? []).map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
49
|
+
};
|
|
50
|
+
case "blockquote": return {
|
|
51
|
+
id: c,
|
|
52
|
+
type: "blockquote",
|
|
53
|
+
position: a,
|
|
54
|
+
children: (e.children ?? []).map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
55
|
+
};
|
|
56
|
+
case "list": return h(e, c, a, r, i);
|
|
57
|
+
case "listItem": return g(e, c, a, r, i);
|
|
58
|
+
case "code": return {
|
|
59
|
+
id: c,
|
|
60
|
+
type: "codeBlock",
|
|
61
|
+
position: a,
|
|
62
|
+
text: e.value,
|
|
63
|
+
attrs: {
|
|
64
|
+
language: e.lang ?? void 0,
|
|
65
|
+
meta: e.meta ?? void 0
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
case "inlineCode": return {
|
|
69
|
+
id: c,
|
|
70
|
+
type: "inlineCode",
|
|
71
|
+
position: a,
|
|
72
|
+
text: e.value
|
|
73
|
+
};
|
|
74
|
+
case "break": return {
|
|
75
|
+
id: c,
|
|
76
|
+
type: "lineBreak",
|
|
77
|
+
position: a
|
|
78
|
+
};
|
|
79
|
+
case "text": return {
|
|
80
|
+
id: c,
|
|
81
|
+
type: "text",
|
|
82
|
+
position: a,
|
|
83
|
+
text: e.value
|
|
84
|
+
};
|
|
85
|
+
case "emphasis": return {
|
|
86
|
+
id: c,
|
|
87
|
+
type: "emphasis",
|
|
88
|
+
position: a,
|
|
89
|
+
children: (e.children ?? []).map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
90
|
+
};
|
|
91
|
+
case "strong": return {
|
|
92
|
+
id: c,
|
|
93
|
+
type: "strong",
|
|
94
|
+
position: a,
|
|
95
|
+
children: (e.children ?? []).map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
96
|
+
};
|
|
97
|
+
case "delete": return {
|
|
98
|
+
id: c,
|
|
99
|
+
type: "strikethrough",
|
|
100
|
+
position: a,
|
|
101
|
+
children: (e.children ?? []).map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
102
|
+
};
|
|
103
|
+
case "link": return m(e, c, a, r, i);
|
|
104
|
+
case "linkReference": {
|
|
105
|
+
let t = e, n = typeof t.identifier == "string" ? t.identifier : "", o = n.length > 0 ? i.get(n) : void 0;
|
|
106
|
+
if (!o?.url) return {
|
|
107
|
+
id: c,
|
|
108
|
+
type: "text",
|
|
109
|
+
position: a,
|
|
110
|
+
text: S(e)
|
|
111
|
+
};
|
|
112
|
+
let s = Array.isArray(t.children) ? t.children : [];
|
|
113
|
+
return {
|
|
114
|
+
id: c,
|
|
115
|
+
type: "link",
|
|
116
|
+
position: a,
|
|
117
|
+
attrs: {
|
|
118
|
+
url: o.url,
|
|
119
|
+
title: o.title ?? void 0
|
|
120
|
+
},
|
|
121
|
+
children: s.map((e, t) => f(e, c, t, r, i)).filter(d)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
case "image": {
|
|
125
|
+
let t = e, n = typeof t.url == "string" ? t.url : "", r = typeof t.title == "string" ? t.title : void 0, i = typeof t.alt == "string" ? t.alt : "";
|
|
126
|
+
return n.length === 0 ? {
|
|
127
|
+
id: c,
|
|
128
|
+
type: "text",
|
|
129
|
+
position: a,
|
|
130
|
+
text: i
|
|
131
|
+
} : {
|
|
132
|
+
id: c,
|
|
133
|
+
type: "image",
|
|
134
|
+
position: a,
|
|
135
|
+
attrs: {
|
|
136
|
+
url: n,
|
|
137
|
+
title: r,
|
|
138
|
+
alt: i
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
case "imageReference": {
|
|
143
|
+
let t = e, n = typeof t.identifier == "string" ? t.identifier : "", r = n.length > 0 ? i.get(n) : void 0, o = typeof t.alt == "string" ? t.alt : "";
|
|
144
|
+
return r?.url ? {
|
|
145
|
+
id: c,
|
|
146
|
+
type: "image",
|
|
147
|
+
position: a,
|
|
148
|
+
attrs: {
|
|
149
|
+
url: r.url,
|
|
150
|
+
title: r.title ?? void 0,
|
|
151
|
+
alt: o
|
|
152
|
+
}
|
|
153
|
+
} : {
|
|
154
|
+
id: c,
|
|
155
|
+
type: "text",
|
|
156
|
+
position: a,
|
|
157
|
+
text: o
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case "thematicBreak": return {
|
|
161
|
+
id: c,
|
|
162
|
+
type: "thematicBreak",
|
|
163
|
+
position: a
|
|
164
|
+
};
|
|
165
|
+
case "table": return _(e, c, a, r, i);
|
|
166
|
+
case "tableRow": return v(e, c, a, r, i);
|
|
167
|
+
case "tableCell": return y(e, c, a, r, i);
|
|
168
|
+
case "definition": return null;
|
|
169
|
+
case "footnoteReference": {
|
|
170
|
+
let t = e, n = typeof t.identifier == "string" ? t.identifier : typeof t.label == "string" ? t.label : "";
|
|
171
|
+
return {
|
|
172
|
+
id: c,
|
|
173
|
+
type: "text",
|
|
174
|
+
position: a,
|
|
175
|
+
text: `[^${n.length > 0 ? n : "?"}]`
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
case "footnoteDefinition": {
|
|
179
|
+
let t = e, n = typeof t.identifier == "string" ? t.identifier : typeof t.label == "string" ? t.label : "", l = n.length > 0 ? n : "?", u = s(`${o}|footnote-label-text`);
|
|
180
|
+
return {
|
|
181
|
+
id: c,
|
|
182
|
+
type: "blockquote",
|
|
183
|
+
position: a,
|
|
184
|
+
children: [{
|
|
185
|
+
id: s(`${o}|footnote-label-paragraph`),
|
|
186
|
+
type: "paragraph",
|
|
187
|
+
position: a,
|
|
188
|
+
children: [{
|
|
189
|
+
id: u,
|
|
190
|
+
type: "text",
|
|
191
|
+
position: a,
|
|
192
|
+
text: `[^${l}]: `
|
|
193
|
+
}]
|
|
194
|
+
}, ...(Array.isArray(t.children) ? t.children : []).map((e, t) => f(e, c, t, r, i)).filter(d)]
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
case "html": return {
|
|
198
|
+
id: c,
|
|
199
|
+
type: "unsupported",
|
|
200
|
+
position: a,
|
|
201
|
+
attrs: { originalType: "html" },
|
|
202
|
+
text: e.value
|
|
203
|
+
};
|
|
204
|
+
default: return {
|
|
205
|
+
id: c,
|
|
206
|
+
type: "unsupported",
|
|
207
|
+
position: a,
|
|
208
|
+
attrs: { originalType: e.type }
|
|
209
|
+
};
|
|
210
|
+
}
|
|
239
211
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
212
|
+
function p(e, t, n, r, i) {
|
|
213
|
+
let a = S(e), o = a.length > 0 ? r.slug(a) : void 0;
|
|
214
|
+
return {
|
|
215
|
+
id: t,
|
|
216
|
+
type: "heading",
|
|
217
|
+
position: n,
|
|
218
|
+
attrs: {
|
|
219
|
+
depth: e.depth,
|
|
220
|
+
anchor: o
|
|
221
|
+
},
|
|
222
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
223
|
+
};
|
|
249
224
|
}
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
225
|
+
function m(e, t, n, r, i) {
|
|
226
|
+
return {
|
|
227
|
+
id: t,
|
|
228
|
+
type: "link",
|
|
229
|
+
position: n,
|
|
230
|
+
attrs: {
|
|
231
|
+
url: e.url,
|
|
232
|
+
title: e.title ?? void 0
|
|
233
|
+
},
|
|
234
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
235
|
+
};
|
|
261
236
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
237
|
+
function h(e, t, n, r, i) {
|
|
238
|
+
return {
|
|
239
|
+
id: t,
|
|
240
|
+
type: "list",
|
|
241
|
+
position: n,
|
|
242
|
+
attrs: {
|
|
243
|
+
ordered: e.ordered ?? !1,
|
|
244
|
+
start: e.start ?? void 0,
|
|
245
|
+
spread: e.spread ?? void 0
|
|
246
|
+
},
|
|
247
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
248
|
+
};
|
|
274
249
|
}
|
|
275
|
-
function
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
250
|
+
function g(e, t, n, r, i) {
|
|
251
|
+
return {
|
|
252
|
+
id: t,
|
|
253
|
+
type: "listItem",
|
|
254
|
+
position: n,
|
|
255
|
+
attrs: {
|
|
256
|
+
checked: e.checked ?? void 0,
|
|
257
|
+
spread: e.spread ?? void 0
|
|
258
|
+
},
|
|
259
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
260
|
+
};
|
|
286
261
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
children: (t.children ?? []).map((r, p) => u(r, e, p, n, l)).filter(o)
|
|
296
|
-
};
|
|
262
|
+
function _(e, t, n, r, i) {
|
|
263
|
+
return {
|
|
264
|
+
id: t,
|
|
265
|
+
type: "table",
|
|
266
|
+
position: n,
|
|
267
|
+
attrs: { align: e.align ?? void 0 },
|
|
268
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
269
|
+
};
|
|
297
270
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
271
|
+
function v(e, t, n, r, i) {
|
|
272
|
+
return {
|
|
273
|
+
id: t,
|
|
274
|
+
type: "tableRow",
|
|
275
|
+
position: n,
|
|
276
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
277
|
+
};
|
|
305
278
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
279
|
+
function y(e, t, n, r, i) {
|
|
280
|
+
return {
|
|
281
|
+
id: t,
|
|
282
|
+
type: "tableCell",
|
|
283
|
+
position: n,
|
|
284
|
+
children: (e.children ?? []).map((e, n) => f(e, t, n, r, i)).filter(d)
|
|
285
|
+
};
|
|
313
286
|
}
|
|
314
|
-
function
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
};
|
|
287
|
+
function b() {
|
|
288
|
+
let e = /* @__PURE__ */ new Map();
|
|
289
|
+
return { slug(t) {
|
|
290
|
+
let n = x(t), r = e.get(n) ?? 0;
|
|
291
|
+
return e.set(n, r + 1), r === 0 ? n : `${n}-${r}`;
|
|
292
|
+
} };
|
|
322
293
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
294
|
+
function x(e) {
|
|
295
|
+
let t = e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]+/gu, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
296
|
+
return t.length > 0 ? t : "section";
|
|
326
297
|
}
|
|
327
|
-
function
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
298
|
+
function S(e) {
|
|
299
|
+
if (!e || typeof e != "object") return "";
|
|
300
|
+
let t = e;
|
|
301
|
+
return typeof t.type == "string" ? t.type === "text" || t.type === "inlineCode" ? typeof t.value == "string" ? t.value : "" : (Array.isArray(t.children) ? t.children : []).map((e) => S(e)).join("") : "";
|
|
331
302
|
}
|
|
332
|
-
function
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
column: r
|
|
343
|
-
};
|
|
303
|
+
function C(e) {
|
|
304
|
+
let t = e;
|
|
305
|
+
if (!t?.start || !t?.end) return;
|
|
306
|
+
let n = t.start.offset, r = t.end.offset, i = t.start.line, a = t.start.column;
|
|
307
|
+
if (!(typeof n != "number" || typeof r != "number" || typeof i != "number" || typeof a != "number")) return {
|
|
308
|
+
start: n,
|
|
309
|
+
end: r,
|
|
310
|
+
line: i,
|
|
311
|
+
column: a
|
|
312
|
+
};
|
|
344
313
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/lib/serialize.ts
|
|
316
|
+
function w(t, i = {}) {
|
|
317
|
+
let a = T(t), o = e().use(r);
|
|
318
|
+
return (i.gfm ?? !0) && o.use(n), String(o.stringify(a));
|
|
348
319
|
}
|
|
349
|
-
function
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
320
|
+
function T(e) {
|
|
321
|
+
return {
|
|
322
|
+
type: "root",
|
|
323
|
+
children: e.nodes.map((e) => E(e))
|
|
324
|
+
};
|
|
354
325
|
}
|
|
355
|
-
function
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
align: Array.isArray(t.attrs?.align) ? t.attrs.align : void 0,
|
|
446
|
-
children: (t.children ?? []).map(h)
|
|
447
|
-
};
|
|
448
|
-
case "tableRow":
|
|
449
|
-
return {
|
|
450
|
-
type: "tableRow",
|
|
451
|
-
children: (t.children ?? []).map(h)
|
|
452
|
-
};
|
|
453
|
-
case "tableCell":
|
|
454
|
-
return {
|
|
455
|
-
type: "tableCell",
|
|
456
|
-
children: (t.children ?? []).map(h)
|
|
457
|
-
};
|
|
458
|
-
case "unsupported":
|
|
459
|
-
return {
|
|
460
|
-
type: "html",
|
|
461
|
-
value: `<!-- Unsupported node: ${String(t.attrs?.originalType ?? "unknown")} -->`
|
|
462
|
-
};
|
|
463
|
-
default:
|
|
464
|
-
return {
|
|
465
|
-
type: "html",
|
|
466
|
-
value: `<!-- Unsupported node: ${String(t.type)} -->`
|
|
467
|
-
};
|
|
468
|
-
}
|
|
326
|
+
function E(e) {
|
|
327
|
+
switch (e.type) {
|
|
328
|
+
case "heading": return {
|
|
329
|
+
type: "heading",
|
|
330
|
+
depth: D(e.attrs?.depth),
|
|
331
|
+
children: (e.children ?? []).map(E)
|
|
332
|
+
};
|
|
333
|
+
case "paragraph": return {
|
|
334
|
+
type: "paragraph",
|
|
335
|
+
children: (e.children ?? []).map(E)
|
|
336
|
+
};
|
|
337
|
+
case "blockquote": return {
|
|
338
|
+
type: "blockquote",
|
|
339
|
+
children: (e.children ?? []).map(E)
|
|
340
|
+
};
|
|
341
|
+
case "list": return {
|
|
342
|
+
type: "list",
|
|
343
|
+
ordered: !!e.attrs?.ordered,
|
|
344
|
+
start: typeof e.attrs?.start == "number" ? e.attrs.start : void 0,
|
|
345
|
+
spread: typeof e.attrs?.spread == "boolean" ? e.attrs.spread : void 0,
|
|
346
|
+
children: (e.children ?? []).map(E)
|
|
347
|
+
};
|
|
348
|
+
case "listItem": return {
|
|
349
|
+
type: "listItem",
|
|
350
|
+
checked: typeof e.attrs?.checked == "boolean" ? e.attrs.checked : null,
|
|
351
|
+
spread: typeof e.attrs?.spread == "boolean" ? e.attrs.spread : void 0,
|
|
352
|
+
children: (e.children ?? []).map(E)
|
|
353
|
+
};
|
|
354
|
+
case "codeBlock": return {
|
|
355
|
+
type: "code",
|
|
356
|
+
lang: typeof e.attrs?.language == "string" ? e.attrs.language : null,
|
|
357
|
+
meta: typeof e.attrs?.meta == "string" ? e.attrs.meta : null,
|
|
358
|
+
value: e.text ?? ""
|
|
359
|
+
};
|
|
360
|
+
case "inlineCode": return {
|
|
361
|
+
type: "inlineCode",
|
|
362
|
+
value: e.text ?? ""
|
|
363
|
+
};
|
|
364
|
+
case "text": return {
|
|
365
|
+
type: "text",
|
|
366
|
+
value: e.text ?? ""
|
|
367
|
+
};
|
|
368
|
+
case "emphasis": return {
|
|
369
|
+
type: "emphasis",
|
|
370
|
+
children: (e.children ?? []).map(E)
|
|
371
|
+
};
|
|
372
|
+
case "strong": return {
|
|
373
|
+
type: "strong",
|
|
374
|
+
children: (e.children ?? []).map(E)
|
|
375
|
+
};
|
|
376
|
+
case "strikethrough": return {
|
|
377
|
+
type: "delete",
|
|
378
|
+
children: (e.children ?? []).map(E)
|
|
379
|
+
};
|
|
380
|
+
case "link": return {
|
|
381
|
+
type: "link",
|
|
382
|
+
url: typeof e.attrs?.url == "string" ? e.attrs.url : "",
|
|
383
|
+
title: typeof e.attrs?.title == "string" ? e.attrs.title : null,
|
|
384
|
+
children: (e.children ?? []).map(E)
|
|
385
|
+
};
|
|
386
|
+
case "image": return {
|
|
387
|
+
type: "image",
|
|
388
|
+
url: typeof e.attrs?.url == "string" ? e.attrs.url : "",
|
|
389
|
+
title: typeof e.attrs?.title == "string" ? e.attrs.title : null,
|
|
390
|
+
alt: typeof e.attrs?.alt == "string" ? e.attrs.alt : ""
|
|
391
|
+
};
|
|
392
|
+
case "thematicBreak": return { type: "thematicBreak" };
|
|
393
|
+
case "lineBreak": return { type: "break" };
|
|
394
|
+
case "table": return {
|
|
395
|
+
type: "table",
|
|
396
|
+
align: Array.isArray(e.attrs?.align) ? e.attrs.align : void 0,
|
|
397
|
+
children: (e.children ?? []).map(E)
|
|
398
|
+
};
|
|
399
|
+
case "tableRow": return {
|
|
400
|
+
type: "tableRow",
|
|
401
|
+
children: (e.children ?? []).map(E)
|
|
402
|
+
};
|
|
403
|
+
case "tableCell": return {
|
|
404
|
+
type: "tableCell",
|
|
405
|
+
children: (e.children ?? []).map(E)
|
|
406
|
+
};
|
|
407
|
+
case "unsupported": return {
|
|
408
|
+
type: "html",
|
|
409
|
+
value: `<!-- Unsupported node: ${String(e.attrs?.originalType ?? "unknown")} -->`
|
|
410
|
+
};
|
|
411
|
+
default: return {
|
|
412
|
+
type: "html",
|
|
413
|
+
value: `<!-- Unsupported node: ${String(e.type)} -->`
|
|
414
|
+
};
|
|
415
|
+
}
|
|
469
416
|
}
|
|
470
|
-
function
|
|
471
|
-
|
|
472
|
-
|
|
417
|
+
function D(e) {
|
|
418
|
+
let t = typeof e == "number" ? Math.trunc(e) : 1;
|
|
419
|
+
return t <= 1 ? 1 : t === 2 ? 2 : t === 3 ? 3 : t === 4 ? 4 : t === 5 ? 5 : 6;
|
|
473
420
|
}
|
|
474
|
-
|
|
475
|
-
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/lib/transform.ts
|
|
423
|
+
function O(e, ...t) {
|
|
424
|
+
return t.reduce((e, t) => t(e), e);
|
|
476
425
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
B as hashStringFNV1a32,
|
|
480
|
-
K as parse,
|
|
481
|
-
Q as serialize,
|
|
482
|
-
W as transform
|
|
483
|
-
};
|
|
426
|
+
//#endregion
|
|
427
|
+
export { s as createNodeId, o as hashStringFNV1a32, c as parse, w as serialize, O as transform };
|