@pretextbook/remark-pretext 0.0.3 → 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 +452 -362
- package/package.json +2 -2
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,14 +43,14 @@ 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
50
|
const W = new Set(
|
|
51
|
-
Object.entries(
|
|
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,
|
|
@@ -61,93 +61,93 @@ function v(e, t, n) {
|
|
|
61
61
|
function C(e) {
|
|
62
62
|
return e.type === "containerDirective" && e.name === "task";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ie(e) {
|
|
65
65
|
return e.type === "containerDirective" && W.has(e.name);
|
|
66
66
|
}
|
|
67
67
|
function D(e) {
|
|
68
68
|
const t = [];
|
|
69
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(
|
|
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
75
|
if (n && l.push(n), e.hasNestedTasks) {
|
|
76
|
-
const c =
|
|
76
|
+
const c = o.findIndex(C);
|
|
77
77
|
if (c !== -1) {
|
|
78
78
|
const a = [];
|
|
79
|
-
for (let
|
|
80
|
-
C(
|
|
81
|
-
const
|
|
82
|
-
for (let
|
|
83
|
-
const
|
|
84
|
-
if (!C(
|
|
85
|
-
if (
|
|
86
|
-
|
|
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
|
+
if (!C(f)) {
|
|
85
|
+
if (p < u) {
|
|
86
|
+
v.push(f);
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
L.push(
|
|
89
|
+
if (ie(f)) {
|
|
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
|
-
const
|
|
103
|
-
d.map((
|
|
102
|
+
const p = D(
|
|
103
|
+
d.map((f) => s(f, r)).filter((f) => f !== null)
|
|
104
104
|
);
|
|
105
|
-
|
|
105
|
+
p.length > 0 && l.push(x("introduction", p));
|
|
106
106
|
}
|
|
107
|
-
for (const
|
|
108
|
-
const
|
|
109
|
-
|
|
107
|
+
for (const p of m) {
|
|
108
|
+
const f = i(p, r);
|
|
109
|
+
f && l.push(f);
|
|
110
110
|
}
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
|
|
111
|
+
if (y.length > 0) {
|
|
112
|
+
const p = D(
|
|
113
|
+
y.map((f) => s(f, r)).filter((f) => f !== null)
|
|
114
114
|
);
|
|
115
|
-
|
|
115
|
+
p.length > 0 && l.push(x("conclusion", p));
|
|
116
116
|
}
|
|
117
|
-
for (const
|
|
118
|
-
const
|
|
119
|
-
|
|
117
|
+
for (const p of L) {
|
|
118
|
+
const f = i(p, r);
|
|
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, n,
|
|
127
|
+
function F(e, t, n, o, r, s) {
|
|
128
128
|
if (t.requiresStatement) {
|
|
129
129
|
const i = [], l = [];
|
|
130
130
|
for (const c of n)
|
|
131
131
|
if (c.type === "containerDirective" && W.has(c.name)) {
|
|
132
|
-
const a = s(c,
|
|
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) =>
|
|
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
|
-
n.map((l) =>
|
|
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
153
|
function h(e, t, n) {
|
|
@@ -158,402 +158,475 @@ function h(e, t, 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
183
|
for (const n of e)
|
|
167
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 n = [],
|
|
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:
|
|
193
|
+
tree: { type: "root", children: K(r, o) },
|
|
177
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 (
|
|
210
|
+
a.type === "heading" && (o = Math.min(o, a.depth));
|
|
211
|
+
if (o === 7)
|
|
189
212
|
return w(e, t, n);
|
|
190
|
-
const
|
|
213
|
+
const r = [];
|
|
191
214
|
let s = null, i = [], l = [];
|
|
192
215
|
const c = () => {
|
|
193
|
-
s && (
|
|
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
|
-
|
|
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;
|
|
198
225
|
}
|
|
199
226
|
function w(e, t, n = !1) {
|
|
200
|
-
const
|
|
201
|
-
for (let
|
|
202
|
-
const s = e[
|
|
227
|
+
const o = [];
|
|
228
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
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),
|
|
234
|
+
c.children.push(l), u && (c.children.push(
|
|
235
|
+
...u
|
|
236
|
+
), r += 1);
|
|
208
237
|
else {
|
|
209
238
|
const d = [l];
|
|
210
|
-
|
|
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 n ?
|
|
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 n =
|
|
275
|
+
const n = he[e.type];
|
|
243
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 n = e.children.filter((
|
|
254
|
-
const
|
|
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
298
|
return h("blockquote", n);
|
|
258
299
|
}
|
|
259
|
-
function
|
|
260
|
-
const n = e.children.map((
|
|
261
|
-
const
|
|
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
309
|
return h(e.ordered ? "ol" : "ul", n);
|
|
265
310
|
}
|
|
266
|
-
function
|
|
267
|
-
const n = w(
|
|
311
|
+
function ge(e, t) {
|
|
312
|
+
const n = w(
|
|
313
|
+
e.children,
|
|
314
|
+
t
|
|
315
|
+
);
|
|
268
316
|
return h("li", n);
|
|
269
317
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
318
|
+
function ye(e, t) {
|
|
319
|
+
return g(
|
|
320
|
+
"program",
|
|
321
|
+
e.value,
|
|
322
|
+
e.lang ? { language: e.lang } : void 0
|
|
323
|
+
);
|
|
272
324
|
}
|
|
273
|
-
function
|
|
274
|
-
const n = e.value.split(/\\\\|[\r\n]+/).map((
|
|
275
|
-
return n.length > 1 ? h(
|
|
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] ?? "");
|
|
276
331
|
}
|
|
277
|
-
function
|
|
278
|
-
return e.meta === "inline" ?
|
|
332
|
+
function ve(e, t) {
|
|
333
|
+
return e.meta === "inline" ? g("m", e.value) : ke(e);
|
|
279
334
|
}
|
|
280
|
-
function
|
|
281
|
-
const n =
|
|
335
|
+
function V(e, t) {
|
|
336
|
+
const n = se(e.name);
|
|
282
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(
|
|
291
348
|
r,
|
|
349
|
+
t
|
|
350
|
+
), l = {
|
|
351
|
+
...t,
|
|
352
|
+
ancestors: [...t.ancestors, e],
|
|
353
|
+
depth: t.depth + 1
|
|
354
|
+
};
|
|
355
|
+
return le(
|
|
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
|
|
365
|
+
function xe(e, t) {
|
|
300
366
|
const n = e[0];
|
|
301
367
|
return n?.type === "paragraph" && n.data?.directiveLabel === !0 ? {
|
|
302
|
-
title: h(
|
|
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
|
|
375
|
+
function be(e) {
|
|
307
376
|
const t = e.attributes ?? {}, n = {};
|
|
308
|
-
for (const [
|
|
309
|
-
|
|
377
|
+
for (const [o, r] of Object.entries(t))
|
|
378
|
+
r != null && (n[o === "id" ? "xml:id" : o] = r);
|
|
310
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((n) =>
|
|
395
|
+
return e.flatMap((n) => De(n, t)).filter((n) => n !== null);
|
|
327
396
|
}
|
|
328
|
-
function
|
|
329
|
-
const n =
|
|
397
|
+
function De(e, t) {
|
|
398
|
+
const n = we[e.type];
|
|
330
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
|
|
419
|
+
], G = "PTX_MATH_TOKEN_", q = new RegExp(`${G}(\\d+)`, "g");
|
|
420
|
+
function J(e, t) {
|
|
348
421
|
let n = null;
|
|
349
|
-
for (const
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
const s = e.indexOf(
|
|
353
|
-
if (s !== -1 && !(
|
|
354
|
-
const i = e.substring(
|
|
355
|
-
n = { index:
|
|
422
|
+
for (const o of Se) {
|
|
423
|
+
const r = e.indexOf(o.open, t);
|
|
424
|
+
if (r === -1) continue;
|
|
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
431
|
return n;
|
|
359
432
|
}
|
|
360
|
-
function
|
|
433
|
+
function Ie(e, t) {
|
|
361
434
|
let n = t;
|
|
362
435
|
for (; n < e.length; ) {
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
let
|
|
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
|
-
|
|
368
|
-
const i = "`".repeat(
|
|
440
|
+
r++, s++;
|
|
441
|
+
const i = "`".repeat(r);
|
|
369
442
|
let l = s;
|
|
370
443
|
for (; l < e.length; ) {
|
|
371
444
|
const c = e.indexOf(i, l);
|
|
372
445
|
if (c === -1) break;
|
|
373
|
-
const a = c +
|
|
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
|
-
n =
|
|
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 n = "",
|
|
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
|
-
n += e.substring(
|
|
461
|
+
n += e.substring(o, s.end), o = s.end;
|
|
389
462
|
continue;
|
|
390
463
|
}
|
|
391
464
|
if (!i) {
|
|
392
|
-
n += e.substring(
|
|
465
|
+
n += e.substring(o);
|
|
393
466
|
break;
|
|
394
467
|
}
|
|
395
|
-
n += e.substring(
|
|
396
|
-
const l = `${
|
|
468
|
+
n += e.substring(o, i.index);
|
|
469
|
+
const l = `${G}${r}`;
|
|
397
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
476
|
return { markdown: n, tokens: t };
|
|
404
477
|
}
|
|
405
|
-
function
|
|
478
|
+
function Te(e) {
|
|
406
479
|
const t = [];
|
|
407
480
|
let n = 0;
|
|
408
481
|
for (; n < e.length; ) {
|
|
409
|
-
const
|
|
410
|
-
if (!
|
|
482
|
+
const o = J(e, n);
|
|
483
|
+
if (!o) {
|
|
411
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(n,
|
|
489
|
+
value: e.substring(n, o.index)
|
|
417
490
|
}), t.push({
|
|
418
491
|
type: "math",
|
|
419
|
-
value:
|
|
420
|
-
meta:
|
|
421
|
-
}), n =
|
|
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
|
|
498
|
+
function Ee(e, t) {
|
|
426
499
|
const n = [];
|
|
427
|
-
let
|
|
428
|
-
|
|
429
|
-
let
|
|
430
|
-
for (;
|
|
431
|
-
const s =
|
|
432
|
-
s >
|
|
500
|
+
let o = 0;
|
|
501
|
+
q.lastIndex = 0;
|
|
502
|
+
let r = q.exec(e);
|
|
503
|
+
for (; r; ) {
|
|
504
|
+
const s = r.index, i = r[0];
|
|
505
|
+
s > o && n.push({ type: "text", value: e.substring(o, s) });
|
|
433
506
|
const l = t.get(i);
|
|
434
|
-
l ? n.push(l) : n.push({ type: "text", value: i }),
|
|
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 n = t.children || [],
|
|
441
|
-
for (const
|
|
442
|
-
if (
|
|
443
|
-
const s =
|
|
444
|
-
|
|
513
|
+
const n = t.children || [], o = [];
|
|
514
|
+
for (const r of n)
|
|
515
|
+
if (r.type === "text") {
|
|
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
|
|
523
|
+
function Me(e, t) {
|
|
451
524
|
z(e, "paragraph", (n) => {
|
|
452
|
-
const
|
|
453
|
-
for (const s of
|
|
525
|
+
const o = n.children || [], r = [];
|
|
526
|
+
for (const s of o)
|
|
454
527
|
if (s.type === "text") {
|
|
455
|
-
const i =
|
|
456
|
-
|
|
528
|
+
const i = Ee(s.value, t);
|
|
529
|
+
r.push(...i);
|
|
457
530
|
} else
|
|
458
|
-
|
|
459
|
-
n.children =
|
|
531
|
+
r.push(s);
|
|
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
541
|
let n = 0;
|
|
469
542
|
for (let s = 0; s < t.length && t[s] === ":"; s++)
|
|
470
543
|
n++;
|
|
471
544
|
if (n < 3) return null;
|
|
472
|
-
const
|
|
473
|
-
return
|
|
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
|
|
548
|
+
function Le(e) {
|
|
476
549
|
const t = [], n = [];
|
|
477
|
-
for (const
|
|
478
|
-
if (
|
|
479
|
-
const
|
|
480
|
-
colons:
|
|
481
|
-
finalColons:
|
|
482
|
-
label:
|
|
483
|
-
openLineIndex:
|
|
550
|
+
for (const o of e)
|
|
551
|
+
if (o.isOpen) {
|
|
552
|
+
const r = {
|
|
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
|
|
487
560
|
};
|
|
488
561
|
if (t.length > 0) {
|
|
489
562
|
const s = t[t.length - 1];
|
|
490
|
-
|
|
563
|
+
r.parent = s, s.children.push(r);
|
|
491
564
|
} else
|
|
492
|
-
n.push(
|
|
493
|
-
t.push(
|
|
565
|
+
n.push(r);
|
|
566
|
+
t.push(r);
|
|
494
567
|
} else {
|
|
495
|
-
const
|
|
496
|
-
|
|
568
|
+
const r = t[t.length - 1];
|
|
569
|
+
r && r.colons === o.colons && (r.closeLineIndex = o.lineIndex, t.pop());
|
|
497
570
|
}
|
|
498
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
|
-
for (const i of
|
|
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
599
|
`), n = [];
|
|
527
|
-
let
|
|
600
|
+
let o = !1, r = null;
|
|
528
601
|
for (let l = 0; l < t.length; l++) {
|
|
529
|
-
const c = t[l],
|
|
530
|
-
if (
|
|
531
|
-
const m =
|
|
532
|
-
|
|
602
|
+
const c = t[l], u = c.trim().match(/^(`{3,}|~{3,})/);
|
|
603
|
+
if (u) {
|
|
604
|
+
const m = u[1];
|
|
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 =
|
|
610
|
+
const d = $e(c);
|
|
538
611
|
d && n.push({ ...d, lineIndex: l });
|
|
539
612
|
}
|
|
540
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
624
|
const n = t.slice(0, -1);
|
|
552
625
|
if (!/^[a-zA-Z]/.test(n)) return null;
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
const [,
|
|
556
|
-
return s && !/^(\[[^\]]*\]|\{[^}]*\})*$/.test(s) || !
|
|
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;
|
|
@@ -566,231 +639,248 @@ function E(e) {
|
|
|
566
639
|
break;
|
|
567
640
|
return t;
|
|
568
641
|
}
|
|
569
|
-
function
|
|
642
|
+
function Ae(e, t) {
|
|
570
643
|
const n = E(e[t]);
|
|
571
|
-
for (let
|
|
572
|
-
if (!
|
|
573
|
-
return E(e[
|
|
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
|
|
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++;
|
|
659
|
+
else
|
|
660
|
+
break;
|
|
661
|
+
return e.slice(o);
|
|
662
|
+
}
|
|
663
|
+
function _e(e) {
|
|
580
664
|
const t = e.split(`
|
|
581
|
-
`), n = [],
|
|
665
|
+
`), n = [], o = {
|
|
582
666
|
level: 0,
|
|
583
667
|
openDirectives: [],
|
|
584
668
|
inCodeFence: !1,
|
|
585
669
|
codeFenceMarker: null
|
|
586
670
|
};
|
|
587
|
-
for (let
|
|
588
|
-
const s = t[
|
|
671
|
+
for (let r = 0; r < t.length; r++) {
|
|
672
|
+
const s = t[r], i = s.trim(), l = E(s), c = i.match(/^(`{3,}|~{3,})/);
|
|
589
673
|
if (c) {
|
|
590
|
-
const
|
|
591
|
-
|
|
674
|
+
const u = c[1];
|
|
675
|
+
o.inCodeFence ? o.codeFenceMarker && i.startsWith(o.codeFenceMarker) && (o.inCodeFence = !1, o.codeFenceMarker = null) : (o.inCodeFence = !0, o.codeFenceMarker = u), n.push(s);
|
|
592
676
|
continue;
|
|
593
677
|
}
|
|
594
|
-
if (
|
|
678
|
+
if (o.inCodeFence) {
|
|
595
679
|
n.push(s);
|
|
596
680
|
continue;
|
|
597
681
|
}
|
|
598
|
-
if (
|
|
682
|
+
if (te(s)) {
|
|
599
683
|
n.push("");
|
|
600
684
|
continue;
|
|
601
685
|
}
|
|
602
|
-
const a =
|
|
603
|
-
if (a &&
|
|
604
|
-
for (;
|
|
605
|
-
const
|
|
606
|
-
|
|
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));
|
|
607
691
|
}
|
|
608
|
-
const
|
|
609
|
-
n.push(":".repeat(m) + d),
|
|
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({
|
|
610
694
|
label: d,
|
|
611
695
|
indentLevel: l,
|
|
612
|
-
colonCount: m
|
|
613
|
-
|
|
696
|
+
colonCount: m,
|
|
697
|
+
bodyBaseIndent: -1
|
|
698
|
+
}), o.level = l;
|
|
614
699
|
} else {
|
|
615
|
-
for (;
|
|
616
|
-
const
|
|
617
|
-
|
|
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));
|
|
618
703
|
}
|
|
619
|
-
|
|
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));
|
|
707
|
+
} else
|
|
708
|
+
n.push(s);
|
|
709
|
+
o.level = l;
|
|
620
710
|
}
|
|
621
711
|
}
|
|
622
|
-
for (;
|
|
623
|
-
const
|
|
624
|
-
|
|
712
|
+
for (; o.openDirectives.length > 0; ) {
|
|
713
|
+
const r = o.openDirectives.pop();
|
|
714
|
+
r && n.push(":".repeat(r.colonCount));
|
|
625
715
|
}
|
|
626
716
|
return n.join(`
|
|
627
717
|
`);
|
|
628
718
|
}
|
|
629
|
-
const
|
|
719
|
+
const Re = function() {
|
|
630
720
|
return function(t, n) {
|
|
631
721
|
if (typeof n?.value == "string") {
|
|
632
|
-
const
|
|
633
|
-
return
|
|
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);
|
|
634
724
|
}
|
|
635
|
-
return
|
|
725
|
+
return Q(t), N(t);
|
|
636
726
|
};
|
|
637
|
-
},
|
|
727
|
+
}, je = /["&'<>`]/g, Be = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ze = (
|
|
638
728
|
// eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
|
|
639
729
|
/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g
|
|
640
|
-
),
|
|
641
|
-
function
|
|
730
|
+
), We = /[|\\{}()[\]^$+*?.]/g, A = /* @__PURE__ */ new WeakMap();
|
|
731
|
+
function He(e, t) {
|
|
642
732
|
if (e = e.replace(
|
|
643
|
-
t.subset ?
|
|
644
|
-
|
|
733
|
+
t.subset ? Ue(t.subset) : je,
|
|
734
|
+
o
|
|
645
735
|
), t.subset || t.escapeOnly)
|
|
646
736
|
return e;
|
|
647
|
-
return e.replace(
|
|
648
|
-
function n(
|
|
737
|
+
return e.replace(Be, n).replace(ze, o);
|
|
738
|
+
function n(r, s, i) {
|
|
649
739
|
return t.format(
|
|
650
|
-
(
|
|
740
|
+
(r.charCodeAt(0) - 55296) * 1024 + r.charCodeAt(1) - 56320 + 65536,
|
|
651
741
|
i.charCodeAt(s + 2),
|
|
652
742
|
t
|
|
653
743
|
);
|
|
654
744
|
}
|
|
655
|
-
function r
|
|
745
|
+
function o(r, s, i) {
|
|
656
746
|
return t.format(
|
|
657
|
-
|
|
747
|
+
r.charCodeAt(0),
|
|
658
748
|
i.charCodeAt(s + 1),
|
|
659
749
|
t
|
|
660
750
|
);
|
|
661
751
|
}
|
|
662
752
|
}
|
|
663
|
-
function
|
|
753
|
+
function Ue(e) {
|
|
664
754
|
let t = A.get(e);
|
|
665
|
-
return t || (t =
|
|
755
|
+
return t || (t = Ze(e), A.set(e, t)), t;
|
|
666
756
|
}
|
|
667
|
-
function
|
|
757
|
+
function Ze(e) {
|
|
668
758
|
const t = [];
|
|
669
759
|
let n = -1;
|
|
670
760
|
for (; ++n < e.length; )
|
|
671
|
-
t.push(e[n].replace(
|
|
761
|
+
t.push(e[n].replace(We, "\\$&"));
|
|
672
762
|
return new RegExp("(?:" + t.join("|") + ")", "g");
|
|
673
763
|
}
|
|
674
|
-
function
|
|
764
|
+
function Xe(e) {
|
|
675
765
|
return "&#x" + e.toString(16).toUpperCase() + ";";
|
|
676
766
|
}
|
|
677
|
-
function
|
|
678
|
-
return
|
|
767
|
+
function Ke(e, t) {
|
|
768
|
+
return He(e, Object.assign({ format: Xe }, t));
|
|
679
769
|
}
|
|
680
|
-
const
|
|
681
|
-
function
|
|
682
|
-
const
|
|
683
|
-
return n ?
|
|
684
|
-
function
|
|
685
|
-
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);
|
|
774
|
+
function r(s) {
|
|
775
|
+
return Ke(s, { subset: t });
|
|
686
776
|
}
|
|
687
777
|
}
|
|
688
|
-
function
|
|
689
|
-
return String(e || "").replace(
|
|
778
|
+
function Ve(e) {
|
|
779
|
+
return String(e || "").replace(Ye, "");
|
|
690
780
|
}
|
|
691
|
-
const
|
|
692
|
-
function
|
|
693
|
-
return "<![CDATA[" +
|
|
781
|
+
const Ge = /]]>/g, Je = [">"];
|
|
782
|
+
function Qe(e) {
|
|
783
|
+
return "<![CDATA[" + k(e.value, Je, Ge) + "]]>";
|
|
694
784
|
}
|
|
695
|
-
function
|
|
696
|
-
return "<!--" +
|
|
785
|
+
function et(e) {
|
|
786
|
+
return "<!--" + k(e.value, ["-"]) + "-->";
|
|
697
787
|
}
|
|
698
|
-
const
|
|
788
|
+
const tt = [" ", `
|
|
699
789
|
`, " ", '"', "&", "'", "/", "<", "=", ">"];
|
|
700
790
|
function S(e) {
|
|
701
|
-
return
|
|
791
|
+
return k(e, tt);
|
|
702
792
|
}
|
|
703
|
-
function
|
|
793
|
+
function P(e, t) {
|
|
704
794
|
const n = String(e);
|
|
705
795
|
if (typeof t != "string")
|
|
706
796
|
throw new TypeError("Expected character");
|
|
707
|
-
let
|
|
708
|
-
for (;
|
|
709
|
-
|
|
710
|
-
return
|
|
797
|
+
let o = 0, r = n.indexOf(t);
|
|
798
|
+
for (; r !== -1; )
|
|
799
|
+
o++, r = n.indexOf(t, r + t.length);
|
|
800
|
+
return o;
|
|
711
801
|
}
|
|
712
802
|
function M(e, t) {
|
|
713
803
|
const n = String(e);
|
|
714
|
-
let
|
|
804
|
+
let o = t.options.quote || '"';
|
|
715
805
|
if (t.options.quoteSmart) {
|
|
716
|
-
const
|
|
717
|
-
|
|
806
|
+
const r = o === '"' ? "'" : '"';
|
|
807
|
+
P(n, o) > P(n, r) && (o = r);
|
|
718
808
|
}
|
|
719
|
-
return
|
|
809
|
+
return o + k(n, ["<", "&", o]) + o;
|
|
720
810
|
}
|
|
721
|
-
function
|
|
722
|
-
const n = S(e.name),
|
|
811
|
+
function nt(e, t) {
|
|
812
|
+
const n = S(e.name), o = e.public, r = e.system;
|
|
723
813
|
let s = "<!DOCTYPE";
|
|
724
|
-
return n !== "" && (s += " " + n),
|
|
814
|
+
return n !== "" && (s += " " + n), o ? s += " PUBLIC " + M(o, t) : r && (s += " SYSTEM"), r && (s += " " + M(r, t)), s + ">";
|
|
725
815
|
}
|
|
726
|
-
const
|
|
727
|
-
function
|
|
728
|
-
const n = S(e.name),
|
|
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 = [];
|
|
729
819
|
let l;
|
|
730
|
-
for (l in
|
|
731
|
-
if (
|
|
732
|
-
const c =
|
|
820
|
+
for (l in r)
|
|
821
|
+
if (ot.call(r, l)) {
|
|
822
|
+
const c = r[l];
|
|
733
823
|
c != null && i.push(S(l) + "=" + M(c, t));
|
|
734
824
|
}
|
|
735
|
-
return "<" + n + (i.length === 0 ? "" : " " + i.join(" ")) + (s ? (t.options.tightClose ? "" : " ") + "/" : "") + ">" +
|
|
825
|
+
return "<" + n + (i.length === 0 ? "" : " " + i.join(" ")) + (s ? (t.options.tightClose ? "" : " ") + "/" : "") + ">" + o + (s ? "" : "</" + n + ">");
|
|
736
826
|
}
|
|
737
|
-
const
|
|
738
|
-
function
|
|
739
|
-
const t = S(e.name) || "x", n =
|
|
827
|
+
const st = /\?>/g, it = [">"];
|
|
828
|
+
function lt(e) {
|
|
829
|
+
const t = S(e.name) || "x", n = k(e.value, it, st);
|
|
740
830
|
return "<?" + t + (n ? " " + n : "") + "?>";
|
|
741
831
|
}
|
|
742
|
-
const
|
|
743
|
-
function
|
|
744
|
-
return
|
|
745
|
-
}
|
|
746
|
-
function
|
|
747
|
-
return t.options.allowDangerousXml ? e.value :
|
|
748
|
-
}
|
|
749
|
-
const
|
|
750
|
-
cdata:
|
|
751
|
-
comment:
|
|
752
|
-
doctype:
|
|
753
|
-
element:
|
|
754
|
-
instruction:
|
|
755
|
-
raw:
|
|
756
|
-
root:
|
|
757
|
-
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
|
|
758
848
|
};
|
|
759
|
-
function
|
|
849
|
+
function oe(e, t) {
|
|
760
850
|
const n = e && e.type;
|
|
761
851
|
if (!n)
|
|
762
852
|
throw new Error("Expected node, not `" + e + "`");
|
|
763
|
-
if (!
|
|
853
|
+
if (!ut.call(_, n))
|
|
764
854
|
throw new Error("Cannot compile unknown node `" + n + "`");
|
|
765
|
-
const
|
|
766
|
-
return
|
|
855
|
+
const o = _[n];
|
|
856
|
+
return o(e, t);
|
|
767
857
|
}
|
|
768
|
-
function
|
|
858
|
+
function re(e, t) {
|
|
769
859
|
const n = e && e.children || [];
|
|
770
|
-
let
|
|
771
|
-
const
|
|
772
|
-
for (; ++
|
|
773
|
-
o
|
|
774
|
-
return
|
|
860
|
+
let o = -1;
|
|
861
|
+
const r = [];
|
|
862
|
+
for (; ++o < n.length; )
|
|
863
|
+
r[o] = oe(n[o], t);
|
|
864
|
+
return r.join("");
|
|
775
865
|
}
|
|
776
|
-
function
|
|
866
|
+
function pt(e, t) {
|
|
777
867
|
const n = { options: {} };
|
|
778
868
|
if (typeof n.options.quote == "string" && n.options.quote !== '"' && n.options.quote !== "'")
|
|
779
869
|
throw new Error(
|
|
780
870
|
"Invalid quote `" + n.options.quote + "`, expected `'` or `\"`"
|
|
781
871
|
);
|
|
782
|
-
const
|
|
783
|
-
return
|
|
872
|
+
const o = Array.isArray(e) ? { type: "root", children: e } : e;
|
|
873
|
+
return oe(o, n);
|
|
784
874
|
}
|
|
785
|
-
function
|
|
786
|
-
const t =
|
|
787
|
-
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);
|
|
788
878
|
}
|
|
789
879
|
export {
|
|
790
|
-
|
|
880
|
+
gt as DIRECTIVE_MAP,
|
|
791
881
|
W as PROOF_SOLUTION_NAMES,
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
882
|
+
kt as markdownToPretext,
|
|
883
|
+
N as mdastToPtxast,
|
|
884
|
+
yt as remarkMath,
|
|
885
|
+
Re as remarkPretext
|
|
796
886
|
};
|