@pretextbook/remark-pretext 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/index.cjs +14 -14
- package/dist/index.js +499 -459
- package/dist/lib/directive-map.d.ts +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { visit as V } from "unist-util-visit";
|
|
2
2
|
import { unified as se } from "unified";
|
|
3
3
|
import oe from "remark-parse";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import Ae from "remark-directive";
|
|
5
|
+
import { gfmTable as ot } from "micromark-extension-gfm-table";
|
|
6
|
+
import { gfmTableFromMarkdown as lt } from "mdast-util-gfm-table";
|
|
7
|
+
import { getPtxSchemaChildElementNames as Oe, isPtxSchemaElementName as ct, isTitlelessDivisionType as at, isTopLevelDivisionType as Me, divisionTypeAtRootDepth as ut, divisionTypeAtRelativeDepth as ht, isRootDivisionType as ft, rootChildDivision as te } from "@pretextbook/ptxast";
|
|
8
|
+
const Re = /([\w:.-]+)=(?:"([^"]*)"|'([^']*)'|([^\s"'{}]+))/g, pt = new RegExp(
|
|
9
|
+
String.raw`\s*\{#([\w:.-]+)((?:\s+${Re.source})*)\s*\}$`
|
|
8
10
|
);
|
|
9
|
-
function
|
|
11
|
+
function dt(e, t) {
|
|
10
12
|
const { start: n, end: i } = e.position ?? {}, r = t?.slice(n?.offset, i?.offset) ?? "";
|
|
11
13
|
return r[r.lastIndexOf("{") - 1] === "\\";
|
|
12
14
|
}
|
|
13
|
-
function
|
|
15
|
+
function mt(e, t) {
|
|
14
16
|
V(e, "heading", (n) => {
|
|
15
17
|
const i = n.children[n.children.length - 1];
|
|
16
18
|
if (i?.type !== "text") return;
|
|
17
|
-
const r =
|
|
18
|
-
if (!r ||
|
|
19
|
+
const r = pt.exec(i.value);
|
|
20
|
+
if (!r || dt(n, t)) return;
|
|
19
21
|
const s = {};
|
|
20
|
-
for (const [, c, ...a] of r[2].matchAll(
|
|
22
|
+
for (const [, c, ...a] of r[2].matchAll(Re))
|
|
21
23
|
s[c] = a.find((h) => h !== void 0) ?? "";
|
|
22
24
|
n.data = {
|
|
23
25
|
...n.data,
|
|
@@ -26,20 +28,20 @@ function ft(e, t) {
|
|
|
26
28
|
}, i.value = i.value.slice(0, r.index), i.value || n.children.pop();
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
|
-
const
|
|
31
|
+
const gt = [
|
|
30
32
|
// Display math (check these first, before single $)
|
|
31
33
|
{ open: "$$", close: "$$", isDisplay: !0 },
|
|
32
34
|
{ open: "\\[", close: "\\]", isDisplay: !0 },
|
|
33
35
|
// Inline math
|
|
34
36
|
{ open: "$", close: "$", isDisplay: !1 },
|
|
35
37
|
{ open: "\\(", close: "\\)", isDisplay: !1 }
|
|
36
|
-
], $e = "",
|
|
38
|
+
], $e = "", qe = "", j = new RegExp(`${$e}\\d+${qe}`, "g"), be = /[\p{L}\p{N}]/u;
|
|
37
39
|
function we(e, t) {
|
|
38
40
|
let n = 0;
|
|
39
41
|
for (let i = t - 1; i >= 0 && e[i] === "\\"; i--) n++;
|
|
40
42
|
return n % 2 === 1;
|
|
41
43
|
}
|
|
42
|
-
function
|
|
44
|
+
function yt(e, t) {
|
|
43
45
|
const n = e[t - 1] ?? "", i = e[t + 1] ?? "";
|
|
44
46
|
if (we(e, t) || n === "$" || i === "$" || be.test(n) || i === "" || /\s/.test(i)) return -1;
|
|
45
47
|
let r = e.indexOf("$", t + 1);
|
|
@@ -50,11 +52,11 @@ function dt(e, t) {
|
|
|
50
52
|
return s.includes(`
|
|
51
53
|
`) || s.includes("`") || /\s$/.test(s) || be.test(e[r + 1] ?? "") ? -1 : r;
|
|
52
54
|
}
|
|
53
|
-
function
|
|
55
|
+
function Fe(e, t) {
|
|
54
56
|
let n = null;
|
|
55
|
-
for (const i of
|
|
57
|
+
for (const i of gt) {
|
|
56
58
|
let r = e.indexOf(i.open, t), s = -1;
|
|
57
|
-
for (; r !== -1 && (s = i.open === "$" ?
|
|
59
|
+
for (; r !== -1 && (s = i.open === "$" ? yt(e, r) : e.indexOf(i.close, r + i.open.length), !(s !== -1 || i.open !== "$")); )
|
|
58
60
|
r = e.indexOf(i.open, r + 1);
|
|
59
61
|
if (!(r === -1 || s === -1) && (!n || r < n.index)) {
|
|
60
62
|
const c = e.substring(r + i.open.length, s);
|
|
@@ -63,7 +65,7 @@ function qe(e, t) {
|
|
|
63
65
|
}
|
|
64
66
|
return n;
|
|
65
67
|
}
|
|
66
|
-
function
|
|
68
|
+
function vt(e, t) {
|
|
67
69
|
let n = t;
|
|
68
70
|
for (; n < e.length; ) {
|
|
69
71
|
const i = e.indexOf("`", n);
|
|
@@ -76,20 +78,20 @@ function mt(e, t) {
|
|
|
76
78
|
for (; a < e.length; ) {
|
|
77
79
|
const h = e.indexOf(c, a);
|
|
78
80
|
if (h === -1) break;
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return { start: i, end:
|
|
81
|
+
const f = h + r;
|
|
82
|
+
if (f >= e.length || e[f] !== "`")
|
|
83
|
+
return { start: i, end: f };
|
|
82
84
|
a = h + 1;
|
|
83
85
|
}
|
|
84
86
|
n = i + r;
|
|
85
87
|
}
|
|
86
88
|
return null;
|
|
87
89
|
}
|
|
88
|
-
function
|
|
90
|
+
function Pe(e) {
|
|
89
91
|
const t = /* @__PURE__ */ new Map();
|
|
90
92
|
let n = "", i = 0, r = 0;
|
|
91
93
|
for (; i < e.length; ) {
|
|
92
|
-
const s =
|
|
94
|
+
const s = vt(e, i), c = Fe(e, i);
|
|
93
95
|
if (s && (!c || s.start < c.index)) {
|
|
94
96
|
n += e.substring(i, s.end), i = s.end;
|
|
95
97
|
continue;
|
|
@@ -99,7 +101,7 @@ function Fe(e) {
|
|
|
99
101
|
break;
|
|
100
102
|
}
|
|
101
103
|
n += e.substring(i, c.index);
|
|
102
|
-
const a = `${$e}${r}${
|
|
104
|
+
const a = `${$e}${r}${qe}`;
|
|
103
105
|
n += a;
|
|
104
106
|
const h = c.index + c.pattern.open.length + c.content.length + c.pattern.close.length;
|
|
105
107
|
t.set(a, {
|
|
@@ -111,11 +113,11 @@ function Fe(e) {
|
|
|
111
113
|
}
|
|
112
114
|
return { markdown: n, tokens: t };
|
|
113
115
|
}
|
|
114
|
-
function
|
|
116
|
+
function bt(e) {
|
|
115
117
|
const t = [];
|
|
116
118
|
let n = 0;
|
|
117
119
|
for (; n < e.length; ) {
|
|
118
|
-
const i =
|
|
120
|
+
const i = Fe(e, n);
|
|
119
121
|
if (!i) {
|
|
120
122
|
n < e.length && t.push({ type: "text", value: e.substring(n) });
|
|
121
123
|
break;
|
|
@@ -131,7 +133,7 @@ function gt(e) {
|
|
|
131
133
|
}
|
|
132
134
|
return t.length === 0 ? [{ type: "text", value: e }] : t;
|
|
133
135
|
}
|
|
134
|
-
function
|
|
136
|
+
function wt(e, t) {
|
|
135
137
|
const n = [];
|
|
136
138
|
let i = 0;
|
|
137
139
|
j.lastIndex = 0;
|
|
@@ -144,7 +146,7 @@ function yt(e, t) {
|
|
|
144
146
|
}
|
|
145
147
|
return i < e.length && n.push({ type: "text", value: e.substring(i) }), n.length === 0 ? [{ type: "text", value: e }] : n;
|
|
146
148
|
}
|
|
147
|
-
function
|
|
149
|
+
function je(e, t) {
|
|
148
150
|
V(e, "text", (n, i, r) => {
|
|
149
151
|
if (!r || i === void 0) return;
|
|
150
152
|
const s = r.type === "paragraph" && !r.data?.directiveLabel, c = t(n.value).map(
|
|
@@ -153,24 +155,24 @@ function Pe(e, t) {
|
|
|
153
155
|
return r.children.splice(i, 1, ...c), i + c.length;
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
+
function Xe(e) {
|
|
159
|
+
je(e, bt);
|
|
158
160
|
}
|
|
159
|
-
const
|
|
161
|
+
const xt = ["value", "url", "title", "alt"];
|
|
160
162
|
function U(e, t) {
|
|
161
163
|
return e.replace(j, (n) => t.get(n)?.source ?? n);
|
|
162
164
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
for (const i of
|
|
165
|
+
function Be(e, t) {
|
|
166
|
+
je(e, (n) => wt(n, t)), V(e, (n) => {
|
|
167
|
+
for (const i of xt)
|
|
166
168
|
typeof n[i] == "string" && (n[i] = U(n[i], t));
|
|
167
169
|
for (const [i, r] of Object.entries(n.attributes ?? {}))
|
|
168
170
|
typeof r == "string" && (n.attributes[i] = U(r, t));
|
|
169
171
|
});
|
|
170
172
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
},
|
|
173
|
+
const Ti = () => (e) => {
|
|
174
|
+
Xe(e);
|
|
175
|
+
}, kt = [
|
|
174
176
|
"blockQuote",
|
|
175
177
|
"codeFenced",
|
|
176
178
|
"codeIndented",
|
|
@@ -181,31 +183,34 @@ const yi = () => (e) => {
|
|
|
181
183
|
"setextUnderline",
|
|
182
184
|
"thematicBreak"
|
|
183
185
|
];
|
|
184
|
-
function
|
|
186
|
+
function Et() {
|
|
185
187
|
const e = this.data();
|
|
186
188
|
e.micromarkExtensions = e.micromarkExtensions?.map(
|
|
187
189
|
({ text: t, ...n }) => n
|
|
188
190
|
);
|
|
189
191
|
}
|
|
190
|
-
function
|
|
191
|
-
const { markdown: t, tokens: n } =
|
|
192
|
-
|
|
192
|
+
function Tt(e) {
|
|
193
|
+
const { markdown: t, tokens: n } = Pe(e), r = se().data("micromarkExtensions", [
|
|
194
|
+
{ disable: { null: ["codeIndented"] } },
|
|
195
|
+
ot()
|
|
196
|
+
]).data("fromMarkdownExtensions", [lt()]).use(oe).use(Ae).use(Et).parse(t);
|
|
197
|
+
return Be(r, n), {
|
|
193
198
|
tree: r,
|
|
194
199
|
source: t,
|
|
195
200
|
restoreSource: (s) => U(s, n)
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
|
-
function
|
|
199
|
-
const { markdown: t, tokens: n } =
|
|
203
|
+
function Dt(e) {
|
|
204
|
+
const { markdown: t, tokens: n } = Pe(e);
|
|
200
205
|
for (const s of n.values()) s.meta = "inline";
|
|
201
|
-
const r = se().data("micromarkExtensions", [{ disable: { null:
|
|
202
|
-
return
|
|
206
|
+
const r = se().data("micromarkExtensions", [{ disable: { null: kt } }]).use(oe).parse(t);
|
|
207
|
+
return Be(r, n), {
|
|
203
208
|
tree: r.children.flatMap((s) => s.children),
|
|
204
209
|
source: t,
|
|
205
210
|
restoreSource: (s) => U(s, n)
|
|
206
211
|
};
|
|
207
212
|
}
|
|
208
|
-
function
|
|
213
|
+
function It(e, t = {}) {
|
|
209
214
|
const n = {};
|
|
210
215
|
for (const [i, r] of Object.entries(t))
|
|
211
216
|
r != null && (n[i] = r);
|
|
@@ -216,21 +221,21 @@ function Et(e, t = {}) {
|
|
|
216
221
|
children: []
|
|
217
222
|
};
|
|
218
223
|
}
|
|
219
|
-
function
|
|
224
|
+
function Ct(e) {
|
|
220
225
|
const t = e.name?.trim();
|
|
221
|
-
return t ?
|
|
226
|
+
return t ? It(t, e.attributes ?? {}) : null;
|
|
222
227
|
}
|
|
223
228
|
var ee, xe;
|
|
224
|
-
function
|
|
229
|
+
function St() {
|
|
225
230
|
if (xe) return ee;
|
|
226
231
|
xe = 1;
|
|
227
232
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, r = (l, o) => {
|
|
228
233
|
for (var u in o)
|
|
229
234
|
e(l, u, { get: o[u], enumerable: !0 });
|
|
230
|
-
}, s = (l, o, u,
|
|
235
|
+
}, s = (l, o, u, p) => {
|
|
231
236
|
if (o && typeof o == "object" || typeof o == "function")
|
|
232
237
|
for (let d of n(o))
|
|
233
|
-
!i.call(l, d) && d !== u && e(l, d, { get: () => o[d], enumerable: !(
|
|
238
|
+
!i.call(l, d) && d !== u && e(l, d, { get: () => o[d], enumerable: !(p = t(o, d)) || p.enumerable });
|
|
234
239
|
return l;
|
|
235
240
|
}, c = (l) => s(e({}, "__esModule", { value: !0 }), l), a = {};
|
|
236
241
|
r(a, {
|
|
@@ -241,17 +246,17 @@ function Tt() {
|
|
|
241
246
|
XmlDocumentType: () => me,
|
|
242
247
|
XmlElement: () => G,
|
|
243
248
|
XmlError: () => ge,
|
|
244
|
-
XmlNode: () =>
|
|
249
|
+
XmlNode: () => x,
|
|
245
250
|
XmlProcessingInstruction: () => K,
|
|
246
251
|
XmlText: () => Z,
|
|
247
|
-
parseXml: () =>
|
|
252
|
+
parseXml: () => st
|
|
248
253
|
}), ee = c(a);
|
|
249
|
-
var h = "",
|
|
254
|
+
var h = "", f = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, m = class {
|
|
250
255
|
constructor(l) {
|
|
251
256
|
if (this.k = this.u(l, !0), this.d = 0, this.length = l.length, this.l = this.k !== this.length, this.h = l, this.l) {
|
|
252
257
|
let o = [];
|
|
253
|
-
for (let u = 0,
|
|
254
|
-
o[
|
|
258
|
+
for (let u = 0, p = 0; p < this.k; ++p)
|
|
259
|
+
o[p] = u, u += l.codePointAt(u) > 65535 ? 2 : 1;
|
|
255
260
|
this.A = o;
|
|
256
261
|
}
|
|
257
262
|
}
|
|
@@ -267,7 +272,7 @@ function Tt() {
|
|
|
267
272
|
* the byte length if the string contains multibyte characters.
|
|
268
273
|
*/
|
|
269
274
|
u(l, o = this.l) {
|
|
270
|
-
return o ? l.replace(
|
|
275
|
+
return o ? l.replace(f, "_").length : l.length;
|
|
271
276
|
}
|
|
272
277
|
// -- Public Methods ---------------------------------------------------------
|
|
273
278
|
/**
|
|
@@ -314,16 +319,16 @@ function Tt() {
|
|
|
314
319
|
* reached.
|
|
315
320
|
*/
|
|
316
321
|
w(l) {
|
|
317
|
-
let { length: o, l: u, h:
|
|
322
|
+
let { length: o, l: u, h: p } = this, d = this.f(), y = d;
|
|
318
323
|
if (u)
|
|
319
324
|
for (; y < o; ) {
|
|
320
|
-
let E =
|
|
321
|
-
if (C && (E +=
|
|
325
|
+
let E = p[y], C = E >= "\uD800" && E <= "\uDBFF";
|
|
326
|
+
if (C && (E += p[y + 1]), !l(E))
|
|
322
327
|
break;
|
|
323
328
|
y += C ? 2 : 1;
|
|
324
329
|
}
|
|
325
330
|
else
|
|
326
|
-
for (; y < o && l(
|
|
331
|
+
for (; y < o && l(p[y]); )
|
|
327
332
|
++y;
|
|
328
333
|
return this.v(y - d);
|
|
329
334
|
}
|
|
@@ -379,31 +384,31 @@ function Tt() {
|
|
|
379
384
|
n(l = 0) {
|
|
380
385
|
this.d = l >= 0 ? Math.min(this.k, l) : Math.max(0, this.d + l);
|
|
381
386
|
}
|
|
382
|
-
}, g = /["&<]/,
|
|
387
|
+
}, g = /["&<]/, k = /['&<]/, D = /\r\n|[\n\r\t]/g, T = /<|&|]]>/, N = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
383
388
|
amp: "&",
|
|
384
389
|
apos: "'",
|
|
385
390
|
gt: ">",
|
|
386
391
|
lt: "<",
|
|
387
392
|
quot: '"'
|
|
388
393
|
}));
|
|
389
|
-
function
|
|
394
|
+
function b(l) {
|
|
390
395
|
let o = l.codePointAt(0);
|
|
391
|
-
return o >= 97 && o <= 122 || o >= 65 && o <= 90 || o >= 48 && o <= 57 || o === 45 || o === 46 || o === 183 || o >= 768 && o <= 879 || o === 8255 || o === 8256 ||
|
|
396
|
+
return o >= 97 && o <= 122 || o >= 65 && o <= 90 || o >= 48 && o <= 57 || o === 45 || o === 46 || o === 183 || o >= 768 && o <= 879 || o === 8255 || o === 8256 || w(l, o);
|
|
392
397
|
}
|
|
393
|
-
function
|
|
398
|
+
function w(l, o = l.codePointAt(0)) {
|
|
394
399
|
return o >= 97 && o <= 122 || o >= 65 && o <= 90 || o === 58 || o === 95 || o >= 192 && o <= 214 || o >= 216 && o <= 246 || o >= 248 && o <= 767 || o >= 880 && o <= 893 || o >= 895 && o <= 8191 || o === 8204 || o === 8205 || o >= 8304 && o <= 8591 || o >= 11264 && o <= 12271 || o >= 12289 && o <= 55295 || o >= 63744 && o <= 64975 || o >= 65008 && o <= 65533 || o >= 65536 && o <= 983039;
|
|
395
400
|
}
|
|
396
401
|
function ae(l) {
|
|
397
|
-
return l === "#" ||
|
|
402
|
+
return l === "#" || b(l);
|
|
398
403
|
}
|
|
399
|
-
function
|
|
404
|
+
function it(l) {
|
|
400
405
|
let o = l.codePointAt(0);
|
|
401
406
|
return o === 32 || o === 9 || o === 10 || o === 13;
|
|
402
407
|
}
|
|
403
408
|
function ue(l) {
|
|
404
409
|
return l >= 32 && l <= 55295 || l === 10 || l === 9 || l === 13 || l >= 57344 && l <= 65533 || l >= 65536 && l <= 1114111;
|
|
405
410
|
}
|
|
406
|
-
var S = class
|
|
411
|
+
var S = class Ue {
|
|
407
412
|
constructor() {
|
|
408
413
|
this.parent = null, this.start = -1, this.end = -1;
|
|
409
414
|
}
|
|
@@ -420,7 +425,7 @@ function Tt() {
|
|
|
420
425
|
* document element).
|
|
421
426
|
*/
|
|
422
427
|
get isRootNode() {
|
|
423
|
-
return this.parent !== null && this.parent === this.document && this.type ===
|
|
428
|
+
return this.parent !== null && this.parent === this.document && this.type === Ue.TYPE_ELEMENT;
|
|
424
429
|
}
|
|
425
430
|
/**
|
|
426
431
|
* Whether whitespace should be preserved in the content of this element and
|
|
@@ -462,51 +467,51 @@ function Tt() {
|
|
|
462
467
|
}
|
|
463
468
|
};
|
|
464
469
|
S.TYPE_CDATA = "cdata", S.TYPE_COMMENT = "comment", S.TYPE_DOCUMENT = "document", S.TYPE_DOCUMENT_TYPE = "doctype", S.TYPE_ELEMENT = "element", S.TYPE_PROCESSING_INSTRUCTION = "pi", S.TYPE_TEXT = "text", S.TYPE_XML_DECLARATION = "xmldecl";
|
|
465
|
-
var
|
|
470
|
+
var x = S, Z = class extends x {
|
|
466
471
|
constructor(l = "") {
|
|
467
472
|
super(), this.text = l;
|
|
468
473
|
}
|
|
469
474
|
get type() {
|
|
470
|
-
return
|
|
475
|
+
return x.TYPE_TEXT;
|
|
471
476
|
}
|
|
472
477
|
toJSON() {
|
|
473
|
-
return Object.assign(
|
|
478
|
+
return Object.assign(x.prototype.toJSON.call(this), {
|
|
474
479
|
text: this.text
|
|
475
480
|
});
|
|
476
481
|
}
|
|
477
482
|
}, he = class extends Z {
|
|
478
483
|
get type() {
|
|
479
|
-
return
|
|
484
|
+
return x.TYPE_CDATA;
|
|
480
485
|
}
|
|
481
|
-
}, fe = class extends
|
|
486
|
+
}, fe = class extends x {
|
|
482
487
|
constructor(l = "") {
|
|
483
488
|
super(), this.content = l;
|
|
484
489
|
}
|
|
485
490
|
get type() {
|
|
486
|
-
return
|
|
491
|
+
return x.TYPE_COMMENT;
|
|
487
492
|
}
|
|
488
493
|
toJSON() {
|
|
489
|
-
return Object.assign(
|
|
494
|
+
return Object.assign(x.prototype.toJSON.call(this), {
|
|
490
495
|
content: this.content
|
|
491
496
|
});
|
|
492
497
|
}
|
|
493
|
-
}, pe = class extends
|
|
498
|
+
}, pe = class extends x {
|
|
494
499
|
constructor(l, o, u) {
|
|
495
500
|
super(), this.version = l, this.encoding = o ?? null, this.standalone = u ?? null;
|
|
496
501
|
}
|
|
497
502
|
get type() {
|
|
498
|
-
return
|
|
503
|
+
return x.TYPE_XML_DECLARATION;
|
|
499
504
|
}
|
|
500
505
|
toJSON() {
|
|
501
|
-
let l =
|
|
506
|
+
let l = x.prototype.toJSON.call(this);
|
|
502
507
|
l.version = this.version;
|
|
503
508
|
for (let o of ["encoding", "standalone"])
|
|
504
509
|
this[o] !== null && (l[o] = this[o]);
|
|
505
510
|
return l;
|
|
506
511
|
}
|
|
507
|
-
}, G = class
|
|
508
|
-
constructor(o, u = /* @__PURE__ */ Object.create(null),
|
|
509
|
-
super(), this.name = o, this.attributes = u, this.children =
|
|
512
|
+
}, G = class Ye extends x {
|
|
513
|
+
constructor(o, u = /* @__PURE__ */ Object.create(null), p = []) {
|
|
514
|
+
super(), this.name = o, this.attributes = u, this.children = p;
|
|
510
515
|
}
|
|
511
516
|
/**
|
|
512
517
|
* Whether this element is empty (meaning it has no children).
|
|
@@ -516,7 +521,7 @@ function Tt() {
|
|
|
516
521
|
}
|
|
517
522
|
get preserveWhitespace() {
|
|
518
523
|
let o = this;
|
|
519
|
-
for (; o instanceof
|
|
524
|
+
for (; o instanceof Ye; ) {
|
|
520
525
|
if ("xml:space" in o.attributes)
|
|
521
526
|
return o.attributes["xml:space"] === "preserve";
|
|
522
527
|
o = o.parent;
|
|
@@ -530,16 +535,16 @@ function Tt() {
|
|
|
530
535
|
return this.children.map((o) => "text" in o ? o.text : "").join("");
|
|
531
536
|
}
|
|
532
537
|
get type() {
|
|
533
|
-
return
|
|
538
|
+
return x.TYPE_ELEMENT;
|
|
534
539
|
}
|
|
535
540
|
toJSON() {
|
|
536
|
-
return Object.assign(
|
|
541
|
+
return Object.assign(x.prototype.toJSON.call(this), {
|
|
537
542
|
name: this.name,
|
|
538
543
|
attributes: this.attributes,
|
|
539
544
|
children: this.children.map((o) => o.toJSON())
|
|
540
545
|
});
|
|
541
546
|
}
|
|
542
|
-
}, de = class extends
|
|
547
|
+
}, de = class extends x {
|
|
543
548
|
constructor(l = []) {
|
|
544
549
|
super(), this.children = l;
|
|
545
550
|
}
|
|
@@ -562,22 +567,22 @@ function Tt() {
|
|
|
562
567
|
return this.children.map((l) => "text" in l ? l.text : "").join("");
|
|
563
568
|
}
|
|
564
569
|
get type() {
|
|
565
|
-
return
|
|
570
|
+
return x.TYPE_DOCUMENT;
|
|
566
571
|
}
|
|
567
572
|
toJSON() {
|
|
568
|
-
return Object.assign(
|
|
573
|
+
return Object.assign(x.prototype.toJSON.call(this), {
|
|
569
574
|
children: this.children.map((l) => l.toJSON())
|
|
570
575
|
});
|
|
571
576
|
}
|
|
572
|
-
}, me = class extends
|
|
573
|
-
constructor(l, o, u,
|
|
574
|
-
super(), this.name = l, this.publicId = o ?? null, this.systemId = u ?? null, this.internalSubset =
|
|
577
|
+
}, me = class extends x {
|
|
578
|
+
constructor(l, o, u, p) {
|
|
579
|
+
super(), this.name = l, this.publicId = o ?? null, this.systemId = u ?? null, this.internalSubset = p ?? null;
|
|
575
580
|
}
|
|
576
581
|
get type() {
|
|
577
|
-
return
|
|
582
|
+
return x.TYPE_DOCUMENT_TYPE;
|
|
578
583
|
}
|
|
579
584
|
toJSON() {
|
|
580
|
-
let l =
|
|
585
|
+
let l = x.prototype.toJSON.call(this);
|
|
581
586
|
l.name = this.name;
|
|
582
587
|
for (let o of ["publicId", "systemId", "internalSubset"])
|
|
583
588
|
this[o] !== null && (l[o] = this[o]);
|
|
@@ -585,37 +590,37 @@ function Tt() {
|
|
|
585
590
|
}
|
|
586
591
|
}, ge = class extends Error {
|
|
587
592
|
constructor(l, o, u) {
|
|
588
|
-
let
|
|
593
|
+
let p = 1, d = "", y = 1;
|
|
589
594
|
for (let Q = 0; Q < o; ++Q) {
|
|
590
595
|
let ve = u[Q];
|
|
591
596
|
ve === `
|
|
592
|
-
` ? (
|
|
597
|
+
` ? (p = 1, d = "", y += 1) : (p += 1, d += ve);
|
|
593
598
|
}
|
|
594
599
|
let E = u.indexOf(`
|
|
595
600
|
`, o);
|
|
596
601
|
d += E === -1 ? u.slice(o) : u.slice(o, E);
|
|
597
602
|
let C = 0;
|
|
598
|
-
d.length > 50 && (
|
|
599
|
-
`${l} (line ${y}, column ${
|
|
603
|
+
d.length > 50 && (p < 40 ? d = d.slice(0, 50) : (C = p - 20, d = d.slice(C, p + 30))), super(
|
|
604
|
+
`${l} (line ${y}, column ${p})
|
|
600
605
|
${d}
|
|
601
|
-
` + " ".repeat(
|
|
606
|
+
` + " ".repeat(p - C + 1) + `^
|
|
602
607
|
`
|
|
603
|
-
), this.column =
|
|
608
|
+
), this.column = p, this.excerpt = d, this.line = y, this.name = "XmlError", this.pos = o;
|
|
604
609
|
}
|
|
605
|
-
}, K = class extends
|
|
610
|
+
}, K = class extends x {
|
|
606
611
|
constructor(l, o = "") {
|
|
607
612
|
super(), this.name = l, this.content = o;
|
|
608
613
|
}
|
|
609
614
|
get type() {
|
|
610
|
-
return
|
|
615
|
+
return x.TYPE_PROCESSING_INSTRUCTION;
|
|
611
616
|
}
|
|
612
617
|
toJSON() {
|
|
613
|
-
return Object.assign(
|
|
618
|
+
return Object.assign(x.prototype.toJSON.call(this), {
|
|
614
619
|
name: this.name,
|
|
615
620
|
content: this.content
|
|
616
621
|
});
|
|
617
622
|
}
|
|
618
|
-
}, ye = "",
|
|
623
|
+
}, ye = "", rt = class {
|
|
619
624
|
/**
|
|
620
625
|
* @param xml XML string to parse.
|
|
621
626
|
* @param options Parser options.
|
|
@@ -640,10 +645,10 @@ function Tt() {
|
|
|
640
645
|
* subject to line break normalization.
|
|
641
646
|
*/
|
|
642
647
|
y(l, o, u = !0) {
|
|
643
|
-
let { children:
|
|
648
|
+
let { children: p } = this.j, { length: d } = p;
|
|
644
649
|
if (u && (l = F(l)), d > 0) {
|
|
645
|
-
let y =
|
|
646
|
-
if (y?.type ===
|
|
650
|
+
let y = p[d - 1];
|
|
651
|
+
if (y?.type === x.TYPE_TEXT) {
|
|
647
652
|
let E = y;
|
|
648
653
|
return E.text += l, this.g.includeOffsets && (E.end = this.c.f()), !0;
|
|
649
654
|
}
|
|
@@ -672,8 +677,8 @@ function Tt() {
|
|
|
672
677
|
}
|
|
673
678
|
if (this.g.sortAttributes) {
|
|
674
679
|
let o = Object.keys(l).sort(), u = /* @__PURE__ */ Object.create(null);
|
|
675
|
-
for (let
|
|
676
|
-
let d = o[
|
|
680
|
+
for (let p = 0; p < o.length; ++p) {
|
|
681
|
+
let d = o[p];
|
|
677
682
|
u[d] = l[d];
|
|
678
683
|
}
|
|
679
684
|
l = u;
|
|
@@ -695,11 +700,11 @@ function Tt() {
|
|
|
695
700
|
if (o !== '"' && o !== "'")
|
|
696
701
|
return !1;
|
|
697
702
|
l.p();
|
|
698
|
-
let u,
|
|
703
|
+
let u, p = !1, d = ye, y = o === '"' ? g : k;
|
|
699
704
|
e: for (; !l.B; )
|
|
700
|
-
switch (u = l.x(y), u && (this.o(u), d += u.replace(
|
|
705
|
+
switch (u = l.x(y), u && (this.o(u), d += u.replace(D, " ")), l.m()) {
|
|
701
706
|
case o:
|
|
702
|
-
|
|
707
|
+
p = !0;
|
|
703
708
|
break e;
|
|
704
709
|
case "&":
|
|
705
710
|
d += this.C();
|
|
@@ -709,7 +714,7 @@ function Tt() {
|
|
|
709
714
|
default:
|
|
710
715
|
break e;
|
|
711
716
|
}
|
|
712
|
-
if (!
|
|
717
|
+
if (!p)
|
|
713
718
|
throw this.a("Unclosed attribute");
|
|
714
719
|
return l.p(), d;
|
|
715
720
|
}
|
|
@@ -735,7 +740,7 @@ function Tt() {
|
|
|
735
740
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#dt-chardata
|
|
736
741
|
*/
|
|
737
742
|
K() {
|
|
738
|
-
let { c: l } = this, o = l.d, u = l.x(
|
|
743
|
+
let { c: l } = this, o = l.d, u = l.x(T);
|
|
739
744
|
if (!u)
|
|
740
745
|
return !1;
|
|
741
746
|
if (this.o(u), l.m(3) === "]]>")
|
|
@@ -786,14 +791,14 @@ function Tt() {
|
|
|
786
791
|
let u = this.e() && this.q();
|
|
787
792
|
if (!u)
|
|
788
793
|
throw this.a("Expected a name");
|
|
789
|
-
let
|
|
794
|
+
let p, d;
|
|
790
795
|
if (this.e()) {
|
|
791
796
|
if (l.b("PUBLIC")) {
|
|
792
|
-
if (
|
|
797
|
+
if (p = this.e() && this.N(), p === !1)
|
|
793
798
|
throw this.a("Expected a public identifier");
|
|
794
799
|
this.e();
|
|
795
800
|
}
|
|
796
|
-
if (
|
|
801
|
+
if (p !== void 0 || l.b("SYSTEM")) {
|
|
797
802
|
if (this.e(), d = this.r(), d === !1)
|
|
798
803
|
throw this.a("Expected a system identifier");
|
|
799
804
|
this.e();
|
|
@@ -807,7 +812,7 @@ function Tt() {
|
|
|
807
812
|
}
|
|
808
813
|
if (!l.b(">"))
|
|
809
814
|
throw this.a("Unclosed doctype declaration");
|
|
810
|
-
return this.g.preserveDocumentType ? this.i(new me(u,
|
|
815
|
+
return this.g.preserveDocumentType ? this.i(new me(u, p, d, y), o) : !0;
|
|
811
816
|
}
|
|
812
817
|
/**
|
|
813
818
|
* Consumes an element if possible.
|
|
@@ -822,7 +827,7 @@ function Tt() {
|
|
|
822
827
|
let u = this.q();
|
|
823
828
|
if (!u)
|
|
824
829
|
return l.n(o), !1;
|
|
825
|
-
let
|
|
830
|
+
let p = this.H(), d = !!l.b("/>"), y = new G(u, p);
|
|
826
831
|
if (y.parent = this.j, !d) {
|
|
827
832
|
if (!l.b(">"))
|
|
828
833
|
throw this.a(`Unclosed start tag for element \`${u}\``);
|
|
@@ -864,7 +869,7 @@ function Tt() {
|
|
|
864
869
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name
|
|
865
870
|
*/
|
|
866
871
|
q() {
|
|
867
|
-
return
|
|
872
|
+
return w(this.c.m()) ? this.c.w(b) : ye;
|
|
868
873
|
}
|
|
869
874
|
/**
|
|
870
875
|
* Consumes a processing instruction if possible.
|
|
@@ -887,10 +892,10 @@ function Tt() {
|
|
|
887
892
|
return this.i(new K(u), o);
|
|
888
893
|
throw this.a("Whitespace is required after a processing instruction name");
|
|
889
894
|
}
|
|
890
|
-
let
|
|
891
|
-
if (this.o(
|
|
895
|
+
let p = l.s("?>");
|
|
896
|
+
if (this.o(p), !l.b("?>"))
|
|
892
897
|
throw this.a("Unterminated processing instruction");
|
|
893
|
-
return this.i(new K(u, F(
|
|
898
|
+
return this.i(new K(u, F(p)), o);
|
|
894
899
|
}
|
|
895
900
|
/**
|
|
896
901
|
* Consumes a prolog if possible.
|
|
@@ -944,15 +949,15 @@ function Tt() {
|
|
|
944
949
|
throw this.a("Unterminated reference (a reference must end with `;`)");
|
|
945
950
|
let u;
|
|
946
951
|
if (o[0] === "#") {
|
|
947
|
-
let
|
|
948
|
-
if (isNaN(
|
|
952
|
+
let p = o[1] === "x" ? parseInt(o.slice(2), 16) : parseInt(o.slice(1), 10);
|
|
953
|
+
if (isNaN(p) || !/^#(?:x[0-9A-Fa-f]+|[0-9]+)$/.test(o))
|
|
949
954
|
throw this.a("Invalid character reference");
|
|
950
|
-
if (!ue(
|
|
955
|
+
if (!ue(p))
|
|
951
956
|
throw this.a("Character reference resolves to an invalid character");
|
|
952
|
-
u = String.fromCodePoint(
|
|
953
|
-
} else if (u =
|
|
957
|
+
u = String.fromCodePoint(p);
|
|
958
|
+
} else if (u = N[o], u === void 0) {
|
|
954
959
|
let {
|
|
955
|
-
ignoreUndefinedEntities:
|
|
960
|
+
ignoreUndefinedEntities: p,
|
|
956
961
|
resolveUndefinedEntity: d
|
|
957
962
|
} = this.g, y = `&${o};`;
|
|
958
963
|
if (d) {
|
|
@@ -964,7 +969,7 @@ function Tt() {
|
|
|
964
969
|
return E;
|
|
965
970
|
}
|
|
966
971
|
}
|
|
967
|
-
if (
|
|
972
|
+
if (p)
|
|
968
973
|
return y;
|
|
969
974
|
throw l.n(-y.length), this.a(`Named entity isn't defined: ${y}`);
|
|
970
975
|
}
|
|
@@ -999,7 +1004,7 @@ function Tt() {
|
|
|
999
1004
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#white
|
|
1000
1005
|
*/
|
|
1001
1006
|
e() {
|
|
1002
|
-
return !!this.c.w(
|
|
1007
|
+
return !!this.c.w(it);
|
|
1003
1008
|
}
|
|
1004
1009
|
/**
|
|
1005
1010
|
* Consumes an XML declaration if possible.
|
|
@@ -1018,10 +1023,10 @@ function Tt() {
|
|
|
1018
1023
|
throw this.a("XML version is missing or invalid");
|
|
1019
1024
|
if (!/^1\.[0-9]+$/.test(u))
|
|
1020
1025
|
throw this.a("Invalid character in version number");
|
|
1021
|
-
let
|
|
1026
|
+
let p, d;
|
|
1022
1027
|
if (this.e()) {
|
|
1023
|
-
if (
|
|
1024
|
-
if (!/^[A-Za-z][\w.-]*$/.test(
|
|
1028
|
+
if (p = !!l.b("encoding") && this.t() && this.r(), p) {
|
|
1029
|
+
if (!/^[A-Za-z][\w.-]*$/.test(p))
|
|
1025
1030
|
throw this.a("Invalid character in encoding name");
|
|
1026
1031
|
this.e();
|
|
1027
1032
|
}
|
|
@@ -1035,7 +1040,7 @@ function Tt() {
|
|
|
1035
1040
|
throw this.a("Invalid or unclosed XML declaration");
|
|
1036
1041
|
return this.g.preserveXmlDeclaration ? this.i(new pe(
|
|
1037
1042
|
u,
|
|
1038
|
-
|
|
1043
|
+
p || void 0,
|
|
1039
1044
|
d || void 0
|
|
1040
1045
|
), o) : !0;
|
|
1041
1046
|
}
|
|
@@ -1064,10 +1069,10 @@ function Tt() {
|
|
|
1064
1069
|
o(l) {
|
|
1065
1070
|
let { length: o } = l;
|
|
1066
1071
|
for (let u = 0; u < o; ++u) {
|
|
1067
|
-
let
|
|
1068
|
-
if (!ue(
|
|
1072
|
+
let p = l.codePointAt(u);
|
|
1073
|
+
if (!ue(p))
|
|
1069
1074
|
throw this.c.n(-([...l].length - u)), this.a("Invalid character");
|
|
1070
|
-
|
|
1075
|
+
p > 65535 && (u += 1);
|
|
1071
1076
|
}
|
|
1072
1077
|
}
|
|
1073
1078
|
};
|
|
@@ -1079,13 +1084,13 @@ function Tt() {
|
|
|
1079
1084
|
` + l.slice(o + 1);
|
|
1080
1085
|
return l;
|
|
1081
1086
|
}
|
|
1082
|
-
function
|
|
1083
|
-
return new
|
|
1087
|
+
function st(l, o) {
|
|
1088
|
+
return new rt(l, o).document;
|
|
1084
1089
|
}
|
|
1085
1090
|
return ee;
|
|
1086
1091
|
}
|
|
1087
|
-
var
|
|
1088
|
-
function
|
|
1092
|
+
var Lt = St();
|
|
1093
|
+
function Nt(e) {
|
|
1089
1094
|
const t = String(e), n = [];
|
|
1090
1095
|
return { toOffset: r, toPoint: i };
|
|
1091
1096
|
function i(s) {
|
|
@@ -1110,9 +1115,9 @@ function Ct(e) {
|
|
|
1110
1115
|
function r(s) {
|
|
1111
1116
|
if (s && typeof s.line == "number" && typeof s.column == "number" && !Number.isNaN(s.line) && !Number.isNaN(s.column)) {
|
|
1112
1117
|
for (; n.length < s.line; ) {
|
|
1113
|
-
const a = n[n.length - 1], h = ke(t, a),
|
|
1114
|
-
if (a ===
|
|
1115
|
-
n.push(
|
|
1118
|
+
const a = n[n.length - 1], h = ke(t, a), f = h === -1 ? t.length + 1 : h + 1;
|
|
1119
|
+
if (a === f) break;
|
|
1120
|
+
n.push(f);
|
|
1116
1121
|
}
|
|
1117
1122
|
const c = (s.line > 1 ? n[s.line - 2] : 0) + s.column - 1;
|
|
1118
1123
|
if (c < n[s.line - 1]) return c;
|
|
@@ -1124,16 +1129,16 @@ function ke(e, t) {
|
|
|
1124
1129
|
`, t);
|
|
1125
1130
|
return i === -1 ? n : n === -1 || n + 1 === i ? i : n < i ? n : i;
|
|
1126
1131
|
}
|
|
1127
|
-
function
|
|
1132
|
+
function _t(e) {
|
|
1128
1133
|
return !e || typeof e != "object" ? "" : "position" in e || "type" in e ? Ee(e.position) : "start" in e || "end" in e ? Ee(e) : "line" in e || "column" in e ? ne(e) : "";
|
|
1129
1134
|
}
|
|
1130
1135
|
function ne(e) {
|
|
1131
|
-
return
|
|
1136
|
+
return Te(e && e.line) + ":" + Te(e && e.column);
|
|
1132
1137
|
}
|
|
1133
1138
|
function Ee(e) {
|
|
1134
1139
|
return ne(e && e.start) + "-" + ne(e && e.end);
|
|
1135
1140
|
}
|
|
1136
|
-
function
|
|
1141
|
+
function Te(e) {
|
|
1137
1142
|
return e && typeof e == "number" ? e : 1;
|
|
1138
1143
|
}
|
|
1139
1144
|
class I extends Error {
|
|
@@ -1207,7 +1212,7 @@ class I extends Error {
|
|
|
1207
1212
|
h && (s.place = h.position);
|
|
1208
1213
|
}
|
|
1209
1214
|
const a = s.place && "start" in s.place ? s.place.start : s.place;
|
|
1210
|
-
this.ancestors = s.ancestors || void 0, this.cause = s.cause || void 0, this.column = a ? a.column : void 0, this.fatal = void 0, this.file = "", this.message = r, this.line = a ? a.line : void 0, this.name =
|
|
1215
|
+
this.ancestors = s.ancestors || void 0, this.cause = s.cause || void 0, this.column = a ? a.column : void 0, this.fatal = void 0, this.file = "", this.message = r, this.line = a ? a.line : void 0, this.name = _t(s.place) || "1:1", this.place = s.place || void 0, this.reason = this.message, this.ruleId = s.ruleId || void 0, this.source = s.source || void 0, this.stack = c && s.cause && typeof s.cause.stack == "string" ? s.cause.stack : "", this.actual = void 0, this.expected = void 0, this.note = void 0, this.url = void 0;
|
|
1211
1216
|
}
|
|
1212
1217
|
}
|
|
1213
1218
|
I.prototype.file = "";
|
|
@@ -1223,11 +1228,11 @@ I.prototype.fatal = void 0;
|
|
|
1223
1228
|
I.prototype.place = void 0;
|
|
1224
1229
|
I.prototype.ruleId = void 0;
|
|
1225
1230
|
I.prototype.source = void 0;
|
|
1226
|
-
function
|
|
1227
|
-
const t =
|
|
1231
|
+
function At(e) {
|
|
1232
|
+
const t = Nt(e);
|
|
1228
1233
|
let n;
|
|
1229
1234
|
try {
|
|
1230
|
-
n =
|
|
1235
|
+
n = Lt.parseXml(String(e), {
|
|
1231
1236
|
// Positional offsets.
|
|
1232
1237
|
includeOffsets: !0,
|
|
1233
1238
|
// `<![CDATA[>&<]]>`
|
|
@@ -1254,19 +1259,19 @@ function Lt(e) {
|
|
|
1254
1259
|
);
|
|
1255
1260
|
throw h.fatal = !0, h.url = "https://github.com/syntax-tree/xast-util-from-xml#throws", h;
|
|
1256
1261
|
}
|
|
1257
|
-
const i = { location: t }, r =
|
|
1258
|
-
return
|
|
1262
|
+
const i = { location: t }, r = Rt(n, i);
|
|
1263
|
+
return Je(n, r, i), r;
|
|
1259
1264
|
}
|
|
1260
|
-
function
|
|
1265
|
+
function Ot(e) {
|
|
1261
1266
|
return { type: "cdata", value: e.text };
|
|
1262
1267
|
}
|
|
1263
|
-
function
|
|
1268
|
+
function Mt(e) {
|
|
1264
1269
|
return { type: "comment", value: e.content };
|
|
1265
1270
|
}
|
|
1266
|
-
function
|
|
1267
|
-
return { type: "root", children:
|
|
1271
|
+
function Rt(e, t) {
|
|
1272
|
+
return { type: "root", children: ze(e.children, t) };
|
|
1268
1273
|
}
|
|
1269
|
-
function
|
|
1274
|
+
function $t(e) {
|
|
1270
1275
|
return {
|
|
1271
1276
|
type: "doctype",
|
|
1272
1277
|
name: e.name,
|
|
@@ -1274,8 +1279,8 @@ function Ot(e) {
|
|
|
1274
1279
|
system: e.systemId || void 0
|
|
1275
1280
|
};
|
|
1276
1281
|
}
|
|
1277
|
-
function
|
|
1278
|
-
const n =
|
|
1282
|
+
function qt(e, t) {
|
|
1283
|
+
const n = ze(e.children, t);
|
|
1279
1284
|
return {
|
|
1280
1285
|
type: "element",
|
|
1281
1286
|
name: e.name,
|
|
@@ -1284,49 +1289,49 @@ function Mt(e, t) {
|
|
|
1284
1289
|
children: n
|
|
1285
1290
|
};
|
|
1286
1291
|
}
|
|
1287
|
-
function
|
|
1292
|
+
function Ft(e) {
|
|
1288
1293
|
return { type: "instruction", name: e.name, value: e.content };
|
|
1289
1294
|
}
|
|
1290
|
-
function
|
|
1295
|
+
function Pt(e) {
|
|
1291
1296
|
return { type: "text", value: e.text };
|
|
1292
1297
|
}
|
|
1293
|
-
function
|
|
1298
|
+
function jt(e) {
|
|
1294
1299
|
const t = [];
|
|
1295
1300
|
return e.version && t.push('version="' + e.version + '"'), e.encoding && t.push('encoding="' + e.encoding + '"'), e.standalone && t.push('standalone="' + e.standalone + '"'), { type: "instruction", name: "xml", value: t.join(" ") };
|
|
1296
1301
|
}
|
|
1297
|
-
function
|
|
1302
|
+
function ze(e, t) {
|
|
1298
1303
|
const n = [];
|
|
1299
1304
|
let i = -1;
|
|
1300
1305
|
for (; ++i < e.length; ) {
|
|
1301
1306
|
const r = e[i];
|
|
1302
1307
|
let s;
|
|
1303
|
-
r.type === "cdata" ? s =
|
|
1308
|
+
r.type === "cdata" ? s = Ot(
|
|
1304
1309
|
/** @type {XmlCdata} */
|
|
1305
1310
|
r
|
|
1306
|
-
) : r.type === "comment" ? s =
|
|
1311
|
+
) : r.type === "comment" ? s = Mt(
|
|
1307
1312
|
/** @type {XmlComment} */
|
|
1308
1313
|
r
|
|
1309
|
-
) : r.type === "doctype" ? s =
|
|
1314
|
+
) : r.type === "doctype" ? s = $t(
|
|
1310
1315
|
/** @type {XmlDocumentType} */
|
|
1311
1316
|
r
|
|
1312
|
-
) : r.type === "element" ? s =
|
|
1317
|
+
) : r.type === "element" ? s = qt(
|
|
1313
1318
|
/** @type {XmlElement} */
|
|
1314
1319
|
r,
|
|
1315
1320
|
t
|
|
1316
|
-
) : r.type === "pi" ? s =
|
|
1321
|
+
) : r.type === "pi" ? s = Ft(
|
|
1317
1322
|
/** @type {XmlProcessingInstruction} */
|
|
1318
1323
|
r
|
|
1319
|
-
) : r.type === "text" ? s =
|
|
1324
|
+
) : r.type === "text" ? s = Pt(
|
|
1320
1325
|
/** @type {XmlText} */
|
|
1321
1326
|
r
|
|
1322
|
-
) : r.type === "xmldecl" && (s =
|
|
1327
|
+
) : r.type === "xmldecl" && (s = jt(
|
|
1323
1328
|
/** @type {XmlDeclaration} */
|
|
1324
1329
|
r
|
|
1325
|
-
)), s && (
|
|
1330
|
+
)), s && (Je(r, s, t), n.push(s));
|
|
1326
1331
|
}
|
|
1327
1332
|
return n;
|
|
1328
1333
|
}
|
|
1329
|
-
function
|
|
1334
|
+
function Je(e, t, n) {
|
|
1330
1335
|
const i = (
|
|
1331
1336
|
// Doesn’t practically happen as far as I found, but `-1` is used in the
|
|
1332
1337
|
// code, so let’s keep it in.
|
|
@@ -1339,7 +1344,7 @@ function ze(e, t, n) {
|
|
|
1339
1344
|
);
|
|
1340
1345
|
i && r && (t.position = { start: i, end: r });
|
|
1341
1346
|
}
|
|
1342
|
-
const
|
|
1347
|
+
const Xt = /<!--[\s\S]*?-->/g, le = /* @__PURE__ */ new Set(["me", "men", "mdn"]), Bt = /* @__PURE__ */ new Set([
|
|
1343
1348
|
...le,
|
|
1344
1349
|
"c",
|
|
1345
1350
|
"cd",
|
|
@@ -1348,39 +1353,39 @@ const Ft = /<!--[\s\S]*?-->/g, le = /* @__PURE__ */ new Set(["me", "men", "mdn"]
|
|
|
1348
1353
|
"md",
|
|
1349
1354
|
"mrow",
|
|
1350
1355
|
"pre"
|
|
1351
|
-
]),
|
|
1356
|
+
]), Ut = /* @__PURE__ */ new Set([
|
|
1352
1357
|
"blockquote",
|
|
1353
1358
|
"containerDirective",
|
|
1354
1359
|
"listItem",
|
|
1355
1360
|
"root"
|
|
1356
|
-
]),
|
|
1361
|
+
]), We = /* @__PURE__ */ new Set([
|
|
1357
1362
|
...le,
|
|
1358
|
-
...
|
|
1363
|
+
...Oe("p")
|
|
1359
1364
|
]);
|
|
1360
|
-
for (const e of
|
|
1361
|
-
|
|
1362
|
-
function
|
|
1363
|
-
return
|
|
1365
|
+
for (const e of Oe("section"))
|
|
1366
|
+
We.delete(e);
|
|
1367
|
+
function Yt(e) {
|
|
1368
|
+
return ct(e) || le.has(e);
|
|
1364
1369
|
}
|
|
1365
|
-
function
|
|
1370
|
+
function $(e) {
|
|
1366
1371
|
let t;
|
|
1367
1372
|
try {
|
|
1368
|
-
t =
|
|
1373
|
+
t = At(`<raw>${e.replace(Xt, "")}</raw>`);
|
|
1369
1374
|
} catch {
|
|
1370
1375
|
return null;
|
|
1371
1376
|
}
|
|
1372
1377
|
const i = t.children.find((s) => s.type === "element").children;
|
|
1373
1378
|
return i.every(
|
|
1374
|
-
(s) => s.type === "element" ?
|
|
1379
|
+
(s) => s.type === "element" ? Yt(s.name) : s.type !== "instruction"
|
|
1375
1380
|
) ? i : null;
|
|
1376
1381
|
}
|
|
1377
|
-
function
|
|
1378
|
-
const t =
|
|
1382
|
+
function zt(e) {
|
|
1383
|
+
const t = $(e);
|
|
1379
1384
|
if (t) return { children: t };
|
|
1380
|
-
const [n] =
|
|
1385
|
+
const [n] = $(e.replace(/>$/, "/>")) ?? [];
|
|
1381
1386
|
return n?.type === "element" ? { children: [], opens: n } : null;
|
|
1382
1387
|
}
|
|
1383
|
-
function
|
|
1388
|
+
function Jt(e, t, n) {
|
|
1384
1389
|
const i = new RegExp(`^<${n}(\\s[^]*)?(?<!/)>$`), r = new RegExp(`^</${n}\\s*>$`);
|
|
1385
1390
|
let s = 1;
|
|
1386
1391
|
for (let c = t + 1; c < e.length; c += 1) {
|
|
@@ -1390,11 +1395,11 @@ function Ut(e, t, n) {
|
|
|
1390
1395
|
}
|
|
1391
1396
|
return -1;
|
|
1392
1397
|
}
|
|
1393
|
-
function
|
|
1398
|
+
function Wt(e) {
|
|
1394
1399
|
const t = [];
|
|
1395
1400
|
let n = null;
|
|
1396
1401
|
for (const i of e) {
|
|
1397
|
-
if (i.type === "element" && !
|
|
1402
|
+
if (i.type === "element" && !We.has(i.name)) {
|
|
1398
1403
|
t.push(i), n = null;
|
|
1399
1404
|
continue;
|
|
1400
1405
|
}
|
|
@@ -1402,8 +1407,8 @@ function Yt(e) {
|
|
|
1402
1407
|
}
|
|
1403
1408
|
return t;
|
|
1404
1409
|
}
|
|
1405
|
-
function
|
|
1406
|
-
const r =
|
|
1410
|
+
function Vt(e, t, n, i) {
|
|
1411
|
+
const r = $(e[t].value);
|
|
1407
1412
|
if (r) return { nodes: r, end: t };
|
|
1408
1413
|
const s = e[t].position?.start.offset;
|
|
1409
1414
|
if (n === void 0 || s === void 0) return null;
|
|
@@ -1412,20 +1417,20 @@ function zt(e, t, n, i) {
|
|
|
1412
1417
|
const h = e[a].position?.end.offset;
|
|
1413
1418
|
if (!n.slice(c, h).includes("</")) continue;
|
|
1414
1419
|
c = h;
|
|
1415
|
-
const
|
|
1416
|
-
if (
|
|
1420
|
+
const f = $(i(n.slice(s, h)));
|
|
1421
|
+
if (f) return { nodes: f, end: a };
|
|
1417
1422
|
}
|
|
1418
1423
|
return null;
|
|
1419
1424
|
}
|
|
1420
|
-
function
|
|
1425
|
+
function Ht(e, t, n) {
|
|
1421
1426
|
V(e, (i) => {
|
|
1422
|
-
if (!
|
|
1427
|
+
if (!Ut.has(i.type)) return;
|
|
1423
1428
|
const r = i.children;
|
|
1424
1429
|
for (let s = 0; s < r.length; s += 1) {
|
|
1425
1430
|
if (r[s].type !== "html") continue;
|
|
1426
|
-
const c =
|
|
1431
|
+
const c = Vt(r, s, t, n);
|
|
1427
1432
|
if (!c) continue;
|
|
1428
|
-
const a =
|
|
1433
|
+
const a = Wt(c.nodes).map(
|
|
1429
1434
|
(h) => ({ type: "ptxRaw", element: h })
|
|
1430
1435
|
);
|
|
1431
1436
|
r.splice(s, c.end - s + 1, ...a), s += a.length - 1;
|
|
@@ -1571,12 +1576,15 @@ const H = {
|
|
|
1571
1576
|
type: "answer",
|
|
1572
1577
|
category: "solution-like",
|
|
1573
1578
|
requiresStatement: !1
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1579
|
+
},
|
|
1580
|
+
// figure-like (a titled wrapper around one piece of content, which for
|
|
1581
|
+
// `table` is a pipe table → <tabular>: `:::table[Caption]{#id}`)
|
|
1582
|
+
table: { type: "table", category: "figure-like", requiresStatement: !1 }
|
|
1583
|
+
}, Di = H;
|
|
1584
|
+
function Zt(e) {
|
|
1577
1585
|
return H[e.toLowerCase()];
|
|
1578
1586
|
}
|
|
1579
|
-
const
|
|
1587
|
+
const Ve = new Set(
|
|
1580
1588
|
Object.entries(H).filter(
|
|
1581
1589
|
([e, t]) => t.category === "proof-like" || t.category === "solution-like"
|
|
1582
1590
|
).map(([e]) => e)
|
|
@@ -1592,8 +1600,8 @@ function M(e, t, n) {
|
|
|
1592
1600
|
function P(e) {
|
|
1593
1601
|
return e.type === "containerDirective" && e.name === "task";
|
|
1594
1602
|
}
|
|
1595
|
-
function
|
|
1596
|
-
return e.type === "containerDirective" &&
|
|
1603
|
+
function Gt(e) {
|
|
1604
|
+
return e.type === "containerDirective" && Ve.has(e.name);
|
|
1597
1605
|
}
|
|
1598
1606
|
function Y(e) {
|
|
1599
1607
|
const t = [];
|
|
@@ -1601,56 +1609,56 @@ function Y(e) {
|
|
|
1601
1609
|
n.name === "ul" || n.name === "ol" ? t.length > 0 && t[t.length - 1]?.name === "p" ? t[t.length - 1].children.push(n) : t.push(M("p", [n])) : t.push(n);
|
|
1602
1610
|
return t;
|
|
1603
1611
|
}
|
|
1604
|
-
function
|
|
1612
|
+
function Kt(e, t, n, i, r, s, c) {
|
|
1605
1613
|
const a = [];
|
|
1606
1614
|
if (n && a.push(n), e.hasNestedTasks) {
|
|
1607
1615
|
const h = i.findIndex(P);
|
|
1608
1616
|
if (h !== -1) {
|
|
1609
|
-
const
|
|
1610
|
-
for (let
|
|
1611
|
-
P(i[
|
|
1612
|
-
const m =
|
|
1613
|
-
for (let
|
|
1614
|
-
const
|
|
1615
|
-
if (!P(
|
|
1616
|
-
if (
|
|
1617
|
-
|
|
1617
|
+
const f = [];
|
|
1618
|
+
for (let b = 0; b < i.length; b++)
|
|
1619
|
+
P(i[b]) && f.push(b);
|
|
1620
|
+
const m = f[f.length - 1], g = i.slice(0, h), k = i.slice(h).filter(P), D = [], T = [], N = [];
|
|
1621
|
+
for (let b = h; b < i.length; b++) {
|
|
1622
|
+
const w = i[b];
|
|
1623
|
+
if (!P(w)) {
|
|
1624
|
+
if (b < m) {
|
|
1625
|
+
D.push(w);
|
|
1618
1626
|
continue;
|
|
1619
1627
|
}
|
|
1620
|
-
if (
|
|
1621
|
-
|
|
1628
|
+
if (Gt(w)) {
|
|
1629
|
+
N.push(w);
|
|
1622
1630
|
continue;
|
|
1623
1631
|
}
|
|
1624
|
-
|
|
1632
|
+
T.push(w);
|
|
1625
1633
|
}
|
|
1626
1634
|
}
|
|
1627
|
-
if (
|
|
1635
|
+
if (D.length > 0 && (r.messages ?? (r.messages = [])).push({
|
|
1628
1636
|
type: "warning",
|
|
1629
|
-
reason: `Dropped ${
|
|
1637
|
+
reason: `Dropped ${D.length} non-task node(s) between task directives in ${e.type}.`,
|
|
1630
1638
|
category: "dropped-content-between-tasks",
|
|
1631
|
-
position:
|
|
1639
|
+
position: D[0].position?.start
|
|
1632
1640
|
}), g.length > 0) {
|
|
1633
|
-
const
|
|
1634
|
-
g.map((
|
|
1641
|
+
const b = Y(
|
|
1642
|
+
g.map((w) => s(w, r)).filter((w) => w !== null)
|
|
1635
1643
|
);
|
|
1636
|
-
|
|
1644
|
+
b.length > 0 && a.push(M("introduction", b));
|
|
1637
1645
|
}
|
|
1638
|
-
for (const
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1646
|
+
for (const b of k) {
|
|
1647
|
+
const w = c(b, r);
|
|
1648
|
+
w && a.push(w);
|
|
1641
1649
|
}
|
|
1642
|
-
if (
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1650
|
+
if (T.length > 0) {
|
|
1651
|
+
const b = Y(
|
|
1652
|
+
T.map((w) => s(w, r)).filter((w) => w !== null)
|
|
1645
1653
|
);
|
|
1646
|
-
|
|
1654
|
+
b.length > 0 && a.push(M("conclusion", b));
|
|
1647
1655
|
}
|
|
1648
|
-
for (const
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1656
|
+
for (const b of N) {
|
|
1657
|
+
const w = c(b, r);
|
|
1658
|
+
w && a.push(w);
|
|
1651
1659
|
}
|
|
1652
1660
|
} else
|
|
1653
|
-
|
|
1661
|
+
De(
|
|
1654
1662
|
a,
|
|
1655
1663
|
e,
|
|
1656
1664
|
i,
|
|
@@ -1659,7 +1667,7 @@ function Ht(e, t, n, i, r, s, c) {
|
|
|
1659
1667
|
c
|
|
1660
1668
|
);
|
|
1661
1669
|
} else
|
|
1662
|
-
|
|
1670
|
+
De(
|
|
1663
1671
|
a,
|
|
1664
1672
|
e,
|
|
1665
1673
|
i,
|
|
@@ -1669,18 +1677,18 @@ function Ht(e, t, n, i, r, s, c) {
|
|
|
1669
1677
|
);
|
|
1670
1678
|
return M(e.type, a, t);
|
|
1671
1679
|
}
|
|
1672
|
-
function
|
|
1680
|
+
function De(e, t, n, i, r, s) {
|
|
1673
1681
|
if (t.requiresStatement) {
|
|
1674
1682
|
const c = [], a = [];
|
|
1675
1683
|
for (const h of n)
|
|
1676
|
-
if (h.type === "containerDirective" &&
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1684
|
+
if (h.type === "containerDirective" && Ve.has(h.name)) {
|
|
1685
|
+
const f = s(h, i);
|
|
1686
|
+
f && a.push(f);
|
|
1679
1687
|
} else
|
|
1680
1688
|
c.push(h);
|
|
1681
1689
|
if (c.length > 0) {
|
|
1682
1690
|
const h = Y(
|
|
1683
|
-
c.map((
|
|
1691
|
+
c.map((f) => r(f, i)).filter((f) => f !== null)
|
|
1684
1692
|
);
|
|
1685
1693
|
h.length > 0 && e.push(M("statement", h));
|
|
1686
1694
|
}
|
|
@@ -1692,10 +1700,10 @@ function Te(e, t, n, i, r, s) {
|
|
|
1692
1700
|
e.push(...c);
|
|
1693
1701
|
}
|
|
1694
1702
|
}
|
|
1695
|
-
function
|
|
1703
|
+
function He(e) {
|
|
1696
1704
|
return { type: "text", value: e };
|
|
1697
1705
|
}
|
|
1698
|
-
function
|
|
1706
|
+
function v(e, t, n) {
|
|
1699
1707
|
return {
|
|
1700
1708
|
type: "element",
|
|
1701
1709
|
name: e,
|
|
@@ -1704,9 +1712,9 @@ function k(e, t, n) {
|
|
|
1704
1712
|
};
|
|
1705
1713
|
}
|
|
1706
1714
|
function _(e, t, n) {
|
|
1707
|
-
return
|
|
1715
|
+
return v(e, [He(t)], n);
|
|
1708
1716
|
}
|
|
1709
|
-
function
|
|
1717
|
+
function Ze(e) {
|
|
1710
1718
|
return { type: "comment", value: e.replace(/--/g, "- -") };
|
|
1711
1719
|
}
|
|
1712
1720
|
function q(e, t) {
|
|
@@ -1714,27 +1722,27 @@ function q(e, t) {
|
|
|
1714
1722
|
return t.source && i != null && r != null ? t.restoreSource(t.source.slice(i, r)) : "";
|
|
1715
1723
|
}
|
|
1716
1724
|
function ce(e, t, n) {
|
|
1717
|
-
return
|
|
1725
|
+
return v("TODO", [Ze(`todo: ${t}`), _("pre", n)], {
|
|
1718
1726
|
type: e
|
|
1719
1727
|
});
|
|
1720
1728
|
}
|
|
1721
|
-
function
|
|
1722
|
-
return
|
|
1729
|
+
function Qt(e, t, n) {
|
|
1730
|
+
return v("TODO", [Ze(`todo: ${t}`), _("c", n)], {
|
|
1723
1731
|
type: e
|
|
1724
1732
|
});
|
|
1725
1733
|
}
|
|
1726
1734
|
function z(e) {
|
|
1727
1735
|
const t = [];
|
|
1728
1736
|
for (const n of e)
|
|
1729
|
-
n.name === "ul" || n.name === "ol" ? t.length > 0 && t[t.length - 1]?.name === "p" ? t[t.length - 1].children.push(n) : t.push(
|
|
1737
|
+
n.name === "ul" || n.name === "ol" ? t.length > 0 && t[t.length - 1]?.name === "p" ? t[t.length - 1].children.push(n) : t.push(v("p", [n])) : t.push(n);
|
|
1730
1738
|
return t;
|
|
1731
1739
|
}
|
|
1732
1740
|
function Ie(e, t, n) {
|
|
1733
|
-
return
|
|
1741
|
+
return en(e, t, n).tree;
|
|
1734
1742
|
}
|
|
1735
|
-
function
|
|
1743
|
+
function en(e, t, n) {
|
|
1736
1744
|
const i = [], r = n?.restoreSource ?? ((g) => g);
|
|
1737
|
-
|
|
1745
|
+
Ht(e, t, r), mt(e, t);
|
|
1738
1746
|
const s = {
|
|
1739
1747
|
ancestors: [],
|
|
1740
1748
|
depth: 0,
|
|
@@ -1748,90 +1756,90 @@ function Gt(e, t, n) {
|
|
|
1748
1756
|
topLevelTitle: n?.topLevelTitle
|
|
1749
1757
|
}, c = e.children;
|
|
1750
1758
|
if (s.documentRoot) {
|
|
1751
|
-
const g = B(s),
|
|
1752
|
-
...
|
|
1753
|
-
...
|
|
1754
|
-
...
|
|
1759
|
+
const g = B(s), k = s.topLevelTitle ? Ce(s.topLevelTitle, s) : null, { introduction: D, rest: T } = X(c, s), N = s.documentRoot === "slideshow" && tn(T) ? nn(T, s) : A(T, s), b = [
|
|
1760
|
+
...k ? [k] : [],
|
|
1761
|
+
...D ? [D] : [],
|
|
1762
|
+
...N
|
|
1755
1763
|
];
|
|
1756
1764
|
return {
|
|
1757
|
-
tree: { type: "root", children: [
|
|
1765
|
+
tree: { type: "root", children: [v(s.documentRoot, b, g)] },
|
|
1758
1766
|
messages: i
|
|
1759
1767
|
};
|
|
1760
1768
|
}
|
|
1761
|
-
if (
|
|
1762
|
-
const g = B(s),
|
|
1769
|
+
if (at(s.topLevelDivision)) {
|
|
1770
|
+
const g = B(s), k = z(
|
|
1763
1771
|
A(c, { ...s, depth: 1 }, !0)
|
|
1764
1772
|
);
|
|
1765
1773
|
return {
|
|
1766
|
-
tree: { type: "root", children: [
|
|
1774
|
+
tree: { type: "root", children: [v(s.topLevelDivision, k, g)] },
|
|
1767
1775
|
messages: i
|
|
1768
1776
|
};
|
|
1769
1777
|
}
|
|
1770
1778
|
if (s.topLevelTitle) {
|
|
1771
|
-
const g = B(s),
|
|
1779
|
+
const g = B(s), k = Ce(s.topLevelTitle, s), D = {
|
|
1772
1780
|
...s,
|
|
1773
1781
|
depth: s.depth + 1,
|
|
1774
1782
|
headingDepthOffset: (s.headingDepthOffset ?? 0) + 1
|
|
1775
|
-
}, { introduction:
|
|
1776
|
-
A(
|
|
1777
|
-
),
|
|
1783
|
+
}, { introduction: T, rest: N } = X(c, D), b = z(
|
|
1784
|
+
A(N, D, !0)
|
|
1785
|
+
), w = T ? [k, T, ...b] : [k, ...b];
|
|
1778
1786
|
return {
|
|
1779
|
-
tree: { type: "root", children: [
|
|
1787
|
+
tree: { type: "root", children: [v(s.topLevelDivision, w, g)] },
|
|
1780
1788
|
messages: i
|
|
1781
1789
|
};
|
|
1782
1790
|
}
|
|
1783
|
-
const { introduction: a, rest: h } = X(c, s),
|
|
1791
|
+
const { introduction: a, rest: h } = X(c, s), f = A(h, s);
|
|
1784
1792
|
return {
|
|
1785
|
-
tree: { type: "root", children: a ? [a, ...
|
|
1793
|
+
tree: { type: "root", children: a ? [a, ...f] : f },
|
|
1786
1794
|
messages: i
|
|
1787
1795
|
};
|
|
1788
1796
|
}
|
|
1789
1797
|
function Ce(e, t) {
|
|
1790
|
-
const { tree: n, source: i, restoreSource: r } =
|
|
1791
|
-
return
|
|
1798
|
+
const { tree: n, source: i, restoreSource: r } = Dt(e);
|
|
1799
|
+
return v(
|
|
1792
1800
|
"title",
|
|
1793
|
-
|
|
1801
|
+
L(n, { ...t, source: i, restoreSource: r })
|
|
1794
1802
|
);
|
|
1795
1803
|
}
|
|
1796
|
-
function
|
|
1804
|
+
function tn(e) {
|
|
1797
1805
|
return e.some((t) => t.type === "thematicBreak");
|
|
1798
1806
|
}
|
|
1799
|
-
function
|
|
1807
|
+
function nn(e, t) {
|
|
1800
1808
|
return A(e, t);
|
|
1801
1809
|
}
|
|
1802
1810
|
function A(e, t, n = !1) {
|
|
1803
1811
|
let i = 7;
|
|
1804
|
-
for (const
|
|
1805
|
-
|
|
1812
|
+
for (const f of e)
|
|
1813
|
+
f.type === "heading" && (i = Math.min(i, f.depth));
|
|
1806
1814
|
if (i === 7)
|
|
1807
|
-
return
|
|
1815
|
+
return R(e, t, n);
|
|
1808
1816
|
const r = [];
|
|
1809
1817
|
let s = null, c = [], a = [];
|
|
1810
1818
|
const h = () => {
|
|
1811
|
-
s && (r.push(
|
|
1819
|
+
s && (r.push(rn(s, a, t)), s = null, a = []);
|
|
1812
1820
|
};
|
|
1813
|
-
for (const
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
), c = []), h(), s =
|
|
1821
|
+
for (const f of e)
|
|
1822
|
+
f.type === "heading" && f.depth === i ? (!s && c.length > 0 && (r.push(
|
|
1823
|
+
...R(c, t, n)
|
|
1824
|
+
), c = []), h(), s = f, a = []) : s ? a.push(f) : c.push(f);
|
|
1817
1825
|
return !s && c.length > 0 && r.push(
|
|
1818
|
-
|
|
1826
|
+
...R(c, t, n)
|
|
1819
1827
|
), h(), r;
|
|
1820
1828
|
}
|
|
1821
|
-
function
|
|
1829
|
+
function R(e, t, n = !1) {
|
|
1822
1830
|
const i = [];
|
|
1823
1831
|
for (let r = 0; r < e.length; r += 1) {
|
|
1824
1832
|
const s = e[r], c = J(s, t);
|
|
1825
1833
|
if (c !== null) {
|
|
1826
1834
|
if (c.name === "p" && c.children.length === 1 && c.children[0].name === "md") {
|
|
1827
|
-
const a = c.children[0], h = i[i.length - 1],
|
|
1835
|
+
const a = c.children[0], h = i[i.length - 1], f = r + 1 < e.length ? J(e[r + 1], t) : null, m = f?.name === "p" ? f.children : null;
|
|
1828
1836
|
if (h?.name === "p")
|
|
1829
1837
|
h.children.push(a), m && (h.children.push(
|
|
1830
1838
|
...m
|
|
1831
1839
|
), r += 1);
|
|
1832
1840
|
else {
|
|
1833
1841
|
const g = [a];
|
|
1834
|
-
m && (g.push(...m), r += 1), i.push(
|
|
1842
|
+
m && (g.push(...m), r += 1), i.push(v("p", g));
|
|
1835
1843
|
}
|
|
1836
1844
|
continue;
|
|
1837
1845
|
}
|
|
@@ -1847,28 +1855,28 @@ function $(e, t, n = !1) {
|
|
|
1847
1855
|
}
|
|
1848
1856
|
return n ? z(i) : i;
|
|
1849
1857
|
}
|
|
1850
|
-
function
|
|
1851
|
-
const i = e.depth + (n.headingDepthOffset ?? 0), r = n.documentRoot ?
|
|
1852
|
-
return
|
|
1858
|
+
function rn(e, t, n) {
|
|
1859
|
+
const i = e.depth + (n.headingDepthOffset ?? 0), r = n.documentRoot ? ut(n.documentRoot, i) : ht(n.topLevelDivision, i), s = v("title", L(e.children, n)), c = ln(e, n), a = { ...n, depth: n.depth + 1 }, { introduction: h, rest: f } = X(t, a), m = A(f, a, !0), g = z(m), k = h ? [s, h, ...g] : [s, ...g];
|
|
1860
|
+
return v(r, k, c);
|
|
1853
1861
|
}
|
|
1854
|
-
function
|
|
1855
|
-
return e.type === "leafDirective" &&
|
|
1862
|
+
function sn(e) {
|
|
1863
|
+
return e.type === "leafDirective" && Me(e.name);
|
|
1856
1864
|
}
|
|
1857
1865
|
function X(e, t) {
|
|
1858
1866
|
const n = e.findIndex(
|
|
1859
|
-
(a) => a.type === "heading" ||
|
|
1867
|
+
(a) => a.type === "heading" || sn(a)
|
|
1860
1868
|
);
|
|
1861
1869
|
if (n <= 0)
|
|
1862
1870
|
return { introduction: null, rest: e };
|
|
1863
|
-
const i = e.slice(0, n), r = e.slice(n), s =
|
|
1864
|
-
return { introduction: s.length > 0 ?
|
|
1871
|
+
const i = e.slice(0, n), r = e.slice(n), s = R(i, t, !0);
|
|
1872
|
+
return { introduction: s.length > 0 ? v("introduction", s) : null, rest: r };
|
|
1865
1873
|
}
|
|
1866
|
-
function
|
|
1874
|
+
function on(e) {
|
|
1867
1875
|
const t = e.data;
|
|
1868
1876
|
return t?.id ? { ...t.attributes, "xml:id": t.id } : void 0;
|
|
1869
1877
|
}
|
|
1870
|
-
function
|
|
1871
|
-
const n =
|
|
1878
|
+
function ln(e, t) {
|
|
1879
|
+
const n = on(e), i = B(t);
|
|
1872
1880
|
if (!(!n && !i))
|
|
1873
1881
|
return { ...i, ...n };
|
|
1874
1882
|
}
|
|
@@ -1878,17 +1886,18 @@ function B(e) {
|
|
|
1878
1886
|
if (!(!e.topLevelAttributes || !t || t.done))
|
|
1879
1887
|
return t.done = !0, e.topLevelAttributes;
|
|
1880
1888
|
}
|
|
1881
|
-
const
|
|
1882
|
-
paragraph: (e, t) =>
|
|
1883
|
-
blockquote: (e, t) =>
|
|
1884
|
-
list: (e, t) =>
|
|
1885
|
-
code: (e, t) =>
|
|
1886
|
-
|
|
1887
|
-
|
|
1889
|
+
const cn = {
|
|
1890
|
+
paragraph: (e, t) => an(e, t),
|
|
1891
|
+
blockquote: (e, t) => un(e, t),
|
|
1892
|
+
list: (e, t) => hn(e, t),
|
|
1893
|
+
code: (e, t) => pn(e),
|
|
1894
|
+
table: (e, t) => dn(e, t),
|
|
1895
|
+
containerDirective: (e, t) => Ge(e, t),
|
|
1896
|
+
leafDirective: (e, t) => bn(e, t),
|
|
1888
1897
|
ptxRaw: (e) => e.element
|
|
1889
1898
|
};
|
|
1890
1899
|
function J(e, t) {
|
|
1891
|
-
const n =
|
|
1900
|
+
const n = cn[e.type];
|
|
1892
1901
|
return n ? n(e, t) : (t.messages && t.messages.push({
|
|
1893
1902
|
type: "warning",
|
|
1894
1903
|
reason: `Unknown block type: ${e.type}`,
|
|
@@ -1899,10 +1908,10 @@ function J(e, t) {
|
|
|
1899
1908
|
q(e, t)
|
|
1900
1909
|
));
|
|
1901
1910
|
}
|
|
1902
|
-
function
|
|
1903
|
-
return
|
|
1911
|
+
function an(e, t) {
|
|
1912
|
+
return v("p", L(e.children, t));
|
|
1904
1913
|
}
|
|
1905
|
-
function
|
|
1914
|
+
function un(e, t) {
|
|
1906
1915
|
const n = e.children.filter((i) => i.type === "paragraph" || i.type === "ptxRaw").map((i) => {
|
|
1907
1916
|
const r = {
|
|
1908
1917
|
...t,
|
|
@@ -1911,49 +1920,80 @@ function ln(e, t) {
|
|
|
1911
1920
|
};
|
|
1912
1921
|
return J(i, r);
|
|
1913
1922
|
});
|
|
1914
|
-
return
|
|
1923
|
+
return v("blockquote", n);
|
|
1915
1924
|
}
|
|
1916
|
-
function
|
|
1925
|
+
function hn(e, t) {
|
|
1917
1926
|
const n = e.children.map((i) => {
|
|
1918
1927
|
const r = {
|
|
1919
1928
|
...t,
|
|
1920
1929
|
ancestors: [...t.ancestors, e],
|
|
1921
1930
|
depth: t.depth + 1
|
|
1922
1931
|
};
|
|
1923
|
-
return
|
|
1932
|
+
return fn(i, r);
|
|
1924
1933
|
});
|
|
1925
|
-
return
|
|
1934
|
+
return v(e.ordered ? "ol" : "ul", n);
|
|
1926
1935
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const n =
|
|
1936
|
+
function fn(e, t) {
|
|
1937
|
+
const n = R(
|
|
1929
1938
|
e.children,
|
|
1930
1939
|
t
|
|
1931
1940
|
);
|
|
1932
|
-
return
|
|
1941
|
+
return v("li", n);
|
|
1933
1942
|
}
|
|
1934
|
-
function
|
|
1943
|
+
function pn(e, t) {
|
|
1935
1944
|
return _(
|
|
1936
1945
|
"program",
|
|
1937
1946
|
e.value,
|
|
1938
1947
|
e.lang ? { language: e.lang } : void 0
|
|
1939
1948
|
);
|
|
1940
1949
|
}
|
|
1941
|
-
function
|
|
1950
|
+
function dn(e, t) {
|
|
1951
|
+
const [n, ...i] = e.children, r = n?.children.length ?? 0, s = Array.from(
|
|
1952
|
+
{ length: r },
|
|
1953
|
+
(m, g) => e.align?.[g] ?? null
|
|
1954
|
+
), c = {
|
|
1955
|
+
...t,
|
|
1956
|
+
ancestors: [...t.ancestors, e],
|
|
1957
|
+
depth: t.depth + 1
|
|
1958
|
+
}, a = [];
|
|
1959
|
+
n && !mn(n) && a.push(Se(n, r, c, { header: "yes" }));
|
|
1960
|
+
for (const m of i) a.push(Se(m, r, c));
|
|
1961
|
+
const h = s.every((m) => m === s[0]) ? s[0] : void 0;
|
|
1962
|
+
if (h) return v("tabular", a, { halign: h });
|
|
1963
|
+
if (h === null) return v("tabular", a);
|
|
1964
|
+
const f = s.map((m) => v("col", [], m ? { halign: m } : void 0));
|
|
1965
|
+
return v("tabular", [...f, ...a]);
|
|
1966
|
+
}
|
|
1967
|
+
function mn(e) {
|
|
1968
|
+
return e.children.every(
|
|
1969
|
+
(t) => t.children.every(
|
|
1970
|
+
(n) => n.type === "text" && n.value.trim() === ""
|
|
1971
|
+
)
|
|
1972
|
+
);
|
|
1973
|
+
}
|
|
1974
|
+
function Se(e, t, n, i) {
|
|
1975
|
+
const r = e.children.map(
|
|
1976
|
+
(s) => v("cell", L(s.children, n))
|
|
1977
|
+
);
|
|
1978
|
+
for (; r.length < t; ) r.push(v("cell", []));
|
|
1979
|
+
return v("row", r, i);
|
|
1980
|
+
}
|
|
1981
|
+
function gn(e, t) {
|
|
1942
1982
|
const n = e.value.split(/\\\\|[\r\n]+/).map((i) => i.trim()).filter((i) => i.length > 0);
|
|
1943
|
-
return n.length > 1 ?
|
|
1983
|
+
return n.length > 1 ? v(
|
|
1944
1984
|
"md",
|
|
1945
1985
|
n.map((i) => _("mrow", i))
|
|
1946
1986
|
) : _("md", n[0] ?? "");
|
|
1947
1987
|
}
|
|
1948
|
-
function
|
|
1949
|
-
return e.meta === "inline" ? _("m", e.value) :
|
|
1988
|
+
function yn(e, t) {
|
|
1989
|
+
return e.meta === "inline" ? _("m", e.value) : gn(e);
|
|
1950
1990
|
}
|
|
1951
|
-
function
|
|
1952
|
-
const n =
|
|
1953
|
-
return /^#./.test(e.url) ?
|
|
1991
|
+
function vn(e, t) {
|
|
1992
|
+
const n = L(e.children, t);
|
|
1993
|
+
return /^#./.test(e.url) ? v("xref", n, { ref: e.url.slice(1) }) : v("url", n, { href: e.url });
|
|
1954
1994
|
}
|
|
1955
|
-
function
|
|
1956
|
-
const n =
|
|
1995
|
+
function bn(e, t) {
|
|
1996
|
+
const n = Ct(e);
|
|
1957
1997
|
return n || (t.messages && t.messages.push({
|
|
1958
1998
|
type: "warning",
|
|
1959
1999
|
reason: "Unnamed leaf directive",
|
|
@@ -1964,8 +2004,8 @@ function dn(e, t) {
|
|
|
1964
2004
|
q(e, t)
|
|
1965
2005
|
));
|
|
1966
2006
|
}
|
|
1967
|
-
function
|
|
1968
|
-
const n =
|
|
2007
|
+
function Ge(e, t) {
|
|
2008
|
+
const n = Zt(e.name);
|
|
1969
2009
|
if (!n)
|
|
1970
2010
|
return t.messages && t.messages.push({
|
|
1971
2011
|
type: "warning",
|
|
@@ -1976,7 +2016,7 @@ function Ze(e, t) {
|
|
|
1976
2016
|
`unknown directive "${e.name}"`,
|
|
1977
2017
|
q(e, t)
|
|
1978
2018
|
);
|
|
1979
|
-
const i =
|
|
2019
|
+
const i = xn(e), r = e.children, { title: s, body: c } = wn(
|
|
1980
2020
|
r,
|
|
1981
2021
|
t
|
|
1982
2022
|
), a = {
|
|
@@ -1984,87 +2024,87 @@ function Ze(e, t) {
|
|
|
1984
2024
|
ancestors: [...t.ancestors, e],
|
|
1985
2025
|
depth: t.depth + 1
|
|
1986
2026
|
};
|
|
1987
|
-
return
|
|
2027
|
+
return Kt(
|
|
1988
2028
|
n,
|
|
1989
2029
|
i,
|
|
1990
2030
|
s,
|
|
1991
2031
|
c,
|
|
1992
2032
|
a,
|
|
1993
|
-
(h,
|
|
1994
|
-
(h,
|
|
2033
|
+
(h, f) => J(h, f),
|
|
2034
|
+
(h, f) => Ge(h, f)
|
|
1995
2035
|
);
|
|
1996
2036
|
}
|
|
1997
|
-
function
|
|
2037
|
+
function wn(e, t) {
|
|
1998
2038
|
const n = e[0];
|
|
1999
2039
|
return n?.type === "paragraph" && n.data?.directiveLabel === !0 ? {
|
|
2000
|
-
title:
|
|
2040
|
+
title: v(
|
|
2001
2041
|
"title",
|
|
2002
|
-
|
|
2042
|
+
L(n.children, t)
|
|
2003
2043
|
),
|
|
2004
2044
|
body: e.slice(1)
|
|
2005
2045
|
} : { title: null, body: e };
|
|
2006
2046
|
}
|
|
2007
|
-
function
|
|
2047
|
+
function xn(e) {
|
|
2008
2048
|
const t = e.attributes ?? {}, n = {};
|
|
2009
2049
|
for (const [i, r] of Object.entries(t))
|
|
2010
2050
|
r != null && (n[i === "id" ? "xml:id" : i] = r);
|
|
2011
2051
|
return Object.keys(n).length > 0 ? n : void 0;
|
|
2012
2052
|
}
|
|
2013
|
-
function
|
|
2053
|
+
function kn(e, t) {
|
|
2014
2054
|
return !t || e.position?.start?.offset === null || e.position?.start?.offset === void 0 ? "asterisk" : t.charAt(e.position.start.offset) === "_" ? "underscore" : "asterisk";
|
|
2015
2055
|
}
|
|
2016
|
-
const
|
|
2017
|
-
text: (e, t) =>
|
|
2056
|
+
const En = {
|
|
2057
|
+
text: (e, t) => He(e.value),
|
|
2018
2058
|
emphasis: (e, t) => {
|
|
2019
|
-
const i =
|
|
2020
|
-
return
|
|
2059
|
+
const i = kn(e, t.source) === "underscore" ? "term" : "em";
|
|
2060
|
+
return v(i, L(e.children, t));
|
|
2021
2061
|
},
|
|
2022
|
-
strong: (e, t) =>
|
|
2062
|
+
strong: (e, t) => v("alert", L(e.children, t)),
|
|
2023
2063
|
inlineCode: (e, t) => _("c", e.value),
|
|
2024
|
-
math: (e, t) =>
|
|
2025
|
-
link: (e, t) =>
|
|
2064
|
+
math: (e, t) => yn(e),
|
|
2065
|
+
link: (e, t) => vn(e, t)
|
|
2026
2066
|
};
|
|
2027
|
-
function
|
|
2067
|
+
function L(e, t) {
|
|
2028
2068
|
const n = [];
|
|
2029
2069
|
for (let i = 0; i < e.length; i += 1) {
|
|
2030
|
-
const r =
|
|
2070
|
+
const r = Tn(e, i, t);
|
|
2031
2071
|
if (r) {
|
|
2032
2072
|
n.push(...r.children), i = r.end;
|
|
2033
2073
|
continue;
|
|
2034
2074
|
}
|
|
2035
|
-
const s =
|
|
2075
|
+
const s = Dn(e[i], t);
|
|
2036
2076
|
s !== null && n.push(s);
|
|
2037
2077
|
}
|
|
2038
2078
|
return n;
|
|
2039
2079
|
}
|
|
2040
|
-
function
|
|
2080
|
+
function Tn(e, t, n) {
|
|
2041
2081
|
const i = e[t];
|
|
2042
2082
|
if (i.type !== "html") return null;
|
|
2043
|
-
const r =
|
|
2083
|
+
const r = zt(i.value);
|
|
2044
2084
|
if (!r) return null;
|
|
2045
2085
|
const { opens: s } = r;
|
|
2046
2086
|
if (!s)
|
|
2047
2087
|
return { children: r.children, end: t };
|
|
2048
|
-
const c =
|
|
2088
|
+
const c = Jt(e, t, s.name);
|
|
2049
2089
|
if (c === -1) return null;
|
|
2050
|
-
if (
|
|
2051
|
-
const
|
|
2090
|
+
if (Bt.has(s.name)) {
|
|
2091
|
+
const f = {
|
|
2052
2092
|
start: i.position?.start,
|
|
2053
2093
|
end: e[c].position?.end
|
|
2054
|
-
}, m =
|
|
2094
|
+
}, m = $(q({ position: f }, n));
|
|
2055
2095
|
return m && { children: m, end: c };
|
|
2056
2096
|
}
|
|
2057
|
-
const a =
|
|
2097
|
+
const a = L(e.slice(t + 1, c), n);
|
|
2058
2098
|
return { children: [{ ...s, children: a }], end: c };
|
|
2059
2099
|
}
|
|
2060
|
-
function
|
|
2061
|
-
const n =
|
|
2100
|
+
function Dn(e, t) {
|
|
2101
|
+
const n = En[e.type];
|
|
2062
2102
|
if (!n)
|
|
2063
2103
|
return t.messages && t.messages.push({
|
|
2064
2104
|
type: "warning",
|
|
2065
2105
|
reason: `Unknown inline type: ${e.type}`,
|
|
2066
2106
|
category: "unknown-inline-type"
|
|
2067
|
-
}),
|
|
2107
|
+
}), Qt(
|
|
2068
2108
|
"unknown-inline-type",
|
|
2069
2109
|
`unknown inline type "${e.type}"`,
|
|
2070
2110
|
q(e, t)
|
|
@@ -2072,7 +2112,7 @@ function wn(e, t) {
|
|
|
2072
2112
|
const i = { ...t, ancestors: [...t.ancestors, e] };
|
|
2073
2113
|
return n(e, i);
|
|
2074
2114
|
}
|
|
2075
|
-
function
|
|
2115
|
+
function In(e) {
|
|
2076
2116
|
const t = e.trim();
|
|
2077
2117
|
if (!t.startsWith(":")) return null;
|
|
2078
2118
|
let n = 0;
|
|
@@ -2089,7 +2129,7 @@ function xn(e) {
|
|
|
2089
2129
|
isOpen: !0
|
|
2090
2130
|
} : null;
|
|
2091
2131
|
}
|
|
2092
|
-
function
|
|
2132
|
+
function Cn(e) {
|
|
2093
2133
|
const t = [], n = [];
|
|
2094
2134
|
for (const i of e)
|
|
2095
2135
|
if (i.isOpen) {
|
|
@@ -2114,16 +2154,16 @@ function kn(e) {
|
|
|
2114
2154
|
}
|
|
2115
2155
|
return n;
|
|
2116
2156
|
}
|
|
2117
|
-
function
|
|
2157
|
+
function Ke(e) {
|
|
2118
2158
|
if (e.children.length === 0)
|
|
2119
2159
|
e.finalColons = e.colons;
|
|
2120
2160
|
else {
|
|
2121
|
-
const t = Math.max(...e.children.map(
|
|
2161
|
+
const t = Math.max(...e.children.map(Ke));
|
|
2122
2162
|
e.finalColons = Math.max(e.colons, t + 1);
|
|
2123
2163
|
}
|
|
2124
2164
|
return e.finalColons;
|
|
2125
2165
|
}
|
|
2126
|
-
function
|
|
2166
|
+
function Sn(e, t, n) {
|
|
2127
2167
|
const i = e.slice(), r = [], s = t.slice();
|
|
2128
2168
|
for (; s.length > 0; ) {
|
|
2129
2169
|
const c = s.shift();
|
|
@@ -2131,38 +2171,38 @@ function En(e, t, n) {
|
|
|
2131
2171
|
}
|
|
2132
2172
|
for (const c of r) {
|
|
2133
2173
|
if (c.openLineIndex >= 0) {
|
|
2134
|
-
const a = i[c.openLineIndex], h = a.match(/^:+/)?.[0].length || 3,
|
|
2135
|
-
i[c.openLineIndex] = ":".repeat(c.finalColons) +
|
|
2174
|
+
const a = i[c.openLineIndex], h = a.match(/^:+/)?.[0].length || 3, f = a.slice(h);
|
|
2175
|
+
i[c.openLineIndex] = ":".repeat(c.finalColons) + f;
|
|
2136
2176
|
}
|
|
2137
2177
|
c.closeLineIndex !== null && c.closeLineIndex >= 0 && (i[c.closeLineIndex] = ":".repeat(c.finalColons));
|
|
2138
2178
|
}
|
|
2139
2179
|
return i;
|
|
2140
2180
|
}
|
|
2141
|
-
function
|
|
2181
|
+
function Ln(e) {
|
|
2142
2182
|
const t = e.split(`
|
|
2143
2183
|
`), n = [];
|
|
2144
2184
|
let i = !1, r = null;
|
|
2145
2185
|
for (let a = 0; a < t.length; a++) {
|
|
2146
2186
|
const h = t[a], m = h.trim().match(/^(`{3,}|~{3,})/);
|
|
2147
2187
|
if (m) {
|
|
2148
|
-
const
|
|
2149
|
-
i ? r &&
|
|
2188
|
+
const k = m[1];
|
|
2189
|
+
i ? r && k[0] === r[0] && k.length >= r.length && (i = !1, r = null) : (i = !0, r = k);
|
|
2150
2190
|
continue;
|
|
2151
2191
|
}
|
|
2152
2192
|
if (i)
|
|
2153
2193
|
continue;
|
|
2154
|
-
const g =
|
|
2194
|
+
const g = In(h);
|
|
2155
2195
|
g && n.push({ ...g, lineIndex: a });
|
|
2156
2196
|
}
|
|
2157
2197
|
if (n.length === 0)
|
|
2158
2198
|
return e;
|
|
2159
|
-
const s =
|
|
2199
|
+
const s = Cn(n);
|
|
2160
2200
|
for (const a of s)
|
|
2161
|
-
|
|
2162
|
-
return
|
|
2201
|
+
Ke(a);
|
|
2202
|
+
return Sn(t, s).join(`
|
|
2163
2203
|
`);
|
|
2164
2204
|
}
|
|
2165
|
-
function
|
|
2205
|
+
function Nn(e) {
|
|
2166
2206
|
const t = e.trim();
|
|
2167
2207
|
if (!t.endsWith(":")) return null;
|
|
2168
2208
|
const n = t.slice(0, -1);
|
|
@@ -2183,17 +2223,17 @@ function ie(e) {
|
|
|
2183
2223
|
break;
|
|
2184
2224
|
return t;
|
|
2185
2225
|
}
|
|
2186
|
-
function
|
|
2226
|
+
function _n(e, t) {
|
|
2187
2227
|
const n = ie(e[t]);
|
|
2188
2228
|
for (let i = t + 1; i < e.length; i++)
|
|
2189
|
-
if (!
|
|
2229
|
+
if (!Qe(e[i]))
|
|
2190
2230
|
return ie(e[i]) > n;
|
|
2191
2231
|
return !1;
|
|
2192
2232
|
}
|
|
2193
|
-
function
|
|
2233
|
+
function Qe(e) {
|
|
2194
2234
|
return e.trim() === "";
|
|
2195
2235
|
}
|
|
2196
|
-
function
|
|
2236
|
+
function An(e, t) {
|
|
2197
2237
|
let n = 0, i = 0;
|
|
2198
2238
|
for (; i < e.length && n < t; )
|
|
2199
2239
|
if (e[i] === " ")
|
|
@@ -2204,7 +2244,7 @@ function Cn(e, t) {
|
|
|
2204
2244
|
break;
|
|
2205
2245
|
return e.slice(i);
|
|
2206
2246
|
}
|
|
2207
|
-
function
|
|
2247
|
+
function On(e) {
|
|
2208
2248
|
const t = e.split(`
|
|
2209
2249
|
`), n = [], i = {
|
|
2210
2250
|
level: 0,
|
|
@@ -2223,21 +2263,21 @@ function Sn(e) {
|
|
|
2223
2263
|
n.push(s);
|
|
2224
2264
|
continue;
|
|
2225
2265
|
}
|
|
2226
|
-
if (
|
|
2266
|
+
if (Qe(s)) {
|
|
2227
2267
|
n.push("");
|
|
2228
2268
|
continue;
|
|
2229
2269
|
}
|
|
2230
|
-
const
|
|
2231
|
-
if (
|
|
2270
|
+
const f = Nn(c);
|
|
2271
|
+
if (f && _n(t, r)) {
|
|
2232
2272
|
for (; i.openDirectives.length > 0 && !(i.openDirectives[i.openDirectives.length - 1].indentLevel < a); ) {
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2273
|
+
const T = i.openDirectives.pop();
|
|
2274
|
+
T && n.push(":".repeat(T.colonCount));
|
|
2235
2275
|
}
|
|
2236
|
-
const m =
|
|
2237
|
-
n.push(":".repeat(
|
|
2276
|
+
const m = f.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)/), g = m ? m[1].toLowerCase() + (m[2] || "") : f, k = i.openDirectives.length * 1 + 3;
|
|
2277
|
+
n.push(":".repeat(k) + g), i.openDirectives.push({
|
|
2238
2278
|
label: g,
|
|
2239
2279
|
indentLevel: a,
|
|
2240
|
-
colonCount:
|
|
2280
|
+
colonCount: k,
|
|
2241
2281
|
bodyBaseIndent: -1
|
|
2242
2282
|
}), i.level = a;
|
|
2243
2283
|
} else {
|
|
@@ -2247,7 +2287,7 @@ function Sn(e) {
|
|
|
2247
2287
|
}
|
|
2248
2288
|
if (i.openDirectives.length > 0) {
|
|
2249
2289
|
const m = i.openDirectives[i.openDirectives.length - 1];
|
|
2250
|
-
m.bodyBaseIndent < 0 && (m.bodyBaseIndent = a), n.push(
|
|
2290
|
+
m.bodyBaseIndent < 0 && (m.bodyBaseIndent = a), n.push(An(s, m.bodyBaseIndent));
|
|
2251
2291
|
} else
|
|
2252
2292
|
n.push(s);
|
|
2253
2293
|
i.level = a;
|
|
@@ -2260,8 +2300,8 @@ function Sn(e) {
|
|
|
2260
2300
|
return n.join(`
|
|
2261
2301
|
`);
|
|
2262
2302
|
}
|
|
2263
|
-
const
|
|
2264
|
-
function
|
|
2303
|
+
const Mn = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/, Rn = /^division:\s*(\S+)\s*$/m, $n = /^id:\s*(\S+)\s*$/m, qn = /^xmlid:\s*(\S+)\s*$/m, Fn = /^xml:id:\s*(\S+)\s*$/m, Pn = /^label:\s*(\S+)\s*$/m, jn = /^component:\s*(\S+)\s*$/m, Xn = /^title:\s*(.+?)\s*$/m;
|
|
2304
|
+
function Bn(e) {
|
|
2265
2305
|
if (e.length >= 2) {
|
|
2266
2306
|
const t = e[0], n = e[e.length - 1];
|
|
2267
2307
|
if (t === '"' && n === '"' || t === "'" && n === "'")
|
|
@@ -2269,30 +2309,30 @@ function qn(e) {
|
|
|
2269
2309
|
}
|
|
2270
2310
|
return e;
|
|
2271
2311
|
}
|
|
2272
|
-
function
|
|
2273
|
-
const t = e.match(
|
|
2312
|
+
function Un(e) {
|
|
2313
|
+
const t = e.match(Mn);
|
|
2274
2314
|
if (!t)
|
|
2275
2315
|
return { body: e };
|
|
2276
|
-
const n = t[1], i = e.slice(t[0].length), r = n.match(
|
|
2316
|
+
const n = t[1], i = e.slice(t[0].length), r = n.match(Rn)?.[1];
|
|
2277
2317
|
let s, c;
|
|
2278
|
-
r &&
|
|
2279
|
-
const a = {}, h = n.match(
|
|
2280
|
-
h && (a["xml:id"] = h),
|
|
2281
|
-
const g = n.match(
|
|
2318
|
+
r && ft(r) ? (c = r, s = te(r)) : r && Me(r) && (s = r);
|
|
2319
|
+
const a = {}, h = n.match($n)?.[1] ?? n.match(qn)?.[1] ?? n.match(Fn)?.[1], f = n.match(Pn)?.[1], m = n.match(jn)?.[1];
|
|
2320
|
+
h && (a["xml:id"] = h), f && (a.label = f), m && (a.component = m);
|
|
2321
|
+
const g = n.match(Xn)?.[1], k = g ? Bn(g) : void 0;
|
|
2282
2322
|
return {
|
|
2283
2323
|
division: s,
|
|
2284
2324
|
documentRoot: c,
|
|
2285
2325
|
attributes: Object.keys(a).length > 0 ? a : void 0,
|
|
2286
|
-
title:
|
|
2326
|
+
title: k,
|
|
2287
2327
|
body: i
|
|
2288
2328
|
};
|
|
2289
2329
|
}
|
|
2290
|
-
const
|
|
2330
|
+
const Yn = function(e) {
|
|
2291
2331
|
return function(n, i) {
|
|
2292
2332
|
if (typeof i?.value == "string") {
|
|
2293
|
-
const r =
|
|
2333
|
+
const r = Un(i.value), s = e?.documentRoot ?? r.documentRoot, c = e?.topLevelDivision ?? r.division ?? (s ? te(s) : "chapter"), a = e?.topLevelAttributes ?? r.attributes, h = e?.topLevelTitle ?? r.title, f = On(
|
|
2294
2334
|
r.body
|
|
2295
|
-
), m =
|
|
2335
|
+
), m = Ln(f), g = Tt(m);
|
|
2296
2336
|
return Ie(g.tree, g.source, {
|
|
2297
2337
|
topLevelDivision: c,
|
|
2298
2338
|
documentRoot: s,
|
|
@@ -2301,24 +2341,24 @@ const Pn = function(e) {
|
|
|
2301
2341
|
restoreSource: g.restoreSource
|
|
2302
2342
|
});
|
|
2303
2343
|
}
|
|
2304
|
-
return
|
|
2344
|
+
return Xe(n), Ie(n, void 0, {
|
|
2305
2345
|
topLevelDivision: e?.topLevelDivision ?? (e?.documentRoot ? te(e.documentRoot) : "chapter"),
|
|
2306
2346
|
documentRoot: e?.documentRoot,
|
|
2307
2347
|
topLevelAttributes: e?.topLevelAttributes,
|
|
2308
2348
|
topLevelTitle: e?.topLevelTitle
|
|
2309
2349
|
});
|
|
2310
2350
|
};
|
|
2311
|
-
},
|
|
2351
|
+
}, zn = /["&'<>`]/g, Jn = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, Wn = (
|
|
2312
2352
|
// eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
|
|
2313
2353
|
/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g
|
|
2314
|
-
),
|
|
2315
|
-
function
|
|
2354
|
+
), Vn = /[|\\{}()[\]^$+*?.]/g, Le = /* @__PURE__ */ new WeakMap();
|
|
2355
|
+
function Hn(e, t) {
|
|
2316
2356
|
if (e = e.replace(
|
|
2317
|
-
t.subset ?
|
|
2357
|
+
t.subset ? Zn(t.subset) : zn,
|
|
2318
2358
|
i
|
|
2319
2359
|
), t.subset || t.escapeOnly)
|
|
2320
2360
|
return e;
|
|
2321
|
-
return e.replace(
|
|
2361
|
+
return e.replace(Jn, n).replace(Wn, i);
|
|
2322
2362
|
function n(r, s, c) {
|
|
2323
2363
|
return t.format(
|
|
2324
2364
|
(r.charCodeAt(0) - 55296) * 1024 + r.charCodeAt(1) - 56320 + 65536,
|
|
@@ -2334,47 +2374,47 @@ function Yn(e, t) {
|
|
|
2334
2374
|
);
|
|
2335
2375
|
}
|
|
2336
2376
|
}
|
|
2337
|
-
function
|
|
2338
|
-
let t =
|
|
2339
|
-
return t || (t =
|
|
2377
|
+
function Zn(e) {
|
|
2378
|
+
let t = Le.get(e);
|
|
2379
|
+
return t || (t = Gn(e), Le.set(e, t)), t;
|
|
2340
2380
|
}
|
|
2341
|
-
function
|
|
2381
|
+
function Gn(e) {
|
|
2342
2382
|
const t = [];
|
|
2343
2383
|
let n = -1;
|
|
2344
2384
|
for (; ++n < e.length; )
|
|
2345
|
-
t.push(e[n].replace(
|
|
2385
|
+
t.push(e[n].replace(Vn, "\\$&"));
|
|
2346
2386
|
return new RegExp("(?:" + t.join("|") + ")", "g");
|
|
2347
2387
|
}
|
|
2348
|
-
function
|
|
2388
|
+
function Kn(e) {
|
|
2349
2389
|
return "&#x" + e.toString(16).toUpperCase() + ";";
|
|
2350
2390
|
}
|
|
2351
|
-
function
|
|
2352
|
-
return
|
|
2391
|
+
function Qn(e, t) {
|
|
2392
|
+
return Hn(e, Object.assign({ format: Kn }, t));
|
|
2353
2393
|
}
|
|
2354
|
-
const
|
|
2394
|
+
const ei = /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;
|
|
2355
2395
|
function O(e, t, n) {
|
|
2356
|
-
const i =
|
|
2396
|
+
const i = ti(e);
|
|
2357
2397
|
return n ? i.replace(n, r) : r(i);
|
|
2358
2398
|
function r(s) {
|
|
2359
|
-
return
|
|
2399
|
+
return Qn(s, { subset: t });
|
|
2360
2400
|
}
|
|
2361
2401
|
}
|
|
2362
|
-
function
|
|
2363
|
-
return String(e || "").replace(
|
|
2402
|
+
function ti(e) {
|
|
2403
|
+
return String(e || "").replace(ei, "");
|
|
2364
2404
|
}
|
|
2365
|
-
const
|
|
2366
|
-
function
|
|
2367
|
-
return "<![CDATA[" + O(e.value,
|
|
2405
|
+
const ni = /]]>/g, ii = [">"];
|
|
2406
|
+
function ri(e) {
|
|
2407
|
+
return "<![CDATA[" + O(e.value, ii, ni) + "]]>";
|
|
2368
2408
|
}
|
|
2369
|
-
function
|
|
2409
|
+
function si(e) {
|
|
2370
2410
|
return "<!--" + O(e.value, ["-"]) + "-->";
|
|
2371
2411
|
}
|
|
2372
|
-
const
|
|
2412
|
+
const oi = [" ", `
|
|
2373
2413
|
`, " ", '"', "&", "'", "/", "<", "=", ">"];
|
|
2374
2414
|
function W(e) {
|
|
2375
|
-
return O(e,
|
|
2415
|
+
return O(e, oi);
|
|
2376
2416
|
}
|
|
2377
|
-
function
|
|
2417
|
+
function Ne(e, t) {
|
|
2378
2418
|
const n = String(e);
|
|
2379
2419
|
if (typeof t != "string")
|
|
2380
2420
|
throw new TypeError("Expected character");
|
|
@@ -2388,86 +2428,86 @@ function re(e, t) {
|
|
|
2388
2428
|
let i = t.options.quote || '"';
|
|
2389
2429
|
if (t.options.quoteSmart) {
|
|
2390
2430
|
const r = i === '"' ? "'" : '"';
|
|
2391
|
-
|
|
2431
|
+
Ne(n, i) > Ne(n, r) && (i = r);
|
|
2392
2432
|
}
|
|
2393
2433
|
return i + O(n, ["<", "&", i]) + i;
|
|
2394
2434
|
}
|
|
2395
|
-
function
|
|
2435
|
+
function li(e, t) {
|
|
2396
2436
|
const n = W(e.name), i = e.public, r = e.system;
|
|
2397
2437
|
let s = "<!DOCTYPE";
|
|
2398
2438
|
return n !== "" && (s += " " + n), i ? s += " PUBLIC " + re(i, t) : r && (s += " SYSTEM"), r && (s += " " + re(r, t)), s + ">";
|
|
2399
2439
|
}
|
|
2400
|
-
const
|
|
2401
|
-
function
|
|
2402
|
-
const n = W(e.name), i =
|
|
2440
|
+
const ci = {}.hasOwnProperty;
|
|
2441
|
+
function ai(e, t) {
|
|
2442
|
+
const n = W(e.name), i = nt(e, t), r = e.attributes || {}, s = i ? !1 : t.options.closeEmptyElements, c = [];
|
|
2403
2443
|
let a;
|
|
2404
2444
|
for (a in r)
|
|
2405
|
-
if (
|
|
2445
|
+
if (ci.call(r, a)) {
|
|
2406
2446
|
const h = r[a];
|
|
2407
2447
|
h != null && c.push(W(a) + "=" + re(h, t));
|
|
2408
2448
|
}
|
|
2409
2449
|
return "<" + n + (c.length === 0 ? "" : " " + c.join(" ")) + (s ? (t.options.tightClose ? "" : " ") + "/" : "") + ">" + i + (s ? "" : "</" + n + ">");
|
|
2410
2450
|
}
|
|
2411
|
-
const
|
|
2412
|
-
function
|
|
2413
|
-
const t = W(e.name) || "x", n = O(e.value,
|
|
2451
|
+
const ui = /\?>/g, hi = [">"];
|
|
2452
|
+
function fi(e) {
|
|
2453
|
+
const t = W(e.name) || "x", n = O(e.value, hi, ui);
|
|
2414
2454
|
return "<?" + t + (n ? " " + n : "") + "?>";
|
|
2415
2455
|
}
|
|
2416
|
-
const
|
|
2417
|
-
function
|
|
2418
|
-
return O(e.value,
|
|
2419
|
-
}
|
|
2420
|
-
function
|
|
2421
|
-
return t.options.allowDangerousXml ? e.value :
|
|
2422
|
-
}
|
|
2423
|
-
const
|
|
2424
|
-
cdata:
|
|
2425
|
-
comment:
|
|
2426
|
-
doctype:
|
|
2427
|
-
element:
|
|
2428
|
-
instruction:
|
|
2429
|
-
raw:
|
|
2430
|
-
root:
|
|
2431
|
-
text:
|
|
2456
|
+
const pi = ["&", "<"];
|
|
2457
|
+
function et(e) {
|
|
2458
|
+
return O(e.value, pi);
|
|
2459
|
+
}
|
|
2460
|
+
function di(e, t) {
|
|
2461
|
+
return t.options.allowDangerousXml ? e.value : et(e);
|
|
2462
|
+
}
|
|
2463
|
+
const mi = {}.hasOwnProperty, _e = {
|
|
2464
|
+
cdata: ri,
|
|
2465
|
+
comment: si,
|
|
2466
|
+
doctype: li,
|
|
2467
|
+
element: ai,
|
|
2468
|
+
instruction: fi,
|
|
2469
|
+
raw: di,
|
|
2470
|
+
root: nt,
|
|
2471
|
+
text: et
|
|
2432
2472
|
};
|
|
2433
|
-
function
|
|
2473
|
+
function tt(e, t) {
|
|
2434
2474
|
const n = e && e.type;
|
|
2435
2475
|
if (!n)
|
|
2436
2476
|
throw new Error("Expected node, not `" + e + "`");
|
|
2437
|
-
if (!
|
|
2477
|
+
if (!mi.call(_e, n))
|
|
2438
2478
|
throw new Error("Cannot compile unknown node `" + n + "`");
|
|
2439
|
-
const i =
|
|
2479
|
+
const i = _e[n];
|
|
2440
2480
|
return i(e, t);
|
|
2441
2481
|
}
|
|
2442
|
-
function
|
|
2482
|
+
function nt(e, t) {
|
|
2443
2483
|
const n = e && e.children || [];
|
|
2444
2484
|
let i = -1;
|
|
2445
2485
|
const r = [];
|
|
2446
2486
|
for (; ++i < n.length; )
|
|
2447
|
-
r[i] =
|
|
2487
|
+
r[i] = tt(n[i], t);
|
|
2448
2488
|
return r.join("");
|
|
2449
2489
|
}
|
|
2450
|
-
function
|
|
2490
|
+
function gi(e, t) {
|
|
2451
2491
|
const n = { options: t || {} };
|
|
2452
2492
|
if (typeof n.options.quote == "string" && n.options.quote !== '"' && n.options.quote !== "'")
|
|
2453
2493
|
throw new Error(
|
|
2454
2494
|
"Invalid quote `" + n.options.quote + "`, expected `'` or `\"`"
|
|
2455
2495
|
);
|
|
2456
2496
|
const i = Array.isArray(e) ? { type: "root", children: e } : e;
|
|
2457
|
-
return
|
|
2497
|
+
return tt(i, n);
|
|
2458
2498
|
}
|
|
2459
|
-
function
|
|
2460
|
-
const n = se().use(oe).use(
|
|
2461
|
-
return
|
|
2499
|
+
function Ii(e, t) {
|
|
2500
|
+
const n = se().use(oe).use(Ae).use(Yn, t), i = n.parse(e), r = n.runSync(i, { value: e });
|
|
2501
|
+
return gi(r.children, {
|
|
2462
2502
|
closeEmptyElements: !0,
|
|
2463
2503
|
tightClose: !0
|
|
2464
2504
|
});
|
|
2465
2505
|
}
|
|
2466
2506
|
export {
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2507
|
+
Di as DIRECTIVE_MAP,
|
|
2508
|
+
Ve as PROOF_SOLUTION_NAMES,
|
|
2509
|
+
Ii as markdownToPretext,
|
|
2470
2510
|
Ie as mdastToPtxast,
|
|
2471
|
-
|
|
2472
|
-
|
|
2511
|
+
Ti as remarkMath,
|
|
2512
|
+
Yn as remarkPretext
|
|
2473
2513
|
};
|