@aiao/code-editor 0.0.8 → 0.0.10

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.
Files changed (121) hide show
  1. package/dist/index.js +101 -17
  2. package/package.json +4 -1
  3. package/dist/apl-B2DGVGxc.js +0 -76
  4. package/dist/asciiarmor-2LVJmxlE.js +0 -34
  5. package/dist/asn1-jKiBa2Ya.js +0 -95
  6. package/dist/asterisk-DS281yxp.js +0 -271
  7. package/dist/brainfuck-C_p9pTT8.js +0 -34
  8. package/dist/clike-BMALKCNj.js +0 -620
  9. package/dist/clojure-CCKyeQKf.js +0 -800
  10. package/dist/cmake-CuaCgAKt.js +0 -28
  11. package/dist/cobol-BlTKFDRj.js +0 -72
  12. package/dist/coffeescript-BVCvwO8I.js +0 -179
  13. package/dist/commonlisp-D_kxz07b.js +0 -75
  14. package/dist/crystal-D309uH6_.js +0 -217
  15. package/dist/css-BkF-NPzE.js +0 -1553
  16. package/dist/cypher-BMq4Fwjl.js +0 -68
  17. package/dist/d-BZcgY6La.js +0 -127
  18. package/dist/diff-Cg9d_RX2.js +0 -18
  19. package/dist/dockerfile-DFX8bq9N.js +0 -194
  20. package/dist/dtd-CtLokQ-U.js +0 -84
  21. package/dist/dylan-QYeExnWK.js +0 -234
  22. package/dist/ebnf-DUPDuY4r.js +0 -78
  23. package/dist/ecl-CiXN-g_D.js +0 -121
  24. package/dist/eiffel-yQhjl4T1.js +0 -110
  25. package/dist/elm-CNT9vbN0.js +0 -108
  26. package/dist/erlang-CFOYdy9e.js +0 -487
  27. package/dist/factor-Clf6BoVk.js +0 -65
  28. package/dist/fcl-CPC2WYrI.js +0 -103
  29. package/dist/forth-BmxRyE9S.js +0 -60
  30. package/dist/fortran-9bvPyrOW.js +0 -442
  31. package/dist/gas-cpmYfFX2.js +0 -183
  32. package/dist/gherkin-CJuwpceU.js +0 -34
  33. package/dist/groovy-DZeT_VM-.js +0 -146
  34. package/dist/haskell-CxiO_7JL.js +0 -375
  35. package/dist/haxe-70NVW1pR.js +0 -359
  36. package/dist/http-D9LttvKF.js +0 -44
  37. package/dist/idl-B6TRFYjl.js +0 -947
  38. package/dist/index-BMiCCEB1.js +0 -309
  39. package/dist/index-BNuasEBW.js +0 -94
  40. package/dist/index-Bg1KDWyt.js +0 -290
  41. package/dist/index-BuVm7ZG6.js +0 -1305
  42. package/dist/index-BvS1cnHq.js +0 -613
  43. package/dist/index-C44L0DmY.js +0 -138
  44. package/dist/index-C71CZfUx.js +0 -247
  45. package/dist/index-CQ6JWNwi.js +0 -566
  46. package/dist/index-CpRVx97-.js +0 -342
  47. package/dist/index-CqvQj6d-.js +0 -270
  48. package/dist/index-CrbQBmWq.js +0 -157
  49. package/dist/index-CzovO10m.js +0 -302
  50. package/dist/index-D0BZOY-S.js +0 -101
  51. package/dist/index-D0svJS59.js +0 -555
  52. package/dist/index-D93XVMi1.js +0 -136
  53. package/dist/index-DEB5VK0f.js +0 -252
  54. package/dist/index-DIaXGPFp.js +0 -12936
  55. package/dist/index-Dp8osI_J.js +0 -960
  56. package/dist/index-Ds4AioqO.js +0 -1918
  57. package/dist/index-Dy-OpkyQ.js +0 -76
  58. package/dist/index-Dyi9rNIT.js +0 -391
  59. package/dist/index-ZJkjD9tT.js +0 -74
  60. package/dist/index-qH2lMs0G.js +0 -945
  61. package/dist/index-srIksFxX.js +0 -59
  62. package/dist/javascript-DOuB9oqA.js +0 -691
  63. package/dist/julia-DpvXAuO6.js +0 -241
  64. package/dist/livescript-CanGTf8u.js +0 -272
  65. package/dist/lua-XplVlWi_.js +0 -217
  66. package/dist/mathematica-jaRHnSxC.js +0 -35
  67. package/dist/mbox-BctzC1hL.js +0 -76
  68. package/dist/mirc-CFBPAOaF.js +0 -72
  69. package/dist/mllike-BSnXJBGA.js +0 -272
  70. package/dist/modelica-vUgVs--1.js +0 -93
  71. package/dist/mscgen-Cpl0NYLN.js +0 -104
  72. package/dist/mumps-CQoS1kWX.js +0 -25
  73. package/dist/nginx-zDPm3Z74.js +0 -89
  74. package/dist/nsis-BCLyjY7m.js +0 -62
  75. package/dist/ntriples-CsNjv2QF.js +0 -79
  76. package/dist/octave-C8PmmSRH.js +0 -143
  77. package/dist/oz-Ce8aN8oE.js +0 -151
  78. package/dist/pascal-De0D6mP7.js +0 -77
  79. package/dist/perl-B4bSCe1C.js +0 -915
  80. package/dist/pig-D24Z8EXi.js +0 -54
  81. package/dist/powershell-DkYVfTzP.js +0 -249
  82. package/dist/properties-Dn9wna3M.js +0 -26
  83. package/dist/protobuf-BPIjwpzm.js +0 -49
  84. package/dist/pug-TGXr6c5j.js +0 -248
  85. package/dist/puppet-nyd4dhjf.js +0 -45
  86. package/dist/python-BkR3uSy8.js +0 -313
  87. package/dist/q-DyHZGnqm.js +0 -86
  88. package/dist/r-LKEuhEGI.js +0 -104
  89. package/dist/rpm-IznJm2Xc.js +0 -57
  90. package/dist/ruby-CcYfvIk6.js +0 -228
  91. package/dist/sas-7E8yHoCW.js +0 -105
  92. package/dist/scheme-DjibxsNh.js +0 -124
  93. package/dist/shell-C0C2sNA_.js +0 -182
  94. package/dist/sieve-Bwz7vjP5.js +0 -72
  95. package/dist/simple-mode-mNVtnu0l.js +0 -89
  96. package/dist/smalltalk-Bhddl2pB.js +0 -48
  97. package/dist/solr-BNlsLglM.js +0 -41
  98. package/dist/sparql-FarWu_Gb.js +0 -197
  99. package/dist/spreadsheet-C-cy4P5N.js +0 -49
  100. package/dist/sql-CfG5lQ3l.js +0 -282
  101. package/dist/stex-Du4h4KAU.js +0 -129
  102. package/dist/stylus-CAdqWld3.js +0 -250
  103. package/dist/swift-DSxqR9R6.js +0 -230
  104. package/dist/tcl-xfoLljhY.js +0 -81
  105. package/dist/textile-D1AWE-pc.js +0 -295
  106. package/dist/tiddlywiki-5wqsXtSk.js +0 -155
  107. package/dist/tiki-__Kn3CeS.js +0 -181
  108. package/dist/toml-DWAmxCjl.js +0 -58
  109. package/dist/troff-D2UO-fKf.js +0 -35
  110. package/dist/ttcn-Bsa4sfRm.js +0 -123
  111. package/dist/ttcn-cfg-Bac_acMi.js +0 -88
  112. package/dist/turtle-xwJUxoPV.js +0 -80
  113. package/dist/vb-c2kQGd6-.js +0 -74
  114. package/dist/vbscript-1f_Dhg5H.js +0 -324
  115. package/dist/velocity-DJd0pTTC.js +0 -96
  116. package/dist/verilog-CiS1jyi5.js +0 -262
  117. package/dist/vhdl-T9HkrbI2.js +0 -106
  118. package/dist/webidl-CjfDENEo.js +0 -155
  119. package/dist/xquery-Ct6lEb4B.js +0 -422
  120. package/dist/yacas-C0absKBh.js +0 -73
  121. package/dist/z80-Pki2zAjW.js +0 -61
@@ -1,1918 +0,0 @@
1
- import { P as st, j as Q, k as v, T as it, l as Ee, s as Ie, p as ot, t as m, m as H, E as at, n as lt, L as fe, o as ht, q as ft, r as ut, u as dt, b as X, e as P, v as z, w as pt, f as Me, i as ct, x as mt, y as gt, z as ue, A as kt } from "./index-DIaXGPFp.js";
2
- import { C as Lt } from "./index-Dyi9rNIT.js";
3
- import { html as bt, htmlCompletionSource as wt } from "./index-qH2lMs0G.js";
4
- class U {
5
- static create(e, r, n, s, i) {
6
- let o = s + (s << 8) + e + (r << 4) | 0;
7
- return new U(e, r, n, o, i, [], []);
8
- }
9
- constructor(e, r, n, s, i, o, a) {
10
- this.type = e, this.value = r, this.from = n, this.hash = s, this.end = i, this.children = o, this.positions = a, this.hashProp = [[v.contextHash, s]];
11
- }
12
- addChild(e, r) {
13
- e.prop(v.contextHash) != this.hash && (e = new H(e.type, e.children, e.positions, e.length, this.hashProp)), this.children.push(e), this.positions.push(r);
14
- }
15
- toTree(e, r = this.end) {
16
- let n = this.children.length - 1;
17
- return n >= 0 && (r = Math.max(r, this.positions[n] + this.children[n].length + this.from)), new H(e.types[this.type], this.children, this.positions, r - this.from).balance({
18
- makeTree: (s, i, o) => new H(Q.none, s, i, o, this.hashProp)
19
- });
20
- }
21
- }
22
- var u;
23
- (function(t) {
24
- t[t.Document = 1] = "Document", t[t.CodeBlock = 2] = "CodeBlock", t[t.FencedCode = 3] = "FencedCode", t[t.Blockquote = 4] = "Blockquote", t[t.HorizontalRule = 5] = "HorizontalRule", t[t.BulletList = 6] = "BulletList", t[t.OrderedList = 7] = "OrderedList", t[t.ListItem = 8] = "ListItem", t[t.ATXHeading1 = 9] = "ATXHeading1", t[t.ATXHeading2 = 10] = "ATXHeading2", t[t.ATXHeading3 = 11] = "ATXHeading3", t[t.ATXHeading4 = 12] = "ATXHeading4", t[t.ATXHeading5 = 13] = "ATXHeading5", t[t.ATXHeading6 = 14] = "ATXHeading6", t[t.SetextHeading1 = 15] = "SetextHeading1", t[t.SetextHeading2 = 16] = "SetextHeading2", t[t.HTMLBlock = 17] = "HTMLBlock", t[t.LinkReference = 18] = "LinkReference", t[t.Paragraph = 19] = "Paragraph", t[t.CommentBlock = 20] = "CommentBlock", t[t.ProcessingInstructionBlock = 21] = "ProcessingInstructionBlock", t[t.Escape = 22] = "Escape", t[t.Entity = 23] = "Entity", t[t.HardBreak = 24] = "HardBreak", t[t.Emphasis = 25] = "Emphasis", t[t.StrongEmphasis = 26] = "StrongEmphasis", t[t.Link = 27] = "Link", t[t.Image = 28] = "Image", t[t.InlineCode = 29] = "InlineCode", t[t.HTMLTag = 30] = "HTMLTag", t[t.Comment = 31] = "Comment", t[t.ProcessingInstruction = 32] = "ProcessingInstruction", t[t.Autolink = 33] = "Autolink", t[t.HeaderMark = 34] = "HeaderMark", t[t.QuoteMark = 35] = "QuoteMark", t[t.ListMark = 36] = "ListMark", t[t.LinkMark = 37] = "LinkMark", t[t.EmphasisMark = 38] = "EmphasisMark", t[t.CodeMark = 39] = "CodeMark", t[t.CodeText = 40] = "CodeText", t[t.CodeInfo = 41] = "CodeInfo", t[t.LinkTitle = 42] = "LinkTitle", t[t.LinkLabel = 43] = "LinkLabel", t[t.URL = 44] = "URL";
25
- })(u || (u = {}));
26
- class St {
27
- /**
28
- @internal
29
- */
30
- constructor(e, r) {
31
- this.start = e, this.content = r, this.marks = [], this.parsers = [];
32
- }
33
- }
34
- class Ct {
35
- constructor() {
36
- this.text = "", this.baseIndent = 0, this.basePos = 0, this.depth = 0, this.markers = [], this.pos = 0, this.indent = 0, this.next = -1;
37
- }
38
- /**
39
- @internal
40
- */
41
- forward() {
42
- this.basePos > this.pos && this.forwardInner();
43
- }
44
- /**
45
- @internal
46
- */
47
- forwardInner() {
48
- let e = this.skipSpace(this.basePos);
49
- this.indent = this.countIndent(e, this.pos, this.indent), this.pos = e, this.next = e == this.text.length ? -1 : this.text.charCodeAt(e);
50
- }
51
- /**
52
- Skip whitespace after the given position, return the position of
53
- the next non-space character or the end of the line if there's
54
- only space after `from`.
55
- */
56
- skipSpace(e) {
57
- return O(this.text, e);
58
- }
59
- /**
60
- @internal
61
- */
62
- reset(e) {
63
- for (this.text = e, this.baseIndent = this.basePos = this.pos = this.indent = 0, this.forwardInner(), this.depth = 1; this.markers.length; )
64
- this.markers.pop();
65
- }
66
- /**
67
- Move the line's base position forward to the given position.
68
- This should only be called by composite [block
69
- parsers](#BlockParser.parse) or [markup skipping
70
- functions](#NodeSpec.composite).
71
- */
72
- moveBase(e) {
73
- this.basePos = e, this.baseIndent = this.countIndent(e, this.pos, this.indent);
74
- }
75
- /**
76
- Move the line's base position forward to the given _column_.
77
- */
78
- moveBaseColumn(e) {
79
- this.baseIndent = e, this.basePos = this.findColumn(e);
80
- }
81
- /**
82
- Store a composite-block-level marker. Should be called from
83
- [markup skipping functions](#NodeSpec.composite) when they
84
- consume any non-whitespace characters.
85
- */
86
- addMarker(e) {
87
- this.markers.push(e);
88
- }
89
- /**
90
- Find the column position at `to`, optionally starting at a given
91
- position and column.
92
- */
93
- countIndent(e, r = 0, n = 0) {
94
- for (let s = r; s < e; s++)
95
- n += this.text.charCodeAt(s) == 9 ? 4 - n % 4 : 1;
96
- return n;
97
- }
98
- /**
99
- Find the position corresponding to the given column.
100
- */
101
- findColumn(e) {
102
- let r = 0;
103
- for (let n = 0; r < this.text.length && n < e; r++)
104
- n += this.text.charCodeAt(r) == 9 ? 4 - n % 4 : 1;
105
- return r;
106
- }
107
- /**
108
- @internal
109
- */
110
- scrub() {
111
- if (!this.baseIndent)
112
- return this.text;
113
- let e = "";
114
- for (let r = 0; r < this.basePos; r++)
115
- e += " ";
116
- return e + this.text.slice(this.basePos);
117
- }
118
- }
119
- function de(t, e, r) {
120
- if (r.pos == r.text.length || t != e.block && r.indent >= e.stack[r.depth + 1].value + r.baseIndent)
121
- return !0;
122
- if (r.indent >= r.baseIndent + 4)
123
- return !1;
124
- let n = (t.type == u.OrderedList ? oe : ie)(r, e, !1);
125
- return n > 0 && (t.type != u.BulletList || se(r, e, !1) < 0) && r.text.charCodeAt(r.pos + n - 1) == t.value;
126
- }
127
- const He = {
128
- [u.Blockquote](t, e, r) {
129
- return r.next != 62 ? !1 : (r.markers.push(k(u.QuoteMark, e.lineStart + r.pos, e.lineStart + r.pos + 1)), r.moveBase(r.pos + (A(r.text.charCodeAt(r.pos + 1)) ? 2 : 1)), t.end = e.lineStart + r.text.length, !0);
130
- },
131
- [u.ListItem](t, e, r) {
132
- return r.indent < r.baseIndent + t.value && r.next > -1 ? !1 : (r.moveBaseColumn(r.baseIndent + t.value), !0);
133
- },
134
- [u.OrderedList]: de,
135
- [u.BulletList]: de,
136
- [u.Document]() {
137
- return !0;
138
- }
139
- };
140
- function A(t) {
141
- return t == 32 || t == 9 || t == 10 || t == 13;
142
- }
143
- function O(t, e = 0) {
144
- for (; e < t.length && A(t.charCodeAt(e)); )
145
- e++;
146
- return e;
147
- }
148
- function pe(t, e, r) {
149
- for (; e > r && A(t.charCodeAt(e - 1)); )
150
- e--;
151
- return e;
152
- }
153
- function Pe(t) {
154
- if (t.next != 96 && t.next != 126)
155
- return -1;
156
- let e = t.pos + 1;
157
- for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
158
- e++;
159
- if (e < t.pos + 3)
160
- return -1;
161
- if (t.next == 96) {
162
- for (let r = e; r < t.text.length; r++)
163
- if (t.text.charCodeAt(r) == 96)
164
- return -1;
165
- }
166
- return e;
167
- }
168
- function ve(t) {
169
- return t.next != 62 ? -1 : t.text.charCodeAt(t.pos + 1) == 32 ? 2 : 1;
170
- }
171
- function se(t, e, r) {
172
- if (t.next != 42 && t.next != 45 && t.next != 95)
173
- return -1;
174
- let n = 1;
175
- for (let s = t.pos + 1; s < t.text.length; s++) {
176
- let i = t.text.charCodeAt(s);
177
- if (i == t.next)
178
- n++;
179
- else if (!A(i))
180
- return -1;
181
- }
182
- return r && t.next == 45 && Re(t) > -1 && t.depth == e.stack.length && e.parser.leafBlockParsers.indexOf(De.SetextHeading) > -1 || n < 3 ? -1 : 1;
183
- }
184
- function Ne(t, e) {
185
- for (let r = t.stack.length - 1; r >= 0; r--)
186
- if (t.stack[r].type == e)
187
- return !0;
188
- return !1;
189
- }
190
- function ie(t, e, r) {
191
- return (t.next == 45 || t.next == 43 || t.next == 42) && (t.pos == t.text.length - 1 || A(t.text.charCodeAt(t.pos + 1))) && (!r || Ne(e, u.BulletList) || t.skipSpace(t.pos + 2) < t.text.length) ? 1 : -1;
192
- }
193
- function oe(t, e, r) {
194
- let n = t.pos, s = t.next;
195
- for (; s >= 48 && s <= 57; ) {
196
- n++;
197
- if (n == t.text.length)
198
- return -1;
199
- s = t.text.charCodeAt(n);
200
- }
201
- return n == t.pos || n > t.pos + 9 || s != 46 && s != 41 || n < t.text.length - 1 && !A(t.text.charCodeAt(n + 1)) || r && !Ne(e, u.OrderedList) && (t.skipSpace(n + 1) == t.text.length || n > t.pos + 1 || t.next != 49) ? -1 : n + 1 - t.pos;
202
- }
203
- function ye(t) {
204
- if (t.next != 35)
205
- return -1;
206
- let e = t.pos + 1;
207
- for (; e < t.text.length && t.text.charCodeAt(e) == 35; )
208
- e++;
209
- if (e < t.text.length && t.text.charCodeAt(e) != 32)
210
- return -1;
211
- let r = e - t.pos;
212
- return r > 6 ? -1 : r;
213
- }
214
- function Re(t) {
215
- if (t.next != 45 && t.next != 61 || t.indent >= t.baseIndent + 4)
216
- return -1;
217
- let e = t.pos + 1;
218
- for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
219
- e++;
220
- let r = e;
221
- for (; e < t.text.length && A(t.text.charCodeAt(e)); )
222
- e++;
223
- return e == t.text.length ? r : -1;
224
- }
225
- const W = /^[ \t]*$/, Oe = /-->/, Te = /\?>/, ee = [
226
- [/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
227
- [/^\s*<!--/, Oe],
228
- [/^\s*<\?/, Te],
229
- [/^\s*<![A-Z]/, />/],
230
- [/^\s*<!\[CDATA\[/, /\]\]>/],
231
- [/^\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, W],
232
- [/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, W]
233
- ];
234
- function ze(t, e, r) {
235
- if (t.next != 60)
236
- return -1;
237
- let n = t.text.slice(t.pos);
238
- for (let s = 0, i = ee.length - (r ? 1 : 0); s < i; s++)
239
- if (ee[s][0].test(n))
240
- return s;
241
- return -1;
242
- }
243
- function ce(t, e) {
244
- let r = t.countIndent(e, t.pos, t.indent), n = t.countIndent(t.skipSpace(e), e, r);
245
- return n >= r + 5 ? r + 1 : n;
246
- }
247
- function x(t, e, r) {
248
- let n = t.length - 1;
249
- n >= 0 && t[n].to == e && t[n].type == u.CodeText ? t[n].to = r : t.push(k(u.CodeText, e, r));
250
- }
251
- const $ = {
252
- LinkReference: void 0,
253
- IndentedCode(t, e) {
254
- let r = e.baseIndent + 4;
255
- if (e.indent < r)
256
- return !1;
257
- let n = e.findColumn(r), s = t.lineStart + n, i = t.lineStart + e.text.length, o = [], a = [];
258
- for (x(o, s, i); t.nextLine() && e.depth >= t.stack.length; )
259
- if (e.pos == e.text.length) {
260
- x(a, t.lineStart - 1, t.lineStart);
261
- for (let l of e.markers)
262
- a.push(l);
263
- } else {
264
- if (e.indent < r)
265
- break;
266
- {
267
- if (a.length) {
268
- for (let h of a)
269
- h.type == u.CodeText ? x(o, h.from, h.to) : o.push(h);
270
- a = [];
271
- }
272
- x(o, t.lineStart - 1, t.lineStart);
273
- for (let h of e.markers)
274
- o.push(h);
275
- i = t.lineStart + e.text.length;
276
- let l = t.lineStart + e.findColumn(e.baseIndent + 4);
277
- l < i && x(o, l, i);
278
- }
279
- }
280
- return a.length && (a = a.filter((l) => l.type != u.CodeText), a.length && (e.markers = a.concat(e.markers))), t.addNode(t.buffer.writeElements(o, -s).finish(u.CodeBlock, i - s), s), !0;
281
- },
282
- FencedCode(t, e) {
283
- let r = Pe(e);
284
- if (r < 0)
285
- return !1;
286
- let n = t.lineStart + e.pos, s = e.next, i = r - e.pos, o = e.skipSpace(r), a = pe(e.text, e.text.length, o), l = [k(u.CodeMark, n, n + i)];
287
- o < a && l.push(k(u.CodeInfo, t.lineStart + o, t.lineStart + a));
288
- for (let h = !0, f = !0, p = !1; t.nextLine() && e.depth >= t.stack.length; h = !1) {
289
- let d = e.pos;
290
- if (e.indent - e.baseIndent < 4)
291
- for (; d < e.text.length && e.text.charCodeAt(d) == s; )
292
- d++;
293
- if (d - e.pos >= i && e.skipSpace(d) == e.text.length) {
294
- for (let c of e.markers)
295
- l.push(c);
296
- f && p && x(l, t.lineStart - 1, t.lineStart), l.push(k(u.CodeMark, t.lineStart + e.pos, t.lineStart + d)), t.nextLine();
297
- break;
298
- } else {
299
- p = !0, h || (x(l, t.lineStart - 1, t.lineStart), f = !1);
300
- for (let g of e.markers)
301
- l.push(g);
302
- let c = t.lineStart + e.basePos, L = t.lineStart + e.text.length;
303
- c < L && (x(l, c, L), f = !1);
304
- }
305
- }
306
- return t.addNode(t.buffer.writeElements(l, -n).finish(u.FencedCode, t.prevLineEnd() - n), n), !0;
307
- },
308
- Blockquote(t, e) {
309
- let r = ve(e);
310
- return r < 0 ? !1 : (t.startContext(u.Blockquote, e.pos), t.addNode(u.QuoteMark, t.lineStart + e.pos, t.lineStart + e.pos + 1), e.moveBase(e.pos + r), null);
311
- },
312
- HorizontalRule(t, e) {
313
- if (se(e, t, !1) < 0)
314
- return !1;
315
- let r = t.lineStart + e.pos;
316
- return t.nextLine(), t.addNode(u.HorizontalRule, r), !0;
317
- },
318
- BulletList(t, e) {
319
- let r = ie(e, t, !1);
320
- if (r < 0)
321
- return !1;
322
- t.block.type != u.BulletList && t.startContext(u.BulletList, e.basePos, e.next);
323
- let n = ce(e, e.pos + 1);
324
- return t.startContext(u.ListItem, e.basePos, n - e.baseIndent), t.addNode(u.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + r), e.moveBaseColumn(n), null;
325
- },
326
- OrderedList(t, e) {
327
- let r = oe(e, t, !1);
328
- if (r < 0)
329
- return !1;
330
- t.block.type != u.OrderedList && t.startContext(u.OrderedList, e.basePos, e.text.charCodeAt(e.pos + r - 1));
331
- let n = ce(e, e.pos + r);
332
- return t.startContext(u.ListItem, e.basePos, n - e.baseIndent), t.addNode(u.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + r), e.moveBaseColumn(n), null;
333
- },
334
- ATXHeading(t, e) {
335
- let r = ye(e);
336
- if (r < 0)
337
- return !1;
338
- let n = e.pos, s = t.lineStart + n, i = pe(e.text, e.text.length, n), o = i;
339
- for (; o > n && e.text.charCodeAt(o - 1) == e.next; )
340
- o--;
341
- (o == i || o == n || !A(e.text.charCodeAt(o - 1))) && (o = e.text.length);
342
- let a = t.buffer.write(u.HeaderMark, 0, r).writeElements(t.parser.parseInline(e.text.slice(n + r + 1, o), s + r + 1), -s);
343
- o < e.text.length && a.write(u.HeaderMark, o - n, i - n);
344
- let l = a.finish(u.ATXHeading1 - 1 + r, e.text.length - n);
345
- return t.nextLine(), t.addNode(l, s), !0;
346
- },
347
- HTMLBlock(t, e) {
348
- let r = ze(e, t, !1);
349
- if (r < 0)
350
- return !1;
351
- let n = t.lineStart + e.pos, s = ee[r][1], i = [], o = s != W;
352
- for (; !s.test(e.text) && t.nextLine(); ) {
353
- if (e.depth < t.stack.length) {
354
- o = !1;
355
- break;
356
- }
357
- for (let h of e.markers)
358
- i.push(h);
359
- }
360
- o && t.nextLine();
361
- let a = s == Oe ? u.CommentBlock : s == Te ? u.ProcessingInstructionBlock : u.HTMLBlock, l = t.prevLineEnd();
362
- return t.addNode(t.buffer.writeElements(i, -n).finish(a, l - n), n), !0;
363
- },
364
- SetextHeading: void 0
365
- // Specifies relative precedence for block-continue function
366
- };
367
- class At {
368
- constructor(e) {
369
- this.stage = 0, this.elts = [], this.pos = 0, this.start = e.start, this.advance(e.content);
370
- }
371
- nextLine(e, r, n) {
372
- if (this.stage == -1)
373
- return !1;
374
- let s = n.content + `
375
- ` + r.scrub(), i = this.advance(s);
376
- return i > -1 && i < s.length ? this.complete(e, n, i) : !1;
377
- }
378
- finish(e, r) {
379
- return (this.stage == 2 || this.stage == 3) && O(r.content, this.pos) == r.content.length ? this.complete(e, r, r.content.length) : !1;
380
- }
381
- complete(e, r, n) {
382
- return e.addLeafElement(r, k(u.LinkReference, this.start, this.start + n, this.elts)), !0;
383
- }
384
- nextStage(e) {
385
- return e ? (this.pos = e.to - this.start, this.elts.push(e), this.stage++, !0) : (e === !1 && (this.stage = -1), !1);
386
- }
387
- advance(e) {
388
- for (; ; ) {
389
- if (this.stage == -1)
390
- return -1;
391
- if (this.stage == 0) {
392
- if (!this.nextStage(Ze(e, this.pos, this.start, !0)))
393
- return -1;
394
- if (e.charCodeAt(this.pos) != 58)
395
- return this.stage = -1;
396
- this.elts.push(k(u.LinkMark, this.pos + this.start, this.pos + this.start + 1)), this.pos++;
397
- } else if (this.stage == 1) {
398
- if (!this.nextStage(qe(e, O(e, this.pos), this.start)))
399
- return -1;
400
- } else if (this.stage == 2) {
401
- let r = O(e, this.pos), n = 0;
402
- if (r > this.pos) {
403
- let s = Qe(e, r, this.start);
404
- if (s) {
405
- let i = V(e, s.to - this.start);
406
- i > 0 && (this.nextStage(s), n = i);
407
- }
408
- }
409
- return n || (n = V(e, this.pos)), n > 0 && n < e.length ? n : -1;
410
- } else
411
- return V(e, this.pos);
412
- }
413
- }
414
- }
415
- function V(t, e) {
416
- for (; e < t.length; e++) {
417
- let r = t.charCodeAt(e);
418
- if (r == 10)
419
- break;
420
- if (!A(r))
421
- return -1;
422
- }
423
- return e;
424
- }
425
- class xt {
426
- nextLine(e, r, n) {
427
- let s = r.depth < e.stack.length ? -1 : Re(r), i = r.next;
428
- if (s < 0)
429
- return !1;
430
- let o = k(u.HeaderMark, e.lineStart + r.pos, e.lineStart + s);
431
- return e.nextLine(), e.addLeafElement(n, k(i == 61 ? u.SetextHeading1 : u.SetextHeading2, n.start, e.prevLineEnd(), [
432
- ...e.parser.parseInline(n.content, n.start),
433
- o
434
- ])), !0;
435
- }
436
- finish() {
437
- return !1;
438
- }
439
- }
440
- const De = {
441
- LinkReference(t, e) {
442
- return e.content.charCodeAt(0) == 91 ? new At(e) : null;
443
- },
444
- SetextHeading() {
445
- return new xt();
446
- }
447
- }, Bt = [
448
- (t, e) => ye(e) >= 0,
449
- (t, e) => Pe(e) >= 0,
450
- (t, e) => ve(e) >= 0,
451
- (t, e) => ie(e, t, !0) >= 0,
452
- (t, e) => oe(e, t, !0) >= 0,
453
- (t, e) => se(e, t, !0) >= 0,
454
- (t, e) => ze(e, t, !0) >= 0
455
- ], Et = { text: "", end: 0 };
456
- class It {
457
- /**
458
- @internal
459
- */
460
- constructor(e, r, n, s) {
461
- this.parser = e, this.input = r, this.ranges = s, this.line = new Ct(), this.atEnd = !1, this.reusePlaceholders = /* @__PURE__ */ new Map(), this.stoppedAt = null, this.rangeI = 0, this.to = s[s.length - 1].to, this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = s[0].from, this.block = U.create(u.Document, 0, this.lineStart, 0, 0), this.stack = [this.block], this.fragments = n.length ? new Pt(n, r) : null, this.readLine();
462
- }
463
- get parsedPos() {
464
- return this.absoluteLineStart;
465
- }
466
- advance() {
467
- if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt)
468
- return this.finish();
469
- let { line: e } = this;
470
- for (; ; ) {
471
- for (let n = 0; ; ) {
472
- let s = e.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
473
- for (; n < e.markers.length && (!s || e.markers[n].from < s.end); ) {
474
- let i = e.markers[n++];
475
- this.addNode(i.type, i.from, i.to);
476
- }
477
- if (!s)
478
- break;
479
- this.finishContext();
480
- }
481
- if (e.pos < e.text.length)
482
- break;
483
- if (!this.nextLine())
484
- return this.finish();
485
- }
486
- if (this.fragments && this.reuseFragment(e.basePos))
487
- return null;
488
- e: for (; ; ) {
489
- for (let n of this.parser.blockParsers)
490
- if (n) {
491
- let s = n(this, e);
492
- if (s != !1) {
493
- if (s == !0)
494
- return null;
495
- e.forward();
496
- continue e;
497
- }
498
- }
499
- break;
500
- }
501
- let r = new St(this.lineStart + e.pos, e.text.slice(e.pos));
502
- for (let n of this.parser.leafBlockParsers)
503
- if (n) {
504
- let s = n(this, r);
505
- s && r.parsers.push(s);
506
- }
507
- e: for (; this.nextLine() && e.pos != e.text.length; ) {
508
- if (e.indent < e.baseIndent + 4) {
509
- for (let n of this.parser.endLeafBlock)
510
- if (n(this, e, r))
511
- break e;
512
- }
513
- for (let n of r.parsers)
514
- if (n.nextLine(this, e, r))
515
- return null;
516
- r.content += `
517
- ` + e.scrub();
518
- for (let n of e.markers)
519
- r.marks.push(n);
520
- }
521
- return this.finishLeaf(r), null;
522
- }
523
- stopAt(e) {
524
- if (this.stoppedAt != null && this.stoppedAt < e)
525
- throw new RangeError("Can't move stoppedAt forward");
526
- this.stoppedAt = e;
527
- }
528
- reuseFragment(e) {
529
- if (!this.fragments.moveTo(this.absoluteLineStart + e, this.absoluteLineStart) || !this.fragments.matches(this.block.hash))
530
- return !1;
531
- let r = this.fragments.takeNodes(this);
532
- return r ? (this.absoluteLineStart += r, this.lineStart = Ve(this.absoluteLineStart, this.ranges), this.moveRangeI(), this.absoluteLineStart < this.to ? (this.lineStart++, this.absoluteLineStart++, this.readLine()) : (this.atEnd = !0, this.readLine()), !0) : !1;
533
- }
534
- /**
535
- The number of parent blocks surrounding the current block.
536
- */
537
- get depth() {
538
- return this.stack.length;
539
- }
540
- /**
541
- Get the type of the parent block at the given depth. When no
542
- depth is passed, return the type of the innermost parent.
543
- */
544
- parentType(e = this.depth - 1) {
545
- return this.parser.nodeSet.types[this.stack[e].type];
546
- }
547
- /**
548
- Move to the next input line. This should only be called by
549
- (non-composite) [block parsers](#BlockParser.parse) that consume
550
- the line directly, or leaf block parser
551
- [`nextLine`](#LeafBlockParser.nextLine) methods when they
552
- consume the current line (and return true).
553
- */
554
- nextLine() {
555
- 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);
556
- }
557
- /**
558
- Retrieve the text of the line after the current one, without
559
- actually moving the context's current line forward.
560
- */
561
- peekLine() {
562
- return this.scanLine(this.absoluteLineEnd + 1).text;
563
- }
564
- moveRangeI() {
565
- for (; this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to; )
566
- this.rangeI++, this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
567
- }
568
- /**
569
- @internal
570
- Collect the text for the next line.
571
- */
572
- scanLine(e) {
573
- let r = Et;
574
- if (r.end = e, e >= this.to)
575
- r.text = "";
576
- else if (r.text = this.lineChunkAt(e), r.end += r.text.length, this.ranges.length > 1) {
577
- let n = this.absoluteLineStart, s = this.rangeI;
578
- for (; this.ranges[s].to < r.end; ) {
579
- s++;
580
- let i = this.ranges[s].from, o = this.lineChunkAt(i);
581
- r.end = i + o.length, r.text = r.text.slice(0, this.ranges[s - 1].to - n) + o, n = r.end - r.text.length;
582
- }
583
- }
584
- return r;
585
- }
586
- /**
587
- @internal
588
- Populate this.line with the content of the next line. Skip
589
- leading characters covered by composite blocks.
590
- */
591
- readLine() {
592
- let { line: e } = this, { text: r, end: n } = this.scanLine(this.absoluteLineStart);
593
- for (this.absoluteLineEnd = n, e.reset(r); e.depth < this.stack.length; e.depth++) {
594
- let s = this.stack[e.depth], i = this.parser.skipContextMarkup[s.type];
595
- if (!i)
596
- throw new Error("Unhandled block context " + u[s.type]);
597
- let o = this.line.markers.length;
598
- if (!i(s, this, e)) {
599
- this.line.markers.length > o && (s.end = this.line.markers[this.line.markers.length - 1].to), e.forward();
600
- break;
601
- }
602
- e.forward();
603
- }
604
- }
605
- lineChunkAt(e) {
606
- let r = this.input.chunk(e), n;
607
- if (this.input.lineChunks)
608
- n = r == `
609
- ` ? "" : r;
610
- else {
611
- let s = r.indexOf(`
612
- `);
613
- n = s < 0 ? r : r.slice(0, s);
614
- }
615
- return e + n.length > this.to ? n.slice(0, this.to - e) : n;
616
- }
617
- /**
618
- The end position of the previous line.
619
- */
620
- prevLineEnd() {
621
- return this.atEnd ? this.lineStart : this.lineStart - 1;
622
- }
623
- /**
624
- @internal
625
- */
626
- startContext(e, r, n = 0) {
627
- this.block = U.create(e, n, this.lineStart + r, this.block.hash, this.lineStart + this.line.text.length), this.stack.push(this.block);
628
- }
629
- /**
630
- Start a composite block. Should only be called from [block
631
- parser functions](#BlockParser.parse) that return null.
632
- */
633
- startComposite(e, r, n = 0) {
634
- this.startContext(this.parser.getNodeType(e), r, n);
635
- }
636
- /**
637
- @internal
638
- */
639
- addNode(e, r, n) {
640
- typeof e == "number" && (e = new H(this.parser.nodeSet.types[e], N, N, (n ?? this.prevLineEnd()) - r)), this.block.addChild(e, r - this.block.from);
641
- }
642
- /**
643
- Add a block element. Can be called by [block
644
- parsers](#BlockParser.parse).
645
- */
646
- addElement(e) {
647
- this.block.addChild(e.toTree(this.parser.nodeSet), e.from - this.block.from);
648
- }
649
- /**
650
- Add a block element from a [leaf parser](#LeafBlockParser). This
651
- makes sure any extra composite block markup (such as blockquote
652
- markers) inside the block are also added to the syntax tree.
653
- */
654
- addLeafElement(e, r) {
655
- this.addNode(this.buffer.writeElements(re(r.children, e.marks), -r.from).finish(r.type, r.to - r.from), r.from);
656
- }
657
- /**
658
- @internal
659
- */
660
- finishContext() {
661
- let e = this.stack.pop(), r = this.stack[this.stack.length - 1];
662
- r.addChild(e.toTree(this.parser.nodeSet), e.from - r.from), this.block = r;
663
- }
664
- finish() {
665
- for (; this.stack.length > 1; )
666
- this.finishContext();
667
- return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
668
- }
669
- addGaps(e) {
670
- return this.ranges.length > 1 ? Fe(this.ranges, 0, e.topNode, this.ranges[0].from, this.reusePlaceholders) : e;
671
- }
672
- /**
673
- @internal
674
- */
675
- finishLeaf(e) {
676
- for (let n of e.parsers)
677
- if (n.finish(this, e))
678
- return;
679
- let r = re(this.parser.parseInline(e.content, e.start), e.marks);
680
- this.addNode(this.buffer.writeElements(r, -e.start).finish(u.Paragraph, e.content.length), e.start);
681
- }
682
- elt(e, r, n, s) {
683
- return typeof e == "string" ? k(this.parser.getNodeType(e), r, n, s) : new je(e, r);
684
- }
685
- /**
686
- @internal
687
- */
688
- get buffer() {
689
- return new $e(this.parser.nodeSet);
690
- }
691
- }
692
- function Fe(t, e, r, n, s) {
693
- let i = t[e].to, o = [], a = [], l = r.from + n;
694
- function h(f, p) {
695
- for (; p ? f >= i : f > i; ) {
696
- let d = t[e + 1].from - i;
697
- n += d, f += d, e++, i = t[e].to;
698
- }
699
- }
700
- for (let f = r.firstChild; f; f = f.nextSibling) {
701
- h(f.from + n, !0);
702
- let p = f.from + n, d, c = s.get(f.tree);
703
- c ? d = c : f.to + n > i ? (d = Fe(t, e, f, n, s), h(f.to + n, !1)) : d = f.toTree(), o.push(d), a.push(p - l);
704
- }
705
- return h(r.to + n, !1), new H(r.type, o, a, r.to + n - l, r.tree ? r.tree.propValues : void 0);
706
- }
707
- class Z extends st {
708
- /**
709
- @internal
710
- */
711
- constructor(e, r, n, s, i, o, a, l, h) {
712
- super(), this.nodeSet = e, this.blockParsers = r, this.leafBlockParsers = n, this.blockNames = s, this.endLeafBlock = i, this.skipContextMarkup = o, this.inlineParsers = a, this.inlineNames = l, this.wrappers = h, this.nodeTypes = /* @__PURE__ */ Object.create(null);
713
- for (let f of e.types)
714
- this.nodeTypes[f.name] = f.id;
715
- }
716
- createParse(e, r, n) {
717
- let s = new It(this, e, r, n);
718
- for (let i of this.wrappers)
719
- s = i(s, e, r, n);
720
- return s;
721
- }
722
- /**
723
- Reconfigure the parser.
724
- */
725
- configure(e) {
726
- let r = te(e);
727
- if (!r)
728
- return this;
729
- let { nodeSet: n, skipContextMarkup: s } = this, i = this.blockParsers.slice(), o = this.leafBlockParsers.slice(), a = this.blockNames.slice(), l = this.inlineParsers.slice(), h = this.inlineNames.slice(), f = this.endLeafBlock.slice(), p = this.wrappers;
730
- if (R(r.defineNodes)) {
731
- s = Object.assign({}, s);
732
- let d = n.types.slice(), c;
733
- for (let L of r.defineNodes) {
734
- let { name: g, block: B, composite: w, style: S } = typeof L == "string" ? { name: L } : L;
735
- if (d.some((I) => I.name == g))
736
- continue;
737
- w && (s[d.length] = (I, y, nt) => w(y, nt, I.value));
738
- let b = d.length, E = w ? ["Block", "BlockContext"] : B ? b >= u.ATXHeading1 && b <= u.SetextHeading2 ? ["Block", "LeafBlock", "Heading"] : ["Block", "LeafBlock"] : void 0;
739
- d.push(Q.define({
740
- id: b,
741
- name: g,
742
- props: E && [[v.group, E]]
743
- })), S && (c || (c = {}), Array.isArray(S) || S instanceof it ? c[g] = S : Object.assign(c, S));
744
- }
745
- n = new Ee(d), c && (n = n.extend(Ie(c)));
746
- }
747
- if (R(r.props) && (n = n.extend(...r.props)), R(r.remove))
748
- for (let d of r.remove) {
749
- let c = this.blockNames.indexOf(d), L = this.inlineNames.indexOf(d);
750
- c > -1 && (i[c] = o[c] = void 0), L > -1 && (l[L] = void 0);
751
- }
752
- if (R(r.parseBlock))
753
- for (let d of r.parseBlock) {
754
- let c = a.indexOf(d.name);
755
- if (c > -1)
756
- i[c] = d.parse, o[c] = d.leaf;
757
- else {
758
- let L = d.before ? j(a, d.before) : d.after ? j(a, d.after) + 1 : a.length - 1;
759
- i.splice(L, 0, d.parse), o.splice(L, 0, d.leaf), a.splice(L, 0, d.name);
760
- }
761
- d.endLeaf && f.push(d.endLeaf);
762
- }
763
- if (R(r.parseInline))
764
- for (let d of r.parseInline) {
765
- let c = h.indexOf(d.name);
766
- if (c > -1)
767
- l[c] = d.parse;
768
- else {
769
- let L = d.before ? j(h, d.before) : d.after ? j(h, d.after) + 1 : h.length - 1;
770
- l.splice(L, 0, d.parse), h.splice(L, 0, d.name);
771
- }
772
- }
773
- return r.wrap && (p = p.concat(r.wrap)), new Z(n, i, o, a, f, s, l, h, p);
774
- }
775
- /**
776
- @internal
777
- */
778
- getNodeType(e) {
779
- let r = this.nodeTypes[e];
780
- if (r == null)
781
- throw new RangeError(`Unknown node type '${e}'`);
782
- return r;
783
- }
784
- /**
785
- Parse the given piece of inline text at the given offset,
786
- returning an array of [`Element`](#Element) objects representing
787
- the inline content.
788
- */
789
- parseInline(e, r) {
790
- let n = new ae(this, e, r);
791
- e: for (let s = r; s < n.end; ) {
792
- let i = n.char(s);
793
- for (let o of this.inlineParsers)
794
- if (o) {
795
- let a = o(n, i, s);
796
- if (a >= 0) {
797
- s = a;
798
- continue e;
799
- }
800
- }
801
- s++;
802
- }
803
- return n.resolveMarkers(0);
804
- }
805
- }
806
- function R(t) {
807
- return t != null && t.length > 0;
808
- }
809
- function te(t) {
810
- if (!Array.isArray(t))
811
- return t;
812
- if (t.length == 0)
813
- return null;
814
- let e = te(t[0]);
815
- if (t.length == 1)
816
- return e;
817
- let r = te(t.slice(1));
818
- if (!r || !e)
819
- return e || r;
820
- let n = (o, a) => (o || N).concat(a || N), s = e.wrap, i = r.wrap;
821
- return {
822
- props: n(e.props, r.props),
823
- defineNodes: n(e.defineNodes, r.defineNodes),
824
- parseBlock: n(e.parseBlock, r.parseBlock),
825
- parseInline: n(e.parseInline, r.parseInline),
826
- remove: n(e.remove, r.remove),
827
- wrap: s ? i ? (o, a, l, h) => s(i(o, a, l, h), a, l, h) : s : i
828
- };
829
- }
830
- function j(t, e) {
831
- let r = t.indexOf(e);
832
- if (r < 0)
833
- throw new RangeError(`Position specified relative to unknown parser ${e}`);
834
- return r;
835
- }
836
- let Xe = [Q.none];
837
- for (let t = 1, e; e = u[t]; t++)
838
- Xe[t] = Q.define({
839
- id: t,
840
- name: e,
841
- props: t >= u.Escape ? [] : [[v.group, t in He ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
842
- top: e == "Document"
843
- });
844
- const N = [];
845
- class $e {
846
- constructor(e) {
847
- this.nodeSet = e, this.content = [], this.nodes = [];
848
- }
849
- write(e, r, n, s = 0) {
850
- return this.content.push(e, r, n, 4 + s * 4), this;
851
- }
852
- writeElements(e, r = 0) {
853
- for (let n of e)
854
- n.writeTo(this, r);
855
- return this;
856
- }
857
- finish(e, r) {
858
- return H.build({
859
- buffer: this.content,
860
- nodeSet: this.nodeSet,
861
- reused: this.nodes,
862
- topID: e,
863
- length: r
864
- });
865
- }
866
- }
867
- class D {
868
- /**
869
- @internal
870
- */
871
- constructor(e, r, n, s = N) {
872
- this.type = e, this.from = r, this.to = n, this.children = s;
873
- }
874
- /**
875
- @internal
876
- */
877
- writeTo(e, r) {
878
- let n = e.content.length;
879
- e.writeElements(this.children, r), e.content.push(this.type, this.from + r, this.to + r, e.content.length + 4 - n);
880
- }
881
- /**
882
- @internal
883
- */
884
- toTree(e) {
885
- return new $e(e).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
886
- }
887
- }
888
- class je {
889
- constructor(e, r) {
890
- this.tree = e, this.from = r;
891
- }
892
- get to() {
893
- return this.from + this.tree.length;
894
- }
895
- get type() {
896
- return this.tree.type.id;
897
- }
898
- get children() {
899
- return N;
900
- }
901
- writeTo(e, r) {
902
- e.nodes.push(this.tree), e.content.push(e.nodes.length - 1, this.from + r, this.to + r, -1);
903
- }
904
- toTree() {
905
- return this.tree;
906
- }
907
- }
908
- function k(t, e, r, n) {
909
- return new D(t, e, r, n);
910
- }
911
- const Ue = { resolve: "Emphasis", mark: "EmphasisMark" }, _e = { resolve: "Emphasis", mark: "EmphasisMark" }, M = {}, _ = {};
912
- class C {
913
- constructor(e, r, n, s) {
914
- this.type = e, this.from = r, this.to = n, this.side = s;
915
- }
916
- }
917
- const me = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
918
- let F = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
919
- try {
920
- F = new RegExp("[\\p{S}|\\p{P}]", "u");
921
- } catch {
922
- }
923
- const G = {
924
- Escape(t, e, r) {
925
- if (e != 92 || r == t.end - 1)
926
- return -1;
927
- let n = t.char(r + 1);
928
- for (let s = 0; s < me.length; s++)
929
- if (me.charCodeAt(s) == n)
930
- return t.append(k(u.Escape, r, r + 2));
931
- return -1;
932
- },
933
- Entity(t, e, r) {
934
- if (e != 38)
935
- return -1;
936
- let n = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(t.slice(r + 1, r + 31));
937
- return n ? t.append(k(u.Entity, r, r + 1 + n[0].length)) : -1;
938
- },
939
- InlineCode(t, e, r) {
940
- if (e != 96 || r && t.char(r - 1) == 96)
941
- return -1;
942
- let n = r + 1;
943
- for (; n < t.end && t.char(n) == 96; )
944
- n++;
945
- let s = n - r, i = 0;
946
- for (; n < t.end; n++)
947
- if (t.char(n) == 96) {
948
- if (i++, i == s && t.char(n + 1) != 96)
949
- return t.append(k(u.InlineCode, r, n + 1, [
950
- k(u.CodeMark, r, r + s),
951
- k(u.CodeMark, n + 1 - s, n + 1)
952
- ]));
953
- } else
954
- i = 0;
955
- return -1;
956
- },
957
- HTMLTag(t, e, r) {
958
- if (e != 60 || r == t.end - 1)
959
- return -1;
960
- let n = t.slice(r + 1, t.end), s = /^(?:[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(n);
961
- if (s)
962
- return t.append(k(u.Autolink, r, r + 1 + s[0].length, [
963
- k(u.LinkMark, r, r + 1),
964
- // url[0] includes the closing bracket, so exclude it from this slice
965
- k(u.URL, r + 1, r + s[0].length),
966
- k(u.LinkMark, r + s[0].length, r + 1 + s[0].length)
967
- ]));
968
- let i = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);
969
- if (i)
970
- return t.append(k(u.Comment, r, r + 1 + i[0].length));
971
- let o = /^\?[^]*?\?>/.exec(n);
972
- if (o)
973
- return t.append(k(u.ProcessingInstruction, r, r + 1 + o[0].length));
974
- let a = /^(?:![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(n);
975
- return a ? t.append(k(u.HTMLTag, r, r + 1 + a[0].length)) : -1;
976
- },
977
- Emphasis(t, e, r) {
978
- if (e != 95 && e != 42)
979
- return -1;
980
- let n = r + 1;
981
- for (; t.char(n) == e; )
982
- n++;
983
- let s = t.slice(r - 1, r), i = t.slice(n, n + 1), o = F.test(s), a = F.test(i), l = /\s|^$/.test(s), h = /\s|^$/.test(i), f = !h && (!a || l || o), p = !l && (!o || h || a), d = f && (e == 42 || !p || o), c = p && (e == 42 || !f || a);
984
- return t.append(new C(e == 95 ? Ue : _e, r, n, (d ? 1 : 0) | (c ? 2 : 0)));
985
- },
986
- HardBreak(t, e, r) {
987
- if (e == 92 && t.char(r + 1) == 10)
988
- return t.append(k(u.HardBreak, r, r + 2));
989
- if (e == 32) {
990
- let n = r + 1;
991
- for (; t.char(n) == 32; )
992
- n++;
993
- if (t.char(n) == 10 && n >= r + 2)
994
- return t.append(k(u.HardBreak, r, n + 1));
995
- }
996
- return -1;
997
- },
998
- Link(t, e, r) {
999
- return e == 91 ? t.append(new C(
1000
- M,
1001
- r,
1002
- r + 1,
1003
- 1
1004
- /* Mark.Open */
1005
- )) : -1;
1006
- },
1007
- Image(t, e, r) {
1008
- return e == 33 && t.char(r + 1) == 91 ? t.append(new C(
1009
- _,
1010
- r,
1011
- r + 2,
1012
- 1
1013
- /* Mark.Open */
1014
- )) : -1;
1015
- },
1016
- LinkEnd(t, e, r) {
1017
- if (e != 93)
1018
- return -1;
1019
- for (let n = t.parts.length - 1; n >= 0; n--) {
1020
- let s = t.parts[n];
1021
- if (s instanceof C && (s.type == M || s.type == _)) {
1022
- if (!s.side || t.skipSpace(s.to) == r && !/[(\[]/.test(t.slice(r + 1, r + 2)))
1023
- return t.parts[n] = null, -1;
1024
- let i = t.takeContent(n), o = t.parts[n] = Mt(t, i, s.type == M ? u.Link : u.Image, s.from, r + 1);
1025
- if (s.type == M)
1026
- for (let a = 0; a < n; a++) {
1027
- let l = t.parts[a];
1028
- l instanceof C && l.type == M && (l.side = 0);
1029
- }
1030
- return o.to;
1031
- }
1032
- }
1033
- return -1;
1034
- }
1035
- };
1036
- function Mt(t, e, r, n, s) {
1037
- let { text: i } = t, o = t.char(s), a = s;
1038
- if (e.unshift(k(u.LinkMark, n, n + (r == u.Image ? 2 : 1))), e.push(k(u.LinkMark, s - 1, s)), o == 40) {
1039
- let l = t.skipSpace(s + 1), h = qe(i, l - t.offset, t.offset), f;
1040
- h && (l = t.skipSpace(h.to), l != h.to && (f = Qe(i, l - t.offset, t.offset), f && (l = t.skipSpace(f.to)))), t.char(l) == 41 && (e.push(k(u.LinkMark, s, s + 1)), a = l + 1, h && e.push(h), f && e.push(f), e.push(k(u.LinkMark, l, a)));
1041
- } else if (o == 91) {
1042
- let l = Ze(i, s - t.offset, t.offset, !1);
1043
- l && (e.push(l), a = l.to);
1044
- }
1045
- return k(r, n, a, e);
1046
- }
1047
- function qe(t, e, r) {
1048
- if (t.charCodeAt(e) == 60) {
1049
- for (let s = e + 1; s < t.length; s++) {
1050
- let i = t.charCodeAt(s);
1051
- if (i == 62)
1052
- return k(u.URL, e + r, s + 1 + r);
1053
- if (i == 60 || i == 10)
1054
- return !1;
1055
- }
1056
- return null;
1057
- } else {
1058
- let s = 0, i = e;
1059
- for (let o = !1; i < t.length; i++) {
1060
- let a = t.charCodeAt(i);
1061
- if (A(a))
1062
- break;
1063
- if (o)
1064
- o = !1;
1065
- else if (a == 40)
1066
- s++;
1067
- else if (a == 41) {
1068
- if (!s)
1069
- break;
1070
- s--;
1071
- } else a == 92 && (o = !0);
1072
- }
1073
- return i > e ? k(u.URL, e + r, i + r) : i == t.length ? null : !1;
1074
- }
1075
- }
1076
- function Qe(t, e, r) {
1077
- let n = t.charCodeAt(e);
1078
- if (n != 39 && n != 34 && n != 40)
1079
- return !1;
1080
- let s = n == 40 ? 41 : n;
1081
- for (let i = e + 1, o = !1; i < t.length; i++) {
1082
- let a = t.charCodeAt(i);
1083
- if (o)
1084
- o = !1;
1085
- else {
1086
- if (a == s)
1087
- return k(u.LinkTitle, e + r, i + 1 + r);
1088
- a == 92 && (o = !0);
1089
- }
1090
- }
1091
- return null;
1092
- }
1093
- function Ze(t, e, r, n) {
1094
- for (let s = !1, i = e + 1, o = Math.min(t.length, i + 999); i < o; i++) {
1095
- let a = t.charCodeAt(i);
1096
- if (s)
1097
- s = !1;
1098
- else {
1099
- if (a == 93)
1100
- return n ? !1 : k(u.LinkLabel, e + r, i + 1 + r);
1101
- if (n && !A(a) && (n = !1), a == 91)
1102
- return !1;
1103
- a == 92 && (s = !0);
1104
- }
1105
- }
1106
- return null;
1107
- }
1108
- class ae {
1109
- /**
1110
- @internal
1111
- */
1112
- constructor(e, r, n) {
1113
- this.parser = e, this.text = r, this.offset = n, this.parts = [];
1114
- }
1115
- /**
1116
- Get the character code at the given (document-relative)
1117
- position.
1118
- */
1119
- char(e) {
1120
- return e >= this.end ? -1 : this.text.charCodeAt(e - this.offset);
1121
- }
1122
- /**
1123
- The position of the end of this inline section.
1124
- */
1125
- get end() {
1126
- return this.offset + this.text.length;
1127
- }
1128
- /**
1129
- Get a substring of this inline section. Again uses
1130
- document-relative positions.
1131
- */
1132
- slice(e, r) {
1133
- return this.text.slice(e - this.offset, r - this.offset);
1134
- }
1135
- /**
1136
- @internal
1137
- */
1138
- append(e) {
1139
- return this.parts.push(e), e.to;
1140
- }
1141
- /**
1142
- Add a [delimiter](#DelimiterType) at this given position. `open`
1143
- and `close` indicate whether this delimiter is opening, closing,
1144
- or both. Returns the end of the delimiter, for convenient
1145
- returning from [parse functions](#InlineParser.parse).
1146
- */
1147
- addDelimiter(e, r, n, s, i) {
1148
- return this.append(new C(e, r, n, (s ? 1 : 0) | (i ? 2 : 0)));
1149
- }
1150
- /**
1151
- Returns true when there is an unmatched link or image opening
1152
- token before the current position.
1153
- */
1154
- get hasOpenLink() {
1155
- for (let e = this.parts.length - 1; e >= 0; e--) {
1156
- let r = this.parts[e];
1157
- if (r instanceof C && (r.type == M || r.type == _))
1158
- return !0;
1159
- }
1160
- return !1;
1161
- }
1162
- /**
1163
- Add an inline element. Returns the end of the element.
1164
- */
1165
- addElement(e) {
1166
- return this.append(e);
1167
- }
1168
- /**
1169
- Resolve markers between this.parts.length and from, wrapping matched markers in the
1170
- appropriate node and updating the content of this.parts. @internal
1171
- */
1172
- resolveMarkers(e) {
1173
- for (let n = e; n < this.parts.length; n++) {
1174
- let s = this.parts[n];
1175
- if (!(s instanceof C && s.type.resolve && s.side & 2))
1176
- continue;
1177
- let i = s.type == Ue || s.type == _e, o = s.to - s.from, a, l = n - 1;
1178
- for (; l >= e; l--) {
1179
- let g = this.parts[l];
1180
- if (g instanceof C && g.side & 1 && g.type == s.type && // Ignore emphasis delimiters where the character count doesn't match
1181
- !(i && (s.side & 1 || g.side & 2) && (g.to - g.from + o) % 3 == 0 && ((g.to - g.from) % 3 || o % 3))) {
1182
- a = g;
1183
- break;
1184
- }
1185
- }
1186
- if (!a)
1187
- continue;
1188
- let h = s.type.resolve, f = [], p = a.from, d = s.to;
1189
- if (i) {
1190
- let g = Math.min(2, a.to - a.from, o);
1191
- p = a.to - g, d = s.from + g, h = g == 1 ? "Emphasis" : "StrongEmphasis";
1192
- }
1193
- a.type.mark && f.push(this.elt(a.type.mark, p, a.to));
1194
- for (let g = l + 1; g < n; g++)
1195
- this.parts[g] instanceof D && f.push(this.parts[g]), this.parts[g] = null;
1196
- s.type.mark && f.push(this.elt(s.type.mark, s.from, d));
1197
- let c = this.elt(h, p, d, f);
1198
- this.parts[l] = i && a.from != p ? new C(a.type, a.from, p, a.side) : null, (this.parts[n] = i && s.to != d ? new C(s.type, d, s.to, s.side) : null) ? this.parts.splice(n, 0, c) : this.parts[n] = c;
1199
- }
1200
- let r = [];
1201
- for (let n = e; n < this.parts.length; n++) {
1202
- let s = this.parts[n];
1203
- s instanceof D && r.push(s);
1204
- }
1205
- return r;
1206
- }
1207
- /**
1208
- Find an opening delimiter of the given type. Returns `null` if
1209
- no delimiter is found, or an index that can be passed to
1210
- [`takeContent`](#InlineContext.takeContent) otherwise.
1211
- */
1212
- findOpeningDelimiter(e) {
1213
- for (let r = this.parts.length - 1; r >= 0; r--) {
1214
- let n = this.parts[r];
1215
- if (n instanceof C && n.type == e && n.side & 1)
1216
- return r;
1217
- }
1218
- return null;
1219
- }
1220
- /**
1221
- Remove all inline elements and delimiters starting from the
1222
- given index (which you should get from
1223
- [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
1224
- resolve delimiters inside of them, and return them as an array
1225
- of elements.
1226
- */
1227
- takeContent(e) {
1228
- let r = this.resolveMarkers(e);
1229
- return this.parts.length = e, r;
1230
- }
1231
- /**
1232
- Return the delimiter at the given index. Mostly useful to get
1233
- additional info out of a delimiter index returned by
1234
- [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
1235
- Returns null if there is no delimiter at this index.
1236
- */
1237
- getDelimiterAt(e) {
1238
- let r = this.parts[e];
1239
- return r instanceof C ? r : null;
1240
- }
1241
- /**
1242
- Skip space after the given (document) position, returning either
1243
- the position of the next non-space character or the end of the
1244
- section.
1245
- */
1246
- skipSpace(e) {
1247
- return O(this.text, e - this.offset) + this.offset;
1248
- }
1249
- elt(e, r, n, s) {
1250
- return typeof e == "string" ? k(this.parser.getNodeType(e), r, n, s) : new je(e, r);
1251
- }
1252
- }
1253
- ae.linkStart = M;
1254
- ae.imageStart = _;
1255
- function re(t, e) {
1256
- if (!e.length)
1257
- return t;
1258
- if (!t.length)
1259
- return e;
1260
- let r = t.slice(), n = 0;
1261
- for (let s of e) {
1262
- for (; n < r.length && r[n].to < s.to; )
1263
- n++;
1264
- if (n < r.length && r[n].from < s.from) {
1265
- let i = r[n];
1266
- i instanceof D && (r[n] = new D(i.type, i.from, i.to, re(i.children, [s])));
1267
- } else
1268
- r.splice(n++, 0, s);
1269
- }
1270
- return r;
1271
- }
1272
- const Ht = [u.CodeBlock, u.ListItem, u.OrderedList, u.BulletList];
1273
- class Pt {
1274
- constructor(e, r) {
1275
- this.fragments = e, this.input = r, this.i = 0, this.fragment = null, this.fragmentEnd = -1, this.cursor = null, e.length && (this.fragment = e[this.i++]);
1276
- }
1277
- nextFragment() {
1278
- this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null, this.cursor = null, this.fragmentEnd = -1;
1279
- }
1280
- moveTo(e, r) {
1281
- for (; this.fragment && this.fragment.to <= e; )
1282
- this.nextFragment();
1283
- if (!this.fragment || this.fragment.from > (e ? e - 1 : 0))
1284
- return !1;
1285
- if (this.fragmentEnd < 0) {
1286
- let i = this.fragment.to;
1287
- for (; i > 0 && this.input.read(i - 1, i) != `
1288
- `; )
1289
- i--;
1290
- this.fragmentEnd = i ? i - 1 : 0;
1291
- }
1292
- let n = this.cursor;
1293
- n || (n = this.cursor = this.fragment.tree.cursor(), n.firstChild());
1294
- let s = e + this.fragment.offset;
1295
- for (; n.to <= s; )
1296
- if (!n.parent())
1297
- return !1;
1298
- for (; ; ) {
1299
- if (n.from >= s)
1300
- return this.fragment.from <= r;
1301
- if (!n.childAfter(s))
1302
- return !1;
1303
- }
1304
- }
1305
- matches(e) {
1306
- let r = this.cursor.tree;
1307
- return r && r.prop(v.contextHash) == e;
1308
- }
1309
- takeNodes(e) {
1310
- let r = this.cursor, n = this.fragment.offset, s = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0), i = e.absoluteLineStart, o = i, a = e.block.children.length, l = o, h = a;
1311
- for (; ; ) {
1312
- if (r.to - n > s) {
1313
- if (r.type.isAnonymous && r.firstChild())
1314
- continue;
1315
- break;
1316
- }
1317
- let f = Ve(r.from - n, e.ranges);
1318
- if (r.to - n <= e.ranges[e.rangeI].to)
1319
- e.addNode(r.tree, f);
1320
- else {
1321
- let p = new H(e.parser.nodeSet.types[u.Paragraph], [], [], 0, e.block.hashProp);
1322
- e.reusePlaceholders.set(p, r.tree), e.addNode(p, f);
1323
- }
1324
- if (r.type.is("Block") && (Ht.indexOf(r.type.id) < 0 ? (o = r.to - n, a = e.block.children.length) : (o = l, a = h, l = r.to - n, h = e.block.children.length)), !r.nextSibling())
1325
- break;
1326
- }
1327
- for (; e.block.children.length > a; )
1328
- e.block.children.pop(), e.block.positions.pop();
1329
- return o - i;
1330
- }
1331
- }
1332
- function Ve(t, e) {
1333
- let r = t;
1334
- for (let n = 1; n < e.length; n++) {
1335
- let s = e[n - 1].to, i = e[n].from;
1336
- s < t && (r -= i - s);
1337
- }
1338
- return r;
1339
- }
1340
- const vt = Ie({
1341
- "Blockquote/...": m.quote,
1342
- HorizontalRule: m.contentSeparator,
1343
- "ATXHeading1/... SetextHeading1/...": m.heading1,
1344
- "ATXHeading2/... SetextHeading2/...": m.heading2,
1345
- "ATXHeading3/...": m.heading3,
1346
- "ATXHeading4/...": m.heading4,
1347
- "ATXHeading5/...": m.heading5,
1348
- "ATXHeading6/...": m.heading6,
1349
- "Comment CommentBlock": m.comment,
1350
- Escape: m.escape,
1351
- Entity: m.character,
1352
- "Emphasis/...": m.emphasis,
1353
- "StrongEmphasis/...": m.strong,
1354
- "Link/... Image/...": m.link,
1355
- "OrderedList/... BulletList/...": m.list,
1356
- "BlockQuote/...": m.quote,
1357
- "InlineCode CodeText": m.monospace,
1358
- "URL Autolink": m.url,
1359
- "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": m.processingInstruction,
1360
- "CodeInfo LinkLabel": m.labelName,
1361
- LinkTitle: m.string,
1362
- Paragraph: m.content
1363
- }), Nt = new Z(new Ee(Xe).extend(vt), Object.keys($).map((t) => $[t]), Object.keys($).map((t) => De[t]), Object.keys($), Bt, He, Object.keys(G).map((t) => G[t]), Object.keys(G), []);
1364
- function yt(t, e, r) {
1365
- let n = [];
1366
- for (let s = t.firstChild, i = e; ; s = s.nextSibling) {
1367
- let o = s ? s.from : r;
1368
- if (o > i && n.push({ from: i, to: o }), !s)
1369
- break;
1370
- i = s.to;
1371
- }
1372
- return n;
1373
- }
1374
- function Rt(t) {
1375
- let { codeParser: e, htmlParser: r } = t;
1376
- return { wrap: ot((s, i) => {
1377
- let o = s.type.id;
1378
- if (e && (o == u.CodeBlock || o == u.FencedCode)) {
1379
- let a = "";
1380
- if (o == u.FencedCode) {
1381
- let h = s.node.getChild(u.CodeInfo);
1382
- h && (a = i.read(h.from, h.to));
1383
- }
1384
- let l = e(a);
1385
- if (l)
1386
- return { parser: l, overlay: (h) => h.type.id == u.CodeText, bracketed: o == u.FencedCode };
1387
- } else if (r && (o == u.HTMLBlock || o == u.HTMLTag || o == u.CommentBlock))
1388
- return { parser: r, overlay: yt(s.node, s.from, s.to) };
1389
- return null;
1390
- }) };
1391
- }
1392
- const Ot = { resolve: "Strikethrough", mark: "StrikethroughMark" }, Tt = {
1393
- defineNodes: [{
1394
- name: "Strikethrough",
1395
- style: { "Strikethrough/...": m.strikethrough }
1396
- }, {
1397
- name: "StrikethroughMark",
1398
- style: m.processingInstruction
1399
- }],
1400
- parseInline: [{
1401
- name: "Strikethrough",
1402
- parse(t, e, r) {
1403
- if (e != 126 || t.char(r + 1) != 126 || t.char(r + 2) == 126)
1404
- return -1;
1405
- let n = t.slice(r - 1, r), s = t.slice(r + 2, r + 3), i = /\s|^$/.test(n), o = /\s|^$/.test(s), a = F.test(n), l = F.test(s);
1406
- return t.addDelimiter(Ot, r, r + 2, !o && (!l || i || a), !i && (!a || o || l));
1407
- },
1408
- after: "Emphasis"
1409
- }]
1410
- };
1411
- function T(t, e, r = 0, n, s = 0) {
1412
- let i = 0, o = !0, a = -1, l = -1, h = !1, f = () => {
1413
- n.push(t.elt("TableCell", s + a, s + l, t.parser.parseInline(e.slice(a, l), s + a)));
1414
- };
1415
- for (let p = r; p < e.length; p++) {
1416
- let d = e.charCodeAt(p);
1417
- d == 124 && !h ? ((!o || a > -1) && i++, o = !1, n && (a > -1 && f(), n.push(t.elt("TableDelimiter", p + s, p + s + 1))), a = l = -1) : (h || d != 32 && d != 9) && (a < 0 && (a = p), l = p + 1), h = !h && d == 92;
1418
- }
1419
- return a > -1 && (i++, n && f()), i;
1420
- }
1421
- function ge(t, e) {
1422
- for (let r = e; r < t.length; r++) {
1423
- let n = t.charCodeAt(r);
1424
- if (n == 124)
1425
- return !0;
1426
- n == 92 && r++;
1427
- }
1428
- return !1;
1429
- }
1430
- const Ge = /^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
1431
- class ke {
1432
- constructor() {
1433
- this.rows = null;
1434
- }
1435
- nextLine(e, r, n) {
1436
- if (this.rows == null) {
1437
- this.rows = !1;
1438
- let s;
1439
- if ((r.next == 45 || r.next == 58 || r.next == 124) && Ge.test(s = r.text.slice(r.pos))) {
1440
- let i = [];
1441
- T(e, n.content, 0, i, n.start) == T(e, s, r.pos) && (this.rows = [
1442
- e.elt("TableHeader", n.start, n.start + n.content.length, i),
1443
- e.elt("TableDelimiter", e.lineStart + r.pos, e.lineStart + r.text.length)
1444
- ]);
1445
- }
1446
- } else if (this.rows) {
1447
- let s = [];
1448
- T(e, r.text, r.pos, s, e.lineStart), this.rows.push(e.elt("TableRow", e.lineStart + r.pos, e.lineStart + r.text.length, s));
1449
- }
1450
- return !1;
1451
- }
1452
- finish(e, r) {
1453
- return this.rows ? (e.addLeafElement(r, e.elt("Table", r.start, r.start + r.content.length, this.rows)), !0) : !1;
1454
- }
1455
- }
1456
- const zt = {
1457
- defineNodes: [
1458
- { name: "Table", block: !0 },
1459
- { name: "TableHeader", style: { "TableHeader/...": m.heading } },
1460
- "TableRow",
1461
- { name: "TableCell", style: m.content },
1462
- { name: "TableDelimiter", style: m.processingInstruction }
1463
- ],
1464
- parseBlock: [{
1465
- name: "Table",
1466
- leaf(t, e) {
1467
- return ge(e.content, 0) ? new ke() : null;
1468
- },
1469
- endLeaf(t, e, r) {
1470
- if (r.parsers.some((s) => s instanceof ke) || !ge(e.text, e.basePos))
1471
- return !1;
1472
- let n = t.peekLine();
1473
- return Ge.test(n) && T(t, e.text, e.basePos) == T(t, n, e.basePos);
1474
- },
1475
- before: "SetextHeading"
1476
- }]
1477
- };
1478
- class Dt {
1479
- nextLine() {
1480
- return !1;
1481
- }
1482
- finish(e, r) {
1483
- return e.addLeafElement(r, e.elt("Task", r.start, r.start + r.content.length, [
1484
- e.elt("TaskMarker", r.start, r.start + 3),
1485
- ...e.parser.parseInline(r.content.slice(3), r.start + 3)
1486
- ])), !0;
1487
- }
1488
- }
1489
- const Ft = {
1490
- defineNodes: [
1491
- { name: "Task", block: !0, style: m.list },
1492
- { name: "TaskMarker", style: m.atom }
1493
- ],
1494
- parseBlock: [{
1495
- name: "TaskList",
1496
- leaf(t, e) {
1497
- return /^\[[ xX]\][ \t]/.test(e.content) && t.parentType().name == "ListItem" ? new Dt() : null;
1498
- },
1499
- after: "SetextHeading"
1500
- }]
1501
- }, Le = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy, be = /[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy, Xt = /[\w-]+\.[\w-]+($|\/)/, we = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy, Se = /\/[a-zA-Z\d@.]+/gy;
1502
- function Ce(t, e, r, n) {
1503
- let s = 0;
1504
- for (let i = e; i < r; i++)
1505
- t[i] == n && s++;
1506
- return s;
1507
- }
1508
- function $t(t, e) {
1509
- be.lastIndex = e;
1510
- let r = be.exec(t);
1511
- if (!r || Xt.exec(r[0])[0].indexOf("_") > -1)
1512
- return -1;
1513
- let n = e + r[0].length;
1514
- for (; ; ) {
1515
- let s = t[n - 1], i;
1516
- if (/[?!.,:*_~]/.test(s) || s == ")" && Ce(t, e, n, ")") > Ce(t, e, n, "("))
1517
- n--;
1518
- else if (s == ";" && (i = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e, n))))
1519
- n = e + i.index;
1520
- else
1521
- break;
1522
- }
1523
- return n;
1524
- }
1525
- function Ae(t, e) {
1526
- we.lastIndex = e;
1527
- let r = we.exec(t);
1528
- if (!r)
1529
- return -1;
1530
- let n = r[0][r[0].length - 1];
1531
- return n == "_" || n == "-" ? -1 : e + r[0].length - (n == "." ? 1 : 0);
1532
- }
1533
- const jt = {
1534
- parseInline: [{
1535
- name: "Autolink",
1536
- parse(t, e, r) {
1537
- let n = r - t.offset;
1538
- if (n && /\w/.test(t.text[n - 1]))
1539
- return -1;
1540
- Le.lastIndex = n;
1541
- let s = Le.exec(t.text), i = -1;
1542
- if (!s)
1543
- return -1;
1544
- if (s[1] || s[2]) {
1545
- if (i = $t(t.text, n + s[0].length), i > -1 && t.hasOpenLink) {
1546
- let o = /([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(n, i));
1547
- i = n + o[0].length;
1548
- }
1549
- } else s[3] ? i = Ae(t.text, n) : (i = Ae(t.text, n + s[0].length), i > -1 && s[0] == "xmpp:" && (Se.lastIndex = i, s = Se.exec(t.text), s && (i = s.index + s[0].length)));
1550
- return i < 0 ? -1 : (t.addElement(t.elt("URL", r, i + t.offset)), i + t.offset);
1551
- }
1552
- }]
1553
- }, Ut = [zt, Ft, Tt, jt];
1554
- function Ke(t, e, r) {
1555
- return (n, s, i) => {
1556
- if (s != t || n.char(i + 1) == t)
1557
- return -1;
1558
- let o = [n.elt(r, i, i + 1)];
1559
- for (let a = i + 1; a < n.end; a++) {
1560
- let l = n.char(a);
1561
- if (l == t)
1562
- return n.addElement(n.elt(e, i, a + 1, o.concat(n.elt(r, a, a + 1))));
1563
- if (l == 92 && o.push(n.elt("Escape", a, a++ + 2)), A(l))
1564
- break;
1565
- }
1566
- return -1;
1567
- };
1568
- }
1569
- const _t = {
1570
- defineNodes: [
1571
- { name: "Superscript", style: m.special(m.content) },
1572
- { name: "SuperscriptMark", style: m.processingInstruction }
1573
- ],
1574
- parseInline: [{
1575
- name: "Superscript",
1576
- parse: Ke(94, "Superscript", "SuperscriptMark")
1577
- }]
1578
- }, qt = {
1579
- defineNodes: [
1580
- { name: "Subscript", style: m.special(m.content) },
1581
- { name: "SubscriptMark", style: m.processingInstruction }
1582
- ],
1583
- parseInline: [{
1584
- name: "Subscript",
1585
- parse: Ke(126, "Subscript", "SubscriptMark")
1586
- }]
1587
- }, Qt = {
1588
- defineNodes: [{ name: "Emoji", style: m.character }],
1589
- parseInline: [{
1590
- name: "Emoji",
1591
- parse(t, e, r) {
1592
- let n;
1593
- return e != 58 || !(n = /^[a-zA-Z_0-9]+:/.exec(t.slice(r + 1, t.end))) ? -1 : t.addElement(t.elt("Emoji", r, r + 1 + n[0].length));
1594
- }
1595
- }]
1596
- }, Je = /* @__PURE__ */ dt({ commentTokens: { block: { open: "<!--", close: "-->" } } }), Ye = /* @__PURE__ */ new v(), We = /* @__PURE__ */ Nt.configure({
1597
- props: [
1598
- /* @__PURE__ */ Me.add((t) => !t.is("Block") || t.is("Document") || ne(t) != null || Zt(t) ? void 0 : (e, r) => ({ from: r.doc.lineAt(e.from).to, to: e.to })),
1599
- /* @__PURE__ */ Ye.add(ne),
1600
- /* @__PURE__ */ ct.add({
1601
- Document: () => null
1602
- }),
1603
- /* @__PURE__ */ mt.add({
1604
- Document: Je
1605
- })
1606
- ]
1607
- });
1608
- function ne(t) {
1609
- let e = /^(?:ATX|Setext)Heading(\d)$/.exec(t.name);
1610
- return e ? +e[1] : void 0;
1611
- }
1612
- function Zt(t) {
1613
- return t.name == "OrderedList" || t.name == "BulletList";
1614
- }
1615
- function Vt(t, e) {
1616
- let r = t;
1617
- for (; ; ) {
1618
- let n = r.nextSibling, s;
1619
- if (!n || (s = ne(n.type)) != null && s <= e)
1620
- break;
1621
- r = n;
1622
- }
1623
- return r.to;
1624
- }
1625
- const Gt = /* @__PURE__ */ lt.of((t, e, r) => {
1626
- for (let n = X(t).resolveInner(r, -1); n && !(n.from < e); n = n.parent) {
1627
- let s = n.type.prop(Ye);
1628
- if (s == null)
1629
- continue;
1630
- let i = Vt(n, s);
1631
- if (i > r)
1632
- return { from: r, to: i };
1633
- }
1634
- return null;
1635
- });
1636
- function le(t) {
1637
- return new ut(Je, t, [], "markdown");
1638
- }
1639
- const Kt = /* @__PURE__ */ le(We), Jt = /* @__PURE__ */ We.configure([Ut, qt, _t, Qt, {
1640
- props: [
1641
- /* @__PURE__ */ Me.add({
1642
- Table: (t, e) => ({ from: e.doc.lineAt(t.from).to, to: t.to })
1643
- })
1644
- ]
1645
- }]), q = /* @__PURE__ */ le(Jt);
1646
- function Yt(t, e) {
1647
- return (r) => {
1648
- if (r && t) {
1649
- let n = null;
1650
- if (r = /\S*/.exec(r)[0], typeof t == "function" ? n = t(r) : n = ue.matchLanguageName(t, r, !0), n instanceof ue)
1651
- return n.support ? n.support.language.parser : kt.getSkippingParser(n.load());
1652
- if (n)
1653
- return n.parser;
1654
- }
1655
- return e ? e.parser : null;
1656
- };
1657
- }
1658
- class K {
1659
- constructor(e, r, n, s, i, o, a) {
1660
- this.node = e, this.from = r, this.to = n, this.spaceBefore = s, this.spaceAfter = i, this.type = o, this.item = a;
1661
- }
1662
- blank(e, r = !0) {
1663
- let n = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
1664
- if (e != null) {
1665
- for (; n.length < e; )
1666
- n += " ";
1667
- return n;
1668
- } else {
1669
- for (let s = this.to - this.from - n.length - this.spaceAfter.length; s > 0; s--)
1670
- n += " ";
1671
- return n + (r ? this.spaceAfter : "");
1672
- }
1673
- }
1674
- marker(e, r) {
1675
- let n = this.node.name == "OrderedList" ? String(+tt(this.item, e)[2] + r) : "";
1676
- return this.spaceBefore + n + this.type + this.spaceAfter;
1677
- }
1678
- }
1679
- function et(t, e) {
1680
- let r = [], n = [];
1681
- for (let s = t; s; s = s.parent) {
1682
- if (s.name == "FencedCode")
1683
- return n;
1684
- (s.name == "ListItem" || s.name == "Blockquote") && r.push(s);
1685
- }
1686
- for (let s = r.length - 1; s >= 0; s--) {
1687
- let i = r[s], o, a = e.lineAt(i.from), l = i.from - a.from;
1688
- if (i.name == "Blockquote" && (o = /^ *>( ?)/.exec(a.text.slice(l))))
1689
- n.push(new K(i, l, l + o[0].length, "", o[1], ">", null));
1690
- else if (i.name == "ListItem" && i.parent.name == "OrderedList" && (o = /^( *)\d+([.)])( *)/.exec(a.text.slice(l)))) {
1691
- let h = o[3], f = o[0].length;
1692
- h.length >= 4 && (h = h.slice(0, h.length - 4), f -= 4), n.push(new K(i.parent, l, l + f, o[1], h, o[2], i));
1693
- } else if (i.name == "ListItem" && i.parent.name == "BulletList" && (o = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))) {
1694
- let h = o[4], f = o[0].length;
1695
- h.length > 4 && (h = h.slice(0, h.length - 4), f -= 4);
1696
- let p = o[2];
1697
- o[3] && (p += o[3].replace(/[xX]/, " ")), n.push(new K(i.parent, l, l + f, o[1], h, p, i));
1698
- }
1699
- }
1700
- return n;
1701
- }
1702
- function tt(t, e) {
1703
- return /^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from, t.from + 10));
1704
- }
1705
- function J(t, e, r, n = 0) {
1706
- for (let s = -1, i = t; ; ) {
1707
- if (i.name == "ListItem") {
1708
- let a = tt(i, e), l = +a[2];
1709
- if (s >= 0) {
1710
- if (l != s + 1)
1711
- return;
1712
- r.push({ from: i.from + a[1].length, to: i.from + a[0].length, insert: String(s + 2 + n) });
1713
- }
1714
- s = l;
1715
- }
1716
- let o = i.nextSibling;
1717
- if (!o)
1718
- break;
1719
- i = o;
1720
- }
1721
- }
1722
- function he(t, e) {
1723
- let r = /^[ \t]*/.exec(t)[0].length;
1724
- if (!r || e.facet(pt) != " ")
1725
- return t;
1726
- let n = z(t, 4, r), s = "";
1727
- for (let i = n; i > 0; )
1728
- i >= 4 ? (s += " ", i -= 4) : (s += " ", i--);
1729
- return s + t.slice(r);
1730
- }
1731
- const Wt = (t = {}) => ({ state: e, dispatch: r }) => {
1732
- let n = X(e), { doc: s } = e, i = null, o = e.changeByRange((a) => {
1733
- if (!a.empty || !q.isActiveAt(e, a.from, -1) && !q.isActiveAt(e, a.from, 1))
1734
- return i = { range: a };
1735
- let l = a.from, h = s.lineAt(l), f = et(n.resolveInner(l, -1), s);
1736
- for (; f.length && f[f.length - 1].from > l - h.from; )
1737
- f.pop();
1738
- if (!f.length)
1739
- return i = { range: a };
1740
- let p = f[f.length - 1];
1741
- if (p.to - p.spaceAfter.length > l - h.from)
1742
- return i = { range: a };
1743
- let d = l >= p.to - p.spaceAfter.length && !/\S/.test(h.text.slice(p.to));
1744
- if (p.item && d) {
1745
- let w = p.node.firstChild, S = p.node.getChild("ListItem", "ListItem");
1746
- if (w.to >= l || S && S.to < l || h.from > 0 && !/[^\s>]/.test(s.lineAt(h.from - 1).text) || t.nonTightLists === !1) {
1747
- let b = f.length > 1 ? f[f.length - 2] : null, E, I = "";
1748
- b && b.item ? (E = h.from + b.from, I = b.marker(s, 1)) : E = h.from + (b ? b.to : 0);
1749
- let y = [{ from: E, to: l, insert: I }];
1750
- return p.node.name == "OrderedList" && J(p.item, s, y, -2), b && b.node.name == "OrderedList" && J(b.item, s, y), { range: P.cursor(E + I.length), changes: y };
1751
- } else {
1752
- let b = Be(f, e, h);
1753
- return {
1754
- range: P.cursor(l + b.length + 1),
1755
- changes: { from: h.from, insert: b + e.lineBreak }
1756
- };
1757
- }
1758
- }
1759
- if (p.node.name == "Blockquote" && d && h.from) {
1760
- let w = s.lineAt(h.from - 1), S = />\s*$/.exec(w.text);
1761
- if (S && S.index == p.from) {
1762
- let b = e.changes([
1763
- { from: w.from + S.index, to: w.to },
1764
- { from: h.from + p.from, to: h.to }
1765
- ]);
1766
- return { range: a.map(b), changes: b };
1767
- }
1768
- }
1769
- let c = [];
1770
- p.node.name == "OrderedList" && J(p.item, s, c);
1771
- let L = p.item && p.item.from < h.from, g = "";
1772
- if (!L || /^[\s\d.)\-+*>]*/.exec(h.text)[0].length >= p.to)
1773
- for (let w = 0, S = f.length - 1; w <= S; w++)
1774
- g += w == S && !L ? f[w].marker(s, 1) : f[w].blank(w < S ? z(h.text, 4, f[w + 1].from) - g.length : null);
1775
- let B = l;
1776
- for (; B > h.from && /\s/.test(h.text.charAt(B - h.from - 1)); )
1777
- B--;
1778
- return g = he(g, e), tr(p.node, e.doc) && (g = Be(f, e, h) + e.lineBreak + g), c.push({ from: B, to: l, insert: e.lineBreak + g }), { range: P.cursor(B + g.length + 1), changes: c };
1779
- });
1780
- return i ? !1 : (r(e.update(o, { scrollIntoView: !0, userEvent: "input" })), !0);
1781
- }, er = /* @__PURE__ */ Wt();
1782
- function xe(t) {
1783
- return t.name == "QuoteMark" || t.name == "ListMark";
1784
- }
1785
- function tr(t, e) {
1786
- if (t.name != "OrderedList" && t.name != "BulletList")
1787
- return !1;
1788
- let r = t.firstChild, n = t.getChild("ListItem", "ListItem");
1789
- if (!n)
1790
- return !1;
1791
- let s = e.lineAt(r.to), i = e.lineAt(n.from), o = /^[\s>]*$/.test(s.text);
1792
- return s.number + (o ? 0 : 1) < i.number;
1793
- }
1794
- function Be(t, e, r) {
1795
- let n = "";
1796
- for (let s = 0, i = t.length - 2; s <= i; s++)
1797
- n += t[s].blank(s < i ? z(r.text, 4, t[s + 1].from) - n.length : null, s < i);
1798
- return he(n, e);
1799
- }
1800
- function rr(t, e) {
1801
- let r = t.resolveInner(e, -1), n = e;
1802
- xe(r) && (n = r.from, r = r.parent);
1803
- for (let s; s = r.childBefore(n); )
1804
- if (xe(s))
1805
- n = s.from;
1806
- else if (s.name == "OrderedList" || s.name == "BulletList")
1807
- r = s.lastChild, n = r.to;
1808
- else
1809
- break;
1810
- return r;
1811
- }
1812
- const nr = ({ state: t, dispatch: e }) => {
1813
- let r = X(t), n = null, s = t.changeByRange((i) => {
1814
- let o = i.from, { doc: a } = t;
1815
- if (i.empty && q.isActiveAt(t, i.from)) {
1816
- let l = a.lineAt(o), h = et(rr(r, o), a);
1817
- if (h.length) {
1818
- let f = h[h.length - 1], p = f.to - f.spaceAfter.length + (f.spaceAfter ? 1 : 0);
1819
- if (o - l.from > p && !/\S/.test(l.text.slice(p, o - l.from)))
1820
- return {
1821
- range: P.cursor(l.from + p),
1822
- changes: { from: l.from + p, to: o }
1823
- };
1824
- if (o - l.from == p && // Only apply this if we're on the line that has the
1825
- // construct's syntax, or there's only indentation in the
1826
- // target range
1827
- (!f.item || l.from <= f.item.from || !/\S/.test(l.text.slice(0, f.to)))) {
1828
- let d = l.from + f.from;
1829
- if (f.item && f.node.from < f.item.from && /\S/.test(l.text.slice(f.from, f.to))) {
1830
- let c = f.blank(z(l.text, 4, f.to) - z(l.text, 4, f.from));
1831
- return d == l.from && (c = he(c, t)), {
1832
- range: P.cursor(d + c.length),
1833
- changes: { from: d, to: l.from + f.to, insert: c }
1834
- };
1835
- }
1836
- if (d < o)
1837
- return { range: P.cursor(d), changes: { from: d, to: o } };
1838
- }
1839
- }
1840
- }
1841
- return n = { range: i };
1842
- });
1843
- return n ? !1 : (e(t.update(s, { scrollIntoView: !0, userEvent: "delete" })), !0);
1844
- }, sr = [
1845
- { key: "Enter", run: er },
1846
- { key: "Backspace", run: nr }
1847
- ], rt = /* @__PURE__ */ bt({ matchClosingTags: !1 });
1848
- function dr(t = {}) {
1849
- let { codeLanguages: e, defaultCodeLanguage: r, addKeymap: n = !0, base: { parser: s } = Kt, completeHTMLTags: i = !0, pasteURLAsLink: o = !0, htmlTagLanguage: a = rt } = t;
1850
- if (!(s instanceof Z))
1851
- throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");
1852
- let l = t.extensions ? [t.extensions] : [], h = [a.support, Gt], f;
1853
- o && h.push(lr), r instanceof fe ? (h.push(r.support), f = r.language) : r && (f = r);
1854
- let p = e || f ? Yt(e, f) : void 0;
1855
- l.push(Rt({ codeParser: p, htmlParser: a.language.parser })), n && h.push(ht.high(ft.of(sr)));
1856
- let d = le(s.configure(l));
1857
- return i && h.push(d.data.of({ autocomplete: ir })), new fe(d, h);
1858
- }
1859
- function ir(t) {
1860
- let { state: e, pos: r } = t, n = /<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(r - 25, r));
1861
- if (!n)
1862
- return null;
1863
- let s = X(e).resolveInner(r, -1);
1864
- for (; s && !s.type.isTop; ) {
1865
- if (s.name == "CodeBlock" || s.name == "FencedCode" || s.name == "ProcessingInstructionBlock" || s.name == "CommentBlock" || s.name == "Link" || s.name == "Image")
1866
- return null;
1867
- s = s.parent;
1868
- }
1869
- return {
1870
- from: r - n[0].length,
1871
- to: r,
1872
- options: or(),
1873
- validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
1874
- };
1875
- }
1876
- let Y = null;
1877
- function or() {
1878
- if (Y)
1879
- return Y;
1880
- let t = wt(new Lt(gt.create({ extensions: rt }), 0, !0));
1881
- return Y = t ? t.options : [];
1882
- }
1883
- const ar = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i, lr = /* @__PURE__ */ at.domEventHandlers({
1884
- paste: (t, e) => {
1885
- var r;
1886
- let { main: n } = e.state.selection;
1887
- if (n.empty)
1888
- return !1;
1889
- let s = (r = t.clipboardData) === null || r === void 0 ? void 0 : r.getData("text/plain");
1890
- if (!s || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s) || (/^www\./.test(s) && (s = "https://" + s), !q.isActiveAt(e.state, n.from, 1)))
1891
- return !1;
1892
- let i = X(e.state), o = !1;
1893
- return i.iterate({
1894
- from: n.from,
1895
- to: n.to,
1896
- enter: (a) => {
1897
- (a.from > n.from || ar.test(a.name)) && (o = !0);
1898
- },
1899
- leave: (a) => {
1900
- a.to < n.to && (o = !0);
1901
- }
1902
- }), o ? !1 : (e.dispatch({
1903
- changes: [{ from: n.from, insert: "[" }, { from: n.to, insert: `](${s})` }],
1904
- userEvent: "input.paste",
1905
- scrollIntoView: !0
1906
- }), !0);
1907
- }
1908
- });
1909
- export {
1910
- Kt as commonmarkLanguage,
1911
- nr as deleteMarkupBackward,
1912
- er as insertNewlineContinueMarkup,
1913
- Wt as insertNewlineContinueMarkupCommand,
1914
- dr as markdown,
1915
- sr as markdownKeymap,
1916
- q as markdownLanguage,
1917
- lr as pasteURLAsLink
1918
- };