@pretextbook/remark-pretext 0.0.5 → 0.0.6

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