@pi-outpost/embed 0.35.1 → 0.36.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/dist/CodeEditor-2Vx8PHAy.js +2790 -0
- package/dist/CodeEditor-Cb6i9oIs.cjs +6 -0
- package/dist/clike-8rZWBES0.cjs +1 -0
- package/dist/clike-D-dOQnrm.js +587 -0
- package/dist/{conversationExport-DU5Xp2g-.js → conversationExport-D8C7qzeU.js} +2 -2
- package/dist/{conversationExport-DwLc0HDC.cjs → conversationExport-DhGnf-eW.cjs} +1 -1
- package/dist/{conversationHistory-DTP8xNqg.cjs → conversationHistory-BtFE4dMu.cjs} +1 -1
- package/dist/{conversationHistory-DHEPfViO.js → conversationHistory-CwYAL6o8.js} +1 -1
- package/dist/dist-B0lO3k1f.js +410 -0
- package/dist/dist-B7I27gkN.cjs +1 -0
- package/dist/dist-B8gmxwh-.cjs +23 -0
- package/dist/dist-BBUKMRrs.js +69 -0
- package/dist/dist-BWlGU9XM.js +395 -0
- package/dist/dist-BZcglaBe.cjs +1 -0
- package/dist/dist-BZjcsPqi.cjs +13 -0
- package/dist/dist-BfQGuM1r.js +1340 -0
- package/dist/dist-BhNvvg0I.js +471 -0
- package/dist/dist-BhXQJ0x3.js +10805 -0
- package/dist/dist-BlD6NhiG.js +296 -0
- package/dist/dist-Bppoi_v9.js +357 -0
- package/dist/dist-BvsCdwbL.cjs +1 -0
- package/dist/dist-C0_uLrCb.cjs +6 -0
- package/dist/dist-C8jjSrIs.cjs +11 -0
- package/dist/dist-C9dtxVRR.cjs +1 -0
- package/dist/dist-CA6ERWRG.js +380 -0
- package/dist/dist-CHKg1Qb9.js +1583 -0
- package/dist/dist-CyFPTQ2l.cjs +1 -0
- package/dist/dist-D8I4FQ-Q.cjs +1 -0
- package/dist/dist-DEl2Ze0j.cjs +2 -0
- package/dist/dist-DJbgM591.cjs +1 -0
- package/dist/dist-DPXHxuWb.js +855 -0
- package/dist/dist-DZrtSp8H.js +607 -0
- package/dist/dist-Dja2VlN5.cjs +1 -0
- package/dist/dist-DqbI0un6.cjs +1 -0
- package/dist/dist-Dr4zY56l.js +440 -0
- package/dist/dist-Dvqp7T4I.cjs +1 -0
- package/dist/dist-FSzij9Rn.js +271 -0
- package/dist/dist-Xjm88mbq.js +756 -0
- package/dist/dist-qNFo_ASR.cjs +9 -0
- package/dist/dist-qq9a_ch2.js +431 -0
- package/dist/dockerfile-4x0UkDoN.js +291 -0
- package/dist/dockerfile-C67wRfne.cjs +1 -0
- package/dist/docxExport-BKC_hi5D.js +67 -0
- package/dist/docxExport-V7joLrkm.cjs +3 -0
- package/dist/{docxExport-BWwEuboU.js → loadReferencedImage-FGse7G4p.js} +538 -306
- package/dist/{docxExport-PjDC4XKL.cjs → loadReferencedImage-QespeGh9.cjs} +7 -9
- package/dist/pi-outpost-embed.cjs +51 -24
- package/dist/pi-outpost-embed.js +3769 -3519
- package/dist/properties-C85NeSsH.js +20 -0
- package/dist/properties-XjDvZYDm.cjs +1 -0
- package/dist/ruby-Bx72aP7E.cjs +1 -0
- package/dist/ruby-CjYBP7RB.js +166 -0
- package/dist/shell-CD1ADQh5.cjs +1 -0
- package/dist/shell-CevoiH_y.js +109 -0
- package/dist/toml-CPJF62TK.js +28 -0
- package/dist/toml-OuUxin0A.cjs +1 -0
- package/package.json +1 -1
- package/dist/loadReferencedImage-C8Hn2ejN.js +0 -268
- package/dist/loadReferencedImage-q-G47ESL.cjs +0 -1
|
@@ -0,0 +1,1583 @@
|
|
|
1
|
+
import { $ as e, Ct as t, Dt as n, Et as r, H as i, M as a, Q as o, St as s, T as c, Tt as l, _ as u, _t as d, a as f, d as p, ft as m, ht as h, i as g, k as _, nt as ee, o as te, r as ne, v as re, vt as v, w as ie, x as ae, xt as y } from "./dist-BhXQJ0x3.js";
|
|
2
|
+
import { html as oe, htmlCompletionSource as se } from "./dist-BfQGuM1r.js";
|
|
3
|
+
import { n as ce } from "./CodeEditor-2Vx8PHAy.js";
|
|
4
|
+
//#region ../node_modules/@lezer/markdown/dist/index.js
|
|
5
|
+
var le = class e {
|
|
6
|
+
static create(t, n, r, i, a) {
|
|
7
|
+
let o = i + (i << 8) + t + (n << 4) | 0;
|
|
8
|
+
return new e(t, n, r, o, a, [], []);
|
|
9
|
+
}
|
|
10
|
+
constructor(e, t, n, r, i, a, o) {
|
|
11
|
+
this.type = e, this.value = t, this.from = n, this.hash = r, this.end = i, this.children = a, this.positions = o, this.hashProp = [[y.contextHash, r]];
|
|
12
|
+
}
|
|
13
|
+
addChild(e, t) {
|
|
14
|
+
e.prop(y.contextHash) != this.hash && (e = new r(e.type, e.children, e.positions, e.length, this.hashProp)), this.children.push(e), this.positions.push(t);
|
|
15
|
+
}
|
|
16
|
+
toTree(e, n = this.end) {
|
|
17
|
+
let i = this.children.length - 1;
|
|
18
|
+
return i >= 0 && (n = Math.max(n, this.positions[i] + this.children[i].length + this.from)), new r(e.types[this.type], this.children, this.positions, n - this.from).balance({ makeTree: (e, n, i) => new r(t.none, e, n, i, this.hashProp) });
|
|
19
|
+
}
|
|
20
|
+
}, b;
|
|
21
|
+
(function(e) {
|
|
22
|
+
e[e.Document = 1] = "Document", e[e.CodeBlock = 2] = "CodeBlock", e[e.FencedCode = 3] = "FencedCode", e[e.Blockquote = 4] = "Blockquote", e[e.HorizontalRule = 5] = "HorizontalRule", e[e.BulletList = 6] = "BulletList", e[e.OrderedList = 7] = "OrderedList", e[e.ListItem = 8] = "ListItem", e[e.ATXHeading1 = 9] = "ATXHeading1", e[e.ATXHeading2 = 10] = "ATXHeading2", e[e.ATXHeading3 = 11] = "ATXHeading3", e[e.ATXHeading4 = 12] = "ATXHeading4", e[e.ATXHeading5 = 13] = "ATXHeading5", e[e.ATXHeading6 = 14] = "ATXHeading6", e[e.SetextHeading1 = 15] = "SetextHeading1", e[e.SetextHeading2 = 16] = "SetextHeading2", e[e.HTMLBlock = 17] = "HTMLBlock", e[e.LinkReference = 18] = "LinkReference", e[e.Paragraph = 19] = "Paragraph", e[e.CommentBlock = 20] = "CommentBlock", e[e.ProcessingInstructionBlock = 21] = "ProcessingInstructionBlock", e[e.Escape = 22] = "Escape", e[e.Entity = 23] = "Entity", e[e.HardBreak = 24] = "HardBreak", e[e.Emphasis = 25] = "Emphasis", e[e.StrongEmphasis = 26] = "StrongEmphasis", e[e.Link = 27] = "Link", e[e.Image = 28] = "Image", e[e.InlineCode = 29] = "InlineCode", e[e.HTMLTag = 30] = "HTMLTag", e[e.Comment = 31] = "Comment", e[e.ProcessingInstruction = 32] = "ProcessingInstruction", e[e.Autolink = 33] = "Autolink", e[e.HeaderMark = 34] = "HeaderMark", e[e.QuoteMark = 35] = "QuoteMark", e[e.ListMark = 36] = "ListMark", e[e.LinkMark = 37] = "LinkMark", e[e.EmphasisMark = 38] = "EmphasisMark", e[e.CodeMark = 39] = "CodeMark", e[e.CodeText = 40] = "CodeText", e[e.CodeInfo = 41] = "CodeInfo", e[e.LinkTitle = 42] = "LinkTitle", e[e.LinkLabel = 43] = "LinkLabel", e[e.URL = 44] = "URL";
|
|
23
|
+
})(b ||= {});
|
|
24
|
+
var ue = class {
|
|
25
|
+
constructor(e, t) {
|
|
26
|
+
this.start = e, this.content = t, this.marks = [], this.parsers = [];
|
|
27
|
+
}
|
|
28
|
+
}, de = class {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.text = "", this.baseIndent = 0, this.basePos = 0, this.depth = 0, this.markers = [], this.pos = 0, this.indent = 0, this.next = -1;
|
|
31
|
+
}
|
|
32
|
+
forward() {
|
|
33
|
+
this.basePos > this.pos && this.forwardInner();
|
|
34
|
+
}
|
|
35
|
+
forwardInner() {
|
|
36
|
+
let e = this.skipSpace(this.basePos);
|
|
37
|
+
this.indent = this.countIndent(e, this.pos, this.indent), this.pos = e, this.next = e == this.text.length ? -1 : this.text.charCodeAt(e);
|
|
38
|
+
}
|
|
39
|
+
skipSpace(e) {
|
|
40
|
+
return S(this.text, e);
|
|
41
|
+
}
|
|
42
|
+
reset(e) {
|
|
43
|
+
for (this.text = e, this.baseIndent = this.basePos = this.pos = this.indent = 0, this.forwardInner(), this.depth = 1; this.markers.length;) this.markers.pop();
|
|
44
|
+
}
|
|
45
|
+
moveBase(e) {
|
|
46
|
+
this.basePos = e, this.baseIndent = this.countIndent(e, this.pos, this.indent);
|
|
47
|
+
}
|
|
48
|
+
moveBaseColumn(e) {
|
|
49
|
+
this.baseIndent = e, this.basePos = this.findColumn(e);
|
|
50
|
+
}
|
|
51
|
+
addMarker(e) {
|
|
52
|
+
this.markers.push(e);
|
|
53
|
+
}
|
|
54
|
+
countIndent(e, t = 0, n = 0) {
|
|
55
|
+
for (let r = t; r < e; r++) n += this.text.charCodeAt(r) == 9 ? 4 - n % 4 : 1;
|
|
56
|
+
return n;
|
|
57
|
+
}
|
|
58
|
+
findColumn(e) {
|
|
59
|
+
let t = 0;
|
|
60
|
+
for (let n = 0; t < this.text.length && n < e; t++) n += this.text.charCodeAt(t) == 9 ? 4 - n % 4 : 1;
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
scrub() {
|
|
64
|
+
if (!this.baseIndent) return this.text;
|
|
65
|
+
let e = "";
|
|
66
|
+
for (let t = 0; t < this.basePos; t++) e += " ";
|
|
67
|
+
return e + this.text.slice(this.basePos);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function fe(e, t, n) {
|
|
71
|
+
if (n.pos == n.text.length || e != t.block && n.indent >= t.stack[n.depth + 1].value + n.baseIndent) return !0;
|
|
72
|
+
if (n.indent >= n.baseIndent + 4) return !1;
|
|
73
|
+
let r = (e.type == b.OrderedList ? T : w)(n, t, !1);
|
|
74
|
+
return r > 0 && (e.type != b.BulletList || C(n, t, !1) < 0) && n.text.charCodeAt(n.pos + r - 1) == e.value;
|
|
75
|
+
}
|
|
76
|
+
var pe = {
|
|
77
|
+
[b.Blockquote](e, t, n) {
|
|
78
|
+
return n.next == 62 && (n.markers.push(I(b.QuoteMark, t.lineStart + n.pos, t.lineStart + n.pos + 1)), n.moveBase(n.pos + (x(n.text.charCodeAt(n.pos + 1)) ? 2 : 1)), e.end = t.lineStart + n.text.length, !0);
|
|
79
|
+
},
|
|
80
|
+
[b.ListItem](e, t, n) {
|
|
81
|
+
return n.indent < n.baseIndent + e.value && n.next > -1 ? !1 : (n.moveBaseColumn(n.baseIndent + e.value), !0);
|
|
82
|
+
},
|
|
83
|
+
[b.OrderedList]: fe,
|
|
84
|
+
[b.BulletList]: fe,
|
|
85
|
+
[b.Document]() {
|
|
86
|
+
return !0;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function x(e) {
|
|
90
|
+
return e == 32 || e == 9 || e == 10 || e == 13;
|
|
91
|
+
}
|
|
92
|
+
function S(e, t = 0) {
|
|
93
|
+
for (; t < e.length && x(e.charCodeAt(t));) t++;
|
|
94
|
+
return t;
|
|
95
|
+
}
|
|
96
|
+
function me(e, t, n) {
|
|
97
|
+
for (; t > n && x(e.charCodeAt(t - 1));) t--;
|
|
98
|
+
return t;
|
|
99
|
+
}
|
|
100
|
+
function he(e) {
|
|
101
|
+
if (e.next != 96 && e.next != 126) return -1;
|
|
102
|
+
let t = e.pos + 1;
|
|
103
|
+
for (; t < e.text.length && e.text.charCodeAt(t) == e.next;) t++;
|
|
104
|
+
if (t < e.pos + 3) return -1;
|
|
105
|
+
if (e.next == 96) {
|
|
106
|
+
for (let n = t; n < e.text.length; n++) if (e.text.charCodeAt(n) == 96) return -1;
|
|
107
|
+
}
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
function ge(e) {
|
|
111
|
+
return e.next == 62 ? e.text.charCodeAt(e.pos + 1) == 32 ? 2 : 1 : -1;
|
|
112
|
+
}
|
|
113
|
+
function C(e, t, n) {
|
|
114
|
+
if (e.next != 42 && e.next != 45 && e.next != 95) return -1;
|
|
115
|
+
let r = 1;
|
|
116
|
+
for (let t = e.pos + 1; t < e.text.length; t++) {
|
|
117
|
+
let n = e.text.charCodeAt(t);
|
|
118
|
+
if (n == e.next) r++;
|
|
119
|
+
else if (!x(n)) return -1;
|
|
120
|
+
}
|
|
121
|
+
return n && e.next == 45 && ye(e) > -1 && e.depth == t.stack.length && t.parser.leafBlockParsers.indexOf(Ee.SetextHeading) > -1 || r < 3 ? -1 : 1;
|
|
122
|
+
}
|
|
123
|
+
function _e(e, t) {
|
|
124
|
+
for (let n = e.stack.length - 1; n >= 0; n--) if (e.stack[n].type == t) return !0;
|
|
125
|
+
return !1;
|
|
126
|
+
}
|
|
127
|
+
function w(e, t, n) {
|
|
128
|
+
return (e.next == 45 || e.next == 43 || e.next == 42) && (e.pos == e.text.length - 1 || x(e.text.charCodeAt(e.pos + 1))) && (!n || _e(t, b.BulletList) || e.skipSpace(e.pos + 2) < e.text.length) ? 1 : -1;
|
|
129
|
+
}
|
|
130
|
+
function T(e, t, n) {
|
|
131
|
+
let r = e.pos, i = e.next;
|
|
132
|
+
for (; i >= 48 && i <= 57;) {
|
|
133
|
+
if (r++, r == e.text.length) return -1;
|
|
134
|
+
i = e.text.charCodeAt(r);
|
|
135
|
+
}
|
|
136
|
+
return r == e.pos || r > e.pos + 9 || i != 46 && i != 41 || r < e.text.length - 1 && !x(e.text.charCodeAt(r + 1)) || n && !_e(t, b.OrderedList) && (e.skipSpace(r + 1) == e.text.length || r > e.pos + 1 || e.next != 49) ? -1 : r + 1 - e.pos;
|
|
137
|
+
}
|
|
138
|
+
function ve(e) {
|
|
139
|
+
if (e.next != 35) return -1;
|
|
140
|
+
let t = e.pos + 1;
|
|
141
|
+
for (; t < e.text.length && e.text.charCodeAt(t) == 35;) t++;
|
|
142
|
+
if (t < e.text.length && e.text.charCodeAt(t) != 32) return -1;
|
|
143
|
+
let n = t - e.pos;
|
|
144
|
+
return n > 6 ? -1 : n;
|
|
145
|
+
}
|
|
146
|
+
function ye(e) {
|
|
147
|
+
if (e.next != 45 && e.next != 61 || e.indent >= e.baseIndent + 4) return -1;
|
|
148
|
+
let t = e.pos + 1;
|
|
149
|
+
for (; t < e.text.length && e.text.charCodeAt(t) == e.next;) t++;
|
|
150
|
+
let n = t;
|
|
151
|
+
for (; t < e.text.length && x(e.text.charCodeAt(t));) t++;
|
|
152
|
+
return t == e.text.length ? n : -1;
|
|
153
|
+
}
|
|
154
|
+
var E = /^[ \t]*$/, be = /-->/, xe = /\?>/, D = [
|
|
155
|
+
[/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
|
|
156
|
+
[/^\s*<!--/, be],
|
|
157
|
+
[/^\s*<\?/, xe],
|
|
158
|
+
[/^\s*<![A-Z]/, />/],
|
|
159
|
+
[/^\s*<!\[CDATA\[/, /\]\]>/],
|
|
160
|
+
[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i, E],
|
|
161
|
+
[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, E]
|
|
162
|
+
];
|
|
163
|
+
function Se(e, t, n) {
|
|
164
|
+
if (e.next != 60) return -1;
|
|
165
|
+
let r = e.text.slice(e.pos);
|
|
166
|
+
for (let e = 0, t = D.length - +!!n; e < t; e++) if (D[e][0].test(r)) return e;
|
|
167
|
+
return -1;
|
|
168
|
+
}
|
|
169
|
+
function Ce(e, t) {
|
|
170
|
+
let n = e.countIndent(t, e.pos, e.indent), r = e.skipSpace(t), i = e.countIndent(r, t, n);
|
|
171
|
+
return i >= n + 5 || r == e.text.length ? n + 1 : i;
|
|
172
|
+
}
|
|
173
|
+
function O(e, t, n) {
|
|
174
|
+
let r = e.length - 1;
|
|
175
|
+
r >= 0 && e[r].to == t && e[r].type == b.CodeText ? e[r].to = n : e.push(I(b.CodeText, t, n));
|
|
176
|
+
}
|
|
177
|
+
var k = {
|
|
178
|
+
LinkReference: void 0,
|
|
179
|
+
IndentedCode(e, t) {
|
|
180
|
+
let n = t.baseIndent + 4;
|
|
181
|
+
if (t.indent < n) return !1;
|
|
182
|
+
let r = t.findColumn(n), i = e.lineStart + r, a = e.lineStart + t.text.length, o = [], s = [];
|
|
183
|
+
for (O(o, i, a); e.nextLine() && t.depth >= e.stack.length;) if (t.pos == t.text.length) {
|
|
184
|
+
O(s, e.lineStart - 1, e.lineStart);
|
|
185
|
+
for (let e of t.markers) s.push(e);
|
|
186
|
+
} else if (t.indent < n) break;
|
|
187
|
+
else {
|
|
188
|
+
if (s.length) {
|
|
189
|
+
for (let e of s) e.type == b.CodeText ? O(o, e.from, e.to) : o.push(e);
|
|
190
|
+
s = [];
|
|
191
|
+
}
|
|
192
|
+
O(o, e.lineStart - 1, e.lineStart);
|
|
193
|
+
for (let e of t.markers) o.push(e);
|
|
194
|
+
a = e.lineStart + t.text.length;
|
|
195
|
+
let n = e.lineStart + t.findColumn(t.baseIndent + 4);
|
|
196
|
+
n < a && O(o, n, a);
|
|
197
|
+
}
|
|
198
|
+
return s.length && (s = s.filter((e) => e.type != b.CodeText), s.length && (t.markers = s.concat(t.markers))), e.addNode(e.buffer.writeElements(o, -i).finish(b.CodeBlock, a - i), i), !0;
|
|
199
|
+
},
|
|
200
|
+
FencedCode(e, t) {
|
|
201
|
+
let n = he(t);
|
|
202
|
+
if (n < 0) return !1;
|
|
203
|
+
let r = e.lineStart + t.pos, i = t.next, a = n - t.pos, o = t.skipSpace(n), s = me(t.text, t.text.length, o), c = [I(b.CodeMark, r, r + a)];
|
|
204
|
+
o < s && c.push(I(b.CodeInfo, e.lineStart + o, e.lineStart + s));
|
|
205
|
+
for (let n = !0, r = !0, o = !1; e.nextLine() && t.depth >= e.stack.length; n = !1) {
|
|
206
|
+
let s = t.pos;
|
|
207
|
+
if (t.indent - t.baseIndent < 4) for (; s < t.text.length && t.text.charCodeAt(s) == i;) s++;
|
|
208
|
+
if (s - t.pos >= a && t.skipSpace(s) == t.text.length) {
|
|
209
|
+
for (let e of t.markers) c.push(e);
|
|
210
|
+
r && o && O(c, e.lineStart - 1, e.lineStart), c.push(I(b.CodeMark, e.lineStart + t.pos, e.lineStart + s)), e.nextLine();
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
{
|
|
214
|
+
o = !0, n || (O(c, e.lineStart - 1, e.lineStart), r = !1);
|
|
215
|
+
for (let e of t.markers) c.push(e);
|
|
216
|
+
let i = e.lineStart + t.basePos, a = e.lineStart + t.text.length;
|
|
217
|
+
i < a && (O(c, i, a), r = !1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return e.addNode(e.buffer.writeElements(c, -r).finish(b.FencedCode, e.prevLineEnd() - r), r), !0;
|
|
221
|
+
},
|
|
222
|
+
Blockquote(e, t) {
|
|
223
|
+
let n = ge(t);
|
|
224
|
+
return n < 0 ? !1 : (e.startContext(b.Blockquote, t.pos), e.addNode(b.QuoteMark, e.lineStart + t.pos, e.lineStart + t.pos + 1), t.moveBase(t.pos + n), null);
|
|
225
|
+
},
|
|
226
|
+
HorizontalRule(e, t) {
|
|
227
|
+
if (C(t, e, !1) < 0) return !1;
|
|
228
|
+
let n = e.lineStart + t.pos;
|
|
229
|
+
return e.nextLine(), e.addNode(b.HorizontalRule, n), !0;
|
|
230
|
+
},
|
|
231
|
+
BulletList(e, t) {
|
|
232
|
+
let n = w(t, e, !1);
|
|
233
|
+
if (n < 0) return !1;
|
|
234
|
+
e.block.type != b.BulletList && e.startContext(b.BulletList, t.basePos, t.next);
|
|
235
|
+
let r = Ce(t, t.pos + 1);
|
|
236
|
+
return e.startContext(b.ListItem, t.basePos, r - t.baseIndent), e.addNode(b.ListMark, e.lineStart + t.pos, e.lineStart + t.pos + n), t.moveBaseColumn(r), null;
|
|
237
|
+
},
|
|
238
|
+
OrderedList(e, t) {
|
|
239
|
+
let n = T(t, e, !1);
|
|
240
|
+
if (n < 0) return !1;
|
|
241
|
+
e.block.type != b.OrderedList && e.startContext(b.OrderedList, t.basePos, t.text.charCodeAt(t.pos + n - 1));
|
|
242
|
+
let r = Ce(t, t.pos + n);
|
|
243
|
+
return e.startContext(b.ListItem, t.basePos, r - t.baseIndent), e.addNode(b.ListMark, e.lineStart + t.pos, e.lineStart + t.pos + n), t.moveBaseColumn(r), null;
|
|
244
|
+
},
|
|
245
|
+
ATXHeading(e, t) {
|
|
246
|
+
let n = ve(t);
|
|
247
|
+
if (n < 0) return !1;
|
|
248
|
+
let r = t.pos, i = e.lineStart + r, a = me(t.text, t.text.length, r), o = a;
|
|
249
|
+
for (; o > r && t.text.charCodeAt(o - 1) == t.next;) o--;
|
|
250
|
+
(o == a || o == r || !x(t.text.charCodeAt(o - 1))) && (o = t.text.length);
|
|
251
|
+
let s = e.buffer.write(b.HeaderMark, 0, n).writeElements(e.parser.parseInline(t.text.slice(r + n + 1, o), i + n + 1), -i);
|
|
252
|
+
o < t.text.length && s.write(b.HeaderMark, o - r, a - r);
|
|
253
|
+
let c = s.finish(b.ATXHeading1 - 1 + n, t.text.length - r);
|
|
254
|
+
return e.nextLine(), e.addNode(c, i), !0;
|
|
255
|
+
},
|
|
256
|
+
HTMLBlock(e, t) {
|
|
257
|
+
let n = Se(t, e, !1);
|
|
258
|
+
if (n < 0) return !1;
|
|
259
|
+
let r = e.lineStart + t.pos, i = D[n][1], a = [], o = i != E;
|
|
260
|
+
for (; !i.test(t.text) && e.nextLine();) {
|
|
261
|
+
if (t.depth < e.stack.length) {
|
|
262
|
+
o = !1;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
for (let e of t.markers) a.push(e);
|
|
266
|
+
}
|
|
267
|
+
o && e.nextLine();
|
|
268
|
+
let s = i == be ? b.CommentBlock : i == xe ? b.ProcessingInstructionBlock : b.HTMLBlock, c = e.prevLineEnd();
|
|
269
|
+
return e.addNode(e.buffer.writeElements(a, -r).finish(s, c - r), r), !0;
|
|
270
|
+
},
|
|
271
|
+
SetextHeading: void 0
|
|
272
|
+
}, we = class {
|
|
273
|
+
constructor(e) {
|
|
274
|
+
this.stage = 0, this.elts = [], this.pos = 0, this.start = e.start, this.advance(e.content);
|
|
275
|
+
}
|
|
276
|
+
nextLine(e, t, n) {
|
|
277
|
+
if (this.stage == -1) return !1;
|
|
278
|
+
let r = n.content + "\n" + t.scrub(), i = this.advance(r);
|
|
279
|
+
return i > -1 && i < r.length && this.complete(e, n, i);
|
|
280
|
+
}
|
|
281
|
+
finish(e, t) {
|
|
282
|
+
return (this.stage == 2 || this.stage == 3) && S(t.content, this.pos) == t.content.length && this.complete(e, t, t.content.length);
|
|
283
|
+
}
|
|
284
|
+
complete(e, t, n) {
|
|
285
|
+
return e.addLeafElement(t, I(b.LinkReference, this.start, this.start + n, this.elts)), !0;
|
|
286
|
+
}
|
|
287
|
+
nextStage(e) {
|
|
288
|
+
return e ? (this.pos = e.to - this.start, this.elts.push(e), this.stage++, !0) : (e === !1 && (this.stage = -1), !1);
|
|
289
|
+
}
|
|
290
|
+
advance(e) {
|
|
291
|
+
for (;;) if (this.stage == -1) return -1;
|
|
292
|
+
else if (this.stage == 0) {
|
|
293
|
+
if (!this.nextStage(ze(e, this.pos, this.start, !0))) return -1;
|
|
294
|
+
if (e.charCodeAt(this.pos) != 58) return this.stage = -1;
|
|
295
|
+
this.elts.push(I(b.LinkMark, this.pos + this.start, this.pos + this.start + 1)), this.pos++;
|
|
296
|
+
} else if (this.stage == 1) {
|
|
297
|
+
if (!this.nextStage(Le(e, S(e, this.pos), this.start))) return -1;
|
|
298
|
+
} else if (this.stage == 2) {
|
|
299
|
+
let t = S(e, this.pos), n = 0;
|
|
300
|
+
if (t > this.pos) {
|
|
301
|
+
let r = Re(e, t, this.start);
|
|
302
|
+
if (r) {
|
|
303
|
+
let t = A(e, r.to - this.start);
|
|
304
|
+
t > 0 && (this.nextStage(r), n = t);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return n ||= A(e, this.pos), n > 0 && n < e.length ? n : -1;
|
|
308
|
+
} else return A(e, this.pos);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
function A(e, t) {
|
|
312
|
+
for (; t < e.length; t++) {
|
|
313
|
+
let n = e.charCodeAt(t);
|
|
314
|
+
if (n == 10) break;
|
|
315
|
+
if (!x(n)) return -1;
|
|
316
|
+
}
|
|
317
|
+
return t;
|
|
318
|
+
}
|
|
319
|
+
var Te = class {
|
|
320
|
+
nextLine(e, t, n) {
|
|
321
|
+
let r = t.depth < e.stack.length ? -1 : ye(t), i = t.next;
|
|
322
|
+
if (r < 0) return !1;
|
|
323
|
+
let a = I(b.HeaderMark, e.lineStart + t.pos, e.lineStart + r);
|
|
324
|
+
return e.nextLine(), e.addLeafElement(n, I(i == 61 ? b.SetextHeading1 : b.SetextHeading2, n.start, e.prevLineEnd(), [...e.parser.parseInline(n.content, n.start), a])), !0;
|
|
325
|
+
}
|
|
326
|
+
finish() {
|
|
327
|
+
return !1;
|
|
328
|
+
}
|
|
329
|
+
}, Ee = {
|
|
330
|
+
LinkReference(e, t) {
|
|
331
|
+
return t.content.charCodeAt(0) == 91 ? new we(t) : null;
|
|
332
|
+
},
|
|
333
|
+
SetextHeading() {
|
|
334
|
+
return new Te();
|
|
335
|
+
}
|
|
336
|
+
}, De = [
|
|
337
|
+
(e, t) => ve(t) >= 0,
|
|
338
|
+
(e, t) => he(t) >= 0,
|
|
339
|
+
(e, t) => ge(t) >= 0,
|
|
340
|
+
(e, t) => w(t, e, !0) >= 0,
|
|
341
|
+
(e, t) => T(t, e, !0) >= 0,
|
|
342
|
+
(e, t) => C(t, e, !0) >= 0,
|
|
343
|
+
(e, t) => Se(t, e, !0) >= 0
|
|
344
|
+
], Oe = {
|
|
345
|
+
text: "",
|
|
346
|
+
end: 0
|
|
347
|
+
}, ke = class {
|
|
348
|
+
constructor(e, t, n, r) {
|
|
349
|
+
this.parser = e, this.input = t, this.ranges = r, this.line = new de(), this.atEnd = !1, this.reusePlaceholders = /* @__PURE__ */ new Map(), this.stoppedAt = null, this.rangeI = 0, this.to = r[r.length - 1].to, this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = r[0].from, this.block = le.create(b.Document, 0, this.lineStart, 0, 0), this.stack = [this.block], this.fragments = n.length ? new Ve(n, t) : null, this.readLine();
|
|
350
|
+
}
|
|
351
|
+
get parsedPos() {
|
|
352
|
+
return this.absoluteLineStart;
|
|
353
|
+
}
|
|
354
|
+
advance() {
|
|
355
|
+
if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt) return this.finish();
|
|
356
|
+
let { line: e } = this;
|
|
357
|
+
for (;;) {
|
|
358
|
+
for (let t = 0;;) {
|
|
359
|
+
let n = e.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
|
|
360
|
+
for (; t < e.markers.length && (!n || e.markers[t].from < n.end);) {
|
|
361
|
+
let n = e.markers[t++];
|
|
362
|
+
this.addNode(n.type, n.from, n.to);
|
|
363
|
+
}
|
|
364
|
+
if (!n) break;
|
|
365
|
+
this.finishContext();
|
|
366
|
+
}
|
|
367
|
+
if (e.pos < e.text.length) break;
|
|
368
|
+
if (!this.nextLine()) return this.finish();
|
|
369
|
+
}
|
|
370
|
+
if (this.fragments && this.reuseFragment(e.basePos)) return null;
|
|
371
|
+
start: for (;;) {
|
|
372
|
+
for (let t of this.parser.blockParsers) if (t) {
|
|
373
|
+
let n = t(this, e);
|
|
374
|
+
if (n != 0) {
|
|
375
|
+
if (n == 1) return null;
|
|
376
|
+
e.forward();
|
|
377
|
+
continue start;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
if (e.pos == e.text.length) return this.nextLine() ? null : this.finish();
|
|
383
|
+
let t = new ue(this.lineStart + e.pos, e.text.slice(e.pos));
|
|
384
|
+
for (let e of this.parser.leafBlockParsers) if (e) {
|
|
385
|
+
let n = e(this, t);
|
|
386
|
+
n && t.parsers.push(n);
|
|
387
|
+
}
|
|
388
|
+
lines: for (; this.nextLine() && e.pos != e.text.length;) {
|
|
389
|
+
if (e.indent < e.baseIndent + 4) {
|
|
390
|
+
for (let n of this.parser.endLeafBlock) if (n(this, e, t)) break lines;
|
|
391
|
+
}
|
|
392
|
+
for (let n of t.parsers) if (n.nextLine(this, e, t)) return null;
|
|
393
|
+
t.content += "\n" + e.scrub();
|
|
394
|
+
for (let n of e.markers) t.marks.push(n);
|
|
395
|
+
}
|
|
396
|
+
return this.finishLeaf(t), null;
|
|
397
|
+
}
|
|
398
|
+
stopAt(e) {
|
|
399
|
+
if (this.stoppedAt != null && this.stoppedAt < e) throw RangeError("Can't move stoppedAt forward");
|
|
400
|
+
this.stoppedAt = e;
|
|
401
|
+
}
|
|
402
|
+
reuseFragment(e) {
|
|
403
|
+
if (!this.fragments.moveTo(this.absoluteLineStart + e, this.absoluteLineStart) || !this.fragments.matches(this.block.hash)) return !1;
|
|
404
|
+
let t = this.fragments.takeNodes(this);
|
|
405
|
+
return t ? (this.absoluteLineStart += t, this.lineStart = He(this.absoluteLineStart, this.ranges), this.moveRangeI(), this.absoluteLineStart < this.to ? (this.lineStart++, this.absoluteLineStart++, this.readLine()) : (this.atEnd = !0, this.readLine()), !0) : !1;
|
|
406
|
+
}
|
|
407
|
+
get depth() {
|
|
408
|
+
return this.stack.length;
|
|
409
|
+
}
|
|
410
|
+
parentType(e = this.depth - 1) {
|
|
411
|
+
return this.parser.nodeSet.types[this.stack[e].type];
|
|
412
|
+
}
|
|
413
|
+
nextLine() {
|
|
414
|
+
return this.lineStart += this.line.text.length, this.absoluteLineEnd >= this.to ? (this.absoluteLineStart = this.absoluteLineEnd, this.atEnd = !0, this.readLine(), !1) : (this.lineStart++, this.absoluteLineStart = this.absoluteLineEnd + 1, this.moveRangeI(), this.readLine(), !0);
|
|
415
|
+
}
|
|
416
|
+
peekLine() {
|
|
417
|
+
return this.scanLine(this.absoluteLineEnd + 1).text;
|
|
418
|
+
}
|
|
419
|
+
moveRangeI() {
|
|
420
|
+
for (; this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to;) this.rangeI++, this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
|
|
421
|
+
}
|
|
422
|
+
scanLine(e) {
|
|
423
|
+
let t = Oe;
|
|
424
|
+
if (t.end = e, e >= this.to) t.text = "";
|
|
425
|
+
else if (t.text = this.lineChunkAt(e), t.end += t.text.length, this.ranges.length > 1) {
|
|
426
|
+
let e = this.absoluteLineStart, n = this.rangeI;
|
|
427
|
+
for (; this.ranges[n].to < t.end;) {
|
|
428
|
+
n++;
|
|
429
|
+
let r = this.ranges[n].from, i = this.lineChunkAt(r);
|
|
430
|
+
t.end = r + i.length, t.text = t.text.slice(0, this.ranges[n - 1].to - e) + i, e = t.end - t.text.length;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return t;
|
|
434
|
+
}
|
|
435
|
+
readLine() {
|
|
436
|
+
let { line: e } = this, { text: t, end: n } = this.scanLine(this.absoluteLineStart);
|
|
437
|
+
for (this.absoluteLineEnd = n, e.reset(t); e.depth < this.stack.length; e.depth++) {
|
|
438
|
+
let t = this.stack[e.depth], n = this.parser.skipContextMarkup[t.type];
|
|
439
|
+
if (!n) throw Error("Unhandled block context " + b[t.type]);
|
|
440
|
+
let r = this.line.markers.length;
|
|
441
|
+
if (!n(t, this, e)) {
|
|
442
|
+
this.line.markers.length > r && (t.end = this.line.markers[this.line.markers.length - 1].to), e.forward();
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
e.forward();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
lineChunkAt(e) {
|
|
449
|
+
let t = this.input.chunk(e), n;
|
|
450
|
+
if (this.input.lineChunks) n = t == "\n" ? "" : t;
|
|
451
|
+
else {
|
|
452
|
+
let e = t.indexOf("\n");
|
|
453
|
+
n = e < 0 ? t : t.slice(0, e);
|
|
454
|
+
}
|
|
455
|
+
return e + n.length > this.to ? n.slice(0, this.to - e) : n;
|
|
456
|
+
}
|
|
457
|
+
prevLineEnd() {
|
|
458
|
+
return this.atEnd ? this.lineStart : this.lineStart - 1;
|
|
459
|
+
}
|
|
460
|
+
startContext(e, t, n = 0) {
|
|
461
|
+
this.block = le.create(e, n, this.lineStart + t, this.block.hash, this.lineStart + this.line.text.length), this.stack.push(this.block);
|
|
462
|
+
}
|
|
463
|
+
startComposite(e, t, n = 0) {
|
|
464
|
+
this.startContext(this.parser.getNodeType(e), t, n);
|
|
465
|
+
}
|
|
466
|
+
addNode(e, t, n) {
|
|
467
|
+
typeof e == "number" && (e = new r(this.parser.nodeSet.types[e], P, P, (n ?? this.prevLineEnd()) - t)), this.block.addChild(e, t - this.block.from);
|
|
468
|
+
}
|
|
469
|
+
addElement(e) {
|
|
470
|
+
this.block.addChild(e.toTree(this.parser.nodeSet), e.from - this.block.from);
|
|
471
|
+
}
|
|
472
|
+
addLeafElement(e, t) {
|
|
473
|
+
this.addNode(this.buffer.writeElements(G(t.children, e.marks), -t.from).finish(t.type, t.to - t.from), t.from);
|
|
474
|
+
}
|
|
475
|
+
finishContext() {
|
|
476
|
+
let e = this.stack.pop(), t = this.stack[this.stack.length - 1];
|
|
477
|
+
t.addChild(e.toTree(this.parser.nodeSet), e.from - t.from), this.block = t;
|
|
478
|
+
}
|
|
479
|
+
finish() {
|
|
480
|
+
for (; this.stack.length > 1;) this.finishContext();
|
|
481
|
+
return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
|
|
482
|
+
}
|
|
483
|
+
addGaps(e) {
|
|
484
|
+
return this.ranges.length > 1 ? Ae(this.ranges, 0, e.topNode, this.ranges[0].from, this.reusePlaceholders) : e;
|
|
485
|
+
}
|
|
486
|
+
finishLeaf(e) {
|
|
487
|
+
for (let t of e.parsers) if (t.finish(this, e)) return;
|
|
488
|
+
let t = G(this.parser.parseInline(e.content, e.start), e.marks);
|
|
489
|
+
this.addNode(this.buffer.writeElements(t, -e.start).finish(b.Paragraph, e.content.length), e.start);
|
|
490
|
+
}
|
|
491
|
+
elt(e, t, n, r) {
|
|
492
|
+
return typeof e == "string" ? I(this.parser.getNodeType(e), t, n, r) : new Pe(e, t);
|
|
493
|
+
}
|
|
494
|
+
get buffer() {
|
|
495
|
+
return new Ne(this.parser.nodeSet);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
function Ae(e, t, n, i, a) {
|
|
499
|
+
let o = e[t].to, s = [], c = [], l = n.from + i;
|
|
500
|
+
function u(n, r) {
|
|
501
|
+
for (; r ? n >= o : n > o;) {
|
|
502
|
+
let r = e[t + 1].from - o;
|
|
503
|
+
i += r, n += r, t++, o = e[t].to;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (let r = n.firstChild; r; r = r.nextSibling) {
|
|
507
|
+
u(r.from + i, !0);
|
|
508
|
+
let n = r.from + i, d, f = a.get(r.tree);
|
|
509
|
+
f ? d = f : r.to + i > o ? (d = Ae(e, t, r, i, a), u(r.to + i, !1)) : d = r.toTree(), s.push(d), c.push(n - l);
|
|
510
|
+
}
|
|
511
|
+
return u(n.to + i, !1), new r(n.type, s, c, n.to + i - l, n.tree ? n.tree.propValues : void 0);
|
|
512
|
+
}
|
|
513
|
+
var je = class e extends l {
|
|
514
|
+
constructor(e, t, n, r, i, a, o, s, c) {
|
|
515
|
+
super(), this.nodeSet = e, this.blockParsers = t, this.leafBlockParsers = n, this.blockNames = r, this.endLeafBlock = i, this.skipContextMarkup = a, this.inlineParsers = o, this.inlineNames = s, this.wrappers = c, this.nodeTypes = Object.create(null);
|
|
516
|
+
for (let t of e.types) this.nodeTypes[t.name] = t.id;
|
|
517
|
+
}
|
|
518
|
+
createParse(e, t, n) {
|
|
519
|
+
let r = new ke(this, e, t, n);
|
|
520
|
+
for (let i of this.wrappers) r = i(r, e, t, n);
|
|
521
|
+
return r;
|
|
522
|
+
}
|
|
523
|
+
configure(n) {
|
|
524
|
+
let r = M(n);
|
|
525
|
+
if (!r) return this;
|
|
526
|
+
let { nodeSet: i, skipContextMarkup: a } = this, o = this.blockParsers.slice(), c = this.leafBlockParsers.slice(), l = this.blockNames.slice(), u = this.inlineParsers.slice(), f = this.inlineNames.slice(), p = this.endLeafBlock.slice(), m = this.wrappers;
|
|
527
|
+
if (j(r.defineNodes)) {
|
|
528
|
+
a = Object.assign({}, a);
|
|
529
|
+
let e = i.types.slice(), n;
|
|
530
|
+
for (let i of r.defineNodes) {
|
|
531
|
+
let { name: r, block: o, composite: s, style: c } = typeof i == "string" ? { name: i } : i;
|
|
532
|
+
if (e.some((e) => e.name == r)) continue;
|
|
533
|
+
s && (a[e.length] = (e, t, n) => s(t, n, e.value));
|
|
534
|
+
let l = e.length, u = s ? ["Block", "BlockContext"] : o ? l >= b.ATXHeading1 && l <= b.SetextHeading2 ? [
|
|
535
|
+
"Block",
|
|
536
|
+
"LeafBlock",
|
|
537
|
+
"Heading"
|
|
538
|
+
] : ["Block", "LeafBlock"] : void 0;
|
|
539
|
+
e.push(t.define({
|
|
540
|
+
id: l,
|
|
541
|
+
name: r,
|
|
542
|
+
props: u && [[y.group, u]]
|
|
543
|
+
})), c && (n ||= {}, Array.isArray(c) || c instanceof h ? n[r] = c : Object.assign(n, c));
|
|
544
|
+
}
|
|
545
|
+
i = new s(e), n && (i = i.extend(d(n)));
|
|
546
|
+
}
|
|
547
|
+
if (j(r.props) && (i = i.extend(...r.props)), j(r.remove)) for (let e of r.remove) {
|
|
548
|
+
let t = this.blockNames.indexOf(e), n = this.inlineNames.indexOf(e);
|
|
549
|
+
t > -1 && (o[t] = c[t] = void 0), n > -1 && (u[n] = void 0);
|
|
550
|
+
}
|
|
551
|
+
if (j(r.parseBlock)) for (let e of r.parseBlock) {
|
|
552
|
+
let t = l.indexOf(e.name);
|
|
553
|
+
if (t > -1) o[t] = e.parse, c[t] = e.leaf;
|
|
554
|
+
else {
|
|
555
|
+
let t = e.before ? N(l, e.before) : e.after ? N(l, e.after) + 1 : l.length - 1;
|
|
556
|
+
o.splice(t, 0, e.parse), c.splice(t, 0, e.leaf), l.splice(t, 0, e.name);
|
|
557
|
+
}
|
|
558
|
+
e.endLeaf && p.push(e.endLeaf);
|
|
559
|
+
}
|
|
560
|
+
if (j(r.parseInline)) for (let e of r.parseInline) {
|
|
561
|
+
let t = f.indexOf(e.name);
|
|
562
|
+
if (t > -1) u[t] = e.parse;
|
|
563
|
+
else {
|
|
564
|
+
let t = e.before ? N(f, e.before) : e.after ? N(f, e.after) + 1 : f.length - 1;
|
|
565
|
+
u.splice(t, 0, e.parse), f.splice(t, 0, e.name);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return r.wrap && (m = m.concat(r.wrap)), new e(i, o, c, l, p, a, u, f, m);
|
|
569
|
+
}
|
|
570
|
+
getNodeType(e) {
|
|
571
|
+
let t = this.nodeTypes[e];
|
|
572
|
+
if (t == null) throw RangeError(`Unknown node type '${e}'`);
|
|
573
|
+
return t;
|
|
574
|
+
}
|
|
575
|
+
parseInline(e, t) {
|
|
576
|
+
let n = new W(this, e, t);
|
|
577
|
+
outer: for (let e = t; e < n.end;) {
|
|
578
|
+
let t = n.char(e);
|
|
579
|
+
for (let r of this.inlineParsers) if (r) {
|
|
580
|
+
let i = r(n, t, e);
|
|
581
|
+
if (i >= 0) {
|
|
582
|
+
e = i;
|
|
583
|
+
continue outer;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
e++;
|
|
587
|
+
}
|
|
588
|
+
return n.resolveMarkers(0);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
function j(e) {
|
|
592
|
+
return e != null && e.length > 0;
|
|
593
|
+
}
|
|
594
|
+
function M(e) {
|
|
595
|
+
if (!Array.isArray(e)) return e;
|
|
596
|
+
if (e.length == 0) return null;
|
|
597
|
+
let t = M(e[0]);
|
|
598
|
+
if (e.length == 1) return t;
|
|
599
|
+
let n = M(e.slice(1));
|
|
600
|
+
if (!n || !t) return t || n;
|
|
601
|
+
let r = (e, t) => (e || P).concat(t || P), i = t.wrap, a = n.wrap;
|
|
602
|
+
return {
|
|
603
|
+
props: r(t.props, n.props),
|
|
604
|
+
defineNodes: r(t.defineNodes, n.defineNodes),
|
|
605
|
+
parseBlock: r(t.parseBlock, n.parseBlock),
|
|
606
|
+
parseInline: r(t.parseInline, n.parseInline),
|
|
607
|
+
remove: r(t.remove, n.remove),
|
|
608
|
+
wrap: i ? a ? (e, t, n, r) => i(a(e, t, n, r), t, n, r) : i : a
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function N(e, t) {
|
|
612
|
+
let n = e.indexOf(t);
|
|
613
|
+
if (n < 0) throw RangeError(`Position specified relative to unknown parser ${t}`);
|
|
614
|
+
return n;
|
|
615
|
+
}
|
|
616
|
+
var Me = [t.none];
|
|
617
|
+
for (let e = 1, n; n = b[e]; e++) Me[e] = t.define({
|
|
618
|
+
id: e,
|
|
619
|
+
name: n,
|
|
620
|
+
props: e >= b.Escape ? [] : [[y.group, e in pe ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
|
|
621
|
+
top: n == "Document"
|
|
622
|
+
});
|
|
623
|
+
var P = [], Ne = class {
|
|
624
|
+
constructor(e) {
|
|
625
|
+
this.nodeSet = e, this.content = [], this.nodes = [];
|
|
626
|
+
}
|
|
627
|
+
write(e, t, n, r = 0) {
|
|
628
|
+
return this.content.push(e, t, n, 4 + r * 4), this;
|
|
629
|
+
}
|
|
630
|
+
writeElements(e, t = 0) {
|
|
631
|
+
for (let n of e) n.writeTo(this, t);
|
|
632
|
+
return this;
|
|
633
|
+
}
|
|
634
|
+
finish(e, t) {
|
|
635
|
+
return r.build({
|
|
636
|
+
buffer: this.content,
|
|
637
|
+
nodeSet: this.nodeSet,
|
|
638
|
+
reused: this.nodes,
|
|
639
|
+
topID: e,
|
|
640
|
+
length: t
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}, F = class {
|
|
644
|
+
constructor(e, t, n, r = P) {
|
|
645
|
+
this.type = e, this.from = t, this.to = n, this.children = r;
|
|
646
|
+
}
|
|
647
|
+
writeTo(e, t) {
|
|
648
|
+
let n = e.content.length;
|
|
649
|
+
e.writeElements(this.children, t), e.content.push(this.type, this.from + t, this.to + t, e.content.length + 4 - n);
|
|
650
|
+
}
|
|
651
|
+
toTree(e) {
|
|
652
|
+
return new Ne(e).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
|
|
653
|
+
}
|
|
654
|
+
}, Pe = class {
|
|
655
|
+
constructor(e, t) {
|
|
656
|
+
this.tree = e, this.from = t;
|
|
657
|
+
}
|
|
658
|
+
get to() {
|
|
659
|
+
return this.from + this.tree.length;
|
|
660
|
+
}
|
|
661
|
+
get type() {
|
|
662
|
+
return this.tree.type.id;
|
|
663
|
+
}
|
|
664
|
+
get children() {
|
|
665
|
+
return P;
|
|
666
|
+
}
|
|
667
|
+
writeTo(e, t) {
|
|
668
|
+
e.nodes.push(this.tree), e.content.push(e.nodes.length - 1, this.from + t, this.to + t, -1);
|
|
669
|
+
}
|
|
670
|
+
toTree() {
|
|
671
|
+
return this.tree;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
function I(e, t, n, r) {
|
|
675
|
+
return new F(e, t, n, r);
|
|
676
|
+
}
|
|
677
|
+
var L = {
|
|
678
|
+
resolve: "Emphasis",
|
|
679
|
+
mark: "EmphasisMark"
|
|
680
|
+
}, R = {
|
|
681
|
+
resolve: "Emphasis",
|
|
682
|
+
mark: "EmphasisMark"
|
|
683
|
+
}, z = {}, B = {}, V = class {
|
|
684
|
+
constructor(e, t, n, r, i = n - t) {
|
|
685
|
+
this.type = e, this.from = t, this.to = n, this.side = r, this.size = i;
|
|
686
|
+
}
|
|
687
|
+
}, Fe = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", H = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
|
|
688
|
+
try {
|
|
689
|
+
H = /* @__PURE__ */ RegExp("[\\p{S}|\\p{P}]", "u");
|
|
690
|
+
} catch {}
|
|
691
|
+
var U = {
|
|
692
|
+
Escape(e, t, n) {
|
|
693
|
+
if (t != 92 || n == e.end - 1) return -1;
|
|
694
|
+
let r = e.char(n + 1);
|
|
695
|
+
for (let t = 0; t < 32; t++) if (Fe.charCodeAt(t) == r) return e.append(I(b.Escape, n, n + 2));
|
|
696
|
+
return -1;
|
|
697
|
+
},
|
|
698
|
+
Entity(e, t, n) {
|
|
699
|
+
if (t != 38) return -1;
|
|
700
|
+
let r = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(e.slice(n + 1, n + 31));
|
|
701
|
+
return r ? e.append(I(b.Entity, n, n + 1 + r[0].length)) : -1;
|
|
702
|
+
},
|
|
703
|
+
InlineCode(e, t, n) {
|
|
704
|
+
if (t != 96 || n && e.char(n - 1) == 96) return -1;
|
|
705
|
+
let r = n + 1;
|
|
706
|
+
for (; r < e.end && e.char(r) == 96;) r++;
|
|
707
|
+
let i = r - n, a = 0;
|
|
708
|
+
for (; r < e.end; r++) if (e.char(r) == 96) {
|
|
709
|
+
if (a++, a == i && e.char(r + 1) != 96) return e.append(I(b.InlineCode, n, r + 1, [I(b.CodeMark, n, n + i), I(b.CodeMark, r + 1 - i, r + 1)]));
|
|
710
|
+
} else a = 0;
|
|
711
|
+
return -1;
|
|
712
|
+
},
|
|
713
|
+
HTMLTag(e, t, n) {
|
|
714
|
+
if (t != 60 || n == e.end - 1) return -1;
|
|
715
|
+
let r = e.slice(n + 1, e.end), i = /^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);
|
|
716
|
+
if (i) return e.append(I(b.Autolink, n, n + 1 + i[0].length, [
|
|
717
|
+
I(b.LinkMark, n, n + 1),
|
|
718
|
+
I(b.URL, n + 1, n + i[0].length),
|
|
719
|
+
I(b.LinkMark, n + i[0].length, n + 1 + i[0].length)
|
|
720
|
+
]));
|
|
721
|
+
let a = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);
|
|
722
|
+
if (a) return e.append(I(b.Comment, n, n + 1 + a[0].length));
|
|
723
|
+
let o = /^\?[^]*?\?>/.exec(r);
|
|
724
|
+
if (o) return e.append(I(b.ProcessingInstruction, n, n + 1 + o[0].length));
|
|
725
|
+
let s = /^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);
|
|
726
|
+
return s ? e.append(I(b.HTMLTag, n, n + 1 + s[0].length)) : -1;
|
|
727
|
+
},
|
|
728
|
+
Emphasis(e, t, n) {
|
|
729
|
+
if (t != 95 && t != 42) return -1;
|
|
730
|
+
let r = n + 1;
|
|
731
|
+
for (; e.char(r) == t;) r++;
|
|
732
|
+
let i = e.slice(n - 1, n), a = e.slice(r, r + 1), o = H.test(i), s = H.test(a), c = /\s|^$/.test(i), l = /\s|^$/.test(a), u = !l && (!s || c || o), d = !c && (!o || l || s), f = u && (t == 42 || !d || o), p = d && (t == 42 || !u || s);
|
|
733
|
+
return e.append(new V(t == 95 ? L : R, n, r, !!f | (p ? 2 : 0)));
|
|
734
|
+
},
|
|
735
|
+
HardBreak(e, t, n) {
|
|
736
|
+
if (t == 92 && e.char(n + 1) == 10) return e.append(I(b.HardBreak, n, n + 2));
|
|
737
|
+
if (t == 32) {
|
|
738
|
+
let t = n + 1;
|
|
739
|
+
for (; e.char(t) == 32;) t++;
|
|
740
|
+
if (e.char(t) == 10 && t >= n + 2) return e.append(I(b.HardBreak, n, t + 1));
|
|
741
|
+
}
|
|
742
|
+
return -1;
|
|
743
|
+
},
|
|
744
|
+
Link(e, t, n) {
|
|
745
|
+
return t == 91 ? e.append(new V(z, n, n + 1, 1)) : -1;
|
|
746
|
+
},
|
|
747
|
+
Image(e, t, n) {
|
|
748
|
+
return t == 33 && e.char(n + 1) == 91 ? e.append(new V(B, n, n + 2, 1)) : -1;
|
|
749
|
+
},
|
|
750
|
+
LinkEnd(e, t, n) {
|
|
751
|
+
if (t != 93) return -1;
|
|
752
|
+
for (let t = e.parts.length - 1; t >= 0; t--) {
|
|
753
|
+
let r = e.parts[t];
|
|
754
|
+
if (r instanceof V && (r.type == z || r.type == B)) {
|
|
755
|
+
if (!r.side || e.skipSpace(r.to) == n && !/[(\[]/.test(e.slice(n + 1, n + 2))) return e.parts[t] = null, -1;
|
|
756
|
+
let i = e.takeContent(t), a = e.parts[t] = Ie(e, i, r.type == z ? b.Link : b.Image, r.from, n + 1);
|
|
757
|
+
if (r.type == z) for (let n = 0; n < t; n++) {
|
|
758
|
+
let t = e.parts[n];
|
|
759
|
+
t instanceof V && t.type == z && (t.side = 0);
|
|
760
|
+
}
|
|
761
|
+
return a.to;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return -1;
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
function Ie(e, t, n, r, i) {
|
|
768
|
+
let { text: a } = e, o = e.char(i), s = i;
|
|
769
|
+
if (t.unshift(I(b.LinkMark, r, r + (n == b.Image ? 2 : 1))), t.push(I(b.LinkMark, i - 1, i)), o == 40) {
|
|
770
|
+
let n = e.skipSpace(i + 1), r = Le(a, n - e.offset, e.offset), o;
|
|
771
|
+
r && (n = e.skipSpace(r.to), n != r.to && (o = Re(a, n - e.offset, e.offset), o && (n = e.skipSpace(o.to)))), e.char(n) == 41 && (t.push(I(b.LinkMark, i, i + 1)), s = n + 1, r && t.push(r), o && t.push(o), t.push(I(b.LinkMark, n, s)));
|
|
772
|
+
} else if (o == 91) {
|
|
773
|
+
let n = ze(a, i - e.offset, e.offset, !1);
|
|
774
|
+
n && (t.push(n), s = n.to);
|
|
775
|
+
}
|
|
776
|
+
return I(n, r, s, t);
|
|
777
|
+
}
|
|
778
|
+
function Le(e, t, n) {
|
|
779
|
+
if (e.charCodeAt(t) == 60) {
|
|
780
|
+
for (let r = t + 1; r < e.length; r++) {
|
|
781
|
+
let i = e.charCodeAt(r);
|
|
782
|
+
if (i == 62) return I(b.URL, t + n, r + 1 + n);
|
|
783
|
+
if (i == 60 || i == 10) return !1;
|
|
784
|
+
}
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
787
|
+
{
|
|
788
|
+
let r = 0, i = t;
|
|
789
|
+
for (let t = !1; i < e.length; i++) {
|
|
790
|
+
let n = e.charCodeAt(i);
|
|
791
|
+
if (x(n)) break;
|
|
792
|
+
if (t) t = !1;
|
|
793
|
+
else if (n == 40) r++;
|
|
794
|
+
else if (n == 41) {
|
|
795
|
+
if (!r) break;
|
|
796
|
+
r--;
|
|
797
|
+
} else n == 92 && (t = !0);
|
|
798
|
+
}
|
|
799
|
+
return i > t ? I(b.URL, t + n, i + n) : i == e.length && null;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function Re(e, t, n) {
|
|
803
|
+
let r = e.charCodeAt(t);
|
|
804
|
+
if (r != 39 && r != 34 && r != 40) return !1;
|
|
805
|
+
let i = r == 40 ? 41 : r;
|
|
806
|
+
for (let r = t + 1, a = !1; r < e.length; r++) {
|
|
807
|
+
let o = e.charCodeAt(r);
|
|
808
|
+
if (a) a = !1;
|
|
809
|
+
else if (o == i) return I(b.LinkTitle, t + n, r + 1 + n);
|
|
810
|
+
else o == 92 && (a = !0);
|
|
811
|
+
}
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
function ze(e, t, n, r) {
|
|
815
|
+
for (let i = !1, a = t + 1, o = Math.min(e.length, a + 999); a < o; a++) {
|
|
816
|
+
let o = e.charCodeAt(a);
|
|
817
|
+
if (i) i = !1;
|
|
818
|
+
else if (o == 93) return !r && I(b.LinkLabel, t + n, a + 1 + n);
|
|
819
|
+
else {
|
|
820
|
+
if (r && !x(o) && (r = !1), o == 91) return !1;
|
|
821
|
+
o == 92 && (i = !0);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
var W = class {
|
|
827
|
+
constructor(e, t, n) {
|
|
828
|
+
this.parser = e, this.text = t, this.offset = n, this.parts = [];
|
|
829
|
+
}
|
|
830
|
+
char(e) {
|
|
831
|
+
return e >= this.end ? -1 : this.text.charCodeAt(e - this.offset);
|
|
832
|
+
}
|
|
833
|
+
get end() {
|
|
834
|
+
return this.offset + this.text.length;
|
|
835
|
+
}
|
|
836
|
+
slice(e, t) {
|
|
837
|
+
return this.text.slice(e - this.offset, t - this.offset);
|
|
838
|
+
}
|
|
839
|
+
append(e) {
|
|
840
|
+
return this.parts.push(e), e.to;
|
|
841
|
+
}
|
|
842
|
+
addDelimiter(e, t, n, r, i) {
|
|
843
|
+
return this.append(new V(e, t, n, !!r | (i ? 2 : 0)));
|
|
844
|
+
}
|
|
845
|
+
get hasOpenLink() {
|
|
846
|
+
for (let e = this.parts.length - 1; e >= 0; e--) {
|
|
847
|
+
let t = this.parts[e];
|
|
848
|
+
if (t instanceof V && (t.type == z || t.type == B)) return !0;
|
|
849
|
+
}
|
|
850
|
+
return !1;
|
|
851
|
+
}
|
|
852
|
+
addElement(e) {
|
|
853
|
+
return this.append(e);
|
|
854
|
+
}
|
|
855
|
+
resolveMarkers(e) {
|
|
856
|
+
for (let t = e; t < this.parts.length; t++) {
|
|
857
|
+
let n = this.parts[t];
|
|
858
|
+
if (!(n instanceof V && n.type.resolve && n.side & 2)) continue;
|
|
859
|
+
let r = n.type == L || n.type == R, i = n.to - n.from, a, o = t - 1;
|
|
860
|
+
for (; o >= e; o--) {
|
|
861
|
+
let e = this.parts[o];
|
|
862
|
+
if (e instanceof V && e.side & 1 && e.type == n.type && !(r && (n.side & 1 || e.side & 2) && (e.size + n.size) % 3 == 0 && (e.size % 3 || n.size % 3))) {
|
|
863
|
+
a = e;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (!a) continue;
|
|
868
|
+
let s = n.type.resolve, c = [], l = a.from, u = n.to;
|
|
869
|
+
if (r) {
|
|
870
|
+
let e = Math.min(2, a.to - a.from, i);
|
|
871
|
+
l = a.to - e, u = n.from + e, s = e == 1 ? "Emphasis" : "StrongEmphasis";
|
|
872
|
+
}
|
|
873
|
+
a.type.mark && c.push(this.elt(a.type.mark, l, a.to));
|
|
874
|
+
for (let e = o + 1; e < t; e++) this.parts[e] instanceof F && c.push(this.parts[e]), this.parts[e] = null;
|
|
875
|
+
n.type.mark && c.push(this.elt(n.type.mark, n.from, u));
|
|
876
|
+
let d = this.elt(s, l, u, c);
|
|
877
|
+
this.parts[o] = r && a.from != l ? new V(a.type, a.from, l, a.side, a.size) : null, (this.parts[t] = r && n.to != u ? new V(n.type, u, n.to, n.side, n.size) : null) ? this.parts.splice(t, 0, d) : this.parts[t] = d;
|
|
878
|
+
}
|
|
879
|
+
let t = [];
|
|
880
|
+
for (let n = e; n < this.parts.length; n++) {
|
|
881
|
+
let e = this.parts[n];
|
|
882
|
+
e instanceof F && t.push(e);
|
|
883
|
+
}
|
|
884
|
+
return t;
|
|
885
|
+
}
|
|
886
|
+
findOpeningDelimiter(e) {
|
|
887
|
+
for (let t = this.parts.length - 1; t >= 0; t--) {
|
|
888
|
+
let n = this.parts[t];
|
|
889
|
+
if (n instanceof V && n.type == e && n.side & 1) return t;
|
|
890
|
+
}
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
takeContent(e) {
|
|
894
|
+
let t = this.resolveMarkers(e);
|
|
895
|
+
return this.parts.length = e, t;
|
|
896
|
+
}
|
|
897
|
+
getDelimiterAt(e) {
|
|
898
|
+
let t = this.parts[e];
|
|
899
|
+
return t instanceof V ? t : null;
|
|
900
|
+
}
|
|
901
|
+
skipSpace(e) {
|
|
902
|
+
return S(this.text, e - this.offset) + this.offset;
|
|
903
|
+
}
|
|
904
|
+
elt(e, t, n, r) {
|
|
905
|
+
return typeof e == "string" ? I(this.parser.getNodeType(e), t, n, r) : new Pe(e, t);
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
W.linkStart = z, W.imageStart = B, W.emphasisAsterisk = R, W.emphasisUnderscore = L;
|
|
909
|
+
function G(e, t) {
|
|
910
|
+
if (!t.length) return e;
|
|
911
|
+
if (!e.length) return t;
|
|
912
|
+
let n = e.slice(), r = 0;
|
|
913
|
+
for (let e of t) {
|
|
914
|
+
for (; r < n.length && n[r].to < e.to;) r++;
|
|
915
|
+
if (r < n.length && n[r].from < e.from) {
|
|
916
|
+
let t = n[r];
|
|
917
|
+
t instanceof F && (n[r] = new F(t.type, t.from, t.to, G(t.children, [e])));
|
|
918
|
+
} else n.splice(r++, 0, e);
|
|
919
|
+
}
|
|
920
|
+
return n;
|
|
921
|
+
}
|
|
922
|
+
var Be = [
|
|
923
|
+
b.CodeBlock,
|
|
924
|
+
b.ListItem,
|
|
925
|
+
b.OrderedList,
|
|
926
|
+
b.BulletList
|
|
927
|
+
], Ve = class {
|
|
928
|
+
constructor(e, t) {
|
|
929
|
+
this.fragments = e, this.input = t, this.i = 0, this.fragment = null, this.fragmentEnd = -1, this.cursor = null, e.length && (this.fragment = e[this.i++]);
|
|
930
|
+
}
|
|
931
|
+
nextFragment() {
|
|
932
|
+
this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null, this.cursor = null, this.fragmentEnd = -1;
|
|
933
|
+
}
|
|
934
|
+
moveTo(e, t) {
|
|
935
|
+
for (; this.fragment && this.fragment.to <= e;) this.nextFragment();
|
|
936
|
+
if (!this.fragment || this.fragment.from > (e ? e - 1 : 0)) return !1;
|
|
937
|
+
if (this.fragmentEnd < 0) {
|
|
938
|
+
let e = this.fragment.to;
|
|
939
|
+
for (; e > 0 && this.input.read(e - 1, e) != "\n";) e--;
|
|
940
|
+
this.fragmentEnd = e ? e - 1 : 0;
|
|
941
|
+
}
|
|
942
|
+
let n = this.cursor;
|
|
943
|
+
n || (n = this.cursor = this.fragment.tree.cursor(), n.firstChild());
|
|
944
|
+
let r = e + this.fragment.offset;
|
|
945
|
+
for (; n.to <= r;) if (!n.parent()) return !1;
|
|
946
|
+
for (;;) {
|
|
947
|
+
if (n.from >= r) return this.fragment.from <= t;
|
|
948
|
+
if (!n.childAfter(r)) return !1;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
matches(e) {
|
|
952
|
+
let t = this.cursor.tree;
|
|
953
|
+
return t && t.prop(y.contextHash) == e;
|
|
954
|
+
}
|
|
955
|
+
takeNodes(e) {
|
|
956
|
+
let t = this.cursor, n = this.fragment.offset, i = this.fragmentEnd - +!!this.fragment.openEnd, a = e.absoluteLineStart, o = a, s = e.block.children.length, c = o, l = s;
|
|
957
|
+
for (;;) {
|
|
958
|
+
if (t.to - n > i || t.to - n > e.to) {
|
|
959
|
+
if (t.type.isAnonymous && t.firstChild()) continue;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
let a = He(t.from - n, e.ranges);
|
|
963
|
+
if (t.to - n <= e.ranges[e.rangeI].to) e.addNode(t.tree, a);
|
|
964
|
+
else {
|
|
965
|
+
let n = new r(e.parser.nodeSet.types[b.Paragraph], [], [], 0, e.block.hashProp);
|
|
966
|
+
e.reusePlaceholders.set(n, t.tree), e.addNode(n, a);
|
|
967
|
+
}
|
|
968
|
+
if (t.type.is("Block") && (Be.indexOf(t.type.id) < 0 ? (o = t.to - n, s = e.block.children.length) : (o = c, s = l), c = t.to - n, l = e.block.children.length), !t.nextSibling()) break;
|
|
969
|
+
}
|
|
970
|
+
for (; e.block.children.length > s;) e.block.children.pop(), e.block.positions.pop();
|
|
971
|
+
return o - a;
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
function He(e, t) {
|
|
975
|
+
let n = e;
|
|
976
|
+
for (let r = 1; r < t.length; r++) {
|
|
977
|
+
let i = t[r - 1].to, a = t[r].from;
|
|
978
|
+
i < e && (n -= a - i);
|
|
979
|
+
}
|
|
980
|
+
return n;
|
|
981
|
+
}
|
|
982
|
+
var Ue = d({
|
|
983
|
+
"Blockquote/...": v.quote,
|
|
984
|
+
HorizontalRule: v.contentSeparator,
|
|
985
|
+
"ATXHeading1/... SetextHeading1/...": v.heading1,
|
|
986
|
+
"ATXHeading2/... SetextHeading2/...": v.heading2,
|
|
987
|
+
"ATXHeading3/...": v.heading3,
|
|
988
|
+
"ATXHeading4/...": v.heading4,
|
|
989
|
+
"ATXHeading5/...": v.heading5,
|
|
990
|
+
"ATXHeading6/...": v.heading6,
|
|
991
|
+
"Comment CommentBlock": v.comment,
|
|
992
|
+
Escape: v.escape,
|
|
993
|
+
Entity: v.character,
|
|
994
|
+
"Emphasis/...": v.emphasis,
|
|
995
|
+
"StrongEmphasis/...": v.strong,
|
|
996
|
+
"Link/... Image/...": v.link,
|
|
997
|
+
"OrderedList/... BulletList/...": v.list,
|
|
998
|
+
"BlockQuote/...": v.quote,
|
|
999
|
+
"InlineCode CodeText": v.monospace,
|
|
1000
|
+
"URL Autolink": v.url,
|
|
1001
|
+
"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": v.processingInstruction,
|
|
1002
|
+
"CodeInfo LinkLabel": v.labelName,
|
|
1003
|
+
LinkTitle: v.string,
|
|
1004
|
+
Paragraph: v.content
|
|
1005
|
+
}), We = new je(new s(Me).extend(Ue), Object.keys(k).map((e) => k[e]), Object.keys(k).map((e) => Ee[e]), Object.keys(k), De, pe, Object.keys(U).map((e) => U[e]), Object.keys(U), []);
|
|
1006
|
+
function Ge(e, t, n) {
|
|
1007
|
+
let r = [];
|
|
1008
|
+
for (let i = e.firstChild, a = t;; i = i.nextSibling) {
|
|
1009
|
+
let e = i ? i.from : n;
|
|
1010
|
+
if (e > a && r.push({
|
|
1011
|
+
from: a,
|
|
1012
|
+
to: e
|
|
1013
|
+
}), !i) break;
|
|
1014
|
+
a = i.to;
|
|
1015
|
+
}
|
|
1016
|
+
return r;
|
|
1017
|
+
}
|
|
1018
|
+
function Ke(e) {
|
|
1019
|
+
let { codeParser: t, htmlParser: r } = e;
|
|
1020
|
+
return { wrap: n((e, n) => {
|
|
1021
|
+
let i = e.type.id;
|
|
1022
|
+
if (t && (i == b.CodeBlock || i == b.FencedCode)) {
|
|
1023
|
+
let r = "";
|
|
1024
|
+
if (i == b.FencedCode) {
|
|
1025
|
+
let t = e.node.getChild(b.CodeInfo);
|
|
1026
|
+
t && (r = n.read(t.from, t.to));
|
|
1027
|
+
}
|
|
1028
|
+
let a = t(r);
|
|
1029
|
+
if (a) return {
|
|
1030
|
+
parser: a,
|
|
1031
|
+
overlay: (e) => e.type.id == b.CodeText,
|
|
1032
|
+
bracketed: i == b.FencedCode
|
|
1033
|
+
};
|
|
1034
|
+
} else if (r && (i == b.HTMLBlock || i == b.HTMLTag || i == b.CommentBlock)) return {
|
|
1035
|
+
parser: r,
|
|
1036
|
+
overlay: Ge(e.node, e.from, e.to)
|
|
1037
|
+
};
|
|
1038
|
+
return null;
|
|
1039
|
+
}) };
|
|
1040
|
+
}
|
|
1041
|
+
var qe = {
|
|
1042
|
+
resolve: "Strikethrough",
|
|
1043
|
+
mark: "StrikethroughMark"
|
|
1044
|
+
}, Je = {
|
|
1045
|
+
defineNodes: [{
|
|
1046
|
+
name: "Strikethrough",
|
|
1047
|
+
style: { "Strikethrough/...": v.strikethrough }
|
|
1048
|
+
}, {
|
|
1049
|
+
name: "StrikethroughMark",
|
|
1050
|
+
style: v.processingInstruction
|
|
1051
|
+
}],
|
|
1052
|
+
parseInline: [{
|
|
1053
|
+
name: "Strikethrough",
|
|
1054
|
+
parse(e, t, n) {
|
|
1055
|
+
if (t != 126 || e.char(n + 1) != 126 || e.char(n + 2) == 126) return -1;
|
|
1056
|
+
let r = e.slice(n - 1, n), i = e.slice(n + 2, n + 3), a = /\s|^$/.test(r), o = /\s|^$/.test(i), s = H.test(r), c = H.test(i);
|
|
1057
|
+
return e.addDelimiter(qe, n, n + 2, !o && (!c || a || s), !a && (!s || o || c));
|
|
1058
|
+
},
|
|
1059
|
+
after: "Emphasis"
|
|
1060
|
+
}]
|
|
1061
|
+
};
|
|
1062
|
+
function K(e, t, n = 0, r, i = 0) {
|
|
1063
|
+
let a = 0, o = !0, s = -1, c = -1, l = !1, u = () => {
|
|
1064
|
+
r.push(e.elt("TableCell", i + s, i + c, e.parser.parseInline(t.slice(s, c), i + s)));
|
|
1065
|
+
};
|
|
1066
|
+
for (let d = n; d < t.length; d++) {
|
|
1067
|
+
let n = t.charCodeAt(d);
|
|
1068
|
+
n == 124 && !l ? ((!o || s > -1) && a++, o = !1, r && (s > -1 && u(), r.push(e.elt("TableDelimiter", d + i, d + i + 1))), s = c = -1) : (l || n != 32 && n != 9) && (s < 0 && (s = d), c = d + 1), l = !l && n == 92;
|
|
1069
|
+
}
|
|
1070
|
+
return s > -1 && (a++, r && u()), a;
|
|
1071
|
+
}
|
|
1072
|
+
function Ye(e, t) {
|
|
1073
|
+
for (let n = t; n < e.length; n++) {
|
|
1074
|
+
let t = e.charCodeAt(n);
|
|
1075
|
+
if (t == 124) return !0;
|
|
1076
|
+
t == 92 && n++;
|
|
1077
|
+
}
|
|
1078
|
+
return !1;
|
|
1079
|
+
}
|
|
1080
|
+
var Xe = /^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/, Ze = class {
|
|
1081
|
+
constructor() {
|
|
1082
|
+
this.rows = null;
|
|
1083
|
+
}
|
|
1084
|
+
nextLine(e, t, n) {
|
|
1085
|
+
if (this.rows == null) {
|
|
1086
|
+
this.rows = !1;
|
|
1087
|
+
let r;
|
|
1088
|
+
if ((t.next == 45 || t.next == 58 || t.next == 124) && Xe.test(r = t.text.slice(t.pos))) {
|
|
1089
|
+
let i = [];
|
|
1090
|
+
K(e, n.content, 0, i, n.start) == K(e, r, 0) && (this.rows = [e.elt("TableHeader", n.start, n.start + n.content.length, i), e.elt("TableDelimiter", e.lineStart + t.pos, e.lineStart + t.text.length)]);
|
|
1091
|
+
}
|
|
1092
|
+
} else if (this.rows) {
|
|
1093
|
+
let n = [];
|
|
1094
|
+
K(e, t.text, t.pos, n, e.lineStart), this.rows.push(e.elt("TableRow", e.lineStart + t.pos, e.lineStart + t.text.length, n));
|
|
1095
|
+
}
|
|
1096
|
+
return !1;
|
|
1097
|
+
}
|
|
1098
|
+
finish(e, t) {
|
|
1099
|
+
return this.rows ? (e.addLeafElement(t, e.elt("Table", t.start, t.start + t.content.length, this.rows)), !0) : !1;
|
|
1100
|
+
}
|
|
1101
|
+
}, Qe = {
|
|
1102
|
+
defineNodes: [
|
|
1103
|
+
{
|
|
1104
|
+
name: "Table",
|
|
1105
|
+
block: !0
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "TableHeader",
|
|
1109
|
+
style: { "TableHeader/...": v.heading }
|
|
1110
|
+
},
|
|
1111
|
+
"TableRow",
|
|
1112
|
+
{
|
|
1113
|
+
name: "TableCell",
|
|
1114
|
+
style: v.content
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
name: "TableDelimiter",
|
|
1118
|
+
style: v.processingInstruction
|
|
1119
|
+
}
|
|
1120
|
+
],
|
|
1121
|
+
parseBlock: [{
|
|
1122
|
+
name: "Table",
|
|
1123
|
+
leaf(e, t) {
|
|
1124
|
+
return Ye(t.content, 0) ? new Ze() : null;
|
|
1125
|
+
},
|
|
1126
|
+
endLeaf(e, t, n) {
|
|
1127
|
+
if (n.parsers.some((e) => e instanceof Ze) || !Ye(t.text, t.basePos)) return !1;
|
|
1128
|
+
let r = e.peekLine();
|
|
1129
|
+
return Xe.test(r) && K(e, t.text, t.basePos) == K(e, r, t.basePos);
|
|
1130
|
+
},
|
|
1131
|
+
before: "SetextHeading"
|
|
1132
|
+
}]
|
|
1133
|
+
}, $e = class {
|
|
1134
|
+
nextLine() {
|
|
1135
|
+
return !1;
|
|
1136
|
+
}
|
|
1137
|
+
finish(e, t) {
|
|
1138
|
+
return e.addLeafElement(t, e.elt("Task", t.start, t.start + t.content.length, [e.elt("TaskMarker", t.start, t.start + 3), ...e.parser.parseInline(t.content.slice(3), t.start + 3)])), !0;
|
|
1139
|
+
}
|
|
1140
|
+
}, et = {
|
|
1141
|
+
defineNodes: [{
|
|
1142
|
+
name: "Task",
|
|
1143
|
+
block: !0,
|
|
1144
|
+
style: v.list
|
|
1145
|
+
}, {
|
|
1146
|
+
name: "TaskMarker",
|
|
1147
|
+
style: v.atom
|
|
1148
|
+
}],
|
|
1149
|
+
parseBlock: [{
|
|
1150
|
+
name: "TaskList",
|
|
1151
|
+
leaf(e, t) {
|
|
1152
|
+
return /^\[[ xX]\][ \t]/.test(t.content) && e.parentType().name == "ListItem" ? new $e() : null;
|
|
1153
|
+
},
|
|
1154
|
+
after: "SetextHeading"
|
|
1155
|
+
}]
|
|
1156
|
+
}, tt = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy, nt = /[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy, rt = /[\w-]+\.[\w-]+($|[/:])/, it = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy, at = /\/[a-zA-Z\d@.]+/gy;
|
|
1157
|
+
function ot(e, t, n, r) {
|
|
1158
|
+
let i = 0;
|
|
1159
|
+
for (let a = t; a < n; a++) e[a] == r && i++;
|
|
1160
|
+
return i;
|
|
1161
|
+
}
|
|
1162
|
+
function st(e, t) {
|
|
1163
|
+
nt.lastIndex = t;
|
|
1164
|
+
let n = nt.exec(e);
|
|
1165
|
+
if (!n || rt.exec(n[0])[0].indexOf("_") > -1) return -1;
|
|
1166
|
+
let r = t + n[0].length;
|
|
1167
|
+
for (;;) {
|
|
1168
|
+
let n = e[r - 1], i;
|
|
1169
|
+
if (/[?!.,:*_~]/.test(n) || n == ")" && ot(e, t, r, ")") > ot(e, t, r, "(")) r--;
|
|
1170
|
+
else if (n == ";" && (i = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t, r)))) r = t + i.index;
|
|
1171
|
+
else break;
|
|
1172
|
+
}
|
|
1173
|
+
return r;
|
|
1174
|
+
}
|
|
1175
|
+
function ct(e, t) {
|
|
1176
|
+
it.lastIndex = t;
|
|
1177
|
+
let n = it.exec(e);
|
|
1178
|
+
if (!n) return -1;
|
|
1179
|
+
let r = n[0][n[0].length - 1];
|
|
1180
|
+
return r == "_" || r == "-" ? -1 : t + n[0].length - +(r == ".");
|
|
1181
|
+
}
|
|
1182
|
+
var lt = [
|
|
1183
|
+
Qe,
|
|
1184
|
+
et,
|
|
1185
|
+
Je,
|
|
1186
|
+
{ parseInline: [{
|
|
1187
|
+
name: "Autolink",
|
|
1188
|
+
parse(e, t, n) {
|
|
1189
|
+
let r = n - e.offset;
|
|
1190
|
+
if (r && /\w/.test(e.text[r - 1])) return -1;
|
|
1191
|
+
tt.lastIndex = r;
|
|
1192
|
+
let i = tt.exec(e.text), a = -1;
|
|
1193
|
+
return !i || (i[1] || i[2] ? (a = st(e.text, r + i[0].length), a > -1 && e.hasOpenLink && (a = r + /([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(r, a))[0].length)) : i[3] ? a = ct(e.text, r) : (a = ct(e.text, r + i[0].length), a > -1 && i[0] == "xmpp:" && (at.lastIndex = a, i = at.exec(e.text), i && (a = i.index + i[0].length))), a < 0) ? -1 : (e.addElement(e.elt("URL", n, a + e.offset)), a + e.offset);
|
|
1194
|
+
}
|
|
1195
|
+
}] }
|
|
1196
|
+
];
|
|
1197
|
+
function ut(e, t, n) {
|
|
1198
|
+
return (r, i, a) => {
|
|
1199
|
+
if (i != e || r.char(a + 1) == e) return -1;
|
|
1200
|
+
let o = [r.elt(n, a, a + 1)];
|
|
1201
|
+
for (let i = a + 1; i < r.end; i++) {
|
|
1202
|
+
let s = r.char(i);
|
|
1203
|
+
if (s == e) return r.addElement(r.elt(t, a, i + 1, o.concat(r.elt(n, i, i + 1))));
|
|
1204
|
+
if (s == 92 && o.push(r.elt("Escape", i, i++ + 2)), x(s)) break;
|
|
1205
|
+
}
|
|
1206
|
+
return -1;
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
var dt = {
|
|
1210
|
+
defineNodes: [{
|
|
1211
|
+
name: "Superscript",
|
|
1212
|
+
style: v.special(v.content)
|
|
1213
|
+
}, {
|
|
1214
|
+
name: "SuperscriptMark",
|
|
1215
|
+
style: v.processingInstruction
|
|
1216
|
+
}],
|
|
1217
|
+
parseInline: [{
|
|
1218
|
+
name: "Superscript",
|
|
1219
|
+
parse: ut(94, "Superscript", "SuperscriptMark")
|
|
1220
|
+
}]
|
|
1221
|
+
}, ft = {
|
|
1222
|
+
defineNodes: [{
|
|
1223
|
+
name: "Subscript",
|
|
1224
|
+
style: v.special(v.content)
|
|
1225
|
+
}, {
|
|
1226
|
+
name: "SubscriptMark",
|
|
1227
|
+
style: v.processingInstruction
|
|
1228
|
+
}],
|
|
1229
|
+
parseInline: [{
|
|
1230
|
+
name: "Subscript",
|
|
1231
|
+
parse: ut(126, "Subscript", "SubscriptMark")
|
|
1232
|
+
}]
|
|
1233
|
+
}, pt = {
|
|
1234
|
+
defineNodes: [{
|
|
1235
|
+
name: "Emoji",
|
|
1236
|
+
style: v.character
|
|
1237
|
+
}],
|
|
1238
|
+
parseInline: [{
|
|
1239
|
+
name: "Emoji",
|
|
1240
|
+
parse(e, t, n) {
|
|
1241
|
+
let r;
|
|
1242
|
+
return t != 58 || !(r = /^[a-zA-Z_0-9]+:/.exec(e.slice(n + 1, e.end))) ? -1 : e.addElement(e.elt("Emoji", n, n + 1 + r[0].length));
|
|
1243
|
+
}
|
|
1244
|
+
}]
|
|
1245
|
+
}, mt = /*@__PURE__*/ p({ commentTokens: { block: {
|
|
1246
|
+
open: "<!--",
|
|
1247
|
+
close: "-->"
|
|
1248
|
+
} } }), ht = /*@__PURE__*/ new y(), gt = /*@__PURE__*/ We.configure({ props: [
|
|
1249
|
+
/*@__PURE__*/ u.add((e) => !e.is("Block") || e.is("Document") || q(e) != null || _t(e) ? void 0 : (e, t) => ({
|
|
1250
|
+
from: t.doc.lineAt(e.from).to,
|
|
1251
|
+
to: e.to
|
|
1252
|
+
})),
|
|
1253
|
+
/*@__PURE__*/ ht.add(q),
|
|
1254
|
+
/*@__PURE__*/ ae.add({ Document: () => null }),
|
|
1255
|
+
/*@__PURE__*/ c.add({ Document: mt })
|
|
1256
|
+
] });
|
|
1257
|
+
function q(e) {
|
|
1258
|
+
let t = /^(?:ATX|Setext)Heading(\d)$/.exec(e.name);
|
|
1259
|
+
return t ? +t[1] : void 0;
|
|
1260
|
+
}
|
|
1261
|
+
function _t(e) {
|
|
1262
|
+
return e.name == "OrderedList" || e.name == "BulletList";
|
|
1263
|
+
}
|
|
1264
|
+
function vt(e, t) {
|
|
1265
|
+
let n = e;
|
|
1266
|
+
for (;;) {
|
|
1267
|
+
let e = n.nextSibling, r;
|
|
1268
|
+
if (!e || (r = q(e.type)) != null && r <= t) break;
|
|
1269
|
+
n = e;
|
|
1270
|
+
}
|
|
1271
|
+
return n.to;
|
|
1272
|
+
}
|
|
1273
|
+
var yt = /*@__PURE__*/ re.of((e, t, n) => {
|
|
1274
|
+
for (let r = _(e).resolveInner(n, -1); r && !(r.from < t); r = r.parent) {
|
|
1275
|
+
let e = r.type.prop(ht);
|
|
1276
|
+
if (e == null) continue;
|
|
1277
|
+
let t = vt(r, e);
|
|
1278
|
+
if (t > n) return {
|
|
1279
|
+
from: n,
|
|
1280
|
+
to: t
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
return null;
|
|
1284
|
+
});
|
|
1285
|
+
function J(e) {
|
|
1286
|
+
return new ne(mt, e, [], "markdown");
|
|
1287
|
+
}
|
|
1288
|
+
var bt = /*@__PURE__*/ J(gt), Y = /*@__PURE__*/ J(/* @__PURE__ */ gt.configure([
|
|
1289
|
+
lt,
|
|
1290
|
+
ft,
|
|
1291
|
+
dt,
|
|
1292
|
+
pt,
|
|
1293
|
+
{ props: [/*@__PURE__*/ u.add({ Table: (e, t) => ({
|
|
1294
|
+
from: t.doc.lineAt(e.from).to,
|
|
1295
|
+
to: e.to
|
|
1296
|
+
}) })] }
|
|
1297
|
+
]));
|
|
1298
|
+
function xt(e, t) {
|
|
1299
|
+
return (n) => {
|
|
1300
|
+
if (n && e) {
|
|
1301
|
+
let t = null;
|
|
1302
|
+
if (n = /\S*/.exec(n)[0], t = typeof e == "function" ? e(n) : g.matchLanguageName(e, n, !0), t instanceof g) return t.support ? t.support.language.parser : te.getSkippingParser(t.load());
|
|
1303
|
+
if (t) return t.parser;
|
|
1304
|
+
}
|
|
1305
|
+
return t ? t.parser : null;
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
var X = class {
|
|
1309
|
+
constructor(e, t, n, r, i, a, o) {
|
|
1310
|
+
this.node = e, this.from = t, this.to = n, this.spaceBefore = r, this.spaceAfter = i, this.type = a, this.item = o;
|
|
1311
|
+
}
|
|
1312
|
+
blank(e, t = !0) {
|
|
1313
|
+
let n = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
|
|
1314
|
+
if (e != null) {
|
|
1315
|
+
for (; n.length < e;) n += " ";
|
|
1316
|
+
return n;
|
|
1317
|
+
}
|
|
1318
|
+
for (let e = this.to - this.from - n.length - this.spaceAfter.length; e > 0; e--) n += " ";
|
|
1319
|
+
return n + (t ? this.spaceAfter : "");
|
|
1320
|
+
}
|
|
1321
|
+
marker(e, t) {
|
|
1322
|
+
let n = this.node.name == "OrderedList" ? String(+Ct(this.item, e)[2] + t) : "";
|
|
1323
|
+
return this.spaceBefore + n + this.type + this.spaceAfter;
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
function St(e, t) {
|
|
1327
|
+
let n = [], r = [];
|
|
1328
|
+
for (let t = e; t; t = t.parent) {
|
|
1329
|
+
if (t.name == "FencedCode") return r;
|
|
1330
|
+
(t.name == "ListItem" || t.name == "Blockquote") && n.push(t);
|
|
1331
|
+
}
|
|
1332
|
+
for (let e = n.length - 1; e >= 0; e--) {
|
|
1333
|
+
let i = n[e], a, o = t.lineAt(i.from), s = i.from - o.from;
|
|
1334
|
+
if (i.name == "Blockquote" && (a = /^ *>( ?)/.exec(o.text.slice(s)))) r.push(new X(i, s, s + a[0].length, "", a[1], ">", null));
|
|
1335
|
+
else if (i.name == "ListItem" && i.parent.name == "OrderedList" && (a = /^( *)\d+([.)])( *)/.exec(o.text.slice(s)))) {
|
|
1336
|
+
let e = a[3], t = a[0].length;
|
|
1337
|
+
e.length >= 4 && (e = e.slice(0, e.length - 4), t -= 4), r.push(new X(i.parent, s, s + t, a[1], e, a[2], i));
|
|
1338
|
+
} else if (i.name == "ListItem" && i.parent.name == "BulletList" && (a = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))) {
|
|
1339
|
+
let e = a[4], t = a[0].length;
|
|
1340
|
+
e.length > 4 && (e = e.slice(0, e.length - 4), t -= 4);
|
|
1341
|
+
let n = a[2];
|
|
1342
|
+
a[3] && (n += a[3].replace(/[xX]/, " ")), r.push(new X(i.parent, s, s + t, a[1], e, n, i));
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
return r;
|
|
1346
|
+
}
|
|
1347
|
+
function Ct(e, t) {
|
|
1348
|
+
return /^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from, e.from + 10));
|
|
1349
|
+
}
|
|
1350
|
+
function Z(e, t, n, r = 0) {
|
|
1351
|
+
for (let i = -1, a = e;;) {
|
|
1352
|
+
if (a.name == "ListItem") {
|
|
1353
|
+
let e = Ct(a, t), o = +e[2];
|
|
1354
|
+
if (i >= 0) {
|
|
1355
|
+
if (o != i + 1) return;
|
|
1356
|
+
n.push({
|
|
1357
|
+
from: a.from + e[1].length,
|
|
1358
|
+
to: a.from + e[0].length,
|
|
1359
|
+
insert: String(i + 2 + r)
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
i = o;
|
|
1363
|
+
}
|
|
1364
|
+
let e = a.nextSibling;
|
|
1365
|
+
if (!e) break;
|
|
1366
|
+
a = e;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
function Q(e, t) {
|
|
1370
|
+
let n = /^[ \t]*/.exec(e)[0].length;
|
|
1371
|
+
if (!n || t.facet(ie) != " ") return e;
|
|
1372
|
+
let r = m(e, 4, n), i = "";
|
|
1373
|
+
for (let e = r; e > 0;) e >= 4 ? (i += " ", e -= 4) : (i += " ", e--);
|
|
1374
|
+
return i + e.slice(n);
|
|
1375
|
+
}
|
|
1376
|
+
var wt = /*@__PURE__*/ ((e = {}) => ({ state: t, dispatch: n }) => {
|
|
1377
|
+
let r = _(t), { doc: i } = t, a = null, s = t.changeByRange((n) => {
|
|
1378
|
+
if (!n.empty || !Y.isActiveAt(t, n.from, -1) && !Y.isActiveAt(t, n.from, 1)) return a = { range: n };
|
|
1379
|
+
let s = n.from, c = i.lineAt(s), l = St(r.resolveInner(s, -1), i);
|
|
1380
|
+
for (; l.length && l[l.length - 1].from > s - c.from;) l.pop();
|
|
1381
|
+
if (!l.length) return a = { range: n };
|
|
1382
|
+
let u = l[l.length - 1];
|
|
1383
|
+
if (u.to - u.spaceAfter.length > s - c.from) return a = { range: n };
|
|
1384
|
+
let d = s >= u.to - u.spaceAfter.length && !/\S/.test(c.text.slice(u.to));
|
|
1385
|
+
if (u.item && d) {
|
|
1386
|
+
if (u.item.from < c.from && !/^[\s>]*$/.test(c.text.slice(0, u.to))) return a = { range: n };
|
|
1387
|
+
let r = u.node.firstChild, d = u.node.getChild("ListItem", "ListItem");
|
|
1388
|
+
if (r.to >= s || d && d.to < s || c.from > 0 && !/[^\s>]/.test(i.lineAt(c.from - 1).text) || e.nonTightLists === !1) {
|
|
1389
|
+
let e = l.length > 1 ? l[l.length - 2] : null, t, n = "";
|
|
1390
|
+
e && e.item ? (t = c.from + e.from, n = e.marker(i, 1)) : t = c.from + (e ? e.to : 0);
|
|
1391
|
+
let r = [{
|
|
1392
|
+
from: t,
|
|
1393
|
+
to: s,
|
|
1394
|
+
insert: n
|
|
1395
|
+
}];
|
|
1396
|
+
return u.node.name == "OrderedList" && Z(u.item, i, r, -2), e && e.node.name == "OrderedList" && Z(e.item, i, r), {
|
|
1397
|
+
range: o.cursor(t + n.length),
|
|
1398
|
+
changes: r
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
{
|
|
1402
|
+
let e = Dt(l, t, c);
|
|
1403
|
+
return {
|
|
1404
|
+
range: o.cursor(s + e.length + 1),
|
|
1405
|
+
changes: {
|
|
1406
|
+
from: c.from,
|
|
1407
|
+
insert: e + t.lineBreak
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (u.node.name == "Blockquote" && d && c.from) {
|
|
1413
|
+
let e = i.lineAt(c.from - 1), r = />\s*$/.exec(e.text);
|
|
1414
|
+
if (r && r.index == u.from) {
|
|
1415
|
+
let i = t.changes([{
|
|
1416
|
+
from: e.from + r.index,
|
|
1417
|
+
to: e.to
|
|
1418
|
+
}, {
|
|
1419
|
+
from: c.from + u.from,
|
|
1420
|
+
to: c.to
|
|
1421
|
+
}]);
|
|
1422
|
+
return {
|
|
1423
|
+
range: n.map(i),
|
|
1424
|
+
changes: i
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
let f = [];
|
|
1429
|
+
u.node.name == "OrderedList" && Z(u.item, i, f);
|
|
1430
|
+
let p = u.item && u.item.from < c.from, h = "";
|
|
1431
|
+
if (!p || /^[\s\d.)\-+*>]*/.exec(c.text)[0].length >= u.to) for (let e = 0, t = l.length - 1; e <= t; e++) h += e == t && !p ? l[e].marker(i, 1) : l[e].blank(e < t ? m(c.text, 4, l[e + 1].from) - h.length : null);
|
|
1432
|
+
let g = s;
|
|
1433
|
+
for (; g > c.from && /\s/.test(c.text.charAt(g - c.from - 1));) g--;
|
|
1434
|
+
return h = Q(h, t), Et(u.node, t.doc) && (h = Dt(l, t, c) + t.lineBreak + h), f.push({
|
|
1435
|
+
from: g,
|
|
1436
|
+
to: s,
|
|
1437
|
+
insert: t.lineBreak + h
|
|
1438
|
+
}), {
|
|
1439
|
+
range: o.cursor(g + h.length + 1),
|
|
1440
|
+
changes: f
|
|
1441
|
+
};
|
|
1442
|
+
});
|
|
1443
|
+
return !a && (n(t.update(s, {
|
|
1444
|
+
scrollIntoView: !0,
|
|
1445
|
+
userEvent: "input"
|
|
1446
|
+
})), !0);
|
|
1447
|
+
})();
|
|
1448
|
+
function Tt(e) {
|
|
1449
|
+
return e.name == "QuoteMark" || e.name == "ListMark";
|
|
1450
|
+
}
|
|
1451
|
+
function Et(e, t) {
|
|
1452
|
+
if (e.name != "OrderedList" && e.name != "BulletList") return !1;
|
|
1453
|
+
let n = e.firstChild, r = e.getChild("ListItem", "ListItem");
|
|
1454
|
+
if (!r) return !1;
|
|
1455
|
+
let i = t.lineAt(n.to), a = t.lineAt(r.from), o = /^[\s>]*$/.test(i.text);
|
|
1456
|
+
return i.number + +!o < a.number;
|
|
1457
|
+
}
|
|
1458
|
+
function Dt(e, t, n) {
|
|
1459
|
+
let r = "";
|
|
1460
|
+
for (let t = 0, i = e.length - 2; t <= i; t++) r += e[t].blank(t < i ? m(n.text, 4, e[t + 1].from) - r.length : null, t < i);
|
|
1461
|
+
return Q(r, t);
|
|
1462
|
+
}
|
|
1463
|
+
function Ot(e, t) {
|
|
1464
|
+
let n = e.resolveInner(t, -1), r = t;
|
|
1465
|
+
Tt(n) && (r = n.from, n = n.parent);
|
|
1466
|
+
for (let e; e = n.childBefore(r);) if (Tt(e)) r = e.from;
|
|
1467
|
+
else if (e.name == "OrderedList" || e.name == "BulletList") n = e.lastChild, r = n.to;
|
|
1468
|
+
else break;
|
|
1469
|
+
return n;
|
|
1470
|
+
}
|
|
1471
|
+
var kt = [{
|
|
1472
|
+
key: "Enter",
|
|
1473
|
+
run: wt
|
|
1474
|
+
}, {
|
|
1475
|
+
key: "Backspace",
|
|
1476
|
+
run: ({ state: e, dispatch: t }) => {
|
|
1477
|
+
let n = _(e), r = null, i = e.changeByRange((t) => {
|
|
1478
|
+
let i = t.from, { doc: a } = e;
|
|
1479
|
+
if (t.empty && Y.isActiveAt(e, t.from)) {
|
|
1480
|
+
let t = a.lineAt(i), r = St(Ot(n, i), a);
|
|
1481
|
+
if (r.length) {
|
|
1482
|
+
let n = r[r.length - 1], a = n.to - n.spaceAfter.length + +!!n.spaceAfter;
|
|
1483
|
+
if (i - t.from > a && !/\S/.test(t.text.slice(a, i - t.from))) return {
|
|
1484
|
+
range: o.cursor(t.from + a),
|
|
1485
|
+
changes: {
|
|
1486
|
+
from: t.from + a,
|
|
1487
|
+
to: i
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
if (i - t.from == a && (n.item && t.from <= n.item.from || /^[\s>]*$/.test(t.text.slice(0, n.to)))) {
|
|
1491
|
+
let r = t.from + n.from;
|
|
1492
|
+
if (n.item && n.node.from < n.item.from && /\S/.test(t.text.slice(n.from, n.to))) {
|
|
1493
|
+
let i = n.blank(m(t.text, 4, n.to) - m(t.text, 4, n.from));
|
|
1494
|
+
return r == t.from && (i = Q(i, e)), {
|
|
1495
|
+
range: o.cursor(r + i.length),
|
|
1496
|
+
changes: {
|
|
1497
|
+
from: r,
|
|
1498
|
+
to: t.from + n.to,
|
|
1499
|
+
insert: i
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
if (r < i) return {
|
|
1504
|
+
range: o.cursor(r),
|
|
1505
|
+
changes: {
|
|
1506
|
+
from: r,
|
|
1507
|
+
to: i
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
return r = { range: t };
|
|
1514
|
+
});
|
|
1515
|
+
return !r && (t(e.update(i, {
|
|
1516
|
+
scrollIntoView: !0,
|
|
1517
|
+
userEvent: "delete"
|
|
1518
|
+
})), !0);
|
|
1519
|
+
}
|
|
1520
|
+
}], At = /*@__PURE__*/ oe({ matchClosingTags: !1 });
|
|
1521
|
+
function jt(e = {}) {
|
|
1522
|
+
let { codeLanguages: t, defaultCodeLanguage: n, addKeymap: r = !0, base: { parser: a } = bt, completeHTMLTags: o = !0, pasteURLAsLink: s = !0, htmlTagLanguage: c = At } = e;
|
|
1523
|
+
if (!(a instanceof je)) throw RangeError("Base parser provided to `markdown` should be a Markdown parser");
|
|
1524
|
+
let l = e.extensions ? [e.extensions] : [], u = [c.support, yt], d;
|
|
1525
|
+
s && u.push(Ft), n instanceof f ? (u.push(n.support), d = n.language) : n && (d = n);
|
|
1526
|
+
let p = t || d ? xt(t, d) : void 0;
|
|
1527
|
+
l.push(Ke({
|
|
1528
|
+
codeParser: p,
|
|
1529
|
+
htmlParser: c.language.parser
|
|
1530
|
+
})), r && u.push(ee.high(i.of(kt)));
|
|
1531
|
+
let m = J(a.configure(l));
|
|
1532
|
+
return o && u.push(m.data.of({ autocomplete: Mt })), new f(m, u);
|
|
1533
|
+
}
|
|
1534
|
+
function Mt(e) {
|
|
1535
|
+
let { state: t, pos: n } = e, r = /<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n - 25, n));
|
|
1536
|
+
if (!r) return null;
|
|
1537
|
+
let i = _(t).resolveInner(n, -1);
|
|
1538
|
+
for (; i && !i.type.isTop;) {
|
|
1539
|
+
if (i.name == "CodeBlock" || i.name == "FencedCode" || i.name == "ProcessingInstructionBlock" || i.name == "CommentBlock" || i.name == "Link" || i.name == "Image") return null;
|
|
1540
|
+
i = i.parent;
|
|
1541
|
+
}
|
|
1542
|
+
return {
|
|
1543
|
+
from: n - r[0].length,
|
|
1544
|
+
to: n,
|
|
1545
|
+
options: Nt(),
|
|
1546
|
+
validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
var $ = null;
|
|
1550
|
+
function Nt() {
|
|
1551
|
+
if ($) return $;
|
|
1552
|
+
let t = se(new ce(e.create({ extensions: At }), 0, !0));
|
|
1553
|
+
return $ = t ? t.options : [];
|
|
1554
|
+
}
|
|
1555
|
+
var Pt = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i, Ft = /*@__PURE__*/ a.domEventHandlers({ paste: (e, t) => {
|
|
1556
|
+
let { main: n } = t.state.selection;
|
|
1557
|
+
if (n.empty) return !1;
|
|
1558
|
+
let r = e.clipboardData?.getData("text/plain");
|
|
1559
|
+
if (!r || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r) || (/^www\./.test(r) && (r = "https://" + r), !Y.isActiveAt(t.state, n.from, 1))) return !1;
|
|
1560
|
+
let i = _(t.state), a = !1;
|
|
1561
|
+
return i.iterate({
|
|
1562
|
+
from: n.from,
|
|
1563
|
+
to: n.to,
|
|
1564
|
+
enter: (e) => {
|
|
1565
|
+
(e.from > n.from || Pt.test(e.name)) && (a = !0);
|
|
1566
|
+
},
|
|
1567
|
+
leave: (e) => {
|
|
1568
|
+
e.to < n.to && (a = !0);
|
|
1569
|
+
}
|
|
1570
|
+
}), !a && (t.dispatch({
|
|
1571
|
+
changes: [{
|
|
1572
|
+
from: n.from,
|
|
1573
|
+
insert: "["
|
|
1574
|
+
}, {
|
|
1575
|
+
from: n.to,
|
|
1576
|
+
insert: `](${r})`
|
|
1577
|
+
}],
|
|
1578
|
+
userEvent: "input.paste",
|
|
1579
|
+
scrollIntoView: !0
|
|
1580
|
+
}), !0);
|
|
1581
|
+
} });
|
|
1582
|
+
//#endregion
|
|
1583
|
+
export { jt as markdown };
|