@pretextbook/remark-pretext 0.0.9 → 0.0.11

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