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