@pretextbook/remark-pretext 0.0.4 → 0.0.5
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.cjs +6 -6
- package/dist/index.js +472 -399
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { unified as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { unified as R } from "unified";
|
|
2
|
+
import j from "remark-parse";
|
|
3
|
+
import B from "remark-directive";
|
|
4
4
|
import { visit as z } from "unist-util-visit";
|
|
5
|
-
const
|
|
5
|
+
const I = {
|
|
6
6
|
// theorem-like (requires statement wrapping)
|
|
7
7
|
theorem: { type: "theorem", category: "theorem-like", requiresStatement: !0 },
|
|
8
8
|
lemma: { type: "lemma", category: "theorem-like", requiresStatement: !0 },
|
|
@@ -43,326 +43,399 @@ const q = {
|
|
|
43
43
|
solution: { type: "solution", category: "solution-like", requiresStatement: !1 },
|
|
44
44
|
hint: { type: "hint", category: "solution-like", requiresStatement: !1 },
|
|
45
45
|
answer: { type: "answer", category: "solution-like", requiresStatement: !1 }
|
|
46
|
-
},
|
|
47
|
-
function
|
|
48
|
-
return
|
|
46
|
+
}, gt = I;
|
|
47
|
+
function se(e) {
|
|
48
|
+
return I[e.toLowerCase()];
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
Object.entries(
|
|
50
|
+
const W = new Set(
|
|
51
|
+
Object.entries(I).filter(([e, t]) => t.category === "proof-like" || t.category === "solution-like").map(([e]) => e)
|
|
52
52
|
);
|
|
53
|
-
function
|
|
53
|
+
function x(e, t, n) {
|
|
54
54
|
return {
|
|
55
55
|
type: "element",
|
|
56
56
|
name: e,
|
|
57
|
-
attributes:
|
|
57
|
+
attributes: n ?? {},
|
|
58
58
|
children: t
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
function C(e) {
|
|
62
62
|
return e.type === "containerDirective" && e.name === "task";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return e.type === "containerDirective" &&
|
|
64
|
+
function ie(e) {
|
|
65
|
+
return e.type === "containerDirective" && W.has(e.name);
|
|
66
66
|
}
|
|
67
67
|
function D(e) {
|
|
68
68
|
const t = [];
|
|
69
|
-
for (const
|
|
70
|
-
|
|
69
|
+
for (const n of e)
|
|
70
|
+
n.name === "ul" || n.name === "ol" ? t.length > 0 && t[t.length - 1]?.name === "p" ? t[t.length - 1].children.push(n) : t.push(x("p", [n])) : t.push(n);
|
|
71
71
|
return t;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function le(e, t, n, o, r, s, i) {
|
|
74
74
|
const l = [];
|
|
75
|
-
if (
|
|
76
|
-
const c =
|
|
75
|
+
if (n && l.push(n), e.hasNestedTasks) {
|
|
76
|
+
const c = o.findIndex(C);
|
|
77
77
|
if (c !== -1) {
|
|
78
78
|
const a = [];
|
|
79
|
-
for (let p = 0; p <
|
|
80
|
-
C(
|
|
81
|
-
const u = a[a.length - 1], d =
|
|
82
|
-
for (let p = c; p <
|
|
83
|
-
const f =
|
|
79
|
+
for (let p = 0; p < o.length; p++)
|
|
80
|
+
C(o[p]) && a.push(p);
|
|
81
|
+
const u = a[a.length - 1], d = o.slice(0, c), m = o.slice(c).filter(C), v = [], y = [], L = [];
|
|
82
|
+
for (let p = c; p < o.length; p++) {
|
|
83
|
+
const f = o[p];
|
|
84
84
|
if (!C(f)) {
|
|
85
85
|
if (p < u) {
|
|
86
|
-
|
|
86
|
+
v.push(f);
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
89
|
+
if (ie(f)) {
|
|
90
90
|
L.push(f);
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
y.push(f);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
96
|
+
if (v.length > 0 && (r.messages ?? (r.messages = [])).push({
|
|
97
97
|
type: "warning",
|
|
98
|
-
reason: `Dropped ${
|
|
98
|
+
reason: `Dropped ${v.length} non-task node(s) between task directives in ${e.type}.`,
|
|
99
99
|
category: "dropped-content-between-tasks",
|
|
100
|
-
position:
|
|
100
|
+
position: v[0].position?.start
|
|
101
101
|
}), d.length > 0) {
|
|
102
102
|
const p = D(
|
|
103
103
|
d.map((f) => s(f, r)).filter((f) => f !== null)
|
|
104
104
|
);
|
|
105
|
-
p.length > 0 && l.push(
|
|
105
|
+
p.length > 0 && l.push(x("introduction", p));
|
|
106
106
|
}
|
|
107
107
|
for (const p of m) {
|
|
108
108
|
const f = i(p, r);
|
|
109
109
|
f && l.push(f);
|
|
110
110
|
}
|
|
111
|
-
if (
|
|
111
|
+
if (y.length > 0) {
|
|
112
112
|
const p = D(
|
|
113
|
-
|
|
113
|
+
y.map((f) => s(f, r)).filter((f) => f !== null)
|
|
114
114
|
);
|
|
115
|
-
p.length > 0 && l.push(
|
|
115
|
+
p.length > 0 && l.push(x("conclusion", p));
|
|
116
116
|
}
|
|
117
117
|
for (const p of L) {
|
|
118
118
|
const f = i(p, r);
|
|
119
119
|
f && l.push(f);
|
|
120
120
|
}
|
|
121
121
|
} else
|
|
122
|
-
F(l, e,
|
|
122
|
+
F(l, e, o, r, s, i);
|
|
123
123
|
} else
|
|
124
|
-
F(l, e,
|
|
125
|
-
return
|
|
124
|
+
F(l, e, o, r, s, i);
|
|
125
|
+
return x(e.type, l, t);
|
|
126
126
|
}
|
|
127
|
-
function F(e, t,
|
|
127
|
+
function F(e, t, n, o, r, s) {
|
|
128
128
|
if (t.requiresStatement) {
|
|
129
129
|
const i = [], l = [];
|
|
130
|
-
for (const c of
|
|
131
|
-
if (c.type === "containerDirective" &&
|
|
132
|
-
const a = s(c,
|
|
130
|
+
for (const c of n)
|
|
131
|
+
if (c.type === "containerDirective" && W.has(c.name)) {
|
|
132
|
+
const a = s(c, o);
|
|
133
133
|
a && l.push(a);
|
|
134
134
|
} else
|
|
135
135
|
i.push(c);
|
|
136
136
|
if (i.length > 0) {
|
|
137
137
|
const c = D(
|
|
138
|
-
i.map((a) => r(a,
|
|
138
|
+
i.map((a) => r(a, o)).filter((a) => a !== null)
|
|
139
139
|
);
|
|
140
|
-
c.length > 0 && e.push(
|
|
140
|
+
c.length > 0 && e.push(x("statement", c));
|
|
141
141
|
}
|
|
142
142
|
e.push(...l);
|
|
143
143
|
} else {
|
|
144
144
|
const i = D(
|
|
145
|
-
|
|
145
|
+
n.map((l) => r(l, o)).filter((l) => l !== null)
|
|
146
146
|
);
|
|
147
147
|
e.push(...i);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function H(e) {
|
|
151
151
|
return { type: "text", value: e };
|
|
152
152
|
}
|
|
153
|
-
function h(e, t,
|
|
153
|
+
function h(e, t, n) {
|
|
154
154
|
return {
|
|
155
155
|
type: "element",
|
|
156
156
|
name: e,
|
|
157
|
-
attributes:
|
|
157
|
+
attributes: n ?? {},
|
|
158
158
|
children: t
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
return h(e, [
|
|
161
|
+
function g(e, t, n) {
|
|
162
|
+
return h(e, [H(t)], n);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function U(e) {
|
|
165
|
+
return { type: "comment", value: e.replace(/--/g, "- -") };
|
|
166
|
+
}
|
|
167
|
+
function $(e, t) {
|
|
168
|
+
const n = e?.position, o = n?.start?.offset, r = n?.end?.offset;
|
|
169
|
+
return t.source && o != null && r != null ? t.source.slice(o, r) : "";
|
|
170
|
+
}
|
|
171
|
+
function Z(e, t, n) {
|
|
172
|
+
return h("TODO", [U(`todo: ${t}`), g("pre", n)], {
|
|
173
|
+
type: e
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function ce(e, t, n) {
|
|
177
|
+
return h("TODO", [U(`todo: ${t}`), g("c", n)], {
|
|
178
|
+
type: e
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function X(e) {
|
|
165
182
|
const t = [];
|
|
166
|
-
for (const
|
|
167
|
-
|
|
183
|
+
for (const n of e)
|
|
184
|
+
n.name === "ul" || n.name === "ol" ? t.length > 0 && t[t.length - 1]?.name === "p" ? t[t.length - 1].children.push(n) : t.push(h("p", [n])) : t.push(n);
|
|
168
185
|
return t;
|
|
169
186
|
}
|
|
170
|
-
function
|
|
171
|
-
return
|
|
187
|
+
function N(e, t) {
|
|
188
|
+
return ae(e, t).tree;
|
|
172
189
|
}
|
|
173
|
-
function
|
|
174
|
-
const
|
|
190
|
+
function ae(e, t) {
|
|
191
|
+
const n = [], o = { ancestors: [], depth: 0, messages: n, source: t }, r = e.children;
|
|
175
192
|
return {
|
|
176
|
-
tree: { type: "root", children:
|
|
177
|
-
messages:
|
|
193
|
+
tree: { type: "root", children: K(r, o) },
|
|
194
|
+
messages: n
|
|
178
195
|
};
|
|
179
196
|
}
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
197
|
+
const O = [
|
|
198
|
+
"chapter",
|
|
199
|
+
"section",
|
|
200
|
+
"subsection",
|
|
201
|
+
"subsubsection",
|
|
202
|
+
"paragraphs"
|
|
203
|
+
];
|
|
204
|
+
function ue(e) {
|
|
205
|
+
return O[Math.min(e - 1, O.length - 1)];
|
|
206
|
+
}
|
|
207
|
+
function K(e, t, n = !1) {
|
|
208
|
+
let o = 7;
|
|
186
209
|
for (const a of e)
|
|
187
|
-
a.type === "heading" && (
|
|
188
|
-
if (
|
|
189
|
-
return w(e, t,
|
|
210
|
+
a.type === "heading" && (o = Math.min(o, a.depth));
|
|
211
|
+
if (o === 7)
|
|
212
|
+
return w(e, t, n);
|
|
190
213
|
const r = [];
|
|
191
214
|
let s = null, i = [], l = [];
|
|
192
215
|
const c = () => {
|
|
193
|
-
s && (r.push(
|
|
216
|
+
s && (r.push(pe(s, l, t)), s = null, l = []);
|
|
194
217
|
};
|
|
195
218
|
for (const a of e)
|
|
196
|
-
a.type === "heading" && a.depth ===
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
219
|
+
a.type === "heading" && a.depth === o ? (!s && i.length > 0 && (r.push(
|
|
220
|
+
...w(i, t, n)
|
|
221
|
+
), i = []), c(), s = a, l = []) : s ? l.push(a) : i.push(a);
|
|
222
|
+
return !s && i.length > 0 && r.push(
|
|
223
|
+
...w(i, t, n)
|
|
224
|
+
), c(), r;
|
|
225
|
+
}
|
|
226
|
+
function w(e, t, n = !1) {
|
|
227
|
+
const o = [];
|
|
201
228
|
for (let r = 0; r < e.length; r += 1) {
|
|
202
229
|
const s = e[r], i = T(s, t);
|
|
203
230
|
if (i !== null) {
|
|
204
231
|
if (i.name === "p" && i.children.length === 1 && i.children[0].name === "md") {
|
|
205
|
-
const l = i.children[0], c =
|
|
232
|
+
const l = i.children[0], c = o[o.length - 1], a = r + 1 < e.length ? T(e[r + 1], t) : null, u = a?.name === "p" ? a.children : null;
|
|
206
233
|
if (c?.name === "p")
|
|
207
|
-
c.children.push(l), u && (c.children.push(
|
|
234
|
+
c.children.push(l), u && (c.children.push(
|
|
235
|
+
...u
|
|
236
|
+
), r += 1);
|
|
208
237
|
else {
|
|
209
238
|
const d = [l];
|
|
210
|
-
u && (d.push(...u), r += 1),
|
|
239
|
+
u && (d.push(...u), r += 1), o.push(h("p", d));
|
|
211
240
|
}
|
|
212
241
|
continue;
|
|
213
242
|
}
|
|
214
|
-
if ((i.name === "ul" || i.name === "ol") &&
|
|
215
|
-
const l =
|
|
243
|
+
if ((i.name === "ul" || i.name === "ol") && o.length > 0) {
|
|
244
|
+
const l = o[o.length - 1];
|
|
216
245
|
if (l?.name === "p") {
|
|
217
246
|
l.children.push(i);
|
|
218
247
|
continue;
|
|
219
248
|
}
|
|
220
249
|
}
|
|
221
|
-
|
|
250
|
+
o.push(i);
|
|
222
251
|
}
|
|
223
252
|
}
|
|
224
|
-
return
|
|
253
|
+
return n ? X(o) : o;
|
|
225
254
|
}
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
|
|
255
|
+
function pe(e, t, n) {
|
|
256
|
+
const o = ue(e.depth), r = h("title", b(e.children, n)), s = fe(e), i = K(
|
|
257
|
+
t,
|
|
258
|
+
{ ...n, depth: n.depth + 1 },
|
|
259
|
+
!0
|
|
260
|
+
), l = X(i);
|
|
261
|
+
return h(o, [r, ...l], s);
|
|
229
262
|
}
|
|
230
|
-
function
|
|
263
|
+
function fe(e) {
|
|
231
264
|
const t = e.data;
|
|
232
265
|
return t?.id ? { "xml:id": t.id } : void 0;
|
|
233
266
|
}
|
|
234
|
-
const
|
|
235
|
-
paragraph: (e, t) =>
|
|
236
|
-
blockquote: (e, t) =>
|
|
237
|
-
list: (e, t) =>
|
|
238
|
-
code: (e, t) =>
|
|
239
|
-
containerDirective: (e, t) =>
|
|
267
|
+
const he = {
|
|
268
|
+
paragraph: (e, t) => Y(e, t),
|
|
269
|
+
blockquote: (e, t) => de(e, t),
|
|
270
|
+
list: (e, t) => me(e, t),
|
|
271
|
+
code: (e, t) => ye(e),
|
|
272
|
+
containerDirective: (e, t) => V(e, t)
|
|
240
273
|
};
|
|
241
274
|
function T(e, t) {
|
|
242
|
-
const
|
|
243
|
-
return
|
|
275
|
+
const n = he[e.type];
|
|
276
|
+
return n ? n(e, t) : (t.messages && t.messages.push({
|
|
244
277
|
type: "warning",
|
|
245
278
|
reason: `Unknown block type: ${e.type}`,
|
|
246
279
|
category: "unknown-block-type"
|
|
247
|
-
}),
|
|
280
|
+
}), Z(
|
|
281
|
+
"unknown-block-type",
|
|
282
|
+
`unknown block type "${e.type}"`,
|
|
283
|
+
$(e, t)
|
|
284
|
+
));
|
|
248
285
|
}
|
|
249
|
-
function
|
|
286
|
+
function Y(e, t) {
|
|
250
287
|
return h("p", b(e.children, t));
|
|
251
288
|
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
const r = {
|
|
255
|
-
|
|
289
|
+
function de(e, t) {
|
|
290
|
+
const n = e.children.filter((o) => o.type === "paragraph").map((o) => {
|
|
291
|
+
const r = {
|
|
292
|
+
...t,
|
|
293
|
+
ancestors: [...t.ancestors, e],
|
|
294
|
+
depth: t.depth + 1
|
|
295
|
+
};
|
|
296
|
+
return Y(o, r);
|
|
256
297
|
});
|
|
257
|
-
return h("blockquote",
|
|
298
|
+
return h("blockquote", n);
|
|
258
299
|
}
|
|
259
|
-
function
|
|
260
|
-
const
|
|
261
|
-
const r = {
|
|
262
|
-
|
|
300
|
+
function me(e, t) {
|
|
301
|
+
const n = e.children.map((o) => {
|
|
302
|
+
const r = {
|
|
303
|
+
...t,
|
|
304
|
+
ancestors: [...t.ancestors, e],
|
|
305
|
+
depth: t.depth + 1
|
|
306
|
+
};
|
|
307
|
+
return ge(o, r);
|
|
263
308
|
});
|
|
264
|
-
return h(e.ordered ? "ol" : "ul",
|
|
265
|
-
}
|
|
266
|
-
function fe(e, t) {
|
|
267
|
-
const o = w(e.children, t);
|
|
268
|
-
return h("li", o);
|
|
269
|
-
}
|
|
270
|
-
function he(e, t) {
|
|
271
|
-
return x("program", e.value, e.lang ? { language: e.lang } : void 0);
|
|
309
|
+
return h(e.ordered ? "ol" : "ul", n);
|
|
272
310
|
}
|
|
273
|
-
function
|
|
274
|
-
const
|
|
275
|
-
|
|
311
|
+
function ge(e, t) {
|
|
312
|
+
const n = w(
|
|
313
|
+
e.children,
|
|
314
|
+
t
|
|
315
|
+
);
|
|
316
|
+
return h("li", n);
|
|
276
317
|
}
|
|
277
|
-
function
|
|
278
|
-
return
|
|
318
|
+
function ye(e, t) {
|
|
319
|
+
return g(
|
|
320
|
+
"program",
|
|
321
|
+
e.value,
|
|
322
|
+
e.lang ? { language: e.lang } : void 0
|
|
323
|
+
);
|
|
279
324
|
}
|
|
280
|
-
function
|
|
281
|
-
const
|
|
282
|
-
|
|
325
|
+
function ke(e, t) {
|
|
326
|
+
const n = e.value.split(/\\\\|[\r\n]+/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
327
|
+
return n.length > 1 ? h(
|
|
328
|
+
"md",
|
|
329
|
+
n.map((o) => g("mrow", o))
|
|
330
|
+
) : g("md", n[0] ?? "");
|
|
331
|
+
}
|
|
332
|
+
function ve(e, t) {
|
|
333
|
+
return e.meta === "inline" ? g("m", e.value) : ke(e);
|
|
334
|
+
}
|
|
335
|
+
function V(e, t) {
|
|
336
|
+
const n = se(e.name);
|
|
337
|
+
if (!n)
|
|
283
338
|
return t.messages && t.messages.push({
|
|
284
339
|
type: "warning",
|
|
285
340
|
reason: `Unknown directive: ${e.name}`,
|
|
286
341
|
category: "unknown-directive"
|
|
287
|
-
}),
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
342
|
+
}), Z(
|
|
343
|
+
"unknown-directive",
|
|
344
|
+
`unknown directive "${e.name}"`,
|
|
345
|
+
$(e, t)
|
|
346
|
+
);
|
|
347
|
+
const o = be(e), r = e.children, { title: s, body: i } = xe(
|
|
348
|
+
r,
|
|
349
|
+
t
|
|
350
|
+
), l = {
|
|
351
|
+
...t,
|
|
352
|
+
ancestors: [...t.ancestors, e],
|
|
353
|
+
depth: t.depth + 1
|
|
354
|
+
};
|
|
355
|
+
return le(
|
|
291
356
|
n,
|
|
357
|
+
o,
|
|
292
358
|
s,
|
|
293
359
|
i,
|
|
294
360
|
l,
|
|
295
361
|
(c, a) => T(c, a),
|
|
296
|
-
(c, a) =>
|
|
362
|
+
(c, a) => V(c, a)
|
|
297
363
|
);
|
|
298
364
|
}
|
|
299
|
-
function
|
|
300
|
-
const
|
|
301
|
-
return
|
|
302
|
-
title: h(
|
|
365
|
+
function xe(e, t) {
|
|
366
|
+
const n = e[0];
|
|
367
|
+
return n?.type === "paragraph" && n.data?.directiveLabel === !0 ? {
|
|
368
|
+
title: h(
|
|
369
|
+
"title",
|
|
370
|
+
b(n.children, t)
|
|
371
|
+
),
|
|
303
372
|
body: e.slice(1)
|
|
304
373
|
} : { title: null, body: e };
|
|
305
374
|
}
|
|
306
|
-
function
|
|
307
|
-
const t = e.attributes ?? {},
|
|
308
|
-
for (const [
|
|
309
|
-
r != null && (o
|
|
310
|
-
return Object.keys(
|
|
375
|
+
function be(e) {
|
|
376
|
+
const t = e.attributes ?? {}, n = {};
|
|
377
|
+
for (const [o, r] of Object.entries(t))
|
|
378
|
+
r != null && (n[o === "id" ? "xml:id" : o] = r);
|
|
379
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
311
380
|
}
|
|
312
|
-
function
|
|
381
|
+
function Ce(e, t) {
|
|
313
382
|
return !t || e.position?.start?.offset === null || e.position?.start?.offset === void 0 ? "asterisk" : t.charAt(e.position.start.offset) === "_" ? "underscore" : "asterisk";
|
|
314
383
|
}
|
|
315
|
-
const
|
|
316
|
-
text: (e, t) =>
|
|
384
|
+
const we = {
|
|
385
|
+
text: (e, t) => H(e.value),
|
|
317
386
|
emphasis: (e, t) => {
|
|
318
|
-
const
|
|
319
|
-
return h(
|
|
387
|
+
const o = Ce(e, t.source) === "underscore" ? "term" : "em";
|
|
388
|
+
return h(o, b(e.children, t));
|
|
320
389
|
},
|
|
321
390
|
strong: (e, t) => h("alert", b(e.children, t)),
|
|
322
|
-
inlineCode: (e, t) =>
|
|
323
|
-
math: (e, t) =>
|
|
391
|
+
inlineCode: (e, t) => g("c", e.value),
|
|
392
|
+
math: (e, t) => ve(e)
|
|
324
393
|
};
|
|
325
394
|
function b(e, t) {
|
|
326
|
-
return e.flatMap((
|
|
395
|
+
return e.flatMap((n) => De(n, t)).filter((n) => n !== null);
|
|
327
396
|
}
|
|
328
|
-
function
|
|
329
|
-
const
|
|
330
|
-
if (!
|
|
397
|
+
function De(e, t) {
|
|
398
|
+
const n = we[e.type];
|
|
399
|
+
if (!n)
|
|
331
400
|
return t.messages && t.messages.push({
|
|
332
401
|
type: "warning",
|
|
333
402
|
reason: `Unknown inline type: ${e.type}`,
|
|
334
403
|
category: "unknown-inline-type"
|
|
335
|
-
}),
|
|
336
|
-
|
|
337
|
-
|
|
404
|
+
}), ce(
|
|
405
|
+
"unknown-inline-type",
|
|
406
|
+
`unknown inline type "${e.type}"`,
|
|
407
|
+
$(e, t)
|
|
408
|
+
);
|
|
409
|
+
const o = { ...t, ancestors: [...t.ancestors, e] };
|
|
410
|
+
return n(e, o);
|
|
338
411
|
}
|
|
339
|
-
const
|
|
412
|
+
const Se = [
|
|
340
413
|
// Display math (check these first, before single $)
|
|
341
414
|
{ open: "$$", close: "$$", isDisplay: !0 },
|
|
342
415
|
{ open: "\\[", close: "\\]", isDisplay: !0 },
|
|
343
416
|
// Inline math
|
|
344
417
|
{ open: "$", close: "$", isDisplay: !1 },
|
|
345
418
|
{ open: "\\(", close: "\\)", isDisplay: !1 }
|
|
346
|
-
],
|
|
347
|
-
function
|
|
348
|
-
let
|
|
349
|
-
for (const
|
|
350
|
-
const r = e.indexOf(
|
|
419
|
+
], G = "PTX_MATH_TOKEN_", q = new RegExp(`${G}(\\d+)`, "g");
|
|
420
|
+
function J(e, t) {
|
|
421
|
+
let n = null;
|
|
422
|
+
for (const o of Se) {
|
|
423
|
+
const r = e.indexOf(o.open, t);
|
|
351
424
|
if (r === -1) continue;
|
|
352
|
-
const s = e.indexOf(
|
|
353
|
-
if (s !== -1 && !(
|
|
354
|
-
const i = e.substring(r +
|
|
355
|
-
|
|
425
|
+
const s = e.indexOf(o.close, r + o.open.length);
|
|
426
|
+
if (s !== -1 && !(o.open === "$" && (r > 0 && e[r - 1] === "$" || r + 1 < e.length && e[r + 1] === "$")) && (!n || r < n.index)) {
|
|
427
|
+
const i = e.substring(r + o.open.length, s);
|
|
428
|
+
n = { index: r, pattern: o, content: i };
|
|
356
429
|
}
|
|
357
430
|
}
|
|
358
|
-
return
|
|
431
|
+
return n;
|
|
359
432
|
}
|
|
360
|
-
function
|
|
361
|
-
let
|
|
362
|
-
for (;
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
let r = 0, s =
|
|
433
|
+
function Ie(e, t) {
|
|
434
|
+
let n = t;
|
|
435
|
+
for (; n < e.length; ) {
|
|
436
|
+
const o = e.indexOf("`", n);
|
|
437
|
+
if (o === -1) return null;
|
|
438
|
+
let r = 0, s = o;
|
|
366
439
|
for (; s < e.length && e[s] === "`"; )
|
|
367
440
|
r++, s++;
|
|
368
441
|
const i = "`".repeat(r);
|
|
@@ -372,115 +445,115 @@ function Ce(e, t) {
|
|
|
372
445
|
if (c === -1) break;
|
|
373
446
|
const a = c + r;
|
|
374
447
|
if (a >= e.length || e[a] !== "`")
|
|
375
|
-
return { start:
|
|
448
|
+
return { start: o, end: a };
|
|
376
449
|
l = c + 1;
|
|
377
450
|
}
|
|
378
|
-
|
|
451
|
+
n = o + r;
|
|
379
452
|
}
|
|
380
453
|
return null;
|
|
381
454
|
}
|
|
382
|
-
function
|
|
455
|
+
function qe(e) {
|
|
383
456
|
const t = /* @__PURE__ */ new Map();
|
|
384
|
-
let
|
|
385
|
-
for (;
|
|
386
|
-
const s =
|
|
457
|
+
let n = "", o = 0, r = 0;
|
|
458
|
+
for (; o < e.length; ) {
|
|
459
|
+
const s = Ie(e, o), i = J(e, o);
|
|
387
460
|
if (s && (!i || s.start < i.index)) {
|
|
388
|
-
|
|
461
|
+
n += e.substring(o, s.end), o = s.end;
|
|
389
462
|
continue;
|
|
390
463
|
}
|
|
391
464
|
if (!i) {
|
|
392
|
-
|
|
465
|
+
n += e.substring(o);
|
|
393
466
|
break;
|
|
394
467
|
}
|
|
395
|
-
|
|
396
|
-
const l = `${
|
|
397
|
-
|
|
468
|
+
n += e.substring(o, i.index);
|
|
469
|
+
const l = `${G}${r}`;
|
|
470
|
+
n += l, t.set(l, {
|
|
398
471
|
type: "math",
|
|
399
472
|
value: i.content,
|
|
400
473
|
meta: i.pattern.isDisplay ? "display" : "inline"
|
|
401
|
-
}),
|
|
474
|
+
}), o = i.index + i.pattern.open.length + i.content.length + i.pattern.close.length, r += 1;
|
|
402
475
|
}
|
|
403
|
-
return { markdown:
|
|
476
|
+
return { markdown: n, tokens: t };
|
|
404
477
|
}
|
|
405
|
-
function
|
|
478
|
+
function Te(e) {
|
|
406
479
|
const t = [];
|
|
407
|
-
let
|
|
408
|
-
for (;
|
|
409
|
-
const
|
|
410
|
-
if (!
|
|
411
|
-
|
|
480
|
+
let n = 0;
|
|
481
|
+
for (; n < e.length; ) {
|
|
482
|
+
const o = J(e, n);
|
|
483
|
+
if (!o) {
|
|
484
|
+
n < e.length && t.push({ type: "text", value: e.substring(n) });
|
|
412
485
|
break;
|
|
413
486
|
}
|
|
414
|
-
|
|
487
|
+
o.index > n && t.push({
|
|
415
488
|
type: "text",
|
|
416
|
-
value: e.substring(
|
|
489
|
+
value: e.substring(n, o.index)
|
|
417
490
|
}), t.push({
|
|
418
491
|
type: "math",
|
|
419
|
-
value:
|
|
420
|
-
meta:
|
|
421
|
-
}),
|
|
492
|
+
value: o.content,
|
|
493
|
+
meta: o.pattern.isDisplay ? "display" : "inline"
|
|
494
|
+
}), n = o.index + o.pattern.open.length + o.content.length + o.pattern.close.length;
|
|
422
495
|
}
|
|
423
496
|
return t.length === 0 ? [{ type: "text", value: e }] : t;
|
|
424
497
|
}
|
|
425
|
-
function
|
|
426
|
-
const
|
|
427
|
-
let
|
|
428
|
-
|
|
429
|
-
let r =
|
|
498
|
+
function Ee(e, t) {
|
|
499
|
+
const n = [];
|
|
500
|
+
let o = 0;
|
|
501
|
+
q.lastIndex = 0;
|
|
502
|
+
let r = q.exec(e);
|
|
430
503
|
for (; r; ) {
|
|
431
504
|
const s = r.index, i = r[0];
|
|
432
|
-
s >
|
|
505
|
+
s > o && n.push({ type: "text", value: e.substring(o, s) });
|
|
433
506
|
const l = t.get(i);
|
|
434
|
-
l ?
|
|
507
|
+
l ? n.push(l) : n.push({ type: "text", value: i }), o = s + i.length, r = q.exec(e);
|
|
435
508
|
}
|
|
436
|
-
return
|
|
509
|
+
return o < e.length && n.push({ type: "text", value: e.substring(o) }), n.length === 0 ? [{ type: "text", value: e }] : n;
|
|
437
510
|
}
|
|
438
|
-
function
|
|
511
|
+
function Q(e) {
|
|
439
512
|
z(e, "paragraph", (t) => {
|
|
440
|
-
const
|
|
441
|
-
for (const r of
|
|
513
|
+
const n = t.children || [], o = [];
|
|
514
|
+
for (const r of n)
|
|
442
515
|
if (r.type === "text") {
|
|
443
|
-
const s =
|
|
444
|
-
|
|
516
|
+
const s = Te(r.value);
|
|
517
|
+
o.push(...s);
|
|
445
518
|
} else
|
|
446
|
-
|
|
447
|
-
t.children =
|
|
519
|
+
o.push(r);
|
|
520
|
+
t.children = o;
|
|
448
521
|
});
|
|
449
522
|
}
|
|
450
|
-
function
|
|
451
|
-
z(e, "paragraph", (
|
|
452
|
-
const
|
|
453
|
-
for (const s of
|
|
523
|
+
function Me(e, t) {
|
|
524
|
+
z(e, "paragraph", (n) => {
|
|
525
|
+
const o = n.children || [], r = [];
|
|
526
|
+
for (const s of o)
|
|
454
527
|
if (s.type === "text") {
|
|
455
|
-
const i =
|
|
528
|
+
const i = Ee(s.value, t);
|
|
456
529
|
r.push(...i);
|
|
457
530
|
} else
|
|
458
531
|
r.push(s);
|
|
459
|
-
|
|
532
|
+
n.children = r;
|
|
460
533
|
});
|
|
461
534
|
}
|
|
462
|
-
const
|
|
463
|
-
|
|
535
|
+
const yt = () => (e) => {
|
|
536
|
+
Q(e);
|
|
464
537
|
};
|
|
465
|
-
function
|
|
538
|
+
function $e(e) {
|
|
466
539
|
const t = e.trim();
|
|
467
540
|
if (!t.startsWith(":")) return null;
|
|
468
|
-
let
|
|
541
|
+
let n = 0;
|
|
469
542
|
for (let s = 0; s < t.length && t[s] === ":"; s++)
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
return
|
|
543
|
+
n++;
|
|
544
|
+
if (n < 3) return null;
|
|
545
|
+
const o = t.slice(n).trim(), r = o.match(/^([a-zA-Z0-9_-]+)(\[[^\]]*\])?(\{[^}]*\})?$/);
|
|
546
|
+
return o === "" ? { colons: n, label: null, lineIndex: -1, isOpen: !1 } : r ? { colons: n, label: r[0], lineIndex: -1, isOpen: !0 } : null;
|
|
474
547
|
}
|
|
475
|
-
function
|
|
476
|
-
const t = [],
|
|
477
|
-
for (const
|
|
478
|
-
if (
|
|
548
|
+
function Le(e) {
|
|
549
|
+
const t = [], n = [];
|
|
550
|
+
for (const o of e)
|
|
551
|
+
if (o.isOpen) {
|
|
479
552
|
const r = {
|
|
480
|
-
colons:
|
|
481
|
-
finalColons:
|
|
482
|
-
label:
|
|
483
|
-
openLineIndex:
|
|
553
|
+
colons: o.colons,
|
|
554
|
+
finalColons: o.colons,
|
|
555
|
+
label: o.label,
|
|
556
|
+
openLineIndex: o.lineIndex,
|
|
484
557
|
closeLineIndex: null,
|
|
485
558
|
children: [],
|
|
486
559
|
parent: null
|
|
@@ -489,107 +562,107 @@ function Te(e) {
|
|
|
489
562
|
const s = t[t.length - 1];
|
|
490
563
|
r.parent = s, s.children.push(r);
|
|
491
564
|
} else
|
|
492
|
-
|
|
565
|
+
n.push(r);
|
|
493
566
|
t.push(r);
|
|
494
567
|
} else {
|
|
495
568
|
const r = t[t.length - 1];
|
|
496
|
-
r && r.colons ===
|
|
569
|
+
r && r.colons === o.colons && (r.closeLineIndex = o.lineIndex, t.pop());
|
|
497
570
|
}
|
|
498
|
-
return
|
|
571
|
+
return n;
|
|
499
572
|
}
|
|
500
|
-
function
|
|
573
|
+
function ee(e) {
|
|
501
574
|
if (e.children.length === 0)
|
|
502
575
|
e.finalColons = e.colons;
|
|
503
576
|
else {
|
|
504
|
-
const t = Math.max(...e.children.map(
|
|
577
|
+
const t = Math.max(...e.children.map(ee));
|
|
505
578
|
e.finalColons = Math.max(e.colons, t + 1);
|
|
506
579
|
}
|
|
507
580
|
return e.finalColons;
|
|
508
581
|
}
|
|
509
|
-
function
|
|
510
|
-
const
|
|
582
|
+
function Fe(e, t, n) {
|
|
583
|
+
const o = e.slice(), r = [], s = t.slice();
|
|
511
584
|
for (; s.length > 0; ) {
|
|
512
585
|
const i = s.shift();
|
|
513
586
|
r.push(i), s.push(...i.children);
|
|
514
587
|
}
|
|
515
588
|
for (const i of r) {
|
|
516
589
|
if (i.openLineIndex >= 0) {
|
|
517
|
-
const l =
|
|
518
|
-
|
|
590
|
+
const l = o[i.openLineIndex], c = l.match(/^:+/)?.[0].length || 3, a = l.slice(c);
|
|
591
|
+
o[i.openLineIndex] = ":".repeat(i.finalColons) + a;
|
|
519
592
|
}
|
|
520
|
-
i.closeLineIndex !== null && i.closeLineIndex >= 0 && (
|
|
593
|
+
i.closeLineIndex !== null && i.closeLineIndex >= 0 && (o[i.closeLineIndex] = ":".repeat(i.finalColons));
|
|
521
594
|
}
|
|
522
|
-
return
|
|
595
|
+
return o;
|
|
523
596
|
}
|
|
524
|
-
function
|
|
597
|
+
function Ne(e) {
|
|
525
598
|
const t = e.split(`
|
|
526
|
-
`),
|
|
527
|
-
let
|
|
599
|
+
`), n = [];
|
|
600
|
+
let o = !1, r = null;
|
|
528
601
|
for (let l = 0; l < t.length; l++) {
|
|
529
602
|
const c = t[l], u = c.trim().match(/^(`{3,}|~{3,})/);
|
|
530
603
|
if (u) {
|
|
531
604
|
const m = u[1];
|
|
532
|
-
|
|
605
|
+
o ? r && m[0] === r[0] && m.length >= r.length && (o = !1, r = null) : (o = !0, r = m);
|
|
533
606
|
continue;
|
|
534
607
|
}
|
|
535
|
-
if (
|
|
608
|
+
if (o)
|
|
536
609
|
continue;
|
|
537
|
-
const d =
|
|
538
|
-
d &&
|
|
610
|
+
const d = $e(c);
|
|
611
|
+
d && n.push({ ...d, lineIndex: l });
|
|
539
612
|
}
|
|
540
|
-
if (
|
|
613
|
+
if (n.length === 0)
|
|
541
614
|
return e;
|
|
542
|
-
const s =
|
|
615
|
+
const s = Le(n);
|
|
543
616
|
for (const l of s)
|
|
544
|
-
|
|
545
|
-
return
|
|
617
|
+
ee(l);
|
|
618
|
+
return Fe(t, s).join(`
|
|
546
619
|
`);
|
|
547
620
|
}
|
|
548
|
-
function
|
|
621
|
+
function Oe(e) {
|
|
549
622
|
const t = e.trim();
|
|
550
623
|
if (!t.endsWith(":")) return null;
|
|
551
|
-
const
|
|
552
|
-
if (!/^[a-zA-Z]/.test(
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
const [, r, s] =
|
|
556
|
-
return s && !/^(\[[^\]]*\]|\{[^}]*\})*$/.test(s) || !
|
|
624
|
+
const n = t.slice(0, -1);
|
|
625
|
+
if (!/^[a-zA-Z]/.test(n)) return null;
|
|
626
|
+
const o = n.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)$/);
|
|
627
|
+
if (!o) return null;
|
|
628
|
+
const [, r, s] = o;
|
|
629
|
+
return s && !/^(\[[^\]]*\]|\{[^}]*\})*$/.test(s) || !I[r.toLowerCase()] ? null : n;
|
|
557
630
|
}
|
|
558
631
|
function E(e) {
|
|
559
632
|
let t = 0;
|
|
560
|
-
for (let
|
|
561
|
-
if (e[
|
|
633
|
+
for (let n = 0; n < e.length; n++)
|
|
634
|
+
if (e[n] === " ")
|
|
562
635
|
t += 1;
|
|
563
|
-
else if (e[
|
|
636
|
+
else if (e[n] === " ")
|
|
564
637
|
t += 4;
|
|
565
638
|
else
|
|
566
639
|
break;
|
|
567
640
|
return t;
|
|
568
641
|
}
|
|
569
|
-
function
|
|
570
|
-
const
|
|
571
|
-
for (let
|
|
572
|
-
if (!
|
|
573
|
-
return E(e[
|
|
642
|
+
function Ae(e, t) {
|
|
643
|
+
const n = E(e[t]);
|
|
644
|
+
for (let o = t + 1; o < e.length; o++)
|
|
645
|
+
if (!te(e[o]))
|
|
646
|
+
return E(e[o]) > n;
|
|
574
647
|
return !1;
|
|
575
648
|
}
|
|
576
|
-
function
|
|
649
|
+
function te(e) {
|
|
577
650
|
return e.trim() === "";
|
|
578
651
|
}
|
|
579
|
-
function
|
|
580
|
-
let
|
|
581
|
-
for (;
|
|
582
|
-
if (e[
|
|
583
|
-
|
|
584
|
-
else if (e[
|
|
585
|
-
|
|
652
|
+
function Pe(e, t) {
|
|
653
|
+
let n = 0, o = 0;
|
|
654
|
+
for (; o < e.length && n < t; )
|
|
655
|
+
if (e[o] === " ")
|
|
656
|
+
n++, o++;
|
|
657
|
+
else if (e[o] === " ")
|
|
658
|
+
n += 4, o++;
|
|
586
659
|
else
|
|
587
660
|
break;
|
|
588
|
-
return e.slice(
|
|
661
|
+
return e.slice(o);
|
|
589
662
|
}
|
|
590
|
-
function
|
|
663
|
+
function _e(e) {
|
|
591
664
|
const t = e.split(`
|
|
592
|
-
`),
|
|
665
|
+
`), n = [], o = {
|
|
593
666
|
level: 0,
|
|
594
667
|
openDirectives: [],
|
|
595
668
|
inCodeFence: !1,
|
|
@@ -599,77 +672,77 @@ function Ne(e) {
|
|
|
599
672
|
const s = t[r], i = s.trim(), l = E(s), c = i.match(/^(`{3,}|~{3,})/);
|
|
600
673
|
if (c) {
|
|
601
674
|
const u = c[1];
|
|
602
|
-
|
|
675
|
+
o.inCodeFence ? o.codeFenceMarker && i.startsWith(o.codeFenceMarker) && (o.inCodeFence = !1, o.codeFenceMarker = null) : (o.inCodeFence = !0, o.codeFenceMarker = u), n.push(s);
|
|
603
676
|
continue;
|
|
604
677
|
}
|
|
605
|
-
if (
|
|
606
|
-
|
|
678
|
+
if (o.inCodeFence) {
|
|
679
|
+
n.push(s);
|
|
607
680
|
continue;
|
|
608
681
|
}
|
|
609
|
-
if (
|
|
610
|
-
|
|
682
|
+
if (te(s)) {
|
|
683
|
+
n.push("");
|
|
611
684
|
continue;
|
|
612
685
|
}
|
|
613
|
-
const a =
|
|
614
|
-
if (a &&
|
|
615
|
-
for (;
|
|
616
|
-
const
|
|
617
|
-
|
|
686
|
+
const a = Oe(i);
|
|
687
|
+
if (a && Ae(t, r)) {
|
|
688
|
+
for (; o.openDirectives.length > 0 && !(o.openDirectives[o.openDirectives.length - 1].indentLevel < l); ) {
|
|
689
|
+
const y = o.openDirectives.pop();
|
|
690
|
+
y && n.push(":".repeat(y.colonCount));
|
|
618
691
|
}
|
|
619
|
-
const u = a.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)/), d = u ? u[1].toLowerCase() + (u[2] || "") : a, m =
|
|
620
|
-
|
|
692
|
+
const u = a.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)/), d = u ? u[1].toLowerCase() + (u[2] || "") : a, m = o.openDirectives.length * 1 + 3;
|
|
693
|
+
n.push(":".repeat(m) + d), o.openDirectives.push({
|
|
621
694
|
label: d,
|
|
622
695
|
indentLevel: l,
|
|
623
696
|
colonCount: m,
|
|
624
697
|
bodyBaseIndent: -1
|
|
625
|
-
}),
|
|
698
|
+
}), o.level = l;
|
|
626
699
|
} else {
|
|
627
|
-
for (;
|
|
628
|
-
const u =
|
|
629
|
-
u &&
|
|
700
|
+
for (; o.openDirectives.length > 0 && l <= o.openDirectives[o.openDirectives.length - 1].indentLevel; ) {
|
|
701
|
+
const u = o.openDirectives.pop();
|
|
702
|
+
u && n.push(":".repeat(u.colonCount));
|
|
630
703
|
}
|
|
631
|
-
if (
|
|
632
|
-
const u =
|
|
633
|
-
u.bodyBaseIndent < 0 && (u.bodyBaseIndent = l),
|
|
704
|
+
if (o.openDirectives.length > 0) {
|
|
705
|
+
const u = o.openDirectives[o.openDirectives.length - 1];
|
|
706
|
+
u.bodyBaseIndent < 0 && (u.bodyBaseIndent = l), n.push(Pe(s, u.bodyBaseIndent));
|
|
634
707
|
} else
|
|
635
|
-
|
|
636
|
-
|
|
708
|
+
n.push(s);
|
|
709
|
+
o.level = l;
|
|
637
710
|
}
|
|
638
711
|
}
|
|
639
|
-
for (;
|
|
640
|
-
const r =
|
|
641
|
-
r &&
|
|
712
|
+
for (; o.openDirectives.length > 0; ) {
|
|
713
|
+
const r = o.openDirectives.pop();
|
|
714
|
+
r && n.push(":".repeat(r.colonCount));
|
|
642
715
|
}
|
|
643
|
-
return
|
|
716
|
+
return n.join(`
|
|
644
717
|
`);
|
|
645
718
|
}
|
|
646
|
-
const
|
|
647
|
-
return function(t,
|
|
648
|
-
if (typeof
|
|
649
|
-
const
|
|
650
|
-
return
|
|
719
|
+
const Re = function() {
|
|
720
|
+
return function(t, n) {
|
|
721
|
+
if (typeof n?.value == "string") {
|
|
722
|
+
const o = _e(n.value), r = Ne(o), s = qe(r), l = R().data("micromarkExtensions", [{ disable: { null: ["codeIndented"] } }]).use(j).use(B).parse(s.markdown);
|
|
723
|
+
return Me(l, s.tokens), N(l, s.markdown);
|
|
651
724
|
}
|
|
652
|
-
return
|
|
725
|
+
return Q(t), N(t);
|
|
653
726
|
};
|
|
654
|
-
},
|
|
727
|
+
}, je = /["&'<>`]/g, Be = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ze = (
|
|
655
728
|
// eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
|
|
656
729
|
/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g
|
|
657
|
-
),
|
|
658
|
-
function
|
|
730
|
+
), We = /[|\\{}()[\]^$+*?.]/g, A = /* @__PURE__ */ new WeakMap();
|
|
731
|
+
function He(e, t) {
|
|
659
732
|
if (e = e.replace(
|
|
660
|
-
t.subset ?
|
|
661
|
-
|
|
733
|
+
t.subset ? Ue(t.subset) : je,
|
|
734
|
+
o
|
|
662
735
|
), t.subset || t.escapeOnly)
|
|
663
736
|
return e;
|
|
664
|
-
return e.replace(
|
|
665
|
-
function
|
|
737
|
+
return e.replace(Be, n).replace(ze, o);
|
|
738
|
+
function n(r, s, i) {
|
|
666
739
|
return t.format(
|
|
667
740
|
(r.charCodeAt(0) - 55296) * 1024 + r.charCodeAt(1) - 56320 + 65536,
|
|
668
741
|
i.charCodeAt(s + 2),
|
|
669
742
|
t
|
|
670
743
|
);
|
|
671
744
|
}
|
|
672
|
-
function
|
|
745
|
+
function o(r, s, i) {
|
|
673
746
|
return t.format(
|
|
674
747
|
r.charCodeAt(0),
|
|
675
748
|
i.charCodeAt(s + 1),
|
|
@@ -677,137 +750,137 @@ function je(e, t) {
|
|
|
677
750
|
);
|
|
678
751
|
}
|
|
679
752
|
}
|
|
680
|
-
function
|
|
753
|
+
function Ue(e) {
|
|
681
754
|
let t = A.get(e);
|
|
682
|
-
return t || (t =
|
|
755
|
+
return t || (t = Ze(e), A.set(e, t)), t;
|
|
683
756
|
}
|
|
684
|
-
function
|
|
757
|
+
function Ze(e) {
|
|
685
758
|
const t = [];
|
|
686
|
-
let
|
|
687
|
-
for (; ++
|
|
688
|
-
t.push(e[
|
|
759
|
+
let n = -1;
|
|
760
|
+
for (; ++n < e.length; )
|
|
761
|
+
t.push(e[n].replace(We, "\\$&"));
|
|
689
762
|
return new RegExp("(?:" + t.join("|") + ")", "g");
|
|
690
763
|
}
|
|
691
|
-
function
|
|
764
|
+
function Xe(e) {
|
|
692
765
|
return "&#x" + e.toString(16).toUpperCase() + ";";
|
|
693
766
|
}
|
|
694
|
-
function
|
|
695
|
-
return
|
|
767
|
+
function Ke(e, t) {
|
|
768
|
+
return He(e, Object.assign({ format: Xe }, t));
|
|
696
769
|
}
|
|
697
|
-
const
|
|
698
|
-
function
|
|
699
|
-
const
|
|
700
|
-
return
|
|
770
|
+
const Ye = /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;
|
|
771
|
+
function k(e, t, n) {
|
|
772
|
+
const o = Ve(e);
|
|
773
|
+
return n ? o.replace(n, r) : r(o);
|
|
701
774
|
function r(s) {
|
|
702
|
-
return
|
|
775
|
+
return Ke(s, { subset: t });
|
|
703
776
|
}
|
|
704
777
|
}
|
|
705
|
-
function
|
|
706
|
-
return String(e || "").replace(
|
|
778
|
+
function Ve(e) {
|
|
779
|
+
return String(e || "").replace(Ye, "");
|
|
707
780
|
}
|
|
708
|
-
const
|
|
709
|
-
function
|
|
710
|
-
return "<![CDATA[" +
|
|
781
|
+
const Ge = /]]>/g, Je = [">"];
|
|
782
|
+
function Qe(e) {
|
|
783
|
+
return "<![CDATA[" + k(e.value, Je, Ge) + "]]>";
|
|
711
784
|
}
|
|
712
|
-
function
|
|
713
|
-
return "<!--" +
|
|
785
|
+
function et(e) {
|
|
786
|
+
return "<!--" + k(e.value, ["-"]) + "-->";
|
|
714
787
|
}
|
|
715
|
-
const
|
|
788
|
+
const tt = [" ", `
|
|
716
789
|
`, " ", '"', "&", "'", "/", "<", "=", ">"];
|
|
717
790
|
function S(e) {
|
|
718
|
-
return
|
|
791
|
+
return k(e, tt);
|
|
719
792
|
}
|
|
720
|
-
function
|
|
721
|
-
const
|
|
793
|
+
function P(e, t) {
|
|
794
|
+
const n = String(e);
|
|
722
795
|
if (typeof t != "string")
|
|
723
796
|
throw new TypeError("Expected character");
|
|
724
|
-
let
|
|
797
|
+
let o = 0, r = n.indexOf(t);
|
|
725
798
|
for (; r !== -1; )
|
|
726
|
-
|
|
727
|
-
return
|
|
799
|
+
o++, r = n.indexOf(t, r + t.length);
|
|
800
|
+
return o;
|
|
728
801
|
}
|
|
729
802
|
function M(e, t) {
|
|
730
|
-
const
|
|
731
|
-
let
|
|
803
|
+
const n = String(e);
|
|
804
|
+
let o = t.options.quote || '"';
|
|
732
805
|
if (t.options.quoteSmart) {
|
|
733
|
-
const r =
|
|
734
|
-
|
|
806
|
+
const r = o === '"' ? "'" : '"';
|
|
807
|
+
P(n, o) > P(n, r) && (o = r);
|
|
735
808
|
}
|
|
736
|
-
return
|
|
809
|
+
return o + k(n, ["<", "&", o]) + o;
|
|
737
810
|
}
|
|
738
|
-
function
|
|
739
|
-
const
|
|
811
|
+
function nt(e, t) {
|
|
812
|
+
const n = S(e.name), o = e.public, r = e.system;
|
|
740
813
|
let s = "<!DOCTYPE";
|
|
741
|
-
return
|
|
814
|
+
return n !== "" && (s += " " + n), o ? s += " PUBLIC " + M(o, t) : r && (s += " SYSTEM"), r && (s += " " + M(r, t)), s + ">";
|
|
742
815
|
}
|
|
743
|
-
const
|
|
744
|
-
function
|
|
745
|
-
const
|
|
816
|
+
const ot = {}.hasOwnProperty;
|
|
817
|
+
function rt(e, t) {
|
|
818
|
+
const n = S(e.name), o = re(e, t), r = e.attributes || {}, s = o ? !1 : t.options.closeEmptyElements, i = [];
|
|
746
819
|
let l;
|
|
747
820
|
for (l in r)
|
|
748
|
-
if (
|
|
821
|
+
if (ot.call(r, l)) {
|
|
749
822
|
const c = r[l];
|
|
750
823
|
c != null && i.push(S(l) + "=" + M(c, t));
|
|
751
824
|
}
|
|
752
|
-
return "<" +
|
|
825
|
+
return "<" + n + (i.length === 0 ? "" : " " + i.join(" ")) + (s ? (t.options.tightClose ? "" : " ") + "/" : "") + ">" + o + (s ? "" : "</" + n + ">");
|
|
753
826
|
}
|
|
754
|
-
const
|
|
755
|
-
function
|
|
756
|
-
const t = S(e.name) || "x",
|
|
757
|
-
return "<?" + t + (
|
|
827
|
+
const st = /\?>/g, it = [">"];
|
|
828
|
+
function lt(e) {
|
|
829
|
+
const t = S(e.name) || "x", n = k(e.value, it, st);
|
|
830
|
+
return "<?" + t + (n ? " " + n : "") + "?>";
|
|
758
831
|
}
|
|
759
|
-
const
|
|
760
|
-
function
|
|
761
|
-
return
|
|
762
|
-
}
|
|
763
|
-
function
|
|
764
|
-
return t.options.allowDangerousXml ? e.value :
|
|
765
|
-
}
|
|
766
|
-
const
|
|
767
|
-
cdata:
|
|
768
|
-
comment:
|
|
769
|
-
doctype:
|
|
770
|
-
element:
|
|
771
|
-
instruction:
|
|
772
|
-
raw:
|
|
773
|
-
root:
|
|
774
|
-
text:
|
|
832
|
+
const ct = ["&", "<"];
|
|
833
|
+
function ne(e) {
|
|
834
|
+
return k(e.value, ct);
|
|
835
|
+
}
|
|
836
|
+
function at(e, t) {
|
|
837
|
+
return t.options.allowDangerousXml ? e.value : ne(e);
|
|
838
|
+
}
|
|
839
|
+
const ut = {}.hasOwnProperty, _ = {
|
|
840
|
+
cdata: Qe,
|
|
841
|
+
comment: et,
|
|
842
|
+
doctype: nt,
|
|
843
|
+
element: rt,
|
|
844
|
+
instruction: lt,
|
|
845
|
+
raw: at,
|
|
846
|
+
root: re,
|
|
847
|
+
text: ne
|
|
775
848
|
};
|
|
776
|
-
function
|
|
777
|
-
const
|
|
778
|
-
if (!
|
|
849
|
+
function oe(e, t) {
|
|
850
|
+
const n = e && e.type;
|
|
851
|
+
if (!n)
|
|
779
852
|
throw new Error("Expected node, not `" + e + "`");
|
|
780
|
-
if (!
|
|
781
|
-
throw new Error("Cannot compile unknown node `" +
|
|
782
|
-
const
|
|
783
|
-
return
|
|
853
|
+
if (!ut.call(_, n))
|
|
854
|
+
throw new Error("Cannot compile unknown node `" + n + "`");
|
|
855
|
+
const o = _[n];
|
|
856
|
+
return o(e, t);
|
|
784
857
|
}
|
|
785
|
-
function
|
|
786
|
-
const
|
|
787
|
-
let
|
|
858
|
+
function re(e, t) {
|
|
859
|
+
const n = e && e.children || [];
|
|
860
|
+
let o = -1;
|
|
788
861
|
const r = [];
|
|
789
|
-
for (; ++
|
|
790
|
-
r[
|
|
862
|
+
for (; ++o < n.length; )
|
|
863
|
+
r[o] = oe(n[o], t);
|
|
791
864
|
return r.join("");
|
|
792
865
|
}
|
|
793
|
-
function
|
|
794
|
-
const
|
|
795
|
-
if (typeof
|
|
866
|
+
function pt(e, t) {
|
|
867
|
+
const n = { options: {} };
|
|
868
|
+
if (typeof n.options.quote == "string" && n.options.quote !== '"' && n.options.quote !== "'")
|
|
796
869
|
throw new Error(
|
|
797
|
-
"Invalid quote `" +
|
|
870
|
+
"Invalid quote `" + n.options.quote + "`, expected `'` or `\"`"
|
|
798
871
|
);
|
|
799
|
-
const
|
|
800
|
-
return
|
|
872
|
+
const o = Array.isArray(e) ? { type: "root", children: e } : e;
|
|
873
|
+
return oe(o, n);
|
|
801
874
|
}
|
|
802
|
-
function
|
|
803
|
-
const t =
|
|
804
|
-
return
|
|
875
|
+
function kt(e) {
|
|
876
|
+
const t = R().use(j).use(B).use(Re), n = t.parse(e), o = t.runSync(n, { value: e });
|
|
877
|
+
return pt(o.children);
|
|
805
878
|
}
|
|
806
879
|
export {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
880
|
+
gt as DIRECTIVE_MAP,
|
|
881
|
+
W as PROOF_SOLUTION_NAMES,
|
|
882
|
+
kt as markdownToPretext,
|
|
883
|
+
N as mdastToPtxast,
|
|
884
|
+
yt as remarkMath,
|
|
885
|
+
Re as remarkPretext
|
|
813
886
|
};
|