@pretextbook/remark-pretext 0.0.6 → 0.0.7

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