@pretextbook/remark-pretext 0.0.8 → 0.0.10

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