@futaba-soft/mbox 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/create-editor-BKTpQ8TK.js +2866 -0
- package/dist/editor/create-editor.d.ts +100 -0
- package/dist/editor/document-cache.d.ts +20 -0
- package/dist/editor/focused-line.d.ts +14 -0
- package/dist/editor/plugin.d.ts +191 -0
- package/dist/editor/test-context.d.ts +28 -0
- package/dist/gfm.d.ts +34 -0
- package/dist/gfm.js +1719 -0
- package/dist/hatena.d.ts +32 -0
- package/dist/hatena.js +856 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +77 -0
- package/dist/plugin-DI0ubB-M.js +297 -0
- package/dist/plugins/bracket-pair-kit.d.ts +9 -0
- package/dist/plugins/code-block-kit.d.ts +77 -0
- package/dist/plugins/code-block-language-loader.d.ts +33 -0
- package/dist/plugins/gfm/active-lines.d.ts +11 -0
- package/dist/plugins/gfm/code-block.d.ts +28 -0
- package/dist/plugins/gfm/footnote.d.ts +17 -0
- package/dist/plugins/gfm/heading.d.ts +12 -0
- package/dist/plugins/gfm/image.d.ts +30 -0
- package/dist/plugins/gfm/index.d.ts +19 -0
- package/dist/plugins/gfm/inline-code.d.ts +4 -0
- package/dist/plugins/gfm/inline.d.ts +4 -0
- package/dist/plugins/gfm/link.d.ts +34 -0
- package/dist/plugins/gfm/list.d.ts +32 -0
- package/dist/plugins/gfm/math.d.ts +39 -0
- package/dist/plugins/gfm/parser-cache.d.ts +3 -0
- package/dist/plugins/gfm/parser.d.ts +355 -0
- package/dist/plugins/gfm/quote.d.ts +3 -0
- package/dist/plugins/gfm/table.d.ts +34 -0
- package/dist/plugins/gfm/thematic-break.d.ts +9 -0
- package/dist/plugins/hatena/blockquote.d.ts +12 -0
- package/dist/plugins/hatena/definition.d.ts +5 -0
- package/dist/plugins/hatena/footnote.d.ts +15 -0
- package/dist/plugins/hatena/heading.d.ts +8 -0
- package/dist/plugins/hatena/index.d.ts +12 -0
- package/dist/plugins/hatena/link.d.ts +16 -0
- package/dist/plugins/hatena/list.d.ts +24 -0
- package/dist/plugins/hatena/parser-cache.d.ts +5 -0
- package/dist/plugins/hatena/parser.d.ts +129 -0
- package/dist/plugins/hatena/pre.d.ts +3 -0
- package/dist/plugins/hatena/shared.d.ts +31 -0
- package/dist/plugins/hatena/super-pre.d.ts +23 -0
- package/dist/plugins/hatena/table.d.ts +12 -0
- package/dist/plugins/image-kit.d.ts +84 -0
- package/dist/plugins/inline-notation-kit.d.ts +39 -0
- package/dist/plugins/inline-style-kit.d.ts +38 -0
- package/dist/plugins/link-url.d.ts +1 -0
- package/dist/plugins/logical-lines.d.ts +18 -0
- package/dist/plugins/mbox/bracket.d.ts +4 -0
- package/dist/plugins/mbox/code-block.d.ts +32 -0
- package/dist/plugins/mbox/complete.d.ts +33 -0
- package/dist/plugins/mbox/default.d.ts +13 -0
- package/dist/plugins/mbox/emoji.d.ts +3 -0
- package/dist/plugins/mbox/footnote.d.ts +14 -0
- package/dist/plugins/mbox/heading.d.ts +10 -0
- package/dist/plugins/mbox/inline-code.d.ts +6 -0
- package/dist/plugins/mbox/inline-style.d.ts +7 -0
- package/dist/plugins/mbox/inline-visitor.d.ts +8 -0
- package/dist/plugins/mbox/list.d.ts +13 -0
- package/dist/plugins/mbox/markdown-image.d.ts +13 -0
- package/dist/plugins/mbox/page-link.d.ts +19 -0
- package/dist/plugins/mbox/paragraph.d.ts +6 -0
- package/dist/plugins/mbox/parser-cache.d.ts +3 -0
- package/dist/plugins/mbox/parser.d.ts +2 -0
- package/dist/plugins/mbox/quote.d.ts +5 -0
- package/dist/plugins/mbox/table.d.ts +13 -0
- package/dist/plugins/mbox/task-list.d.ts +19 -0
- package/dist/plugins/mbox/types.d.ts +172 -0
- package/dist/plugins/mbox/url-link.d.ts +3 -0
- package/dist/plugins/mbox/vertical-motion.d.ts +3 -0
- package/dist/plugins/pipe-table-row.d.ts +18 -0
- package/dist/plugins/scrapbox/bracket.d.ts +20 -0
- package/dist/plugins/scrapbox/code-block.d.ts +37 -0
- package/dist/plugins/scrapbox/command-line.d.ts +9 -0
- package/dist/plugins/scrapbox/complete.d.ts +58 -0
- package/dist/plugins/scrapbox/decoration.d.ts +16 -0
- package/dist/plugins/scrapbox/formula.d.ts +43 -0
- package/dist/plugins/scrapbox/image.d.ts +62 -0
- package/dist/plugins/scrapbox/indent.d.ts +40 -0
- package/dist/plugins/scrapbox/index.d.ts +41 -0
- package/dist/plugins/scrapbox/inline-code-highlight.d.ts +16 -0
- package/dist/plugins/scrapbox/inline-code.d.ts +7 -0
- package/dist/plugins/scrapbox/inline-scanner-kit.d.ts +66 -0
- package/dist/plugins/scrapbox/inline-walker.d.ts +2 -0
- package/dist/plugins/scrapbox/inline.d.ts +86 -0
- package/dist/plugins/scrapbox/link.d.ts +110 -0
- package/dist/plugins/scrapbox/list.d.ts +21 -0
- package/dist/plugins/scrapbox/parser-cache.d.ts +5 -0
- package/dist/plugins/scrapbox/parser.d.ts +65 -0
- package/dist/plugins/scrapbox/quote.d.ts +7 -0
- package/dist/plugins/scrapbox/table.d.ts +22 -0
- package/dist/plugins/scrapbox/title.d.ts +3 -0
- package/dist/plugins/scrapbox/visible-lines.d.ts +34 -0
- package/dist/plugins/table-kit.d.ts +142 -0
- package/dist/plugins/task-checkbox-kit.d.ts +18 -0
- package/dist/scrapbox.d.ts +42 -0
- package/dist/scrapbox.js +1903 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +13 -0
- package/dist/themes/code-token-presentation.d.ts +6 -0
- package/dist/themes/default-presentation.d.ts +4 -0
- package/dist/themes/gfm-presentation.d.ts +15 -0
- package/dist/themes/hatena-presentation.d.ts +10 -0
- package/dist/themes/heading-presentation.d.ts +18 -0
- package/dist/themes/scrapbox-presentation.d.ts +10 -0
- package/docs/guide.md +297 -0
- package/package.json +121 -4
package/dist/gfm.js
ADDED
|
@@ -0,0 +1,1719 @@
|
|
|
1
|
+
import { ai as Ze, aj as Qe, am as Je, an as Ve, C as _e, ao as Xe, ax as Ye, ay as et, az as tt, ak as ce, aA as me, al as nt, aB as ot, aC as rt, ap as st, aq as it, ar as at, aD as lt, at as ct, as as mt, au as ft, av as ut, n as ht, aw as gt } from "./create-editor-BKTpQ8TK.js";
|
|
2
|
+
import { fromMarkdown as dt } from "mdast-util-from-markdown";
|
|
3
|
+
import { gfm as pt } from "micromark-extension-gfm";
|
|
4
|
+
import { decodeString as ee } from "micromark-util-decode-string";
|
|
5
|
+
import { gfmFromMarkdown as bt } from "mdast-util-gfm";
|
|
6
|
+
import { Facet as xt } from "@codemirror/state";
|
|
7
|
+
import { WidgetType as M, EditorView as kt } from "@codemirror/view";
|
|
8
|
+
function Z(e) {
|
|
9
|
+
return e.fenced && e.language?.id === "math";
|
|
10
|
+
}
|
|
11
|
+
function h(e) {
|
|
12
|
+
const t = e.position;
|
|
13
|
+
if (!t || t.start.offset == null || t.end.offset == null)
|
|
14
|
+
throw new Error(`mdast node ${e.type} is missing position offsets`);
|
|
15
|
+
return { from: t.start.offset, to: t.end.offset };
|
|
16
|
+
}
|
|
17
|
+
function Q(e, t) {
|
|
18
|
+
const n = t.slice(e.from, e.to);
|
|
19
|
+
let o = 0;
|
|
20
|
+
for (; o < n.length && n[o] === "`"; )
|
|
21
|
+
o += 1;
|
|
22
|
+
let r = 0;
|
|
23
|
+
for (; r < n.length - o && n[n.length - 1 - r] === "`"; )
|
|
24
|
+
r += 1;
|
|
25
|
+
let i = e.from + o, s = e.to - r;
|
|
26
|
+
const a = t.slice(i, s);
|
|
27
|
+
return !a.includes(`
|
|
28
|
+
`) && !a.includes("\r") && a.startsWith(" ") && a.endsWith(" ") && /[^ ]/.test(a) && (i += 1, s -= 1), {
|
|
29
|
+
open: { from: e.from, to: i },
|
|
30
|
+
content: { from: i, to: s },
|
|
31
|
+
close: { from: s, to: e.to }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function k(e) {
|
|
35
|
+
return e.position?.start.line ?? 1;
|
|
36
|
+
}
|
|
37
|
+
function w(e) {
|
|
38
|
+
return e.position?.end.line ?? 1;
|
|
39
|
+
}
|
|
40
|
+
function y(e) {
|
|
41
|
+
return "children" in e && Array.isArray(e.children);
|
|
42
|
+
}
|
|
43
|
+
const Ct = /^((?:[-*+]|\d+[.)])(?:[ \t]+|$))(\[[ xX]\][ \t]*)?/;
|
|
44
|
+
function Lt(e, t) {
|
|
45
|
+
const n = [{ node: e, context: t }], o = (i, s, a = {}) => {
|
|
46
|
+
if (!y(i))
|
|
47
|
+
return;
|
|
48
|
+
const l = a.ordered !== void 0 ? { ...s, orderedList: a.ordered } : s;
|
|
49
|
+
for (let c = i.children.length - 1; c >= 0; c -= 1)
|
|
50
|
+
n.push({ node: i.children[c], context: l });
|
|
51
|
+
}, r = (i, s) => {
|
|
52
|
+
if (y(i))
|
|
53
|
+
for (let a = i.children.length - 1; a >= 0; a -= 1) {
|
|
54
|
+
const l = i.children[a];
|
|
55
|
+
l.type === "paragraph" && n.push({ node: l, context: s });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
for (; n.length > 0; ) {
|
|
59
|
+
const i = n.pop();
|
|
60
|
+
switch (e = i.node, t = i.context, e.type) {
|
|
61
|
+
case "heading": {
|
|
62
|
+
const s = h(e), a = e.children[0], l = a ? h(a).from : s.to, c = { from: s.from, to: l }, m = c.from === c.to ? w(e) : null;
|
|
63
|
+
t.document.headings.push({
|
|
64
|
+
line: k(e),
|
|
65
|
+
from: s.from,
|
|
66
|
+
level: e.depth,
|
|
67
|
+
marker: c,
|
|
68
|
+
...m === null ? {} : {
|
|
69
|
+
setextUnderline: {
|
|
70
|
+
line: m,
|
|
71
|
+
from: t.lineStarts[m - 1],
|
|
72
|
+
to: I(t.input, t.lineStarts, m)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}), o(e, t);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
case "list": {
|
|
79
|
+
const s = { ...t, listDepth: t.listDepth + 1 };
|
|
80
|
+
o(e, s, { ordered: !!e.ordered });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
case "listItem": {
|
|
84
|
+
const s = h(e), a = e.children[0], l = a ? h(a).from : s.to, c = t.input.slice(s.from, l), m = Ct.exec(c), f = m ? m[1] : "", u = s.from + f.length;
|
|
85
|
+
let g = null;
|
|
86
|
+
e.checked != null && m && m[2] && (g = {
|
|
87
|
+
marker: { from: u, to: u + m[2].length },
|
|
88
|
+
checked: e.checked
|
|
89
|
+
}), t.document.listItems.push({
|
|
90
|
+
line: k(e),
|
|
91
|
+
from: s.from,
|
|
92
|
+
depth: Math.max(0, t.listDepth - 1),
|
|
93
|
+
ordered: t.orderedList ?? !1,
|
|
94
|
+
bullet: { from: s.from, to: u },
|
|
95
|
+
task: g
|
|
96
|
+
}), o(e, t);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
case "code": {
|
|
100
|
+
t.document.codeBlocks.push(Tt(e, t.input, t.lineStarts));
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
case "blockquote": {
|
|
104
|
+
const s = h(e), a = t.blockquoteDepth + 1;
|
|
105
|
+
t.document.blockquotes.push({ from: s.from, to: s.to, depth: a }), t.blockquoteDepth === 0 && Ft(e, t), o(e, { ...t, blockquoteDepth: a });
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
case "emphasis":
|
|
109
|
+
case "strong":
|
|
110
|
+
case "delete": {
|
|
111
|
+
const s = h(e), a = e.children[0], l = e.children[e.children.length - 1], c = a ? h(a).from : s.from, m = l ? h(l).to : s.to;
|
|
112
|
+
t.document.inlineStyles.push({
|
|
113
|
+
type: e.type,
|
|
114
|
+
startLine: k(e),
|
|
115
|
+
endLine: w(e),
|
|
116
|
+
open: { from: s.from, to: c },
|
|
117
|
+
content: { from: c, to: m },
|
|
118
|
+
close: { from: m, to: s.to }
|
|
119
|
+
}), o(e, t);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
case "link": {
|
|
123
|
+
const s = h(e), a = e.children[0], l = e.children[e.children.length - 1], c = a ? h(a).from : s.from, m = l ? h(l).to : s.to;
|
|
124
|
+
t.document.links.push({
|
|
125
|
+
from: s.from,
|
|
126
|
+
to: s.to,
|
|
127
|
+
textFrom: c,
|
|
128
|
+
textTo: m,
|
|
129
|
+
text: he(e, t.input),
|
|
130
|
+
label: e.children.map((f) => ge(f, t.input, c)),
|
|
131
|
+
labelSource: t.input.slice(c, m),
|
|
132
|
+
url: e.url,
|
|
133
|
+
// A bracketed markdown link starts with `[`; a GFM autolink is the bare
|
|
134
|
+
// URL/`www.` run, so its first character is not a bracket.
|
|
135
|
+
autolink: t.input[s.from] !== "[",
|
|
136
|
+
startLine: k(e),
|
|
137
|
+
endLine: w(e),
|
|
138
|
+
inTableCell: t.inTableCell ?? !1
|
|
139
|
+
});
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
case "inlineCode": {
|
|
143
|
+
const s = h(e), a = Q(s, t.input), l = {
|
|
144
|
+
open: a.open,
|
|
145
|
+
content: a.content,
|
|
146
|
+
close: a.close,
|
|
147
|
+
startLine: k(e),
|
|
148
|
+
endLine: w(e)
|
|
149
|
+
};
|
|
150
|
+
t.document.inlineCodes.push(l), !t.inFootnoteDefinition && l.startLine === l.endLine && J(s, t.input) && t.document.inlineMath.push({
|
|
151
|
+
from: s.from - 1,
|
|
152
|
+
to: s.to + 1,
|
|
153
|
+
// Ordinary single-line inline code reaches CommonMark's whitespace
|
|
154
|
+
// result through its source ranges; math instead uses mdast's
|
|
155
|
+
// normalized value. Multiline normalization still waits for Section 8.
|
|
156
|
+
expression: e.value,
|
|
157
|
+
delimiter: "backtick",
|
|
158
|
+
sourceCodeSpan: { from: s.from, to: s.to },
|
|
159
|
+
display: "inline",
|
|
160
|
+
startLine: l.startLine,
|
|
161
|
+
endLine: l.endLine,
|
|
162
|
+
inTableCell: t.inTableCell ?? !1
|
|
163
|
+
});
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
case "image": {
|
|
167
|
+
const s = h(e);
|
|
168
|
+
t.document.images.push({
|
|
169
|
+
from: s.from,
|
|
170
|
+
to: s.to,
|
|
171
|
+
url: e.url,
|
|
172
|
+
alt: e.alt ?? "",
|
|
173
|
+
line: k(e),
|
|
174
|
+
inTableCell: t.inTableCell ?? !1
|
|
175
|
+
});
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
case "thematicBreak": {
|
|
179
|
+
const s = h(e);
|
|
180
|
+
t.document.thematicBreaks.push({ line: k(e), from: s.from, to: s.to });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
case "text": {
|
|
184
|
+
const s = h(e), a = t.input.slice(s.from, s.to);
|
|
185
|
+
let l = k(e), c = 0;
|
|
186
|
+
for (const m of de(a)) {
|
|
187
|
+
for (; c < m; )
|
|
188
|
+
a[c] === `
|
|
189
|
+
` && (l += 1), c += 1;
|
|
190
|
+
t.document.escapes.push({ line: l, from: s.from + m, to: s.from + m + 1 }), c = m + 2;
|
|
191
|
+
}
|
|
192
|
+
for (; c < a.length; )
|
|
193
|
+
a[c] === `
|
|
194
|
+
` && (l += 1), c += 1;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
case "break": {
|
|
198
|
+
const s = h(e);
|
|
199
|
+
t.document.hardBreaks.push({
|
|
200
|
+
line: k(e),
|
|
201
|
+
from: s.from,
|
|
202
|
+
backslash: t.input[s.from] === "\\"
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
case "footnoteReference": {
|
|
207
|
+
const s = h(e);
|
|
208
|
+
t.protectedRanges.push(s), t.document.footnoteReferences.push({
|
|
209
|
+
line: k(e),
|
|
210
|
+
from: s.from,
|
|
211
|
+
to: s.to,
|
|
212
|
+
identifier: e.identifier,
|
|
213
|
+
label: e.label ?? e.identifier
|
|
214
|
+
});
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
case "footnoteDefinition": {
|
|
218
|
+
const s = h(e);
|
|
219
|
+
t.protectedRanges.push(s);
|
|
220
|
+
const a = t.input.indexOf("]:", s.from) + 2;
|
|
221
|
+
t.document.footnoteDefinitions.push({
|
|
222
|
+
identifier: e.identifier,
|
|
223
|
+
label: e.label ?? e.identifier,
|
|
224
|
+
from: s.from,
|
|
225
|
+
to: s.to,
|
|
226
|
+
startLine: k(e),
|
|
227
|
+
endLine: w(e),
|
|
228
|
+
marker: { from: s.from, to: a },
|
|
229
|
+
text: t.input.slice(a, s.to).replace(/\s+/g, " ").trim()
|
|
230
|
+
}), r(e, { ...t, inFootnoteDefinition: !0 });
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
case "definition":
|
|
234
|
+
case "html": {
|
|
235
|
+
t.protectedRanges.push(h(e));
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
case "table": {
|
|
239
|
+
t.document.tables.push(St(e, t.input, t.lineStarts, t.document.quoteMarkers)), o(e, t);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
case "tableCell": {
|
|
243
|
+
o(e, { ...t, inTableCell: !0 });
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
default:
|
|
247
|
+
y(e) && o(e, t);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function St(e, t, n, o) {
|
|
252
|
+
const r = h(e), i = e.position, s = i.start.line, a = i.end.line, l = (d) => {
|
|
253
|
+
let x = n[d - 1];
|
|
254
|
+
for (const S of o)
|
|
255
|
+
S.line === d && S.to > x && (x = S.to);
|
|
256
|
+
return x;
|
|
257
|
+
}, c = (d) => {
|
|
258
|
+
const x = l(d), S = I(t, n, d);
|
|
259
|
+
return t.slice(x, S);
|
|
260
|
+
}, m = H(c(s), l(s)), f = H(c(s + 1), l(s + 1)), u = [];
|
|
261
|
+
for (let d = s + 2; d <= a; d += 1) {
|
|
262
|
+
const x = c(d);
|
|
263
|
+
if (!It(x))
|
|
264
|
+
break;
|
|
265
|
+
u.push(H(x, l(d)));
|
|
266
|
+
}
|
|
267
|
+
const g = "align" in e && Array.isArray(e.align) ? e.align : [], p = y(e) ? e.children : [];
|
|
268
|
+
return te(m, p[0], t), u.forEach((d, x) => te(d, p[x + 1], t)), { line: s, from: r.from, to: r.to, align: g, header: m, delimiter: f, rows: u };
|
|
269
|
+
}
|
|
270
|
+
const fe = /* @__PURE__ */ new WeakMap();
|
|
271
|
+
function ue(e) {
|
|
272
|
+
return e.some((t) => t.type === "image" || y(t) && ue(t.children));
|
|
273
|
+
}
|
|
274
|
+
function te(e, t, n) {
|
|
275
|
+
!t || !y(t) || e.cells.forEach((o, r) => {
|
|
276
|
+
const i = t.children[r];
|
|
277
|
+
if (i && y(i)) {
|
|
278
|
+
const s = Nt(i.children, n);
|
|
279
|
+
fe.set(o, s), o.displayValue = s.map((a) => a.text).join(""), ue(i.children) && (o.hasImage = !0);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function Nt(e, t) {
|
|
284
|
+
const n = [], o = /* @__PURE__ */ new Map();
|
|
285
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
286
|
+
const i = e[r], s = e[r + 1], a = e[r + 2];
|
|
287
|
+
if (i.type === "text" && s?.type === "inlineCode" && a?.type === "text" && t[h(i).to - 1] === "$" && t[h(a).from] === "$" && J(h(s), t)) {
|
|
288
|
+
const c = h(i), m = { from: o.get(r) ?? c.from, to: c.to };
|
|
289
|
+
h(s);
|
|
290
|
+
const f = h(a);
|
|
291
|
+
n.push(...P(i, t, m.from, m.to - 1)), n.push({ from: m.to - 1, to: f.from + 1, text: s.value }), o.set(r + 2, f.from + 1), r += 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const l = h(i);
|
|
295
|
+
n.push(...P(i, t, o.get(r) ?? l.from, l.to));
|
|
296
|
+
}
|
|
297
|
+
return n;
|
|
298
|
+
}
|
|
299
|
+
function P(e, t, n, o) {
|
|
300
|
+
const r = h(e);
|
|
301
|
+
switch (e.type) {
|
|
302
|
+
case "text": {
|
|
303
|
+
const i = n ?? r.from, s = o ?? r.to;
|
|
304
|
+
return [{ from: i, to: s, text: K(t.slice(i, s)), projectSourceSlice: (a, l) => K(t.slice(a, l)) }];
|
|
305
|
+
}
|
|
306
|
+
case "emphasis":
|
|
307
|
+
case "strong":
|
|
308
|
+
case "delete":
|
|
309
|
+
return e.children.flatMap((i) => P(i, t));
|
|
310
|
+
case "inlineCode": {
|
|
311
|
+
if (J(r, t))
|
|
312
|
+
return [{ from: r.from - 1, to: r.to + 1, text: e.value }];
|
|
313
|
+
const i = Q(r, t);
|
|
314
|
+
return [{ from: i.content.from, to: i.content.to, text: t.slice(i.content.from, i.content.to) }];
|
|
315
|
+
}
|
|
316
|
+
// Widgets replace their whole source spans. Their projection must match the
|
|
317
|
+
// widget's visible text so table-width measurement and DOM rendering agree.
|
|
318
|
+
case "link":
|
|
319
|
+
return [{ from: r.from, to: r.to, text: he(e, t) }];
|
|
320
|
+
case "image":
|
|
321
|
+
case "footnoteReference":
|
|
322
|
+
return [{ from: r.from, to: r.to, text: U(e) }];
|
|
323
|
+
default:
|
|
324
|
+
return [{ from: r.from, to: r.to, text: t.slice(r.from, r.to) }];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function J(e, t) {
|
|
328
|
+
return t[e.from - 1] === "$" && t[e.to] === "$" && !R(t, e.from - 1);
|
|
329
|
+
}
|
|
330
|
+
function R(e, t) {
|
|
331
|
+
let n = 0;
|
|
332
|
+
for (let o = t - 1; o >= 0 && e[o] === "\\"; o -= 1)
|
|
333
|
+
n += 1;
|
|
334
|
+
return n % 2 === 1;
|
|
335
|
+
}
|
|
336
|
+
function he(e, t) {
|
|
337
|
+
return e.children.flatMap((o) => P(o, t)).map((o) => o.text).join("") || t.slice(h(e).from, h(e).to);
|
|
338
|
+
}
|
|
339
|
+
function U(e) {
|
|
340
|
+
return e.type === "image" ? e.alt || e.url : e.label ?? e.identifier;
|
|
341
|
+
}
|
|
342
|
+
function ge(e, t, n) {
|
|
343
|
+
const o = h(e), r = { from: o.from - n, to: o.to - n };
|
|
344
|
+
switch (e.type) {
|
|
345
|
+
case "text":
|
|
346
|
+
return { kind: "text", ...r };
|
|
347
|
+
case "emphasis":
|
|
348
|
+
case "strong":
|
|
349
|
+
case "delete":
|
|
350
|
+
return { kind: e.type, ...r, children: e.children.map((i) => ge(i, t, n)) };
|
|
351
|
+
case "inlineCode": {
|
|
352
|
+
const i = Q(o, t);
|
|
353
|
+
return {
|
|
354
|
+
kind: "inlineCode",
|
|
355
|
+
...r,
|
|
356
|
+
content: { from: i.content.from - n, to: i.content.to - n }
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
case "break":
|
|
360
|
+
return { kind: "break", ...r };
|
|
361
|
+
case "image":
|
|
362
|
+
return { kind: "image", ...r, text: U(e), url: e.url };
|
|
363
|
+
case "footnoteReference":
|
|
364
|
+
return { kind: e.type, ...r, text: U(e) };
|
|
365
|
+
// This is the parser half of the link-label trust boundary. The renderer
|
|
366
|
+
// receives no mdast node and therefore only this explicit unknown kind for
|
|
367
|
+
// HTML, links, and any future syntax we have not approved.
|
|
368
|
+
default:
|
|
369
|
+
return { kind: "unknown", ...r };
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function de(e) {
|
|
373
|
+
const t = [];
|
|
374
|
+
for (let n = 0; n < e.length - 1; n += 1)
|
|
375
|
+
e[n] === "\\" && Zt.includes(e[n + 1]) && (t.push(n), n += 1);
|
|
376
|
+
return t;
|
|
377
|
+
}
|
|
378
|
+
function K(e) {
|
|
379
|
+
const t = de(e);
|
|
380
|
+
if (t.length === 0)
|
|
381
|
+
return e;
|
|
382
|
+
let n = "", o = 0;
|
|
383
|
+
for (const r of t)
|
|
384
|
+
n += e.slice(o, r), o = r + 1;
|
|
385
|
+
return n + e.slice(o);
|
|
386
|
+
}
|
|
387
|
+
const yt = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
|
|
388
|
+
function Mt(e) {
|
|
389
|
+
return e === " " || e === " " || e === "\r" || e === `
|
|
390
|
+
`;
|
|
391
|
+
}
|
|
392
|
+
function wt(e, t) {
|
|
393
|
+
const n = /[ \t\r\n]*([^ \t\r\n]+)/.exec(e);
|
|
394
|
+
if (!n?.[1] || n.index === void 0 || t === null)
|
|
395
|
+
return null;
|
|
396
|
+
const o = n.index + n[0].indexOf(n[1]);
|
|
397
|
+
return { id: t, span: { from: o, to: o + n[1].length } };
|
|
398
|
+
}
|
|
399
|
+
function vt(e, t) {
|
|
400
|
+
const n = [];
|
|
401
|
+
let o = "", r = null, i = 0, s = !1, a = 0;
|
|
402
|
+
const l = (c, m, f) => {
|
|
403
|
+
const u = ee(c);
|
|
404
|
+
n.push(u);
|
|
405
|
+
for (let g = 0; g < u.length; g += 1) {
|
|
406
|
+
const p = u[g];
|
|
407
|
+
if (Mt(p)) {
|
|
408
|
+
r !== null && (s = !0);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
s || (r === null && (r = m), o += p, i = f);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
for (const c of e.matchAll(yt)) {
|
|
415
|
+
const m = c.index;
|
|
416
|
+
for (let u = a; u < m; u += 1)
|
|
417
|
+
l(e[u], u, u + 1);
|
|
418
|
+
const f = c[0];
|
|
419
|
+
l(f, m, m + f.length), a = m + f.length;
|
|
420
|
+
}
|
|
421
|
+
for (let c = a; c < e.length; c += 1)
|
|
422
|
+
l(e[c], c, c + 1);
|
|
423
|
+
return n.join("") !== ee(e) ? wt(e, t) : r === null ? null : { id: o, span: { from: r, to: i } };
|
|
424
|
+
}
|
|
425
|
+
function Tt(e, t, n) {
|
|
426
|
+
const o = h(e), r = k(e), i = w(e), s = "value" in e && typeof e.value == "string" ? e.value : "", a = (F) => {
|
|
427
|
+
const B = n[F - 1], A = I(t, n, F);
|
|
428
|
+
return t.slice(B, A);
|
|
429
|
+
}, l = n[r - 1], c = a(r), m = /^(\`{3,}|~{3,})(.*)$/.exec(t.slice(o.from, l + c.length));
|
|
430
|
+
let f = !1, u = { from: l, to: l }, g = { from: l, to: l }, p = null, d = null, x = "", S = null, T = null;
|
|
431
|
+
if (m) {
|
|
432
|
+
f = !0;
|
|
433
|
+
const F = m[1][0], B = m[1].length, A = o.from;
|
|
434
|
+
u = { from: A, to: A + B };
|
|
435
|
+
const ze = u.to, He = l + c.length;
|
|
436
|
+
g = { from: ze, to: He }, p = "lang" in e && typeof e.lang == "string" ? e.lang : null, d = "meta" in e && typeof e.meta == "string" ? e.meta : null, x = m[2];
|
|
437
|
+
const E = vt(x, p);
|
|
438
|
+
S = E && {
|
|
439
|
+
...E,
|
|
440
|
+
span: {
|
|
441
|
+
from: g.from + E.span.from,
|
|
442
|
+
to: g.from + E.span.to
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const je = s === "" ? 0 : s.split(`
|
|
446
|
+
`).length, Ue = i > r + je;
|
|
447
|
+
if (i > r) {
|
|
448
|
+
const Ke = a(i), $ = /(`{3,}|~{3,})\s*$/.exec(Ke);
|
|
449
|
+
if (Ue && $ && $[1][0] === F && $[1].length >= B) {
|
|
450
|
+
const Y = n[i - 1] + $.index;
|
|
451
|
+
T = { from: Y, to: Y + $[1].length };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
const Oe = f ? r < i ? n[r] : u.to : o.from, Re = f && T ? T.from : o.to, We = { from: Oe, to: Re }, qe = $t(
|
|
456
|
+
s,
|
|
457
|
+
f ? r + 1 : r,
|
|
458
|
+
f && T ? i - 1 : i,
|
|
459
|
+
t,
|
|
460
|
+
n
|
|
461
|
+
);
|
|
462
|
+
return { from: o.from, to: o.to, firstLine: r, lastLine: i, fenced: f, openingFence: u, info: g, lang: p, meta: d, infoValue: x, language: S, content: We, contentSegments: qe, value: s, closingFence: T };
|
|
463
|
+
}
|
|
464
|
+
function $t(e, t, n, o, r) {
|
|
465
|
+
const i = e.split(`
|
|
466
|
+
`);
|
|
467
|
+
if (e === "")
|
|
468
|
+
return [];
|
|
469
|
+
const s = [];
|
|
470
|
+
for (let a = 0; a < i.length; a += 1) {
|
|
471
|
+
const l = i[a], c = t + a;
|
|
472
|
+
if (c > n)
|
|
473
|
+
continue;
|
|
474
|
+
const m = r[c - 1], f = I(o, r, c), u = o.slice(m, f), g = m + u.length - l.length;
|
|
475
|
+
s.push({ from: g, to: g + l.length, text: l });
|
|
476
|
+
}
|
|
477
|
+
return s;
|
|
478
|
+
}
|
|
479
|
+
function H(e, t) {
|
|
480
|
+
const n = pe(e), o = n.includes(e.length - e.trimStart().length), r = n.includes(e.trimEnd().length - 1), i = [
|
|
481
|
+
o ? n[0] : -1,
|
|
482
|
+
...n.slice(o ? 1 : 0, r ? -1 : void 0),
|
|
483
|
+
r ? n[n.length - 1] : e.length
|
|
484
|
+
], s = [];
|
|
485
|
+
for (let a = 0; a < i.length - 1; a += 1) {
|
|
486
|
+
const l = i[a] + 1, c = i[a + 1], m = e.slice(l, c), f = m.length - m.trimStart().length, u = m.length - m.trimEnd().length, g = l + f, p = c - u;
|
|
487
|
+
s.push({
|
|
488
|
+
from: t + l,
|
|
489
|
+
to: t + c,
|
|
490
|
+
content: { from: t + g, to: t + p },
|
|
491
|
+
value: e.slice(g, p)
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return { from: t, to: t + e.length, cells: s };
|
|
495
|
+
}
|
|
496
|
+
function pe(e) {
|
|
497
|
+
return Ze(e).filter((t) => !R(e, t));
|
|
498
|
+
}
|
|
499
|
+
function It(e) {
|
|
500
|
+
const t = pe(e), n = e.length - e.trimStart().length, o = e.trimEnd().length - 1;
|
|
501
|
+
return !(t.includes(n) && t.includes(o) && n === o);
|
|
502
|
+
}
|
|
503
|
+
function Ft(e, t) {
|
|
504
|
+
const n = e.position;
|
|
505
|
+
if (!n)
|
|
506
|
+
return;
|
|
507
|
+
const o = t.lineStarts;
|
|
508
|
+
for (let r = n.start.line; r <= n.end.line; r += 1) {
|
|
509
|
+
const i = o[r - 1];
|
|
510
|
+
if (i == null)
|
|
511
|
+
continue;
|
|
512
|
+
const s = I(t.input, o, r);
|
|
513
|
+
let a = i;
|
|
514
|
+
for (; a < s && (t.input[a] === " " || t.input[a] === " "); )
|
|
515
|
+
a += 1;
|
|
516
|
+
let l = 0;
|
|
517
|
+
for (; a < s && t.input[a] === ">"; ) {
|
|
518
|
+
const c = a;
|
|
519
|
+
a += 1, a < s && t.input[a] === " " && (a += 1), l += 1, t.document.quoteMarkers.push({ line: r, from: c, to: a, depth: l });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function Bt(e) {
|
|
524
|
+
const t = [0];
|
|
525
|
+
for (let n = 0; n < e.length; n += 1)
|
|
526
|
+
e[n] === "\r" ? (e[n + 1] === `
|
|
527
|
+
` && (n += 1), t.push(n + 1)) : e[n] === `
|
|
528
|
+
` && t.push(n + 1);
|
|
529
|
+
return t;
|
|
530
|
+
}
|
|
531
|
+
function I(e, t, n) {
|
|
532
|
+
const o = t[n];
|
|
533
|
+
return o == null ? e.length : o - (e[o - 2] === "\r" ? 2 : 1);
|
|
534
|
+
}
|
|
535
|
+
function At(e, t) {
|
|
536
|
+
const n = {
|
|
537
|
+
headings: [],
|
|
538
|
+
listItems: [],
|
|
539
|
+
codeBlocks: [],
|
|
540
|
+
blockquotes: [],
|
|
541
|
+
quoteMarkers: [],
|
|
542
|
+
inlineStyles: [],
|
|
543
|
+
inlineCodes: [],
|
|
544
|
+
inlineMath: [],
|
|
545
|
+
links: [],
|
|
546
|
+
images: [],
|
|
547
|
+
tables: [],
|
|
548
|
+
thematicBreaks: [],
|
|
549
|
+
hardBreaks: [],
|
|
550
|
+
escapes: [],
|
|
551
|
+
footnoteReferences: [],
|
|
552
|
+
footnoteDefinitions: []
|
|
553
|
+
}, o = Bt(t), r = [];
|
|
554
|
+
return Lt(e, { input: t, document: n, listDepth: 0, blockquoteDepth: 0, lineStarts: o, protectedRanges: r }), r.push(...Et(t)), Pt(n, t, o, r), Dt(n), n;
|
|
555
|
+
}
|
|
556
|
+
function Et(e) {
|
|
557
|
+
const t = [], n = /<!--[\s\S]*?-->|<\/?([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/g, o = [], r = /* @__PURE__ */ new Map();
|
|
558
|
+
for (let i = n.exec(e); i; i = n.exec(e)) {
|
|
559
|
+
const s = i[0], a = i.index, l = a + s.length;
|
|
560
|
+
if (s.startsWith("<!--")) {
|
|
561
|
+
t.push({ from: a, to: l });
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
const c = i[1].toLowerCase();
|
|
565
|
+
if (s.startsWith("</")) {
|
|
566
|
+
const f = r.get(c)?.pop();
|
|
567
|
+
if (f !== void 0) {
|
|
568
|
+
const u = o[f];
|
|
569
|
+
u.closed = !0, t.push({ from: u.from, to: l });
|
|
570
|
+
}
|
|
571
|
+
} else if (s.endsWith("/>"))
|
|
572
|
+
t.push({ from: a, to: l });
|
|
573
|
+
else {
|
|
574
|
+
const m = o.length;
|
|
575
|
+
o.push({ name: c, from: a, to: l, closed: !1 });
|
|
576
|
+
const f = r.get(c);
|
|
577
|
+
f ? f.push(m) : r.set(c, [m]);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return t.push(...o.filter((i) => !i.closed).map(({ from: i, to: s }) => ({ from: i, to: s }))), t;
|
|
581
|
+
}
|
|
582
|
+
function Dt(e, t) {
|
|
583
|
+
for (const n of e.tables)
|
|
584
|
+
for (const o of [n.header, ...n.rows])
|
|
585
|
+
for (const r of o.cells) {
|
|
586
|
+
const i = fe.get(r);
|
|
587
|
+
if (!i) continue;
|
|
588
|
+
const s = e.inlineMath.filter(
|
|
589
|
+
(a) => a.display === "inline" && r.content.from <= a.from && a.to <= r.content.to
|
|
590
|
+
);
|
|
591
|
+
r.displayValue = i.map((a) => Gt(a, s)).join("");
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function Gt(e, t) {
|
|
595
|
+
const n = t.filter((i) => e.from <= i.from && i.to <= e.to);
|
|
596
|
+
if (n.length === 0) return e.text;
|
|
597
|
+
if (!e.projectSourceSlice)
|
|
598
|
+
return n.length === 1 && n[0].from === e.from && n[0].to === e.to ? n[0].expression : e.text;
|
|
599
|
+
let o = e.from, r = "";
|
|
600
|
+
for (const i of n)
|
|
601
|
+
r += e.projectSourceSlice(o, i.from), r += i.expression, o = i.to;
|
|
602
|
+
return r + e.projectSourceSlice(o, e.to);
|
|
603
|
+
}
|
|
604
|
+
function Pt(e, t, n, o) {
|
|
605
|
+
const r = [
|
|
606
|
+
...e.inlineCodes.map((l) => ({ from: l.open.from, to: l.close.to })),
|
|
607
|
+
...e.codeBlocks.map((l) => ({ from: l.from, to: l.to })),
|
|
608
|
+
...e.links.map(({ from: l, to: c }) => ({ from: l, to: c })),
|
|
609
|
+
...e.images.map(({ from: l, to: c }) => ({ from: l, to: c })),
|
|
610
|
+
// An escape protects both the slash and the escaped punctuation character.
|
|
611
|
+
...e.escapes.map(({ from: l, to: c }) => ({ from: l, to: Math.min(t.length, c + 1) })),
|
|
612
|
+
// An escape protects both the slash and the escaped punctuation character.
|
|
613
|
+
...e.inlineMath.map(({ from: l, to: c }) => ({ from: l, to: c })),
|
|
614
|
+
...o
|
|
615
|
+
];
|
|
616
|
+
r.sort((l, c) => l.from - c.from || l.to - c.to);
|
|
617
|
+
const i = [];
|
|
618
|
+
for (const l of r) {
|
|
619
|
+
const c = i[i.length - 1];
|
|
620
|
+
c && l.from <= c.to ? c.to = Math.max(c.to, l.to) : i.push({ ...l });
|
|
621
|
+
}
|
|
622
|
+
r.splice(0, r.length, ...i);
|
|
623
|
+
const s = (l, c) => zt(r, l, c);
|
|
624
|
+
let a = -1;
|
|
625
|
+
for (let l = 0; l < t.length; l += 1) {
|
|
626
|
+
if (t[l] !== "$" || R(t, l) || s(l, l + 1) || t[l - 1] === "$" && l !== a) continue;
|
|
627
|
+
const c = t[l + 1] === "$" ? 2 : 1;
|
|
628
|
+
if (t[l + c] === "$") continue;
|
|
629
|
+
const m = Rt(t, l, c, s);
|
|
630
|
+
if (m === -1) continue;
|
|
631
|
+
const f = m + c, u = t.slice(l + c, m), g = c === 2 ? Ot(u) : u, p = g.includes(`
|
|
632
|
+
`) || g.includes("\r");
|
|
633
|
+
if (c === 1 && p || c === 1 && (g.length === 0 || /^\s/.test(g) || /\s$/.test(g)) || c === 1 && e.inlineStyles.some((S) => qt(S, l, f)) || ne(t[l - 1]) || ne(t[f]) || c === 2 && jt(t, l)) continue;
|
|
634
|
+
const d = c === 2 && Ht(t, l, f) ? "block" : "inline";
|
|
635
|
+
if (d === "inline" && p) continue;
|
|
636
|
+
const x = Kt(e.tables, l, f);
|
|
637
|
+
e.inlineMath.push({
|
|
638
|
+
from: l,
|
|
639
|
+
to: f,
|
|
640
|
+
expression: g,
|
|
641
|
+
delimiter: "dollar",
|
|
642
|
+
display: d,
|
|
643
|
+
startLine: oe(n, l),
|
|
644
|
+
endLine: oe(n, f - 1),
|
|
645
|
+
inTableCell: x
|
|
646
|
+
}), a = c === 1 ? f : -1, l = f - 1;
|
|
647
|
+
}
|
|
648
|
+
e.inlineMath.sort((l, c) => l.from - c.from || l.to - c.to);
|
|
649
|
+
}
|
|
650
|
+
function Ot(e) {
|
|
651
|
+
return e.replace(/^(?:\r\n|\n|\r)/, "").replace(/(?:\r\n|\n|\r)$/, "");
|
|
652
|
+
}
|
|
653
|
+
function Rt(e, t, n, o) {
|
|
654
|
+
for (let r = t + n; r < e.length; r += 1)
|
|
655
|
+
if (!(e[r] !== "$" || R(e, r) || o(r, r + n)) && e.slice(r, r + n) === "$".repeat(n) && !(n === 2 && (e[r - 1] === "$" || e[r + n] === "$")) && !(n === 1 && Wt(e, r)))
|
|
656
|
+
return r;
|
|
657
|
+
return -1;
|
|
658
|
+
}
|
|
659
|
+
function Wt(e, t) {
|
|
660
|
+
return e[t - 2] === "$" && e[t - 1] === "$" || e[t - 1] === "$" && e[t + 1] === "$" || e[t + 1] === "$" && e[t + 2] === "$";
|
|
661
|
+
}
|
|
662
|
+
function ne(e) {
|
|
663
|
+
return e !== void 0 && /[A-Za-z0-9]/.test(e);
|
|
664
|
+
}
|
|
665
|
+
function oe(e, t) {
|
|
666
|
+
let n = 0, o = e.length;
|
|
667
|
+
for (; n < o; ) {
|
|
668
|
+
const r = Math.floor((n + o) / 2);
|
|
669
|
+
e[r] <= t ? n = r + 1 : o = r;
|
|
670
|
+
}
|
|
671
|
+
return n;
|
|
672
|
+
}
|
|
673
|
+
function qt(e, t, n) {
|
|
674
|
+
return t < e.close.to && e.open.from < n ? !(e.content.from <= t && n <= e.content.to && (e.type === "strong" || e.type === "delete")) : !1;
|
|
675
|
+
}
|
|
676
|
+
function zt(e, t, n) {
|
|
677
|
+
let o = 0, r = e.length;
|
|
678
|
+
for (; o < r; ) {
|
|
679
|
+
const i = Math.floor((o + r) / 2);
|
|
680
|
+
e[i].to <= t ? o = i + 1 : r = i;
|
|
681
|
+
}
|
|
682
|
+
return o < e.length && e[o].from < n;
|
|
683
|
+
}
|
|
684
|
+
function Ht(e, t, n) {
|
|
685
|
+
const o = be(e, t), r = Ut(e, n), i = e.slice(o, t), s = e.slice(n, r);
|
|
686
|
+
return /^(?:[ \t]*>[ \t]*)*$/.test(i) && /^[ \t]*$/.test(s);
|
|
687
|
+
}
|
|
688
|
+
function jt(e, t) {
|
|
689
|
+
const n = be(e, t);
|
|
690
|
+
return /^[ \t]*(?:[-*+]|\d+[.)])[ \t]+/.test(e.slice(n, t));
|
|
691
|
+
}
|
|
692
|
+
function be(e, t) {
|
|
693
|
+
return Math.max(e.lastIndexOf(`
|
|
694
|
+
`, t - 1), e.lastIndexOf("\r", t - 1)) + 1;
|
|
695
|
+
}
|
|
696
|
+
function Ut(e, t) {
|
|
697
|
+
const n = e.indexOf("\r", t), o = e.indexOf(`
|
|
698
|
+
`, t);
|
|
699
|
+
return n === -1 ? o === -1 ? e.length : o : o === -1 ? n : Math.min(n, o);
|
|
700
|
+
}
|
|
701
|
+
function Kt(e, t, n) {
|
|
702
|
+
return e.some((o) => [o.header, ...o.rows].some(
|
|
703
|
+
(r) => r.cells.some((i) => i.content.from <= t && n <= i.content.to)
|
|
704
|
+
));
|
|
705
|
+
}
|
|
706
|
+
const Zt = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
|
|
707
|
+
function Qt(e) {
|
|
708
|
+
const t = dt(e, {
|
|
709
|
+
extensions: [pt()],
|
|
710
|
+
mdastExtensions: [bt()]
|
|
711
|
+
});
|
|
712
|
+
return At(t, e);
|
|
713
|
+
}
|
|
714
|
+
const Jt = Qe(Qt);
|
|
715
|
+
function b(e) {
|
|
716
|
+
return Jt.get(e);
|
|
717
|
+
}
|
|
718
|
+
const xe = "mbox-gfm-code-block", C = {
|
|
719
|
+
fenceLine: "mbox-gfm-code-fence-line",
|
|
720
|
+
headerLine: "mbox-gfm-code-header-line",
|
|
721
|
+
openingFenceLine: "mbox-gfm-code-opening-fence-line",
|
|
722
|
+
closingFenceLine: "mbox-gfm-code-closing-fence-line",
|
|
723
|
+
contentLine: "mbox-gfm-code-content-line",
|
|
724
|
+
copyButton: "mbox-gfm-code-copy-button",
|
|
725
|
+
languageLabel: "mbox-gfm-code-language-label",
|
|
726
|
+
token: "mbox-gfm-code-token"
|
|
727
|
+
};
|
|
728
|
+
function Vt(e, t, n) {
|
|
729
|
+
return e.codeBlocks.flatMap(
|
|
730
|
+
(o) => n && Z(o) ? [] : _t(o, t)
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
function _t(e, t) {
|
|
734
|
+
const n = [
|
|
735
|
+
{ type: "lineRange", from: e.from, to: e.to, className: xe }
|
|
736
|
+
];
|
|
737
|
+
for (const { from: r } of e.contentSegments)
|
|
738
|
+
n.push({ type: "line", from: r, className: C.contentLine });
|
|
739
|
+
if (!e.fenced)
|
|
740
|
+
return n;
|
|
741
|
+
const o = t.has(e.firstLine);
|
|
742
|
+
if (n.push({
|
|
743
|
+
type: "line",
|
|
744
|
+
from: e.openingFence.from,
|
|
745
|
+
className: o ? `${C.fenceLine} ${C.openingFenceLine}` : `${C.fenceLine} ${C.openingFenceLine} ${C.headerLine}`
|
|
746
|
+
}), o || (n.push({ type: "replace", from: e.openingFence.from, to: e.openingFence.to }), e.language && n.push({
|
|
747
|
+
type: "mark",
|
|
748
|
+
from: e.language.span.from,
|
|
749
|
+
to: e.language.span.to,
|
|
750
|
+
className: C.languageLabel
|
|
751
|
+
}), n.push({
|
|
752
|
+
type: "widget",
|
|
753
|
+
from: e.info.to,
|
|
754
|
+
widget: new _e(e.value, C.copyButton),
|
|
755
|
+
side: 1
|
|
756
|
+
})), e.closingFence) {
|
|
757
|
+
const r = t.has(e.lastLine);
|
|
758
|
+
n.push({
|
|
759
|
+
type: "line",
|
|
760
|
+
from: e.closingFence.from,
|
|
761
|
+
className: `${C.fenceLine} ${C.closingFenceLine}`
|
|
762
|
+
}), r || n.push({ type: "replace", from: e.closingFence.from, to: e.closingFence.to });
|
|
763
|
+
}
|
|
764
|
+
return n;
|
|
765
|
+
}
|
|
766
|
+
const Xt = {
|
|
767
|
+
[`.${xe}`]: {
|
|
768
|
+
fontFamily: 'var(--mbox-code-block-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
function Yt(e = {}) {
|
|
772
|
+
return {
|
|
773
|
+
theme: Xt,
|
|
774
|
+
name: "gfm/code-block",
|
|
775
|
+
decorations: (t) => Vt(b(t.state), t.activeLineNumbers, e.excludeMathFences === !0)
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function re(e, t) {
|
|
779
|
+
return e.codeBlocks.flatMap((n) => {
|
|
780
|
+
if (Z(n))
|
|
781
|
+
return [];
|
|
782
|
+
const o = n.language ? t(n.language.id) : null;
|
|
783
|
+
return o ? Ve(n.contentSegments, o, C.token) : [];
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
function en(e = {}) {
|
|
787
|
+
if (!e.languages)
|
|
788
|
+
return {
|
|
789
|
+
name: "gfm/code-block-highlight",
|
|
790
|
+
decorations: (n) => re(b(n.state), Xe)
|
|
791
|
+
};
|
|
792
|
+
const t = Je(
|
|
793
|
+
(n) => b(n).codeBlocks.flatMap((o) => o.language ? [o.language.id] : []),
|
|
794
|
+
{
|
|
795
|
+
...e.languages === "all" ? {} : { languages: e.languages },
|
|
796
|
+
onLoadError: e.onLoadError
|
|
797
|
+
}
|
|
798
|
+
);
|
|
799
|
+
return {
|
|
800
|
+
extensions: [t.extension],
|
|
801
|
+
name: "gfm/code-block-highlight",
|
|
802
|
+
decorations: (n) => re(b(n.state), t.getLanguage)
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
const j = "mbox-gfm-heading", ke = "mbox-gfm-heading-setext-underline", N = {
|
|
806
|
+
h1: "mbox-gfm-h1",
|
|
807
|
+
h2: "mbox-gfm-h2",
|
|
808
|
+
h3: "mbox-gfm-h3",
|
|
809
|
+
h4: "mbox-gfm-h4",
|
|
810
|
+
h5: "mbox-gfm-h5",
|
|
811
|
+
h6: "mbox-gfm-h6"
|
|
812
|
+
}, tn = (e) => N[`h${e}`];
|
|
813
|
+
function nn(e, t) {
|
|
814
|
+
return e.headings.flatMap((n) => {
|
|
815
|
+
const o = t.has(n.line) || n.setextUnderline !== void 0 && t.has(n.setextUnderline.line), r = tn(n.level);
|
|
816
|
+
if (n.marker.to - n.marker.from, n.setextUnderline !== void 0) {
|
|
817
|
+
const s = [
|
|
818
|
+
{
|
|
819
|
+
type: "line",
|
|
820
|
+
from: n.from,
|
|
821
|
+
className: `${j} ${r}`
|
|
822
|
+
}
|
|
823
|
+
];
|
|
824
|
+
return o || s.push({ type: "line", from: n.setextUnderline.from, className: ke }), s;
|
|
825
|
+
}
|
|
826
|
+
return o ? [
|
|
827
|
+
{
|
|
828
|
+
type: "line",
|
|
829
|
+
from: n.from,
|
|
830
|
+
className: `${j} ${r}`
|
|
831
|
+
}
|
|
832
|
+
] : [
|
|
833
|
+
{
|
|
834
|
+
type: "line",
|
|
835
|
+
from: n.from,
|
|
836
|
+
className: `${j} ${r}`
|
|
837
|
+
},
|
|
838
|
+
{ type: "replace", from: n.marker.from, to: n.marker.to }
|
|
839
|
+
];
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
const on = {
|
|
843
|
+
[`.${ke}`]: { display: "none" }
|
|
844
|
+
};
|
|
845
|
+
function rn() {
|
|
846
|
+
return {
|
|
847
|
+
name: "gfm/heading",
|
|
848
|
+
theme: on,
|
|
849
|
+
decorations: (e) => nn(b(e.state), e.activeLineNumbers)
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
const sn = "mbox-gfm-image", v = {
|
|
853
|
+
image: sn,
|
|
854
|
+
token: "mbox-gfm-image-token",
|
|
855
|
+
preview: "mbox-gfm-image-preview",
|
|
856
|
+
element: "mbox-gfm-image-element"
|
|
857
|
+
}, W = {
|
|
858
|
+
measure: "mbox-gfm-image-measure"
|
|
859
|
+
}, Ce = "preview", V = xt.define({
|
|
860
|
+
combine: (e) => e.some(Boolean)
|
|
861
|
+
});
|
|
862
|
+
class an extends tt {
|
|
863
|
+
constructor(t) {
|
|
864
|
+
super(t, v, W);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
const ln = {
|
|
868
|
+
measure: (e) => new an(e)
|
|
869
|
+
};
|
|
870
|
+
function cn(e, t, n, o) {
|
|
871
|
+
const r = o.renderMode ?? Ce;
|
|
872
|
+
return e.images.flatMap(
|
|
873
|
+
(i) => et(
|
|
874
|
+
[{ from: i.from, to: i.to, src: i.url, alt: i.alt, text: i.alt || i.url }],
|
|
875
|
+
n.has(i.line),
|
|
876
|
+
t,
|
|
877
|
+
v,
|
|
878
|
+
W,
|
|
879
|
+
// Table cells used to force the token here. They no longer do: the table
|
|
880
|
+
// plugin reserves a column for a cell that holds an image (see
|
|
881
|
+
// gfmImagePreviewEnabled), and the theme keeps the picture inside that
|
|
882
|
+
// cell. `inTableCell` stays on the record because the reservation is the
|
|
883
|
+
// table's business, not this plugin's.
|
|
884
|
+
r,
|
|
885
|
+
ln
|
|
886
|
+
)
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
function mn(e = {}) {
|
|
890
|
+
return {
|
|
891
|
+
theme: Ye(v, W),
|
|
892
|
+
extensions: [V.of((e.renderMode ?? Ce) === "preview")],
|
|
893
|
+
name: "gfm/image",
|
|
894
|
+
decorations: (t) => cn(b(t.state), t.state.doc, t.activeLineNumbers, e)
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
const D = "mbox-gfm-footnote", Le = "mbox-gfm-footnote-marker", Se = "mbox-gfm-footnote-ref";
|
|
898
|
+
class fn extends M {
|
|
899
|
+
constructor(t, n, o) {
|
|
900
|
+
super(), this.label = t, this.note = n, this.targetId = o;
|
|
901
|
+
}
|
|
902
|
+
label;
|
|
903
|
+
note;
|
|
904
|
+
targetId;
|
|
905
|
+
eq(t) {
|
|
906
|
+
const n = t;
|
|
907
|
+
return this.constructor === t.constructor && this.label === n.label && this.note === n.note && this.targetId === n.targetId;
|
|
908
|
+
}
|
|
909
|
+
toDOM() {
|
|
910
|
+
const t = document.createElement(this.targetId ? "a" : "span");
|
|
911
|
+
return t.className = Se, t.textContent = this.label, this.targetId && (t.setAttribute("href", `#${this.targetId}`), t.setAttribute("role", "doc-noteref"), t.setAttribute("aria-label", `Footnote ${this.label}`)), this.note && (t.title = this.note), t;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
function un(e, t, n) {
|
|
915
|
+
const o = new Map(e.footnoteDefinitions.map((a) => [a.identifier, a])), r = (a) => {
|
|
916
|
+
for (let l = a.startLine; l <= a.endLine; l += 1)
|
|
917
|
+
if (n.has(l)) return !1;
|
|
918
|
+
return !0;
|
|
919
|
+
}, i = e.footnoteReferences.flatMap(
|
|
920
|
+
(a) => ce(
|
|
921
|
+
a,
|
|
922
|
+
n.has(a.line),
|
|
923
|
+
t.doc,
|
|
924
|
+
() => {
|
|
925
|
+
const l = o.get(a.identifier);
|
|
926
|
+
return new fn(
|
|
927
|
+
a.label,
|
|
928
|
+
l?.text ?? "",
|
|
929
|
+
l && r(l) ? `gfm-footnote-${l.from}` : void 0
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
)
|
|
933
|
+
), s = e.footnoteDefinitions.flatMap((a) => {
|
|
934
|
+
const l = r(a), c = `gfm-footnote-${a.from}`, m = Array.from(
|
|
935
|
+
{ length: a.endLine - a.startLine },
|
|
936
|
+
(p, d) => t.doc.line(a.startLine + d + 1).from
|
|
937
|
+
), f = m.map((p) => `${c}-line-${p}`), u = l ? {
|
|
938
|
+
id: c,
|
|
939
|
+
role: "doc-footnote",
|
|
940
|
+
"aria-label": `Footnote ${a.label}`,
|
|
941
|
+
...f.length > 0 ? { "aria-owns": f.join(" ") } : {}
|
|
942
|
+
} : void 0, g = l ? { "aria-hidden": "true" } : void 0;
|
|
943
|
+
return [
|
|
944
|
+
{ type: "lineRange", from: a.from, to: a.to, className: D },
|
|
945
|
+
...l ? [{
|
|
946
|
+
type: "line",
|
|
947
|
+
from: a.from,
|
|
948
|
+
className: D,
|
|
949
|
+
attributes: u
|
|
950
|
+
}, ...m.map((p, d) => ({
|
|
951
|
+
type: "line",
|
|
952
|
+
from: p,
|
|
953
|
+
className: D,
|
|
954
|
+
attributes: { id: f[d] }
|
|
955
|
+
}))] : [],
|
|
956
|
+
{
|
|
957
|
+
type: "mark",
|
|
958
|
+
from: a.marker.from,
|
|
959
|
+
to: a.marker.to,
|
|
960
|
+
className: Le,
|
|
961
|
+
...g ? { attributes: g } : {}
|
|
962
|
+
}
|
|
963
|
+
];
|
|
964
|
+
});
|
|
965
|
+
return [...i, ...s];
|
|
966
|
+
}
|
|
967
|
+
const hn = {
|
|
968
|
+
// The chip stays inside the line box: sized down and top-aligned instead of
|
|
969
|
+
// raised on the baseline, so an idle/focused swap never changes line height.
|
|
970
|
+
[`.${Se}`]: {
|
|
971
|
+
display: "inline-block",
|
|
972
|
+
fontSize: "0.7em",
|
|
973
|
+
verticalAlign: "text-top",
|
|
974
|
+
background: "rgba(127, 127, 127, 0.16)",
|
|
975
|
+
borderRadius: "3px",
|
|
976
|
+
padding: "0 0.35em",
|
|
977
|
+
color: "#555",
|
|
978
|
+
cursor: "default"
|
|
979
|
+
},
|
|
980
|
+
[`.${D}`]: {
|
|
981
|
+
fontSize: "0.85em",
|
|
982
|
+
color: "#666"
|
|
983
|
+
},
|
|
984
|
+
[`.${Le}`]: {
|
|
985
|
+
color: "#999"
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
function gn() {
|
|
989
|
+
return {
|
|
990
|
+
theme: hn,
|
|
991
|
+
name: "gfm/footnote",
|
|
992
|
+
decorations: (e) => un(b(e.state), e.state, e.activeLineNumbers)
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
function q(e, t) {
|
|
996
|
+
for (let n = e.startLine; n <= e.endLine; n += 1)
|
|
997
|
+
if (t.has(n))
|
|
998
|
+
return !0;
|
|
999
|
+
return !1;
|
|
1000
|
+
}
|
|
1001
|
+
const Ne = {
|
|
1002
|
+
emphasis: "mbox-gfm-em",
|
|
1003
|
+
strong: "mbox-gfm-strong",
|
|
1004
|
+
delete: "mbox-gfm-del"
|
|
1005
|
+
}, dn = {
|
|
1006
|
+
emphasis: "em",
|
|
1007
|
+
strong: "strong",
|
|
1008
|
+
delete: "del"
|
|
1009
|
+
};
|
|
1010
|
+
function pn(e, t) {
|
|
1011
|
+
return [...e.inlineStyles.flatMap(
|
|
1012
|
+
(o) => me(
|
|
1013
|
+
{
|
|
1014
|
+
openMarker: o.open,
|
|
1015
|
+
content: o.content,
|
|
1016
|
+
closeMarker: o.close,
|
|
1017
|
+
className: Ne[o.type],
|
|
1018
|
+
tagName: dn[o.type]
|
|
1019
|
+
},
|
|
1020
|
+
!q(o, t)
|
|
1021
|
+
)
|
|
1022
|
+
), ...bn(e, t), ...xn(e, t)];
|
|
1023
|
+
}
|
|
1024
|
+
function bn(e, t) {
|
|
1025
|
+
return e.hardBreaks.flatMap((n) => !n.backslash || t.has(n.line) ? [] : [{ type: "replace", from: n.from, to: n.from + 1 }]);
|
|
1026
|
+
}
|
|
1027
|
+
function xn(e, t) {
|
|
1028
|
+
return e.escapes.flatMap((n) => t.has(n.line) ? [] : [{ type: "replace", from: n.from, to: n.to }]);
|
|
1029
|
+
}
|
|
1030
|
+
const kn = {
|
|
1031
|
+
".mbox-gfm-em": { fontStyle: "italic" },
|
|
1032
|
+
".mbox-gfm-strong": { fontWeight: "bold" },
|
|
1033
|
+
".mbox-gfm-del": { textDecoration: "line-through" }
|
|
1034
|
+
};
|
|
1035
|
+
function Cn() {
|
|
1036
|
+
return {
|
|
1037
|
+
theme: kn,
|
|
1038
|
+
name: "gfm/inline",
|
|
1039
|
+
decorations: (e) => pn(b(e.state), e.activeLineNumbers)
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
const _ = "mbox-gfm-code";
|
|
1043
|
+
function Ln(e, t, n) {
|
|
1044
|
+
const o = n ? e.inlineMath.flatMap((r) => r.sourceCodeSpan ? [r.sourceCodeSpan] : []) : void 0;
|
|
1045
|
+
return e.inlineCodes.flatMap(
|
|
1046
|
+
(r) => o?.some((i) => i.from === r.open.from && i.to === r.close.to) ? [] : me(
|
|
1047
|
+
{
|
|
1048
|
+
openMarker: r.open,
|
|
1049
|
+
content: r.content,
|
|
1050
|
+
closeMarker: r.close,
|
|
1051
|
+
className: _,
|
|
1052
|
+
tagName: "code"
|
|
1053
|
+
},
|
|
1054
|
+
!q(r, t)
|
|
1055
|
+
)
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
function Sn() {
|
|
1059
|
+
return ye(!1);
|
|
1060
|
+
}
|
|
1061
|
+
function Nn() {
|
|
1062
|
+
return ye(!0);
|
|
1063
|
+
}
|
|
1064
|
+
function ye(e) {
|
|
1065
|
+
return {
|
|
1066
|
+
name: "gfm/inline-code",
|
|
1067
|
+
decorations: (t) => Ln(b(t.state), t.activeLineNumbers, e)
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
const G = "mbox-gfm-link", yn = "mbox-gfm-link-unsafe", Mn = (e) => e, wn = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), Me = /* @__PURE__ */ new Set(["javascript:", "vbscript:", "data:", "file:", "blob:"]), vn = /^[A-Za-z][A-Za-z0-9+.-]*$/;
|
|
1071
|
+
class Tn extends M {
|
|
1072
|
+
constructor(t, n, o, r, i, s, a = !1) {
|
|
1073
|
+
super(), this.text = t, this.href = n, this.autolink = o, this.external = r, this.label = i, this.source = s, this.renderImages = a;
|
|
1074
|
+
}
|
|
1075
|
+
text;
|
|
1076
|
+
href;
|
|
1077
|
+
autolink;
|
|
1078
|
+
external;
|
|
1079
|
+
label;
|
|
1080
|
+
source;
|
|
1081
|
+
renderImages;
|
|
1082
|
+
eq(t) {
|
|
1083
|
+
const n = t;
|
|
1084
|
+
return this.constructor === t.constructor && this.text === n.text && this.href === n.href && this.autolink === n.autolink && this.external === n.external && this.renderImages === n.renderImages && this.labelSignature() === n.labelSignature();
|
|
1085
|
+
}
|
|
1086
|
+
toDOM() {
|
|
1087
|
+
const t = this.autolink ? `${G} ${G}-autolink` : G, n = nt({
|
|
1088
|
+
href: this.href,
|
|
1089
|
+
text: this.text,
|
|
1090
|
+
className: t,
|
|
1091
|
+
attributes: this.external ? { target: "_blank", rel: "noreferrer" } : void 0
|
|
1092
|
+
});
|
|
1093
|
+
return we(n, this.text, this.label, this.source, this.renderImages), n;
|
|
1094
|
+
}
|
|
1095
|
+
labelSignature() {
|
|
1096
|
+
return JSON.stringify(this.label ?? null);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
class X extends M {
|
|
1100
|
+
constructor(t, n, o, r = !1) {
|
|
1101
|
+
super(), this.text = t, this.label = n, this.source = o, this.renderImages = r;
|
|
1102
|
+
}
|
|
1103
|
+
text;
|
|
1104
|
+
label;
|
|
1105
|
+
source;
|
|
1106
|
+
renderImages;
|
|
1107
|
+
eq(t) {
|
|
1108
|
+
return t instanceof X && this.text === t.text && this.renderImages === t.renderImages && JSON.stringify(this.label ?? null) === JSON.stringify(t.label ?? null);
|
|
1109
|
+
}
|
|
1110
|
+
toDOM() {
|
|
1111
|
+
const t = document.createElement("span");
|
|
1112
|
+
return t.className = yn, we(t, this.text, this.label, this.source, this.renderImages), t;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
function we(e, t, n, o, r) {
|
|
1116
|
+
if (n === void 0 || n.length === 0 || o === void 0) {
|
|
1117
|
+
e.textContent = t;
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
e.replaceChildren(...n.map((i) => ve(i, o, r)));
|
|
1121
|
+
}
|
|
1122
|
+
function ve(e, t, n) {
|
|
1123
|
+
switch (e.kind) {
|
|
1124
|
+
case "emphasis":
|
|
1125
|
+
case "strong":
|
|
1126
|
+
case "delete": {
|
|
1127
|
+
const o = document.createElement(e.kind === "delete" ? "del" : e.kind === "emphasis" ? "em" : "strong");
|
|
1128
|
+
return o.className = Ne[e.kind], o.replaceChildren(...e.children.map((r) => ve(r, t, n))), o;
|
|
1129
|
+
}
|
|
1130
|
+
case "inlineCode": {
|
|
1131
|
+
const o = document.createElement("code");
|
|
1132
|
+
return o.className = _, o.append(document.createTextNode(t.slice(e.content.from, e.content.to))), o;
|
|
1133
|
+
}
|
|
1134
|
+
case "break":
|
|
1135
|
+
return document.createElement("br");
|
|
1136
|
+
case "text":
|
|
1137
|
+
return document.createTextNode(K(t.slice(e.from, e.to)));
|
|
1138
|
+
case "image": {
|
|
1139
|
+
if (!n || e.url === void 0)
|
|
1140
|
+
return document.createTextNode(e.text);
|
|
1141
|
+
const o = document.createElement("img");
|
|
1142
|
+
return o.className = v.element, o.src = e.url, o.alt = e.text, o.loading = "lazy", o.decoding = "async", o;
|
|
1143
|
+
}
|
|
1144
|
+
case "footnoteReference":
|
|
1145
|
+
return document.createTextNode(e.text);
|
|
1146
|
+
case "unknown":
|
|
1147
|
+
return document.createTextNode(t.slice(e.from, e.to));
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function $n(e) {
|
|
1151
|
+
const t = new Set(wn);
|
|
1152
|
+
for (const n of e ?? []) {
|
|
1153
|
+
if (!vn.test(n)) continue;
|
|
1154
|
+
const o = `${n.toLowerCase()}:`;
|
|
1155
|
+
Me.has(o) || t.add(o);
|
|
1156
|
+
}
|
|
1157
|
+
return t;
|
|
1158
|
+
}
|
|
1159
|
+
function In(e, t) {
|
|
1160
|
+
try {
|
|
1161
|
+
const n = new URL(e, "https://mbox.invalid/");
|
|
1162
|
+
return t.has(n.protocol) && !Me.has(n.protocol) ? n : void 0;
|
|
1163
|
+
} catch {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function Fn(e, t) {
|
|
1168
|
+
const n = e.replace(/[\t\n\r]/g, "").replace(/^[\u0000-\u0020]+/, ""), o = /^([A-Za-z][A-Za-z0-9+.-]*):/.exec(n)?.[1]?.toLowerCase();
|
|
1169
|
+
return (o === "http" || o === "https") && (t.protocol === "http:" || t.protocol === "https:");
|
|
1170
|
+
}
|
|
1171
|
+
function Bn(e, t, n, o, r, i) {
|
|
1172
|
+
return e.links.flatMap(
|
|
1173
|
+
(s) => ce(s, q(s, n), t, () => {
|
|
1174
|
+
const a = s.text, l = o(s.url), c = In(l, r);
|
|
1175
|
+
return c ? new Tn(a, l, s.autolink, Fn(l, c), s.label, s.labelSource, i) : new X(a, s.label, s.labelSource, i);
|
|
1176
|
+
})
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
function An(e = {}) {
|
|
1180
|
+
const t = e.linkUrl ?? Mn, n = $n(e.additionalAllowedProtocols);
|
|
1181
|
+
return {
|
|
1182
|
+
name: "gfm/link",
|
|
1183
|
+
decorations: (o) => Bn(
|
|
1184
|
+
b(o.state),
|
|
1185
|
+
o.state.doc,
|
|
1186
|
+
o.activeLineNumbers,
|
|
1187
|
+
t,
|
|
1188
|
+
n,
|
|
1189
|
+
// Whether pictures are drawn at all is the image plugin's setting, and
|
|
1190
|
+
// a link label is not an exception to it. Read through the same facet
|
|
1191
|
+
// the table plugin uses, so a host assembling plugins by hand gets the
|
|
1192
|
+
// same answer as one using the bundle.
|
|
1193
|
+
o.state.facet(V)
|
|
1194
|
+
)
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
const se = "mbox-gfm-list-line", En = "mbox-gfm-task-line", Te = "mbox-gfm-bullet", O = "mbox-gfm-task-checkbox", ie = (e) => `mbox-gfm-li-d${e}`;
|
|
1198
|
+
class Dn extends M {
|
|
1199
|
+
constructor(t, n) {
|
|
1200
|
+
super(), this.width = t, this.label = n;
|
|
1201
|
+
}
|
|
1202
|
+
width;
|
|
1203
|
+
label;
|
|
1204
|
+
eq(t) {
|
|
1205
|
+
const n = t;
|
|
1206
|
+
return this.constructor === t.constructor && this.width === n.width && this.label === n.label;
|
|
1207
|
+
}
|
|
1208
|
+
toDOM() {
|
|
1209
|
+
const t = document.createElement("span");
|
|
1210
|
+
return t.className = Te, t.style.display = "inline-block", t.style.width = `${this.width}ch`, t.textContent = this.label, t;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
class Gn extends M {
|
|
1214
|
+
constructor(t, n, o, r = !1) {
|
|
1215
|
+
super(), this.checked = t, this.from = n, this.to = o, this.readOnly = r;
|
|
1216
|
+
}
|
|
1217
|
+
checked;
|
|
1218
|
+
from;
|
|
1219
|
+
to;
|
|
1220
|
+
readOnly;
|
|
1221
|
+
eq(t) {
|
|
1222
|
+
const n = t;
|
|
1223
|
+
return this.constructor === t.constructor && this.checked === n.checked && this.from === n.from && this.to === n.to && this.readOnly === n.readOnly;
|
|
1224
|
+
}
|
|
1225
|
+
toDOM(t) {
|
|
1226
|
+
const n = document.createElement("span");
|
|
1227
|
+
return n.className = O, n.appendChild(ot(t, { checked: this.checked, from: this.from, to: this.to })), n;
|
|
1228
|
+
}
|
|
1229
|
+
updateDOM(t, n) {
|
|
1230
|
+
if (t.className !== O || t.childElementCount !== 1)
|
|
1231
|
+
return !1;
|
|
1232
|
+
const o = t.firstElementChild;
|
|
1233
|
+
return o instanceof HTMLInputElement && o.type === "checkbox" ? rt(o, n, { checked: this.checked, from: this.from, to: this.to }) : !1;
|
|
1234
|
+
}
|
|
1235
|
+
ignoreEvent() {
|
|
1236
|
+
return !0;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function Pn(e, t, n) {
|
|
1240
|
+
return e.listItems.flatMap((o) => {
|
|
1241
|
+
const r = o.task ? `${se} ${ie(o.depth)} ${En}` : `${se} ${ie(o.depth)}`, s = [{ type: "line", from: n.doc.line(o.line).from, className: r }];
|
|
1242
|
+
if (t.has(o.line))
|
|
1243
|
+
return s;
|
|
1244
|
+
if (o.task)
|
|
1245
|
+
s.push(
|
|
1246
|
+
{
|
|
1247
|
+
type: "replace",
|
|
1248
|
+
from: o.bullet.from,
|
|
1249
|
+
to: o.task.marker.to,
|
|
1250
|
+
// The `[ ]` bracket is the first three chars of the marker range; that is
|
|
1251
|
+
// the exact span the click toggles.
|
|
1252
|
+
widget: new Gn(o.task.checked, o.task.marker.from, o.task.marker.from + 3, n.readOnly)
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
else {
|
|
1256
|
+
const a = o.ordered ? n.doc.sliceString(o.bullet.from, o.bullet.to).trim() : "•";
|
|
1257
|
+
s.push({ type: "replace", from: o.bullet.from, to: o.bullet.to, widget: new Dn(o.bullet.to - o.bullet.from, a) });
|
|
1258
|
+
}
|
|
1259
|
+
return s;
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
const On = {
|
|
1263
|
+
[`.${Te}`]: { textAlign: "center", opacity: "0.65" },
|
|
1264
|
+
// The same compact slot the mbox notation's task list uses: a 2ch inline-flex
|
|
1265
|
+
// box, checkbox sized to the text (1em) and optically centered in the slot.
|
|
1266
|
+
[`.${O}`]: {
|
|
1267
|
+
alignItems: "center",
|
|
1268
|
+
display: "inline-flex",
|
|
1269
|
+
flexShrink: "0",
|
|
1270
|
+
blockSize: "1lh",
|
|
1271
|
+
inlineSize: "2ch",
|
|
1272
|
+
justifyContent: "flex-start",
|
|
1273
|
+
// Top-align the 1lh box: sitting on the BASELINE its descender half would
|
|
1274
|
+
// push the line taller than its text (focused vs unfocused height jump).
|
|
1275
|
+
verticalAlign: "top"
|
|
1276
|
+
},
|
|
1277
|
+
[`.${O} input`]: {
|
|
1278
|
+
blockSize: "1em",
|
|
1279
|
+
boxSizing: "border-box",
|
|
1280
|
+
font: "inherit",
|
|
1281
|
+
inlineSize: "1em",
|
|
1282
|
+
margin: "0 0 0 calc(0.5ch - 0.5em)",
|
|
1283
|
+
verticalAlign: "-0.125em"
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
function Rn() {
|
|
1287
|
+
return {
|
|
1288
|
+
theme: On,
|
|
1289
|
+
name: "gfm/list",
|
|
1290
|
+
decorations: (e) => Pn(b(e.state), e.activeLineNumbers, e.state)
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
const Wn = "mbox-gfm-math", $e = "mbox-gfm-math-inline", Ie = "mbox-gfm-math-block", Fe = "mbox-gfm-math-hidden-line", Be = "mbox-gfm-math-source";
|
|
1294
|
+
class z extends M {
|
|
1295
|
+
constructor(t, n, o = !1) {
|
|
1296
|
+
super(), this.expression = t, this.render = n, this.inline = o;
|
|
1297
|
+
}
|
|
1298
|
+
expression;
|
|
1299
|
+
render;
|
|
1300
|
+
inline;
|
|
1301
|
+
// `eq` promises that two widgets produce the same DOM, which is how
|
|
1302
|
+
// CodeMirror decides it may keep the element it already built. `inline`
|
|
1303
|
+
// picks the tag and the presentation class, so it belongs here. Two
|
|
1304
|
+
// proposed sequences for observing a stale element -- turning `$x$` into
|
|
1305
|
+
// `$$x$$` in one transaction, and deleting the leading `x ` from
|
|
1306
|
+
// `x $$x$$` so an inline range becomes a block range of the same length --
|
|
1307
|
+
// were both measured and both rebuilt the DOM correctly. The clause is here
|
|
1308
|
+
// because the contract requires it, not because a reuse was observed.
|
|
1309
|
+
eq(t) {
|
|
1310
|
+
return t instanceof z && this.expression === t.expression && this.render === t.render && this.inline === t.inline;
|
|
1311
|
+
}
|
|
1312
|
+
toDOM() {
|
|
1313
|
+
const t = document.createElement(this.inline ? "span" : "div");
|
|
1314
|
+
t.className = `${Wn} ${this.inline ? $e : Ie}`, t.setAttribute("role", "math");
|
|
1315
|
+
try {
|
|
1316
|
+
t.appendChild(this.render(this.expression));
|
|
1317
|
+
} catch {
|
|
1318
|
+
return t.textContent = this.expression, t;
|
|
1319
|
+
}
|
|
1320
|
+
if (!this.render.providesAccessibleMath) {
|
|
1321
|
+
const n = document.createElement("span");
|
|
1322
|
+
n.className = Be, n.textContent = this.expression, t.appendChild(n);
|
|
1323
|
+
}
|
|
1324
|
+
return t;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function qn(e, t) {
|
|
1328
|
+
for (let n = e.firstLine; n <= e.lastLine; n += 1)
|
|
1329
|
+
if (t.has(n))
|
|
1330
|
+
return !0;
|
|
1331
|
+
return !1;
|
|
1332
|
+
}
|
|
1333
|
+
function zn(e, t, n, o) {
|
|
1334
|
+
return o ? e.codeBlocks.flatMap(
|
|
1335
|
+
(r) => Z(r) && !qn(r, n) ? jn(r, t, o) : []
|
|
1336
|
+
) : [];
|
|
1337
|
+
}
|
|
1338
|
+
function Hn(e, t, n, o) {
|
|
1339
|
+
return o ? e.inlineMath.flatMap(
|
|
1340
|
+
(r) => q(r, n) ? [] : r.display === "block" ? Kn(r, t, o) : Un(r, o)
|
|
1341
|
+
) : [];
|
|
1342
|
+
}
|
|
1343
|
+
function jn(e, t, n) {
|
|
1344
|
+
return Ae(e.from, e.info.to, e.firstLine, e.lastLine, e.value, t, n);
|
|
1345
|
+
}
|
|
1346
|
+
function Ae(e, t, n, o, r, i, s) {
|
|
1347
|
+
const a = [
|
|
1348
|
+
{ type: "replace", from: e, to: t, widget: new z(r, s) }
|
|
1349
|
+
];
|
|
1350
|
+
for (let l = n + 1; l <= o; l += 1) {
|
|
1351
|
+
const c = i.line(l);
|
|
1352
|
+
c.from < c.to && a.push({ type: "replace", from: c.from, to: c.to }), a.push({ type: "line", from: c.from, className: Fe });
|
|
1353
|
+
}
|
|
1354
|
+
return a;
|
|
1355
|
+
}
|
|
1356
|
+
function Un(e, t) {
|
|
1357
|
+
return [{ type: "replace", from: e.from, to: e.to, widget: new z(e.expression, t, !0) }];
|
|
1358
|
+
}
|
|
1359
|
+
function Kn(e, t, n) {
|
|
1360
|
+
return Ae(
|
|
1361
|
+
e.from,
|
|
1362
|
+
t.line(e.startLine).to,
|
|
1363
|
+
e.startLine,
|
|
1364
|
+
e.endLine,
|
|
1365
|
+
e.expression,
|
|
1366
|
+
t,
|
|
1367
|
+
n
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
const Zn = {
|
|
1371
|
+
[`.${$e}`]: {
|
|
1372
|
+
display: "inline-block",
|
|
1373
|
+
verticalAlign: "baseline"
|
|
1374
|
+
},
|
|
1375
|
+
[`.${Ie}`]: {
|
|
1376
|
+
display: "block"
|
|
1377
|
+
},
|
|
1378
|
+
[`.${Fe}`]: {
|
|
1379
|
+
display: "none"
|
|
1380
|
+
},
|
|
1381
|
+
[`.${Be}`]: {
|
|
1382
|
+
border: "0",
|
|
1383
|
+
clip: "rect(0 0 0 0)",
|
|
1384
|
+
height: "1px",
|
|
1385
|
+
margin: "-1px",
|
|
1386
|
+
overflow: "hidden",
|
|
1387
|
+
padding: "0",
|
|
1388
|
+
position: "absolute",
|
|
1389
|
+
whiteSpace: "nowrap",
|
|
1390
|
+
width: "1px"
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
function Qn(e = {}) {
|
|
1394
|
+
return {
|
|
1395
|
+
theme: Zn,
|
|
1396
|
+
name: "gfm/math",
|
|
1397
|
+
decorations: (t) => [
|
|
1398
|
+
...zn(b(t.state), t.state.doc, t.activeLineNumbers, e.render),
|
|
1399
|
+
...Hn(b(t.state), t.state.doc, t.activeLineNumbers, e.render)
|
|
1400
|
+
]
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
const Ee = "mbox-gfm-quote";
|
|
1404
|
+
function Jn(e, t) {
|
|
1405
|
+
const n = e.blockquotes.map((r) => ({
|
|
1406
|
+
type: "lineRange",
|
|
1407
|
+
from: r.from,
|
|
1408
|
+
to: r.to,
|
|
1409
|
+
className: Ee,
|
|
1410
|
+
attributes: { style: `--mbox-gfm-quote-depth: ${r.depth}` }
|
|
1411
|
+
})), o = e.quoteMarkers.flatMap((r) => t.has(r.line) ? [] : [{ type: "replace", from: r.from, to: r.to }]);
|
|
1412
|
+
return [...n, ...o];
|
|
1413
|
+
}
|
|
1414
|
+
const Vn = {
|
|
1415
|
+
[`.${Ee}`]: {
|
|
1416
|
+
backgroundImage: "repeating-linear-gradient(to right, rgba(127, 127, 127, 0.4) 0 3px, transparent 3px 1em)",
|
|
1417
|
+
backgroundRepeat: "no-repeat",
|
|
1418
|
+
// Start the bars at the editor's own text column (the 6px `.cm-line` left
|
|
1419
|
+
// padding), not at the line element's edge — the bars line up with the
|
|
1420
|
+
// surrounding text instead of jutting out to its left.
|
|
1421
|
+
backgroundPosition: "6px 0",
|
|
1422
|
+
backgroundSize: "calc((var(--mbox-gfm-quote-depth, 1) - 1) * 1em + 3px) 100%",
|
|
1423
|
+
paddingLeft: "calc(6px + (var(--mbox-gfm-quote-depth, 1) - 1) * 1em + 3px + 0.5em)",
|
|
1424
|
+
color: "rgba(90, 90, 90, 1)"
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
function _n() {
|
|
1428
|
+
return {
|
|
1429
|
+
theme: Vn,
|
|
1430
|
+
name: "gfm/quote",
|
|
1431
|
+
decorations: (e) => Jn(b(e.state), e.activeLineNumbers)
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
const De = "mbox-gfm-table-rendered", Ge = "mbox-gfm-table-raw-cell", L = {
|
|
1435
|
+
table: "mbox-gfm-table",
|
|
1436
|
+
header: "mbox-gfm-table-header",
|
|
1437
|
+
delimiter: "mbox-gfm-table-delimiter",
|
|
1438
|
+
row: "mbox-gfm-table-row",
|
|
1439
|
+
cell: "mbox-gfm-table-cell",
|
|
1440
|
+
rendered: De,
|
|
1441
|
+
rawCell: Ge
|
|
1442
|
+
}, ae = {
|
|
1443
|
+
table: L.table,
|
|
1444
|
+
renderedLine: De,
|
|
1445
|
+
cell: L.cell,
|
|
1446
|
+
rawCell: Ge
|
|
1447
|
+
}, le = 32;
|
|
1448
|
+
function Xn(e) {
|
|
1449
|
+
return e === void 0 ? le : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : le;
|
|
1450
|
+
}
|
|
1451
|
+
function Yn(e, t, n) {
|
|
1452
|
+
const o = e.header.cells.length, r = (i, s = !1, a = !1) => {
|
|
1453
|
+
const l = s && !a ? i.cells.slice(0, o) : i.cells;
|
|
1454
|
+
return {
|
|
1455
|
+
...i,
|
|
1456
|
+
cells: [
|
|
1457
|
+
...l.map((c, m) => ({
|
|
1458
|
+
...c,
|
|
1459
|
+
align: e.align[m] ?? null,
|
|
1460
|
+
// A cell holding an image asks its column for room. The ask is dropped
|
|
1461
|
+
// when it is zero so the property never appears without meaning.
|
|
1462
|
+
...c.hasImage && n > 0 ? { minimumColumnWidth: n } : {}
|
|
1463
|
+
})),
|
|
1464
|
+
...!s || i.cells.length >= o || a ? [] : Array.from({ length: o - l.length }, (c, m) => ({
|
|
1465
|
+
from: i.to,
|
|
1466
|
+
to: i.to,
|
|
1467
|
+
content: { from: i.to, to: i.to },
|
|
1468
|
+
value: "",
|
|
1469
|
+
align: e.align[l.length + m] ?? null,
|
|
1470
|
+
virtual: !0
|
|
1471
|
+
}))
|
|
1472
|
+
]
|
|
1473
|
+
};
|
|
1474
|
+
};
|
|
1475
|
+
return [
|
|
1476
|
+
{ className: L.header, line: e.line, ...r(e.header) },
|
|
1477
|
+
{
|
|
1478
|
+
className: L.delimiter,
|
|
1479
|
+
includeInColumnWidths: !1,
|
|
1480
|
+
line: e.line + 1,
|
|
1481
|
+
from: e.delimiter.from,
|
|
1482
|
+
to: e.delimiter.to,
|
|
1483
|
+
cells: e.delimiter.cells.map((i) => ({ ...i, className: "mbox-gfm-table-delimiter-cell" }))
|
|
1484
|
+
},
|
|
1485
|
+
...e.rows.map((i, s) => {
|
|
1486
|
+
const a = e.line + 2 + s;
|
|
1487
|
+
return { className: L.row, line: a, ...r(i, !0, t.has(a)) };
|
|
1488
|
+
})
|
|
1489
|
+
];
|
|
1490
|
+
}
|
|
1491
|
+
function eo(e, t, n) {
|
|
1492
|
+
return e.tables.flatMap((o) => oo(o, t, n));
|
|
1493
|
+
}
|
|
1494
|
+
function to(e, t) {
|
|
1495
|
+
return e.facet(V) ? Xn(t.imageMinimumColumnWidth) : 0;
|
|
1496
|
+
}
|
|
1497
|
+
function no(e, t) {
|
|
1498
|
+
return e.tables.flatMap((n) => {
|
|
1499
|
+
const o = n.header.cells.length;
|
|
1500
|
+
return n.rows.flatMap((r, i) => {
|
|
1501
|
+
const s = n.line + 2 + i;
|
|
1502
|
+
return t.has(s) || r.cells.length <= o ? [] : [{ from: r.cells[o - 1].to, to: r.to }];
|
|
1503
|
+
});
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
function oo(e, t, n) {
|
|
1507
|
+
let o = Yn(e, t, n);
|
|
1508
|
+
const r = o.some((i) => t.has(i.line)) ? void 0 : { tableId: `gfm-table-${e.from}`, columnCount: e.header.cells.length };
|
|
1509
|
+
return r && (o = o.map((i, s) => s === 1 ? { ...i, attributes: { "aria-hidden": "true" } } : i)), [
|
|
1510
|
+
...st(o, t, ae, r),
|
|
1511
|
+
...it(o, t, r),
|
|
1512
|
+
...at(o, t, ae, { measureWidth: mt }, r),
|
|
1513
|
+
...lt(o, t),
|
|
1514
|
+
...ct(o, t)
|
|
1515
|
+
];
|
|
1516
|
+
}
|
|
1517
|
+
function ro(e = {}) {
|
|
1518
|
+
return {
|
|
1519
|
+
theme: {
|
|
1520
|
+
[`.${L.table}`]: {
|
|
1521
|
+
fontFamily: 'var(--mbox-table-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
1522
|
+
},
|
|
1523
|
+
[`.${L.cell}`]: {
|
|
1524
|
+
width: "var(--mbox-table-cell-width, var(--mbox-table-kit-column-width))",
|
|
1525
|
+
maxWidth: "var(--mbox-table-kit-cell-max-width, 100%)",
|
|
1526
|
+
minWidth: 0,
|
|
1527
|
+
overflowWrap: "anywhere"
|
|
1528
|
+
},
|
|
1529
|
+
// Both classes: a raw cell carries the base cell class too, so a
|
|
1530
|
+
// single-class rule would only win by being written second.
|
|
1531
|
+
[`.${L.cell}.${L.rawCell}`]: {
|
|
1532
|
+
width: "auto",
|
|
1533
|
+
maxWidth: "none",
|
|
1534
|
+
minWidth: "auto"
|
|
1535
|
+
},
|
|
1536
|
+
// The one place this library sizes an image.
|
|
1537
|
+
//
|
|
1538
|
+
// Ordinary GFM images get no width cap from mbox at all -- that is a
|
|
1539
|
+
// standing decision, and a host that writes no CSS gets a 900px image at
|
|
1540
|
+
// 900px. Inside a fixed-grid table cell the library cannot keep that
|
|
1541
|
+
// promise and the promise that the table stays on screen at the same
|
|
1542
|
+
// time, so here, and only here, it caps the picture. Both limits are
|
|
1543
|
+
// written down in docs/guide.md.
|
|
1544
|
+
//
|
|
1545
|
+
// Descendant selectors, not child: the image can sit inside emphasis or
|
|
1546
|
+
// any other mark, so the figure is not necessarily the cell's own child.
|
|
1547
|
+
[`.${L.cell} .${v.preview}`]: {
|
|
1548
|
+
maxWidth: "100%"
|
|
1549
|
+
},
|
|
1550
|
+
// An ACTIVE row shows raw source, so its cell carries no column width and
|
|
1551
|
+
// the hidden measure figure would size itself to the whole row -- making
|
|
1552
|
+
// the row TALLER while it is being edited than it was at rest, which is
|
|
1553
|
+
// the opposite of what a measure figure is for. Constrain it to the width
|
|
1554
|
+
// the row already gives a cell. The row line carries that property
|
|
1555
|
+
// whether or not it is active.
|
|
1556
|
+
[`.${L.cell} .${W.measure}`]: {
|
|
1557
|
+
maxWidth: "var(--mbox-table-kit-cell-max-width, 100%)"
|
|
1558
|
+
},
|
|
1559
|
+
[`.${L.cell} .${v.element}`]: {
|
|
1560
|
+
maxWidth: "100%",
|
|
1561
|
+
// Caps height without cropping: with width and height both auto the
|
|
1562
|
+
// browser scales the whole picture down and the aspect ratio holds.
|
|
1563
|
+
// `object-fit: contain` would need a box with fixed dimensions to
|
|
1564
|
+
// contain within, and `figure > img` has none.
|
|
1565
|
+
maxHeight: "var(--mbox-gfm-table-image-max-height, 256px)",
|
|
1566
|
+
width: "auto",
|
|
1567
|
+
height: "auto"
|
|
1568
|
+
}
|
|
1569
|
+
},
|
|
1570
|
+
name: "gfm/table",
|
|
1571
|
+
decorations: (t) => eo(b(t.state), t.activeLineNumbers, to(t.state, e)),
|
|
1572
|
+
decorationFirewallRanges: (t) => no(b(t.state), t.activeLineNumbers)
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
const so = "mbox-gfm-hr-line", Pe = "mbox-gfm-hr";
|
|
1576
|
+
class io extends M {
|
|
1577
|
+
eq(t) {
|
|
1578
|
+
return this.constructor === t.constructor;
|
|
1579
|
+
}
|
|
1580
|
+
toDOM() {
|
|
1581
|
+
const t = document.createElement("span");
|
|
1582
|
+
return t.className = Pe, t.setAttribute("role", "separator"), t;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
function ao(e, t) {
|
|
1586
|
+
return e.thematicBreaks.flatMap((n) => {
|
|
1587
|
+
const o = [
|
|
1588
|
+
{ type: "line", from: n.from, className: so }
|
|
1589
|
+
];
|
|
1590
|
+
return t.has(n.line) || o.push({ type: "replace", from: n.from, to: n.to, widget: new io() }), o;
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
const lo = {
|
|
1594
|
+
[`.${Pe}`]: {
|
|
1595
|
+
display: "inline-block",
|
|
1596
|
+
width: "100%",
|
|
1597
|
+
verticalAlign: "middle",
|
|
1598
|
+
borderTop: "2px solid rgba(127, 127, 127, 0.4)"
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
function co() {
|
|
1602
|
+
return {
|
|
1603
|
+
theme: lo,
|
|
1604
|
+
name: "gfm/thematic-break",
|
|
1605
|
+
decorations: (e) => ao(b(e.state), e.activeLineNumbers)
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
function mo(e) {
|
|
1609
|
+
return e === !0 ? void 0 : e || void 0;
|
|
1610
|
+
}
|
|
1611
|
+
function fo(e = {}) {
|
|
1612
|
+
const t = e.math?.render !== void 0;
|
|
1613
|
+
return [
|
|
1614
|
+
// Code block first: its container styling should sit under the others, and
|
|
1615
|
+
// its literal interior is already inline-free from the tree.
|
|
1616
|
+
Yt({ excludeMathFences: t }),
|
|
1617
|
+
...e.codeHighlight ? [en(mo(e.codeHighlight))] : [],
|
|
1618
|
+
...t ? [Qn(e.math)] : [],
|
|
1619
|
+
_n(),
|
|
1620
|
+
rn(),
|
|
1621
|
+
Rn(),
|
|
1622
|
+
ro(e.table),
|
|
1623
|
+
co(),
|
|
1624
|
+
Cn(),
|
|
1625
|
+
gn(),
|
|
1626
|
+
t ? Nn() : Sn(),
|
|
1627
|
+
An(e.link),
|
|
1628
|
+
mn(e.image)
|
|
1629
|
+
];
|
|
1630
|
+
}
|
|
1631
|
+
const uo = {
|
|
1632
|
+
...ut([C.token]),
|
|
1633
|
+
...ft([
|
|
1634
|
+
{ level: 1, className: N.h1 },
|
|
1635
|
+
{ level: 2, className: N.h2 },
|
|
1636
|
+
{ level: 3, className: N.h3 },
|
|
1637
|
+
{ level: 4, className: N.h4 },
|
|
1638
|
+
{ level: 5, className: N.h5 },
|
|
1639
|
+
{ level: 6, className: N.h6 }
|
|
1640
|
+
]),
|
|
1641
|
+
[`.${G}`]: {
|
|
1642
|
+
color: "var(--mbox-gfm-link-color, #0969da)",
|
|
1643
|
+
textDecoration: "none",
|
|
1644
|
+
cursor: "pointer"
|
|
1645
|
+
},
|
|
1646
|
+
[`.${_}`]: {
|
|
1647
|
+
fontFamily: 'var(--mbox-gfm-code-font-family, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace)',
|
|
1648
|
+
fontSize: "var(--mbox-gfm-code-font-size, 85%)",
|
|
1649
|
+
background: "var(--mbox-gfm-code-background, #818b981f)",
|
|
1650
|
+
borderRadius: "var(--mbox-gfm-code-border-radius, 6px)",
|
|
1651
|
+
padding: "var(--mbox-gfm-code-padding, 0.2em 0.4em)"
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
function ho() {
|
|
1655
|
+
return kt.theme(uo);
|
|
1656
|
+
}
|
|
1657
|
+
function go(e = {}) {
|
|
1658
|
+
return gt(e, fo(e), ho);
|
|
1659
|
+
}
|
|
1660
|
+
function No(e) {
|
|
1661
|
+
const { parent: t, ...n } = e;
|
|
1662
|
+
return ht({ parent: t, state: go(n) });
|
|
1663
|
+
}
|
|
1664
|
+
export {
|
|
1665
|
+
Dn as GfmBulletWidget,
|
|
1666
|
+
_e as GfmCodeBlockCopyButtonWidget,
|
|
1667
|
+
fn as GfmFootnoteRefWidget,
|
|
1668
|
+
Tn as GfmLinkWidget,
|
|
1669
|
+
z as GfmMathWidget,
|
|
1670
|
+
Gn as GfmTaskCheckboxWidget,
|
|
1671
|
+
io as GfmThematicBreakWidget,
|
|
1672
|
+
At as adaptGfmDocument,
|
|
1673
|
+
No as createGfmEditor,
|
|
1674
|
+
go as createGfmEditorState,
|
|
1675
|
+
b as getGfmDocumentFromState,
|
|
1676
|
+
Te as gfmBulletClassName,
|
|
1677
|
+
xe as gfmCodeBlockClassName,
|
|
1678
|
+
C as gfmCodeBlockClassNames,
|
|
1679
|
+
en as gfmCodeBlockHighlightPlugin,
|
|
1680
|
+
Yt as gfmCodeBlockPlugin,
|
|
1681
|
+
ho as gfmDefaultPresentationTheme,
|
|
1682
|
+
uo as gfmDefaultPresentationThemeSpec,
|
|
1683
|
+
D as gfmFootnoteClassName,
|
|
1684
|
+
Le as gfmFootnoteMarkerClassName,
|
|
1685
|
+
gn as gfmFootnotePlugin,
|
|
1686
|
+
Se as gfmFootnoteRefClassName,
|
|
1687
|
+
N as gfmHeadingClassNames,
|
|
1688
|
+
j as gfmHeadingLineClassName,
|
|
1689
|
+
rn as gfmHeadingPlugin,
|
|
1690
|
+
ke as gfmHeadingSetextUnderlineClassName,
|
|
1691
|
+
sn as gfmImageClassName,
|
|
1692
|
+
v as gfmImageClassNames,
|
|
1693
|
+
mn as gfmImagePlugin,
|
|
1694
|
+
Ne as gfmInlineClassNames,
|
|
1695
|
+
_ as gfmInlineCodeClassName,
|
|
1696
|
+
Sn as gfmInlineCodePlugin,
|
|
1697
|
+
Cn as gfmInlinePlugin,
|
|
1698
|
+
G as gfmLinkClassName,
|
|
1699
|
+
An as gfmLinkPlugin,
|
|
1700
|
+
ie as gfmListDepthClassName,
|
|
1701
|
+
se as gfmListLineClassName,
|
|
1702
|
+
Rn as gfmListPlugin,
|
|
1703
|
+
Wn as gfmMathClassName,
|
|
1704
|
+
Qn as gfmMathPlugin,
|
|
1705
|
+
fo as gfmPlugins,
|
|
1706
|
+
Ee as gfmQuoteClassName,
|
|
1707
|
+
_n as gfmQuotePlugin,
|
|
1708
|
+
L as gfmTableClassNames,
|
|
1709
|
+
ro as gfmTablePlugin,
|
|
1710
|
+
Ge as gfmTableRawCellClassName,
|
|
1711
|
+
De as gfmTableRenderedClassName,
|
|
1712
|
+
O as gfmTaskCheckboxClassName,
|
|
1713
|
+
En as gfmTaskLineClassName,
|
|
1714
|
+
Pe as gfmThematicBreakClassName,
|
|
1715
|
+
so as gfmThematicBreakLineClassName,
|
|
1716
|
+
co as gfmThematicBreakPlugin,
|
|
1717
|
+
yn as gfmUnsafeLinkClassName,
|
|
1718
|
+
Qt as parseGfmDocument
|
|
1719
|
+
};
|