@veltra/desktop 1.3.0 → 1.3.2

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 (67) hide show
  1. package/dist/components/action/action-group.vue.d.ts +2 -2
  2. package/dist/components/action/action.vue.d.ts +2 -2
  3. package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
  4. package/dist/components/breadcrumb/style2.css +1 -2
  5. package/dist/components/button/style2.css +3 -3
  6. package/dist/components/card/style2.css +1 -1
  7. package/dist/components/cascade/cascade.vue.d.ts +4 -4
  8. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  9. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
  10. package/dist/components/code-editor/code-editor.vue.d.ts +2 -2
  11. package/dist/components/code-editor/lang-loaders.js +1 -0
  12. package/dist/components/code-editor/lang-loaders.js.map +1 -1
  13. package/dist/components/condition-editor/style2.css +2 -4
  14. package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
  15. package/dist/components/date-picker/date-picker.vue.d.ts +3 -3
  16. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +3 -3
  17. package/dist/components/empty/empty.vue.d.ts +1 -1
  18. package/dist/components/form-item/form-item.js.map +1 -1
  19. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +2 -1
  20. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/input/input.vue.d.ts +8 -8
  22. package/dist/components/multi-select/multi-select.vue.d.ts +4 -4
  23. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +4 -4
  24. package/dist/components/number-input/number-input.vue.d.ts +2 -2
  25. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  26. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  27. package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
  28. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  29. package/dist/components/rich-text-editor/style2.css +1 -1
  30. package/dist/components/select/select.vue.d.ts +3 -3
  31. package/dist/components/textarea/textarea.vue.d.ts +4 -4
  32. package/dist/components/tip/tip.js +32 -5
  33. package/dist/components/tip/tip.js.map +1 -1
  34. package/dist/components/tip/tip.vue.d.ts +1 -0
  35. package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
  36. package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +1 -1
  37. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +914 -0
  38. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -0
  39. package/dist/node_modules/.bun/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js +994 -0
  40. package/dist/node_modules/.bun/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js.map +1 -0
  41. package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +1 -1
  42. package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.1/node_modules/@codemirror/lang-markdown/dist/index.js +471 -0
  43. package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.1/node_modules/@codemirror/lang-markdown/dist/index.js.map +1 -0
  44. package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js +71 -1
  45. package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +1 -1
  46. package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js +326 -2
  47. package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js.map +1 -1
  48. package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js +250 -0
  49. package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js.map +1 -0
  50. package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +1 -1
  51. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +438 -0
  52. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -0
  53. package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js +1952 -0
  54. package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js.map +1 -0
  55. package/dist/types/code-editor.d.ts +1 -1
  56. package/dist/types/tip.d.ts +5 -0
  57. package/package.json +7 -6
  58. package/src/components/breadcrumb/style.scss +1 -2
  59. package/src/components/button/style.scss +6 -4
  60. package/src/components/card/style.scss +1 -1
  61. package/src/components/code-editor/lang-loaders.ts +1 -0
  62. package/src/components/condition-editor/style.scss +2 -4
  63. package/src/components/form-item/form-item.vue +1 -1
  64. package/src/components/rich-text-editor/style.scss +1 -1
  65. package/src/components/tip/tip.vue +36 -5
  66. package/src/types/code-editor.ts +9 -1
  67. package/src/types/tip.ts +6 -0
@@ -0,0 +1,1952 @@
1
+ import { NodeProp, NodeSet, NodeType, Parser, Tree, parseMixed } from "../../../../../@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js";
2
+ import { Tag, styleTags, tags } from "../../../../../@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js";
3
+ //#region ../../node_modules/.bun/@lezer+markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js
4
+ var CompositeBlock = class CompositeBlock {
5
+ static create(type, value, from, parentHash, end) {
6
+ return new CompositeBlock(type, value, from, parentHash + (parentHash << 8) + type + (value << 4) | 0, end, [], []);
7
+ }
8
+ constructor(type, value, from, hash, end, children, positions) {
9
+ this.type = type;
10
+ this.value = value;
11
+ this.from = from;
12
+ this.hash = hash;
13
+ this.end = end;
14
+ this.children = children;
15
+ this.positions = positions;
16
+ this.hashProp = [[NodeProp.contextHash, hash]];
17
+ }
18
+ addChild(child, pos) {
19
+ if (child.prop(NodeProp.contextHash) != this.hash) child = new Tree(child.type, child.children, child.positions, child.length, this.hashProp);
20
+ this.children.push(child);
21
+ this.positions.push(pos);
22
+ }
23
+ toTree(nodeSet, end = this.end) {
24
+ let last = this.children.length - 1;
25
+ if (last >= 0) end = Math.max(end, this.positions[last] + this.children[last].length + this.from);
26
+ return new Tree(nodeSet.types[this.type], this.children, this.positions, end - this.from).balance({ makeTree: (children, positions, length) => new Tree(NodeType.none, children, positions, length, this.hashProp) });
27
+ }
28
+ };
29
+ var Type;
30
+ (function(Type) {
31
+ Type[Type["Document"] = 1] = "Document";
32
+ Type[Type["CodeBlock"] = 2] = "CodeBlock";
33
+ Type[Type["FencedCode"] = 3] = "FencedCode";
34
+ Type[Type["Blockquote"] = 4] = "Blockquote";
35
+ Type[Type["HorizontalRule"] = 5] = "HorizontalRule";
36
+ Type[Type["BulletList"] = 6] = "BulletList";
37
+ Type[Type["OrderedList"] = 7] = "OrderedList";
38
+ Type[Type["ListItem"] = 8] = "ListItem";
39
+ Type[Type["ATXHeading1"] = 9] = "ATXHeading1";
40
+ Type[Type["ATXHeading2"] = 10] = "ATXHeading2";
41
+ Type[Type["ATXHeading3"] = 11] = "ATXHeading3";
42
+ Type[Type["ATXHeading4"] = 12] = "ATXHeading4";
43
+ Type[Type["ATXHeading5"] = 13] = "ATXHeading5";
44
+ Type[Type["ATXHeading6"] = 14] = "ATXHeading6";
45
+ Type[Type["SetextHeading1"] = 15] = "SetextHeading1";
46
+ Type[Type["SetextHeading2"] = 16] = "SetextHeading2";
47
+ Type[Type["HTMLBlock"] = 17] = "HTMLBlock";
48
+ Type[Type["LinkReference"] = 18] = "LinkReference";
49
+ Type[Type["Paragraph"] = 19] = "Paragraph";
50
+ Type[Type["CommentBlock"] = 20] = "CommentBlock";
51
+ Type[Type["ProcessingInstructionBlock"] = 21] = "ProcessingInstructionBlock";
52
+ Type[Type["Escape"] = 22] = "Escape";
53
+ Type[Type["Entity"] = 23] = "Entity";
54
+ Type[Type["HardBreak"] = 24] = "HardBreak";
55
+ Type[Type["Emphasis"] = 25] = "Emphasis";
56
+ Type[Type["StrongEmphasis"] = 26] = "StrongEmphasis";
57
+ Type[Type["Link"] = 27] = "Link";
58
+ Type[Type["Image"] = 28] = "Image";
59
+ Type[Type["InlineCode"] = 29] = "InlineCode";
60
+ Type[Type["HTMLTag"] = 30] = "HTMLTag";
61
+ Type[Type["Comment"] = 31] = "Comment";
62
+ Type[Type["ProcessingInstruction"] = 32] = "ProcessingInstruction";
63
+ Type[Type["Autolink"] = 33] = "Autolink";
64
+ Type[Type["HeaderMark"] = 34] = "HeaderMark";
65
+ Type[Type["QuoteMark"] = 35] = "QuoteMark";
66
+ Type[Type["ListMark"] = 36] = "ListMark";
67
+ Type[Type["LinkMark"] = 37] = "LinkMark";
68
+ Type[Type["EmphasisMark"] = 38] = "EmphasisMark";
69
+ Type[Type["CodeMark"] = 39] = "CodeMark";
70
+ Type[Type["CodeText"] = 40] = "CodeText";
71
+ Type[Type["CodeInfo"] = 41] = "CodeInfo";
72
+ Type[Type["LinkTitle"] = 42] = "LinkTitle";
73
+ Type[Type["LinkLabel"] = 43] = "LinkLabel";
74
+ Type[Type["URL"] = 44] = "URL";
75
+ })(Type || (Type = {}));
76
+ /**
77
+ Data structure used to accumulate a block's content during [leaf
78
+ block parsing](#BlockParser.leaf).
79
+ */
80
+ var LeafBlock = class {
81
+ /**
82
+ @internal
83
+ */
84
+ constructor(start, content) {
85
+ this.start = start;
86
+ this.content = content;
87
+ /**
88
+ @internal
89
+ */
90
+ this.marks = [];
91
+ /**
92
+ The block parsers active for this block.
93
+ */
94
+ this.parsers = [];
95
+ }
96
+ };
97
+ /**
98
+ Data structure used during block-level per-line parsing.
99
+ */
100
+ var Line = class {
101
+ constructor() {
102
+ /**
103
+ The line's full text.
104
+ */
105
+ this.text = "";
106
+ /**
107
+ The base indent provided by the composite contexts (that have
108
+ been handled so far).
109
+ */
110
+ this.baseIndent = 0;
111
+ /**
112
+ The string position corresponding to the base indent.
113
+ */
114
+ this.basePos = 0;
115
+ /**
116
+ The number of contexts handled @internal
117
+ */
118
+ this.depth = 0;
119
+ /**
120
+ Any markers (i.e. block quote markers) parsed for the contexts.
121
+ A block parser that moves across lines, covering such marks, may
122
+ need to include these in its node structure.
123
+ */
124
+ this.markers = [];
125
+ /**
126
+ The position of the next non-whitespace character beyond any
127
+ list, blockquote, or other composite block markers.
128
+ */
129
+ this.pos = 0;
130
+ /**
131
+ The column of the next non-whitespace character.
132
+ */
133
+ this.indent = 0;
134
+ /**
135
+ The character code of the character after `pos`.
136
+ */
137
+ this.next = -1;
138
+ }
139
+ /**
140
+ @internal
141
+ */
142
+ forward() {
143
+ if (this.basePos > this.pos) this.forwardInner();
144
+ }
145
+ /**
146
+ @internal
147
+ */
148
+ forwardInner() {
149
+ let newPos = this.skipSpace(this.basePos);
150
+ this.indent = this.countIndent(newPos, this.pos, this.indent);
151
+ this.pos = newPos;
152
+ this.next = newPos == this.text.length ? -1 : this.text.charCodeAt(newPos);
153
+ }
154
+ /**
155
+ Skip whitespace after the given position, return the position of
156
+ the next non-space character or the end of the line if there's
157
+ only space after `from`.
158
+ */
159
+ skipSpace(from) {
160
+ return skipSpace(this.text, from);
161
+ }
162
+ /**
163
+ @internal
164
+ */
165
+ reset(text) {
166
+ this.text = text;
167
+ this.baseIndent = this.basePos = this.pos = this.indent = 0;
168
+ this.forwardInner();
169
+ this.depth = 1;
170
+ while (this.markers.length) this.markers.pop();
171
+ }
172
+ /**
173
+ Move the line's base position forward to the given position.
174
+ This should only be called by composite [block
175
+ parsers](#BlockParser.parse) or [markup skipping
176
+ functions](#NodeSpec.composite).
177
+ */
178
+ moveBase(to) {
179
+ this.basePos = to;
180
+ this.baseIndent = this.countIndent(to, this.pos, this.indent);
181
+ }
182
+ /**
183
+ Move the line's base position forward to the given _column_.
184
+ */
185
+ moveBaseColumn(indent) {
186
+ this.baseIndent = indent;
187
+ this.basePos = this.findColumn(indent);
188
+ }
189
+ /**
190
+ Store a composite-block-level marker. Should be called from
191
+ [markup skipping functions](#NodeSpec.composite) when they
192
+ consume any non-whitespace characters.
193
+ */
194
+ addMarker(elt) {
195
+ this.markers.push(elt);
196
+ }
197
+ /**
198
+ Find the column position at `to`, optionally starting at a given
199
+ position and column.
200
+ */
201
+ countIndent(to, from = 0, indent = 0) {
202
+ for (let i = from; i < to; i++) indent += this.text.charCodeAt(i) == 9 ? 4 - indent % 4 : 1;
203
+ return indent;
204
+ }
205
+ /**
206
+ Find the position corresponding to the given column.
207
+ */
208
+ findColumn(goal) {
209
+ let i = 0;
210
+ for (let indent = 0; i < this.text.length && indent < goal; i++) indent += this.text.charCodeAt(i) == 9 ? 4 - indent % 4 : 1;
211
+ return i;
212
+ }
213
+ /**
214
+ @internal
215
+ */
216
+ scrub() {
217
+ if (!this.baseIndent) return this.text;
218
+ let result = "";
219
+ for (let i = 0; i < this.basePos; i++) result += " ";
220
+ return result + this.text.slice(this.basePos);
221
+ }
222
+ };
223
+ function skipForList(bl, cx, line) {
224
+ if (line.pos == line.text.length || bl != cx.block && line.indent >= cx.stack[line.depth + 1].value + line.baseIndent) return true;
225
+ if (line.indent >= line.baseIndent + 4) return false;
226
+ let size = (bl.type == Type.OrderedList ? isOrderedList : isBulletList)(line, cx, false);
227
+ return size > 0 && (bl.type != Type.BulletList || isHorizontalRule(line, cx, false) < 0) && line.text.charCodeAt(line.pos + size - 1) == bl.value;
228
+ }
229
+ const DefaultSkipMarkup = {
230
+ [Type.Blockquote](bl, cx, line) {
231
+ if (line.next != 62) return false;
232
+ line.markers.push(elt(Type.QuoteMark, cx.lineStart + line.pos, cx.lineStart + line.pos + 1));
233
+ line.moveBase(line.pos + (space(line.text.charCodeAt(line.pos + 1)) ? 2 : 1));
234
+ bl.end = cx.lineStart + line.text.length;
235
+ return true;
236
+ },
237
+ [Type.ListItem](bl, _cx, line) {
238
+ if (line.indent < line.baseIndent + bl.value && line.next > -1) return false;
239
+ line.moveBaseColumn(line.baseIndent + bl.value);
240
+ return true;
241
+ },
242
+ [Type.OrderedList]: skipForList,
243
+ [Type.BulletList]: skipForList,
244
+ [Type.Document]() {
245
+ return true;
246
+ }
247
+ };
248
+ function space(ch) {
249
+ return ch == 32 || ch == 9 || ch == 10 || ch == 13;
250
+ }
251
+ function skipSpace(line, i = 0) {
252
+ while (i < line.length && space(line.charCodeAt(i))) i++;
253
+ return i;
254
+ }
255
+ function skipSpaceBack(line, i, to) {
256
+ while (i > to && space(line.charCodeAt(i - 1))) i--;
257
+ return i;
258
+ }
259
+ function isFencedCode(line) {
260
+ if (line.next != 96 && line.next != 126) return -1;
261
+ let pos = line.pos + 1;
262
+ while (pos < line.text.length && line.text.charCodeAt(pos) == line.next) pos++;
263
+ if (pos < line.pos + 3) return -1;
264
+ if (line.next == 96) {
265
+ for (let i = pos; i < line.text.length; i++) if (line.text.charCodeAt(i) == 96) return -1;
266
+ }
267
+ return pos;
268
+ }
269
+ function isBlockquote(line) {
270
+ return line.next != 62 ? -1 : line.text.charCodeAt(line.pos + 1) == 32 ? 2 : 1;
271
+ }
272
+ function isHorizontalRule(line, cx, breaking) {
273
+ if (line.next != 42 && line.next != 45 && line.next != 95) return -1;
274
+ let count = 1;
275
+ for (let pos = line.pos + 1; pos < line.text.length; pos++) {
276
+ let ch = line.text.charCodeAt(pos);
277
+ if (ch == line.next) count++;
278
+ else if (!space(ch)) return -1;
279
+ }
280
+ if (breaking && line.next == 45 && isSetextUnderline(line) > -1 && line.depth == cx.stack.length && cx.parser.leafBlockParsers.indexOf(DefaultLeafBlocks.SetextHeading) > -1) return -1;
281
+ return count < 3 ? -1 : 1;
282
+ }
283
+ function inList(cx, type) {
284
+ for (let i = cx.stack.length - 1; i >= 0; i--) if (cx.stack[i].type == type) return true;
285
+ return false;
286
+ }
287
+ function isBulletList(line, cx, breaking) {
288
+ return (line.next == 45 || line.next == 43 || line.next == 42) && (line.pos == line.text.length - 1 || space(line.text.charCodeAt(line.pos + 1))) && (!breaking || inList(cx, Type.BulletList) || line.skipSpace(line.pos + 2) < line.text.length) ? 1 : -1;
289
+ }
290
+ function isOrderedList(line, cx, breaking) {
291
+ let pos = line.pos, next = line.next;
292
+ for (;;) {
293
+ if (next >= 48 && next <= 57) pos++;
294
+ else break;
295
+ if (pos == line.text.length) return -1;
296
+ next = line.text.charCodeAt(pos);
297
+ }
298
+ if (pos == line.pos || pos > line.pos + 9 || next != 46 && next != 41 || pos < line.text.length - 1 && !space(line.text.charCodeAt(pos + 1)) || breaking && !inList(cx, Type.OrderedList) && (line.skipSpace(pos + 1) == line.text.length || pos > line.pos + 1 || line.next != 49)) return -1;
299
+ return pos + 1 - line.pos;
300
+ }
301
+ function isAtxHeading(line) {
302
+ if (line.next != 35) return -1;
303
+ let pos = line.pos + 1;
304
+ while (pos < line.text.length && line.text.charCodeAt(pos) == 35) pos++;
305
+ if (pos < line.text.length && line.text.charCodeAt(pos) != 32) return -1;
306
+ let size = pos - line.pos;
307
+ return size > 6 ? -1 : size;
308
+ }
309
+ function isSetextUnderline(line) {
310
+ if (line.next != 45 && line.next != 61 || line.indent >= line.baseIndent + 4) return -1;
311
+ let pos = line.pos + 1;
312
+ while (pos < line.text.length && line.text.charCodeAt(pos) == line.next) pos++;
313
+ let end = pos;
314
+ while (pos < line.text.length && space(line.text.charCodeAt(pos))) pos++;
315
+ return pos == line.text.length ? end : -1;
316
+ }
317
+ const EmptyLine = /^[ \t]*$/, CommentEnd = /-->/, ProcessingEnd = /\?>/;
318
+ const HTMLBlockStyle = [
319
+ [/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
320
+ [/^\s*<!--/, CommentEnd],
321
+ [/^\s*<\?/, ProcessingEnd],
322
+ [/^\s*<![A-Z]/, />/],
323
+ [/^\s*<!\[CDATA\[/, /\]\]>/],
324
+ [/^\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, EmptyLine],
325
+ [/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, EmptyLine]
326
+ ];
327
+ function isHTMLBlock(line, _cx, breaking) {
328
+ if (line.next != 60) return -1;
329
+ let rest = line.text.slice(line.pos);
330
+ for (let i = 0, e = HTMLBlockStyle.length - (breaking ? 1 : 0); i < e; i++) if (HTMLBlockStyle[i][0].test(rest)) return i;
331
+ return -1;
332
+ }
333
+ function getListIndent(line, pos) {
334
+ let indentAfter = line.countIndent(pos, line.pos, line.indent);
335
+ let skipped = line.skipSpace(pos);
336
+ let indented = line.countIndent(skipped, pos, indentAfter);
337
+ return indented >= indentAfter + 5 || skipped == line.text.length ? indentAfter + 1 : indented;
338
+ }
339
+ function addCodeText(marks, from, to) {
340
+ let last = marks.length - 1;
341
+ if (last >= 0 && marks[last].to == from && marks[last].type == Type.CodeText) marks[last].to = to;
342
+ else marks.push(elt(Type.CodeText, from, to));
343
+ }
344
+ const DefaultBlockParsers = {
345
+ LinkReference: void 0,
346
+ IndentedCode(cx, line) {
347
+ let base = line.baseIndent + 4;
348
+ if (line.indent < base) return false;
349
+ let start = line.findColumn(base);
350
+ let from = cx.lineStart + start, to = cx.lineStart + line.text.length;
351
+ let marks = [], pendingMarks = [];
352
+ addCodeText(marks, from, to);
353
+ while (cx.nextLine() && line.depth >= cx.stack.length) if (line.pos == line.text.length) {
354
+ addCodeText(pendingMarks, cx.lineStart - 1, cx.lineStart);
355
+ for (let m of line.markers) pendingMarks.push(m);
356
+ } else if (line.indent < base) break;
357
+ else {
358
+ if (pendingMarks.length) {
359
+ for (let m of pendingMarks) if (m.type == Type.CodeText) addCodeText(marks, m.from, m.to);
360
+ else marks.push(m);
361
+ pendingMarks = [];
362
+ }
363
+ addCodeText(marks, cx.lineStart - 1, cx.lineStart);
364
+ for (let m of line.markers) marks.push(m);
365
+ to = cx.lineStart + line.text.length;
366
+ let codeStart = cx.lineStart + line.findColumn(line.baseIndent + 4);
367
+ if (codeStart < to) addCodeText(marks, codeStart, to);
368
+ }
369
+ if (pendingMarks.length) {
370
+ pendingMarks = pendingMarks.filter((m) => m.type != Type.CodeText);
371
+ if (pendingMarks.length) line.markers = pendingMarks.concat(line.markers);
372
+ }
373
+ cx.addNode(cx.buffer.writeElements(marks, -from).finish(Type.CodeBlock, to - from), from);
374
+ return true;
375
+ },
376
+ FencedCode(cx, line) {
377
+ let fenceEnd = isFencedCode(line);
378
+ if (fenceEnd < 0) return false;
379
+ let from = cx.lineStart + line.pos, ch = line.next, len = fenceEnd - line.pos;
380
+ let infoFrom = line.skipSpace(fenceEnd), infoTo = skipSpaceBack(line.text, line.text.length, infoFrom);
381
+ let marks = [elt(Type.CodeMark, from, from + len)];
382
+ if (infoFrom < infoTo) marks.push(elt(Type.CodeInfo, cx.lineStart + infoFrom, cx.lineStart + infoTo));
383
+ for (let first = true, empty = true, hasLine = false; cx.nextLine() && line.depth >= cx.stack.length; first = false) {
384
+ let i = line.pos;
385
+ if (line.indent - line.baseIndent < 4) while (i < line.text.length && line.text.charCodeAt(i) == ch) i++;
386
+ if (i - line.pos >= len && line.skipSpace(i) == line.text.length) {
387
+ for (let m of line.markers) marks.push(m);
388
+ if (empty && hasLine) addCodeText(marks, cx.lineStart - 1, cx.lineStart);
389
+ marks.push(elt(Type.CodeMark, cx.lineStart + line.pos, cx.lineStart + i));
390
+ cx.nextLine();
391
+ break;
392
+ } else {
393
+ hasLine = true;
394
+ if (!first) {
395
+ addCodeText(marks, cx.lineStart - 1, cx.lineStart);
396
+ empty = false;
397
+ }
398
+ for (let m of line.markers) marks.push(m);
399
+ let textStart = cx.lineStart + line.basePos, textEnd = cx.lineStart + line.text.length;
400
+ if (textStart < textEnd) {
401
+ addCodeText(marks, textStart, textEnd);
402
+ empty = false;
403
+ }
404
+ }
405
+ }
406
+ cx.addNode(cx.buffer.writeElements(marks, -from).finish(Type.FencedCode, cx.prevLineEnd() - from), from);
407
+ return true;
408
+ },
409
+ Blockquote(cx, line) {
410
+ let size = isBlockquote(line);
411
+ if (size < 0) return false;
412
+ cx.startContext(Type.Blockquote, line.pos);
413
+ cx.addNode(Type.QuoteMark, cx.lineStart + line.pos, cx.lineStart + line.pos + 1);
414
+ line.moveBase(line.pos + size);
415
+ return null;
416
+ },
417
+ HorizontalRule(cx, line) {
418
+ if (isHorizontalRule(line, cx, false) < 0) return false;
419
+ let from = cx.lineStart + line.pos;
420
+ cx.nextLine();
421
+ cx.addNode(Type.HorizontalRule, from);
422
+ return true;
423
+ },
424
+ BulletList(cx, line) {
425
+ let size = isBulletList(line, cx, false);
426
+ if (size < 0) return false;
427
+ if (cx.block.type != Type.BulletList) cx.startContext(Type.BulletList, line.basePos, line.next);
428
+ let newBase = getListIndent(line, line.pos + 1);
429
+ cx.startContext(Type.ListItem, line.basePos, newBase - line.baseIndent);
430
+ cx.addNode(Type.ListMark, cx.lineStart + line.pos, cx.lineStart + line.pos + size);
431
+ line.moveBaseColumn(newBase);
432
+ return null;
433
+ },
434
+ OrderedList(cx, line) {
435
+ let size = isOrderedList(line, cx, false);
436
+ if (size < 0) return false;
437
+ if (cx.block.type != Type.OrderedList) cx.startContext(Type.OrderedList, line.basePos, line.text.charCodeAt(line.pos + size - 1));
438
+ let newBase = getListIndent(line, line.pos + size);
439
+ cx.startContext(Type.ListItem, line.basePos, newBase - line.baseIndent);
440
+ cx.addNode(Type.ListMark, cx.lineStart + line.pos, cx.lineStart + line.pos + size);
441
+ line.moveBaseColumn(newBase);
442
+ return null;
443
+ },
444
+ ATXHeading(cx, line) {
445
+ let size = isAtxHeading(line);
446
+ if (size < 0) return false;
447
+ let off = line.pos, from = cx.lineStart + off;
448
+ let endOfSpace = skipSpaceBack(line.text, line.text.length, off), after = endOfSpace;
449
+ while (after > off && line.text.charCodeAt(after - 1) == line.next) after--;
450
+ if (after == endOfSpace || after == off || !space(line.text.charCodeAt(after - 1))) after = line.text.length;
451
+ let buf = cx.buffer.write(Type.HeaderMark, 0, size).writeElements(cx.parser.parseInline(line.text.slice(off + size + 1, after), from + size + 1), -from);
452
+ if (after < line.text.length) buf.write(Type.HeaderMark, after - off, endOfSpace - off);
453
+ let node = buf.finish(Type.ATXHeading1 - 1 + size, line.text.length - off);
454
+ cx.nextLine();
455
+ cx.addNode(node, from);
456
+ return true;
457
+ },
458
+ HTMLBlock(cx, line) {
459
+ let type = isHTMLBlock(line, cx, false);
460
+ if (type < 0) return false;
461
+ let from = cx.lineStart + line.pos, end = HTMLBlockStyle[type][1];
462
+ let marks = [], trailing = end != EmptyLine;
463
+ while (!end.test(line.text) && cx.nextLine()) {
464
+ if (line.depth < cx.stack.length) {
465
+ trailing = false;
466
+ break;
467
+ }
468
+ for (let m of line.markers) marks.push(m);
469
+ }
470
+ if (trailing) cx.nextLine();
471
+ let nodeType = end == CommentEnd ? Type.CommentBlock : end == ProcessingEnd ? Type.ProcessingInstructionBlock : Type.HTMLBlock;
472
+ let to = cx.prevLineEnd();
473
+ cx.addNode(cx.buffer.writeElements(marks, -from).finish(nodeType, to - from), from);
474
+ return true;
475
+ },
476
+ SetextHeading: void 0
477
+ };
478
+ var LinkReferenceParser = class {
479
+ constructor(leaf) {
480
+ this.stage = 0;
481
+ this.elts = [];
482
+ this.pos = 0;
483
+ this.start = leaf.start;
484
+ this.advance(leaf.content);
485
+ }
486
+ nextLine(cx, line, leaf) {
487
+ if (this.stage == -1) return false;
488
+ let content = leaf.content + "\n" + line.scrub();
489
+ let finish = this.advance(content);
490
+ if (finish > -1 && finish < content.length) return this.complete(cx, leaf, finish);
491
+ return false;
492
+ }
493
+ finish(cx, leaf) {
494
+ if ((this.stage == 2 || this.stage == 3) && skipSpace(leaf.content, this.pos) == leaf.content.length) return this.complete(cx, leaf, leaf.content.length);
495
+ return false;
496
+ }
497
+ complete(cx, leaf, len) {
498
+ cx.addLeafElement(leaf, elt(Type.LinkReference, this.start, this.start + len, this.elts));
499
+ return true;
500
+ }
501
+ nextStage(elt) {
502
+ if (elt) {
503
+ this.pos = elt.to - this.start;
504
+ this.elts.push(elt);
505
+ this.stage++;
506
+ return true;
507
+ }
508
+ if (elt === false) this.stage = -1;
509
+ return false;
510
+ }
511
+ advance(content) {
512
+ for (;;) if (this.stage == -1) return -1;
513
+ else if (this.stage == 0) {
514
+ if (!this.nextStage(parseLinkLabel(content, this.pos, this.start, true))) return -1;
515
+ if (content.charCodeAt(this.pos) != 58) return this.stage = -1;
516
+ this.elts.push(elt(Type.LinkMark, this.pos + this.start, this.pos + this.start + 1));
517
+ this.pos++;
518
+ } else if (this.stage == 1) {
519
+ if (!this.nextStage(parseURL(content, skipSpace(content, this.pos), this.start))) return -1;
520
+ } else if (this.stage == 2) {
521
+ let skip = skipSpace(content, this.pos), end = 0;
522
+ if (skip > this.pos) {
523
+ let title = parseLinkTitle(content, skip, this.start);
524
+ if (title) {
525
+ let titleEnd = lineEnd(content, title.to - this.start);
526
+ if (titleEnd > 0) {
527
+ this.nextStage(title);
528
+ end = titleEnd;
529
+ }
530
+ }
531
+ }
532
+ if (!end) end = lineEnd(content, this.pos);
533
+ return end > 0 && end < content.length ? end : -1;
534
+ } else return lineEnd(content, this.pos);
535
+ }
536
+ };
537
+ function lineEnd(text, pos) {
538
+ for (; pos < text.length; pos++) {
539
+ let next = text.charCodeAt(pos);
540
+ if (next == 10) break;
541
+ if (!space(next)) return -1;
542
+ }
543
+ return pos;
544
+ }
545
+ var SetextHeadingParser = class {
546
+ nextLine(cx, line, leaf) {
547
+ let underline = line.depth < cx.stack.length ? -1 : isSetextUnderline(line);
548
+ let next = line.next;
549
+ if (underline < 0) return false;
550
+ let underlineMark = elt(Type.HeaderMark, cx.lineStart + line.pos, cx.lineStart + underline);
551
+ cx.nextLine();
552
+ cx.addLeafElement(leaf, elt(next == 61 ? Type.SetextHeading1 : Type.SetextHeading2, leaf.start, cx.prevLineEnd(), [...cx.parser.parseInline(leaf.content, leaf.start), underlineMark]));
553
+ return true;
554
+ }
555
+ finish() {
556
+ return false;
557
+ }
558
+ };
559
+ const DefaultLeafBlocks = {
560
+ LinkReference(_, leaf) {
561
+ return leaf.content.charCodeAt(0) == 91 ? new LinkReferenceParser(leaf) : null;
562
+ },
563
+ SetextHeading() {
564
+ return new SetextHeadingParser();
565
+ }
566
+ };
567
+ const DefaultEndLeaf = [
568
+ (_, line) => isAtxHeading(line) >= 0,
569
+ (_, line) => isFencedCode(line) >= 0,
570
+ (_, line) => isBlockquote(line) >= 0,
571
+ (p, line) => isBulletList(line, p, true) >= 0,
572
+ (p, line) => isOrderedList(line, p, true) >= 0,
573
+ (p, line) => isHorizontalRule(line, p, true) >= 0,
574
+ (p, line) => isHTMLBlock(line, p, true) >= 0
575
+ ];
576
+ const scanLineResult = {
577
+ text: "",
578
+ end: 0
579
+ };
580
+ /**
581
+ Block-level parsing functions get access to this context object.
582
+ */
583
+ var BlockContext = class {
584
+ /**
585
+ @internal
586
+ */
587
+ constructor(parser, input, fragments, ranges) {
588
+ this.parser = parser;
589
+ this.input = input;
590
+ this.ranges = ranges;
591
+ this.line = new Line();
592
+ this.atEnd = false;
593
+ /**
594
+ For reused nodes on gaps, we can't directly put the original
595
+ node into the tree, since that may be bigger than its parent.
596
+ When this happens, we create a dummy tree that is replaced by
597
+ the proper node in `injectGaps` @internal
598
+ */
599
+ this.reusePlaceholders = /* @__PURE__ */ new Map();
600
+ this.stoppedAt = null;
601
+ /**
602
+ The range index that absoluteLineStart points into @internal
603
+ */
604
+ this.rangeI = 0;
605
+ this.to = ranges[ranges.length - 1].to;
606
+ this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = ranges[0].from;
607
+ this.block = CompositeBlock.create(Type.Document, 0, this.lineStart, 0, 0);
608
+ this.stack = [this.block];
609
+ this.fragments = fragments.length ? new FragmentCursor(fragments, input) : null;
610
+ this.readLine();
611
+ }
612
+ get parsedPos() {
613
+ return this.absoluteLineStart;
614
+ }
615
+ advance() {
616
+ if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt) return this.finish();
617
+ let { line } = this;
618
+ for (;;) {
619
+ for (let markI = 0;;) {
620
+ let next = line.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
621
+ while (markI < line.markers.length && (!next || line.markers[markI].from < next.end)) {
622
+ let mark = line.markers[markI++];
623
+ this.addNode(mark.type, mark.from, mark.to);
624
+ }
625
+ if (!next) break;
626
+ this.finishContext();
627
+ }
628
+ if (line.pos < line.text.length) break;
629
+ if (!this.nextLine()) return this.finish();
630
+ }
631
+ if (this.fragments && this.reuseFragment(line.basePos)) return null;
632
+ start: for (;;) {
633
+ for (let type of this.parser.blockParsers) if (type) {
634
+ let result = type(this, line);
635
+ if (result != false) {
636
+ if (result == true) return null;
637
+ line.forward();
638
+ continue start;
639
+ }
640
+ }
641
+ break;
642
+ }
643
+ if (line.pos == line.text.length) return this.nextLine() ? null : this.finish();
644
+ let leaf = new LeafBlock(this.lineStart + line.pos, line.text.slice(line.pos));
645
+ for (let parse of this.parser.leafBlockParsers) if (parse) {
646
+ let parser = parse(this, leaf);
647
+ if (parser) leaf.parsers.push(parser);
648
+ }
649
+ lines: while (this.nextLine()) {
650
+ if (line.pos == line.text.length) break;
651
+ if (line.indent < line.baseIndent + 4) {
652
+ for (let stop of this.parser.endLeafBlock) if (stop(this, line, leaf)) break lines;
653
+ }
654
+ for (let parser of leaf.parsers) if (parser.nextLine(this, line, leaf)) return null;
655
+ leaf.content += "\n" + line.scrub();
656
+ for (let m of line.markers) leaf.marks.push(m);
657
+ }
658
+ this.finishLeaf(leaf);
659
+ return null;
660
+ }
661
+ stopAt(pos) {
662
+ if (this.stoppedAt != null && this.stoppedAt < pos) throw new RangeError("Can't move stoppedAt forward");
663
+ this.stoppedAt = pos;
664
+ }
665
+ reuseFragment(start) {
666
+ if (!this.fragments.moveTo(this.absoluteLineStart + start, this.absoluteLineStart) || !this.fragments.matches(this.block.hash)) return false;
667
+ let taken = this.fragments.takeNodes(this);
668
+ if (!taken) return false;
669
+ this.absoluteLineStart += taken;
670
+ this.lineStart = toRelative(this.absoluteLineStart, this.ranges);
671
+ this.moveRangeI();
672
+ if (this.absoluteLineStart < this.to) {
673
+ this.lineStart++;
674
+ this.absoluteLineStart++;
675
+ this.readLine();
676
+ } else {
677
+ this.atEnd = true;
678
+ this.readLine();
679
+ }
680
+ return true;
681
+ }
682
+ /**
683
+ The number of parent blocks surrounding the current block.
684
+ */
685
+ get depth() {
686
+ return this.stack.length;
687
+ }
688
+ /**
689
+ Get the type of the parent block at the given depth. When no
690
+ depth is passed, return the type of the innermost parent.
691
+ */
692
+ parentType(depth = this.depth - 1) {
693
+ return this.parser.nodeSet.types[this.stack[depth].type];
694
+ }
695
+ /**
696
+ Move to the next input line. This should only be called by
697
+ (non-composite) [block parsers](#BlockParser.parse) that consume
698
+ the line directly, or leaf block parser
699
+ [`nextLine`](#LeafBlockParser.nextLine) methods when they
700
+ consume the current line (and return true).
701
+ */
702
+ nextLine() {
703
+ this.lineStart += this.line.text.length;
704
+ if (this.absoluteLineEnd >= this.to) {
705
+ this.absoluteLineStart = this.absoluteLineEnd;
706
+ this.atEnd = true;
707
+ this.readLine();
708
+ return false;
709
+ } else {
710
+ this.lineStart++;
711
+ this.absoluteLineStart = this.absoluteLineEnd + 1;
712
+ this.moveRangeI();
713
+ this.readLine();
714
+ return true;
715
+ }
716
+ }
717
+ /**
718
+ Retrieve the text of the line after the current one, without
719
+ actually moving the context's current line forward.
720
+ */
721
+ peekLine() {
722
+ return this.scanLine(this.absoluteLineEnd + 1).text;
723
+ }
724
+ moveRangeI() {
725
+ while (this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to) {
726
+ this.rangeI++;
727
+ this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
728
+ }
729
+ }
730
+ /**
731
+ @internal
732
+ Collect the text for the next line.
733
+ */
734
+ scanLine(start) {
735
+ let r = scanLineResult;
736
+ r.end = start;
737
+ if (start >= this.to) r.text = "";
738
+ else {
739
+ r.text = this.lineChunkAt(start);
740
+ r.end += r.text.length;
741
+ if (this.ranges.length > 1) {
742
+ let textOffset = this.absoluteLineStart, rangeI = this.rangeI;
743
+ while (this.ranges[rangeI].to < r.end) {
744
+ rangeI++;
745
+ let nextFrom = this.ranges[rangeI].from;
746
+ let after = this.lineChunkAt(nextFrom);
747
+ r.end = nextFrom + after.length;
748
+ r.text = r.text.slice(0, this.ranges[rangeI - 1].to - textOffset) + after;
749
+ textOffset = r.end - r.text.length;
750
+ }
751
+ }
752
+ }
753
+ return r;
754
+ }
755
+ /**
756
+ @internal
757
+ Populate this.line with the content of the next line. Skip
758
+ leading characters covered by composite blocks.
759
+ */
760
+ readLine() {
761
+ let { line } = this, { text, end } = this.scanLine(this.absoluteLineStart);
762
+ this.absoluteLineEnd = end;
763
+ line.reset(text);
764
+ for (; line.depth < this.stack.length; line.depth++) {
765
+ let cx = this.stack[line.depth], handler = this.parser.skipContextMarkup[cx.type];
766
+ if (!handler) throw new Error("Unhandled block context " + Type[cx.type]);
767
+ let marks = this.line.markers.length;
768
+ if (!handler(cx, this, line)) {
769
+ if (this.line.markers.length > marks) cx.end = this.line.markers[this.line.markers.length - 1].to;
770
+ line.forward();
771
+ break;
772
+ }
773
+ line.forward();
774
+ }
775
+ }
776
+ lineChunkAt(pos) {
777
+ let next = this.input.chunk(pos), text;
778
+ if (!this.input.lineChunks) {
779
+ let eol = next.indexOf("\n");
780
+ text = eol < 0 ? next : next.slice(0, eol);
781
+ } else text = next == "\n" ? "" : next;
782
+ return pos + text.length > this.to ? text.slice(0, this.to - pos) : text;
783
+ }
784
+ /**
785
+ The end position of the previous line.
786
+ */
787
+ prevLineEnd() {
788
+ return this.atEnd ? this.lineStart : this.lineStart - 1;
789
+ }
790
+ /**
791
+ @internal
792
+ */
793
+ startContext(type, start, value = 0) {
794
+ this.block = CompositeBlock.create(type, value, this.lineStart + start, this.block.hash, this.lineStart + this.line.text.length);
795
+ this.stack.push(this.block);
796
+ }
797
+ /**
798
+ Start a composite block. Should only be called from [block
799
+ parser functions](#BlockParser.parse) that return null.
800
+ */
801
+ startComposite(type, start, value = 0) {
802
+ this.startContext(this.parser.getNodeType(type), start, value);
803
+ }
804
+ /**
805
+ @internal
806
+ */
807
+ addNode(block, from, to) {
808
+ if (typeof block == "number") block = new Tree(this.parser.nodeSet.types[block], none, none, (to !== null && to !== void 0 ? to : this.prevLineEnd()) - from);
809
+ this.block.addChild(block, from - this.block.from);
810
+ }
811
+ /**
812
+ Add a block element. Can be called by [block
813
+ parsers](#BlockParser.parse).
814
+ */
815
+ addElement(elt) {
816
+ this.block.addChild(elt.toTree(this.parser.nodeSet), elt.from - this.block.from);
817
+ }
818
+ /**
819
+ Add a block element from a [leaf parser](#LeafBlockParser). This
820
+ makes sure any extra composite block markup (such as blockquote
821
+ markers) inside the block are also added to the syntax tree.
822
+ */
823
+ addLeafElement(leaf, elt) {
824
+ this.addNode(this.buffer.writeElements(injectMarks(elt.children, leaf.marks), -elt.from).finish(elt.type, elt.to - elt.from), elt.from);
825
+ }
826
+ /**
827
+ @internal
828
+ */
829
+ finishContext() {
830
+ let cx = this.stack.pop();
831
+ let top = this.stack[this.stack.length - 1];
832
+ top.addChild(cx.toTree(this.parser.nodeSet), cx.from - top.from);
833
+ this.block = top;
834
+ }
835
+ finish() {
836
+ while (this.stack.length > 1) this.finishContext();
837
+ return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
838
+ }
839
+ addGaps(tree) {
840
+ return this.ranges.length > 1 ? injectGaps(this.ranges, 0, tree.topNode, this.ranges[0].from, this.reusePlaceholders) : tree;
841
+ }
842
+ /**
843
+ @internal
844
+ */
845
+ finishLeaf(leaf) {
846
+ for (let parser of leaf.parsers) if (parser.finish(this, leaf)) return;
847
+ let inline = injectMarks(this.parser.parseInline(leaf.content, leaf.start), leaf.marks);
848
+ this.addNode(this.buffer.writeElements(inline, -leaf.start).finish(Type.Paragraph, leaf.content.length), leaf.start);
849
+ }
850
+ elt(type, from, to, children) {
851
+ if (typeof type == "string") return elt(this.parser.getNodeType(type), from, to, children);
852
+ return new TreeElement(type, from);
853
+ }
854
+ /**
855
+ @internal
856
+ */
857
+ get buffer() {
858
+ return new Buffer(this.parser.nodeSet);
859
+ }
860
+ };
861
+ function injectGaps(ranges, rangeI, tree, offset, dummies) {
862
+ let rangeEnd = ranges[rangeI].to;
863
+ let children = [], positions = [], start = tree.from + offset;
864
+ function movePastNext(upto, inclusive) {
865
+ while (inclusive ? upto >= rangeEnd : upto > rangeEnd) {
866
+ let size = ranges[rangeI + 1].from - rangeEnd;
867
+ offset += size;
868
+ upto += size;
869
+ rangeI++;
870
+ rangeEnd = ranges[rangeI].to;
871
+ }
872
+ }
873
+ for (let ch = tree.firstChild; ch; ch = ch.nextSibling) {
874
+ movePastNext(ch.from + offset, true);
875
+ let from = ch.from + offset, node, reuse = dummies.get(ch.tree);
876
+ if (reuse) node = reuse;
877
+ else if (ch.to + offset > rangeEnd) {
878
+ node = injectGaps(ranges, rangeI, ch, offset, dummies);
879
+ movePastNext(ch.to + offset, false);
880
+ } else node = ch.toTree();
881
+ children.push(node);
882
+ positions.push(from - start);
883
+ }
884
+ movePastNext(tree.to + offset, false);
885
+ return new Tree(tree.type, children, positions, tree.to + offset - start, tree.tree ? tree.tree.propValues : void 0);
886
+ }
887
+ /**
888
+ A Markdown parser configuration.
889
+ */
890
+ var MarkdownParser = class MarkdownParser extends Parser {
891
+ /**
892
+ @internal
893
+ */
894
+ constructor(nodeSet, blockParsers, leafBlockParsers, blockNames, endLeafBlock, skipContextMarkup, inlineParsers, inlineNames, wrappers) {
895
+ super();
896
+ this.nodeSet = nodeSet;
897
+ this.blockParsers = blockParsers;
898
+ this.leafBlockParsers = leafBlockParsers;
899
+ this.blockNames = blockNames;
900
+ this.endLeafBlock = endLeafBlock;
901
+ this.skipContextMarkup = skipContextMarkup;
902
+ this.inlineParsers = inlineParsers;
903
+ this.inlineNames = inlineNames;
904
+ this.wrappers = wrappers;
905
+ /**
906
+ @internal
907
+ */
908
+ this.nodeTypes = Object.create(null);
909
+ for (let t of nodeSet.types) this.nodeTypes[t.name] = t.id;
910
+ }
911
+ createParse(input, fragments, ranges) {
912
+ let parse = new BlockContext(this, input, fragments, ranges);
913
+ for (let w of this.wrappers) parse = w(parse, input, fragments, ranges);
914
+ return parse;
915
+ }
916
+ /**
917
+ Reconfigure the parser.
918
+ */
919
+ configure(spec) {
920
+ let config = resolveConfig(spec);
921
+ if (!config) return this;
922
+ let { nodeSet, skipContextMarkup } = this;
923
+ let blockParsers = this.blockParsers.slice(), leafBlockParsers = this.leafBlockParsers.slice(), blockNames = this.blockNames.slice(), inlineParsers = this.inlineParsers.slice(), inlineNames = this.inlineNames.slice(), endLeafBlock = this.endLeafBlock.slice(), wrappers = this.wrappers;
924
+ if (nonEmpty(config.defineNodes)) {
925
+ skipContextMarkup = Object.assign({}, skipContextMarkup);
926
+ let nodeTypes = nodeSet.types.slice(), styles;
927
+ for (let s of config.defineNodes) {
928
+ let { name, block, composite, style } = typeof s == "string" ? { name: s } : s;
929
+ if (nodeTypes.some((t) => t.name == name)) continue;
930
+ if (composite) skipContextMarkup[nodeTypes.length] = (bl, cx, line) => composite(cx, line, bl.value);
931
+ let id = nodeTypes.length;
932
+ let group = composite ? ["Block", "BlockContext"] : !block ? void 0 : id >= Type.ATXHeading1 && id <= Type.SetextHeading2 ? [
933
+ "Block",
934
+ "LeafBlock",
935
+ "Heading"
936
+ ] : ["Block", "LeafBlock"];
937
+ nodeTypes.push(NodeType.define({
938
+ id,
939
+ name,
940
+ props: group && [[NodeProp.group, group]]
941
+ }));
942
+ if (style) {
943
+ if (!styles) styles = {};
944
+ if (Array.isArray(style) || style instanceof Tag) styles[name] = style;
945
+ else Object.assign(styles, style);
946
+ }
947
+ }
948
+ nodeSet = new NodeSet(nodeTypes);
949
+ if (styles) nodeSet = nodeSet.extend(styleTags(styles));
950
+ }
951
+ if (nonEmpty(config.props)) nodeSet = nodeSet.extend(...config.props);
952
+ if (nonEmpty(config.remove)) for (let rm of config.remove) {
953
+ let block = this.blockNames.indexOf(rm), inline = this.inlineNames.indexOf(rm);
954
+ if (block > -1) blockParsers[block] = leafBlockParsers[block] = void 0;
955
+ if (inline > -1) inlineParsers[inline] = void 0;
956
+ }
957
+ if (nonEmpty(config.parseBlock)) for (let spec of config.parseBlock) {
958
+ let found = blockNames.indexOf(spec.name);
959
+ if (found > -1) {
960
+ blockParsers[found] = spec.parse;
961
+ leafBlockParsers[found] = spec.leaf;
962
+ } else {
963
+ let pos = spec.before ? findName(blockNames, spec.before) : spec.after ? findName(blockNames, spec.after) + 1 : blockNames.length - 1;
964
+ blockParsers.splice(pos, 0, spec.parse);
965
+ leafBlockParsers.splice(pos, 0, spec.leaf);
966
+ blockNames.splice(pos, 0, spec.name);
967
+ }
968
+ if (spec.endLeaf) endLeafBlock.push(spec.endLeaf);
969
+ }
970
+ if (nonEmpty(config.parseInline)) for (let spec of config.parseInline) {
971
+ let found = inlineNames.indexOf(spec.name);
972
+ if (found > -1) inlineParsers[found] = spec.parse;
973
+ else {
974
+ let pos = spec.before ? findName(inlineNames, spec.before) : spec.after ? findName(inlineNames, spec.after) + 1 : inlineNames.length - 1;
975
+ inlineParsers.splice(pos, 0, spec.parse);
976
+ inlineNames.splice(pos, 0, spec.name);
977
+ }
978
+ }
979
+ if (config.wrap) wrappers = wrappers.concat(config.wrap);
980
+ return new MarkdownParser(nodeSet, blockParsers, leafBlockParsers, blockNames, endLeafBlock, skipContextMarkup, inlineParsers, inlineNames, wrappers);
981
+ }
982
+ /**
983
+ @internal
984
+ */
985
+ getNodeType(name) {
986
+ let found = this.nodeTypes[name];
987
+ if (found == null) throw new RangeError(`Unknown node type '${name}'`);
988
+ return found;
989
+ }
990
+ /**
991
+ Parse the given piece of inline text at the given offset,
992
+ returning an array of [`Element`](#Element) objects representing
993
+ the inline content.
994
+ */
995
+ parseInline(text, offset) {
996
+ let cx = new InlineContext(this, text, offset);
997
+ outer: for (let pos = offset; pos < cx.end;) {
998
+ let next = cx.char(pos);
999
+ for (let token of this.inlineParsers) if (token) {
1000
+ let result = token(cx, next, pos);
1001
+ if (result >= 0) {
1002
+ pos = result;
1003
+ continue outer;
1004
+ }
1005
+ }
1006
+ pos++;
1007
+ }
1008
+ return cx.resolveMarkers(0);
1009
+ }
1010
+ };
1011
+ function nonEmpty(a) {
1012
+ return a != null && a.length > 0;
1013
+ }
1014
+ function resolveConfig(spec) {
1015
+ if (!Array.isArray(spec)) return spec;
1016
+ if (spec.length == 0) return null;
1017
+ let conf = resolveConfig(spec[0]);
1018
+ if (spec.length == 1) return conf;
1019
+ let rest = resolveConfig(spec.slice(1));
1020
+ if (!rest || !conf) return conf || rest;
1021
+ let conc = (a, b) => (a || none).concat(b || none);
1022
+ let wrapA = conf.wrap, wrapB = rest.wrap;
1023
+ return {
1024
+ props: conc(conf.props, rest.props),
1025
+ defineNodes: conc(conf.defineNodes, rest.defineNodes),
1026
+ parseBlock: conc(conf.parseBlock, rest.parseBlock),
1027
+ parseInline: conc(conf.parseInline, rest.parseInline),
1028
+ remove: conc(conf.remove, rest.remove),
1029
+ wrap: !wrapA ? wrapB : !wrapB ? wrapA : (inner, input, fragments, ranges) => wrapA(wrapB(inner, input, fragments, ranges), input, fragments, ranges)
1030
+ };
1031
+ }
1032
+ function findName(names, name) {
1033
+ let found = names.indexOf(name);
1034
+ if (found < 0) throw new RangeError(`Position specified relative to unknown parser ${name}`);
1035
+ return found;
1036
+ }
1037
+ let nodeTypes = [NodeType.none];
1038
+ for (let i = 1, name; name = Type[i]; i++) nodeTypes[i] = NodeType.define({
1039
+ id: i,
1040
+ name,
1041
+ props: i >= Type.Escape ? [] : [[NodeProp.group, i in DefaultSkipMarkup ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
1042
+ top: name == "Document"
1043
+ });
1044
+ const none = [];
1045
+ var Buffer = class {
1046
+ constructor(nodeSet) {
1047
+ this.nodeSet = nodeSet;
1048
+ this.content = [];
1049
+ this.nodes = [];
1050
+ }
1051
+ write(type, from, to, children = 0) {
1052
+ this.content.push(type, from, to, 4 + children * 4);
1053
+ return this;
1054
+ }
1055
+ writeElements(elts, offset = 0) {
1056
+ for (let e of elts) e.writeTo(this, offset);
1057
+ return this;
1058
+ }
1059
+ finish(type, length) {
1060
+ return Tree.build({
1061
+ buffer: this.content,
1062
+ nodeSet: this.nodeSet,
1063
+ reused: this.nodes,
1064
+ topID: type,
1065
+ length
1066
+ });
1067
+ }
1068
+ };
1069
+ /**
1070
+ Elements are used to compose syntax nodes during parsing.
1071
+ */
1072
+ var Element = class {
1073
+ /**
1074
+ @internal
1075
+ */
1076
+ constructor(type, from, to, children = none) {
1077
+ this.type = type;
1078
+ this.from = from;
1079
+ this.to = to;
1080
+ this.children = children;
1081
+ }
1082
+ /**
1083
+ @internal
1084
+ */
1085
+ writeTo(buf, offset) {
1086
+ let startOff = buf.content.length;
1087
+ buf.writeElements(this.children, offset);
1088
+ buf.content.push(this.type, this.from + offset, this.to + offset, buf.content.length + 4 - startOff);
1089
+ }
1090
+ /**
1091
+ @internal
1092
+ */
1093
+ toTree(nodeSet) {
1094
+ return new Buffer(nodeSet).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
1095
+ }
1096
+ };
1097
+ var TreeElement = class {
1098
+ constructor(tree, from) {
1099
+ this.tree = tree;
1100
+ this.from = from;
1101
+ }
1102
+ get to() {
1103
+ return this.from + this.tree.length;
1104
+ }
1105
+ get type() {
1106
+ return this.tree.type.id;
1107
+ }
1108
+ get children() {
1109
+ return none;
1110
+ }
1111
+ writeTo(buf, offset) {
1112
+ buf.nodes.push(this.tree);
1113
+ buf.content.push(buf.nodes.length - 1, this.from + offset, this.to + offset, -1);
1114
+ }
1115
+ toTree() {
1116
+ return this.tree;
1117
+ }
1118
+ };
1119
+ function elt(type, from, to, children) {
1120
+ return new Element(type, from, to, children);
1121
+ }
1122
+ const EmphasisUnderscore = {
1123
+ resolve: "Emphasis",
1124
+ mark: "EmphasisMark"
1125
+ };
1126
+ const EmphasisAsterisk = {
1127
+ resolve: "Emphasis",
1128
+ mark: "EmphasisMark"
1129
+ };
1130
+ const LinkStart = {}, ImageStart = {};
1131
+ var InlineDelimiter = class {
1132
+ constructor(type, from, to, side) {
1133
+ this.type = type;
1134
+ this.from = from;
1135
+ this.to = to;
1136
+ this.side = side;
1137
+ }
1138
+ };
1139
+ const Escapable = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
1140
+ let Punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
1141
+ try {
1142
+ Punctuation = /* @__PURE__ */ new RegExp("[\\p{S}|\\p{P}]", "u");
1143
+ } catch (_) {}
1144
+ const DefaultInline = {
1145
+ Escape(cx, next, start) {
1146
+ if (next != 92 || start == cx.end - 1) return -1;
1147
+ let escaped = cx.char(start + 1);
1148
+ for (let i = 0; i < 32; i++) if (Escapable.charCodeAt(i) == escaped) return cx.append(elt(Type.Escape, start, start + 2));
1149
+ return -1;
1150
+ },
1151
+ Entity(cx, next, start) {
1152
+ if (next != 38) return -1;
1153
+ let m = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(cx.slice(start + 1, start + 31));
1154
+ return m ? cx.append(elt(Type.Entity, start, start + 1 + m[0].length)) : -1;
1155
+ },
1156
+ InlineCode(cx, next, start) {
1157
+ if (next != 96 || start && cx.char(start - 1) == 96) return -1;
1158
+ let pos = start + 1;
1159
+ while (pos < cx.end && cx.char(pos) == 96) pos++;
1160
+ let size = pos - start, curSize = 0;
1161
+ for (; pos < cx.end; pos++) if (cx.char(pos) == 96) {
1162
+ curSize++;
1163
+ if (curSize == size && cx.char(pos + 1) != 96) return cx.append(elt(Type.InlineCode, start, pos + 1, [elt(Type.CodeMark, start, start + size), elt(Type.CodeMark, pos + 1 - size, pos + 1)]));
1164
+ } else curSize = 0;
1165
+ return -1;
1166
+ },
1167
+ HTMLTag(cx, next, start) {
1168
+ if (next != 60 || start == cx.end - 1) return -1;
1169
+ let after = cx.slice(start + 1, cx.end);
1170
+ let url = /^(?:[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(after);
1171
+ if (url) return cx.append(elt(Type.Autolink, start, start + 1 + url[0].length, [
1172
+ elt(Type.LinkMark, start, start + 1),
1173
+ elt(Type.URL, start + 1, start + url[0].length),
1174
+ elt(Type.LinkMark, start + url[0].length, start + 1 + url[0].length)
1175
+ ]));
1176
+ let comment = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(after);
1177
+ if (comment) return cx.append(elt(Type.Comment, start, start + 1 + comment[0].length));
1178
+ let procInst = /^\?[^]*?\?>/.exec(after);
1179
+ if (procInst) return cx.append(elt(Type.ProcessingInstruction, start, start + 1 + procInst[0].length));
1180
+ let m = /^(?:![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(after);
1181
+ if (!m) return -1;
1182
+ return cx.append(elt(Type.HTMLTag, start, start + 1 + m[0].length));
1183
+ },
1184
+ Emphasis(cx, next, start) {
1185
+ if (next != 95 && next != 42) return -1;
1186
+ let pos = start + 1;
1187
+ while (cx.char(pos) == next) pos++;
1188
+ let before = cx.slice(start - 1, start), after = cx.slice(pos, pos + 1);
1189
+ let pBefore = Punctuation.test(before), pAfter = Punctuation.test(after);
1190
+ let sBefore = /\s|^$/.test(before), sAfter = /\s|^$/.test(after);
1191
+ let leftFlanking = !sAfter && (!pAfter || sBefore || pBefore);
1192
+ let rightFlanking = !sBefore && (!pBefore || sAfter || pAfter);
1193
+ let canOpen = leftFlanking && (next == 42 || !rightFlanking || pBefore);
1194
+ let canClose = rightFlanking && (next == 42 || !leftFlanking || pAfter);
1195
+ return cx.append(new InlineDelimiter(next == 95 ? EmphasisUnderscore : EmphasisAsterisk, start, pos, (canOpen ? 1 : 0) | (canClose ? 2 : 0)));
1196
+ },
1197
+ HardBreak(cx, next, start) {
1198
+ if (next == 92 && cx.char(start + 1) == 10) return cx.append(elt(Type.HardBreak, start, start + 2));
1199
+ if (next == 32) {
1200
+ let pos = start + 1;
1201
+ while (cx.char(pos) == 32) pos++;
1202
+ if (cx.char(pos) == 10 && pos >= start + 2) return cx.append(elt(Type.HardBreak, start, pos + 1));
1203
+ }
1204
+ return -1;
1205
+ },
1206
+ Link(cx, next, start) {
1207
+ return next == 91 ? cx.append(new InlineDelimiter(LinkStart, start, start + 1, 1)) : -1;
1208
+ },
1209
+ Image(cx, next, start) {
1210
+ return next == 33 && cx.char(start + 1) == 91 ? cx.append(new InlineDelimiter(ImageStart, start, start + 2, 1)) : -1;
1211
+ },
1212
+ LinkEnd(cx, next, start) {
1213
+ if (next != 93) return -1;
1214
+ for (let i = cx.parts.length - 1; i >= 0; i--) {
1215
+ let part = cx.parts[i];
1216
+ if (part instanceof InlineDelimiter && (part.type == LinkStart || part.type == ImageStart)) {
1217
+ if (!part.side || cx.skipSpace(part.to) == start && !/[(\[]/.test(cx.slice(start + 1, start + 2))) {
1218
+ cx.parts[i] = null;
1219
+ return -1;
1220
+ }
1221
+ let content = cx.takeContent(i);
1222
+ let link = cx.parts[i] = finishLink(cx, content, part.type == LinkStart ? Type.Link : Type.Image, part.from, start + 1);
1223
+ if (part.type == LinkStart) for (let j = 0; j < i; j++) {
1224
+ let p = cx.parts[j];
1225
+ if (p instanceof InlineDelimiter && p.type == LinkStart) p.side = 0;
1226
+ }
1227
+ return link.to;
1228
+ }
1229
+ }
1230
+ return -1;
1231
+ }
1232
+ };
1233
+ function finishLink(cx, content, type, start, startPos) {
1234
+ let { text } = cx, next = cx.char(startPos), endPos = startPos;
1235
+ content.unshift(elt(Type.LinkMark, start, start + (type == Type.Image ? 2 : 1)));
1236
+ content.push(elt(Type.LinkMark, startPos - 1, startPos));
1237
+ if (next == 40) {
1238
+ let pos = cx.skipSpace(startPos + 1);
1239
+ let dest = parseURL(text, pos - cx.offset, cx.offset), title;
1240
+ if (dest) {
1241
+ pos = cx.skipSpace(dest.to);
1242
+ if (pos != dest.to) {
1243
+ title = parseLinkTitle(text, pos - cx.offset, cx.offset);
1244
+ if (title) pos = cx.skipSpace(title.to);
1245
+ }
1246
+ }
1247
+ if (cx.char(pos) == 41) {
1248
+ content.push(elt(Type.LinkMark, startPos, startPos + 1));
1249
+ endPos = pos + 1;
1250
+ if (dest) content.push(dest);
1251
+ if (title) content.push(title);
1252
+ content.push(elt(Type.LinkMark, pos, endPos));
1253
+ }
1254
+ } else if (next == 91) {
1255
+ let label = parseLinkLabel(text, startPos - cx.offset, cx.offset, false);
1256
+ if (label) {
1257
+ content.push(label);
1258
+ endPos = label.to;
1259
+ }
1260
+ }
1261
+ return elt(type, start, endPos, content);
1262
+ }
1263
+ function parseURL(text, start, offset) {
1264
+ if (text.charCodeAt(start) == 60) {
1265
+ for (let pos = start + 1; pos < text.length; pos++) {
1266
+ let ch = text.charCodeAt(pos);
1267
+ if (ch == 62) return elt(Type.URL, start + offset, pos + 1 + offset);
1268
+ if (ch == 60 || ch == 10) return false;
1269
+ }
1270
+ return null;
1271
+ } else {
1272
+ let depth = 0, pos = start;
1273
+ for (let escaped = false; pos < text.length; pos++) {
1274
+ let ch = text.charCodeAt(pos);
1275
+ if (space(ch)) break;
1276
+ else if (escaped) escaped = false;
1277
+ else if (ch == 40) depth++;
1278
+ else if (ch == 41) {
1279
+ if (!depth) break;
1280
+ depth--;
1281
+ } else if (ch == 92) escaped = true;
1282
+ }
1283
+ return pos > start ? elt(Type.URL, start + offset, pos + offset) : pos == text.length ? null : false;
1284
+ }
1285
+ }
1286
+ function parseLinkTitle(text, start, offset) {
1287
+ let next = text.charCodeAt(start);
1288
+ if (next != 39 && next != 34 && next != 40) return false;
1289
+ let end = next == 40 ? 41 : next;
1290
+ for (let pos = start + 1, escaped = false; pos < text.length; pos++) {
1291
+ let ch = text.charCodeAt(pos);
1292
+ if (escaped) escaped = false;
1293
+ else if (ch == end) return elt(Type.LinkTitle, start + offset, pos + 1 + offset);
1294
+ else if (ch == 92) escaped = true;
1295
+ }
1296
+ return null;
1297
+ }
1298
+ function parseLinkLabel(text, start, offset, requireNonWS) {
1299
+ for (let escaped = false, pos = start + 1, end = Math.min(text.length, pos + 999); pos < end; pos++) {
1300
+ let ch = text.charCodeAt(pos);
1301
+ if (escaped) escaped = false;
1302
+ else if (ch == 93) return requireNonWS ? false : elt(Type.LinkLabel, start + offset, pos + 1 + offset);
1303
+ else {
1304
+ if (requireNonWS && !space(ch)) requireNonWS = false;
1305
+ if (ch == 91) return false;
1306
+ else if (ch == 92) escaped = true;
1307
+ }
1308
+ }
1309
+ return null;
1310
+ }
1311
+ /**
1312
+ Inline parsing functions get access to this context, and use it to
1313
+ read the content and emit syntax nodes.
1314
+ */
1315
+ var InlineContext = class {
1316
+ /**
1317
+ @internal
1318
+ */
1319
+ constructor(parser, text, offset) {
1320
+ this.parser = parser;
1321
+ this.text = text;
1322
+ this.offset = offset;
1323
+ /**
1324
+ @internal
1325
+ */
1326
+ this.parts = [];
1327
+ }
1328
+ /**
1329
+ Get the character code at the given (document-relative)
1330
+ position.
1331
+ */
1332
+ char(pos) {
1333
+ return pos >= this.end ? -1 : this.text.charCodeAt(pos - this.offset);
1334
+ }
1335
+ /**
1336
+ The position of the end of this inline section.
1337
+ */
1338
+ get end() {
1339
+ return this.offset + this.text.length;
1340
+ }
1341
+ /**
1342
+ Get a substring of this inline section. Again uses
1343
+ document-relative positions.
1344
+ */
1345
+ slice(from, to) {
1346
+ return this.text.slice(from - this.offset, to - this.offset);
1347
+ }
1348
+ /**
1349
+ @internal
1350
+ */
1351
+ append(elt) {
1352
+ this.parts.push(elt);
1353
+ return elt.to;
1354
+ }
1355
+ /**
1356
+ Add a [delimiter](#DelimiterType) at this given position. `open`
1357
+ and `close` indicate whether this delimiter is opening, closing,
1358
+ or both. Returns the end of the delimiter, for convenient
1359
+ returning from [parse functions](#InlineParser.parse).
1360
+ */
1361
+ addDelimiter(type, from, to, open, close) {
1362
+ return this.append(new InlineDelimiter(type, from, to, (open ? 1 : 0) | (close ? 2 : 0)));
1363
+ }
1364
+ /**
1365
+ Returns true when there is an unmatched link or image opening
1366
+ token before the current position.
1367
+ */
1368
+ get hasOpenLink() {
1369
+ for (let i = this.parts.length - 1; i >= 0; i--) {
1370
+ let part = this.parts[i];
1371
+ if (part instanceof InlineDelimiter && (part.type == LinkStart || part.type == ImageStart)) return true;
1372
+ }
1373
+ return false;
1374
+ }
1375
+ /**
1376
+ Add an inline element. Returns the end of the element.
1377
+ */
1378
+ addElement(elt) {
1379
+ return this.append(elt);
1380
+ }
1381
+ /**
1382
+ Resolve markers between this.parts.length and from, wrapping matched markers in the
1383
+ appropriate node and updating the content of this.parts. @internal
1384
+ */
1385
+ resolveMarkers(from) {
1386
+ for (let i = from; i < this.parts.length; i++) {
1387
+ let close = this.parts[i];
1388
+ if (!(close instanceof InlineDelimiter && close.type.resolve && close.side & 2)) continue;
1389
+ let emp = close.type == EmphasisUnderscore || close.type == EmphasisAsterisk;
1390
+ let closeSize = close.to - close.from;
1391
+ let open, j = i - 1;
1392
+ for (; j >= from; j--) {
1393
+ let part = this.parts[j];
1394
+ if (part instanceof InlineDelimiter && part.side & 1 && part.type == close.type && !(emp && (close.side & 1 || part.side & 2) && (part.to - part.from + closeSize) % 3 == 0 && ((part.to - part.from) % 3 || closeSize % 3))) {
1395
+ open = part;
1396
+ break;
1397
+ }
1398
+ }
1399
+ if (!open) continue;
1400
+ let type = close.type.resolve, content = [];
1401
+ let start = open.from, end = close.to;
1402
+ if (emp) {
1403
+ let size = Math.min(2, open.to - open.from, closeSize);
1404
+ start = open.to - size;
1405
+ end = close.from + size;
1406
+ type = size == 1 ? "Emphasis" : "StrongEmphasis";
1407
+ }
1408
+ if (open.type.mark) content.push(this.elt(open.type.mark, start, open.to));
1409
+ for (let k = j + 1; k < i; k++) {
1410
+ if (this.parts[k] instanceof Element) content.push(this.parts[k]);
1411
+ this.parts[k] = null;
1412
+ }
1413
+ if (close.type.mark) content.push(this.elt(close.type.mark, close.from, end));
1414
+ let element = this.elt(type, start, end, content);
1415
+ this.parts[j] = emp && open.from != start ? new InlineDelimiter(open.type, open.from, start, open.side) : null;
1416
+ if (this.parts[i] = emp && close.to != end ? new InlineDelimiter(close.type, end, close.to, close.side) : null) this.parts.splice(i, 0, element);
1417
+ else this.parts[i] = element;
1418
+ }
1419
+ let result = [];
1420
+ for (let i = from; i < this.parts.length; i++) {
1421
+ let part = this.parts[i];
1422
+ if (part instanceof Element) result.push(part);
1423
+ }
1424
+ return result;
1425
+ }
1426
+ /**
1427
+ Find an opening delimiter of the given type. Returns `null` if
1428
+ no delimiter is found, or an index that can be passed to
1429
+ [`takeContent`](#InlineContext.takeContent) otherwise.
1430
+ */
1431
+ findOpeningDelimiter(type) {
1432
+ for (let i = this.parts.length - 1; i >= 0; i--) {
1433
+ let part = this.parts[i];
1434
+ if (part instanceof InlineDelimiter && part.type == type && part.side & 1) return i;
1435
+ }
1436
+ return null;
1437
+ }
1438
+ /**
1439
+ Remove all inline elements and delimiters starting from the
1440
+ given index (which you should get from
1441
+ [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
1442
+ resolve delimiters inside of them, and return them as an array
1443
+ of elements.
1444
+ */
1445
+ takeContent(startIndex) {
1446
+ let content = this.resolveMarkers(startIndex);
1447
+ this.parts.length = startIndex;
1448
+ return content;
1449
+ }
1450
+ /**
1451
+ Return the delimiter at the given index. Mostly useful to get
1452
+ additional info out of a delimiter index returned by
1453
+ [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
1454
+ Returns null if there is no delimiter at this index.
1455
+ */
1456
+ getDelimiterAt(index) {
1457
+ let part = this.parts[index];
1458
+ return part instanceof InlineDelimiter ? part : null;
1459
+ }
1460
+ /**
1461
+ Skip space after the given (document) position, returning either
1462
+ the position of the next non-space character or the end of the
1463
+ section.
1464
+ */
1465
+ skipSpace(from) {
1466
+ return skipSpace(this.text, from - this.offset) + this.offset;
1467
+ }
1468
+ elt(type, from, to, children) {
1469
+ if (typeof type == "string") return elt(this.parser.getNodeType(type), from, to, children);
1470
+ return new TreeElement(type, from);
1471
+ }
1472
+ };
1473
+ /**
1474
+ The opening delimiter type used by the standard link parser.
1475
+ */
1476
+ InlineContext.linkStart = LinkStart;
1477
+ /**
1478
+ Opening delimiter type used for standard images.
1479
+ */
1480
+ InlineContext.imageStart = ImageStart;
1481
+ function injectMarks(elements, marks) {
1482
+ if (!marks.length) return elements;
1483
+ if (!elements.length) return marks;
1484
+ let elts = elements.slice(), eI = 0;
1485
+ for (let mark of marks) {
1486
+ while (eI < elts.length && elts[eI].to < mark.to) eI++;
1487
+ if (eI < elts.length && elts[eI].from < mark.from) {
1488
+ let e = elts[eI];
1489
+ if (e instanceof Element) elts[eI] = new Element(e.type, e.from, e.to, injectMarks(e.children, [mark]));
1490
+ } else elts.splice(eI++, 0, mark);
1491
+ }
1492
+ return elts;
1493
+ }
1494
+ const NotLast = [
1495
+ Type.CodeBlock,
1496
+ Type.ListItem,
1497
+ Type.OrderedList,
1498
+ Type.BulletList
1499
+ ];
1500
+ var FragmentCursor = class {
1501
+ constructor(fragments, input) {
1502
+ this.fragments = fragments;
1503
+ this.input = input;
1504
+ this.i = 0;
1505
+ this.fragment = null;
1506
+ this.fragmentEnd = -1;
1507
+ this.cursor = null;
1508
+ if (fragments.length) this.fragment = fragments[this.i++];
1509
+ }
1510
+ nextFragment() {
1511
+ this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null;
1512
+ this.cursor = null;
1513
+ this.fragmentEnd = -1;
1514
+ }
1515
+ moveTo(pos, lineStart) {
1516
+ while (this.fragment && this.fragment.to <= pos) this.nextFragment();
1517
+ if (!this.fragment || this.fragment.from > (pos ? pos - 1 : 0)) return false;
1518
+ if (this.fragmentEnd < 0) {
1519
+ let end = this.fragment.to;
1520
+ while (end > 0 && this.input.read(end - 1, end) != "\n") end--;
1521
+ this.fragmentEnd = end ? end - 1 : 0;
1522
+ }
1523
+ let c = this.cursor;
1524
+ if (!c) {
1525
+ c = this.cursor = this.fragment.tree.cursor();
1526
+ c.firstChild();
1527
+ }
1528
+ let rPos = pos + this.fragment.offset;
1529
+ while (c.to <= rPos) if (!c.parent()) return false;
1530
+ for (;;) {
1531
+ if (c.from >= rPos) return this.fragment.from <= lineStart;
1532
+ if (!c.childAfter(rPos)) return false;
1533
+ }
1534
+ }
1535
+ matches(hash) {
1536
+ let tree = this.cursor.tree;
1537
+ return tree && tree.prop(NodeProp.contextHash) == hash;
1538
+ }
1539
+ takeNodes(cx) {
1540
+ let cur = this.cursor, off = this.fragment.offset, fragEnd = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0);
1541
+ let start = cx.absoluteLineStart, end = start, blockI = cx.block.children.length;
1542
+ let prevEnd = end, prevI = blockI;
1543
+ for (;;) {
1544
+ if (cur.to - off > fragEnd) {
1545
+ if (cur.type.isAnonymous && cur.firstChild()) continue;
1546
+ break;
1547
+ }
1548
+ let pos = toRelative(cur.from - off, cx.ranges);
1549
+ if (cur.to - off <= cx.ranges[cx.rangeI].to) cx.addNode(cur.tree, pos);
1550
+ else {
1551
+ let dummy = new Tree(cx.parser.nodeSet.types[Type.Paragraph], [], [], 0, cx.block.hashProp);
1552
+ cx.reusePlaceholders.set(dummy, cur.tree);
1553
+ cx.addNode(dummy, pos);
1554
+ }
1555
+ if (cur.type.is("Block")) {
1556
+ if (NotLast.indexOf(cur.type.id) < 0) {
1557
+ end = cur.to - off;
1558
+ blockI = cx.block.children.length;
1559
+ } else {
1560
+ end = prevEnd;
1561
+ blockI = prevI;
1562
+ }
1563
+ prevEnd = cur.to - off;
1564
+ prevI = cx.block.children.length;
1565
+ }
1566
+ if (!cur.nextSibling()) break;
1567
+ }
1568
+ while (cx.block.children.length > blockI) {
1569
+ cx.block.children.pop();
1570
+ cx.block.positions.pop();
1571
+ }
1572
+ return end - start;
1573
+ }
1574
+ };
1575
+ function toRelative(abs, ranges) {
1576
+ let pos = abs;
1577
+ for (let i = 1; i < ranges.length; i++) {
1578
+ let gapFrom = ranges[i - 1].to, gapTo = ranges[i].from;
1579
+ if (gapFrom < abs) pos -= gapTo - gapFrom;
1580
+ }
1581
+ return pos;
1582
+ }
1583
+ const markdownHighlighting = styleTags({
1584
+ "Blockquote/...": tags.quote,
1585
+ HorizontalRule: tags.contentSeparator,
1586
+ "ATXHeading1/... SetextHeading1/...": tags.heading1,
1587
+ "ATXHeading2/... SetextHeading2/...": tags.heading2,
1588
+ "ATXHeading3/...": tags.heading3,
1589
+ "ATXHeading4/...": tags.heading4,
1590
+ "ATXHeading5/...": tags.heading5,
1591
+ "ATXHeading6/...": tags.heading6,
1592
+ "Comment CommentBlock": tags.comment,
1593
+ Escape: tags.escape,
1594
+ Entity: tags.character,
1595
+ "Emphasis/...": tags.emphasis,
1596
+ "StrongEmphasis/...": tags.strong,
1597
+ "Link/... Image/...": tags.link,
1598
+ "OrderedList/... BulletList/...": tags.list,
1599
+ "BlockQuote/...": tags.quote,
1600
+ "InlineCode CodeText": tags.monospace,
1601
+ "URL Autolink": tags.url,
1602
+ "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": tags.processingInstruction,
1603
+ "CodeInfo LinkLabel": tags.labelName,
1604
+ LinkTitle: tags.string,
1605
+ Paragraph: tags.content
1606
+ });
1607
+ /**
1608
+ The default CommonMark parser.
1609
+ */
1610
+ const parser = new MarkdownParser(new NodeSet(nodeTypes).extend(markdownHighlighting), Object.keys(DefaultBlockParsers).map((n) => DefaultBlockParsers[n]), Object.keys(DefaultBlockParsers).map((n) => DefaultLeafBlocks[n]), Object.keys(DefaultBlockParsers), DefaultEndLeaf, DefaultSkipMarkup, Object.keys(DefaultInline).map((n) => DefaultInline[n]), Object.keys(DefaultInline), []);
1611
+ function leftOverSpace(node, from, to) {
1612
+ let ranges = [];
1613
+ for (let n = node.firstChild, pos = from;; n = n.nextSibling) {
1614
+ let nextPos = n ? n.from : to;
1615
+ if (nextPos > pos) ranges.push({
1616
+ from: pos,
1617
+ to: nextPos
1618
+ });
1619
+ if (!n) break;
1620
+ pos = n.to;
1621
+ }
1622
+ return ranges;
1623
+ }
1624
+ /**
1625
+ Create a Markdown extension to enable nested parsing on code
1626
+ blocks and/or embedded HTML.
1627
+ */
1628
+ function parseCode(config) {
1629
+ let { codeParser, htmlParser } = config;
1630
+ return { wrap: parseMixed((node, input) => {
1631
+ let id = node.type.id;
1632
+ if (codeParser && (id == Type.CodeBlock || id == Type.FencedCode)) {
1633
+ let info = "";
1634
+ if (id == Type.FencedCode) {
1635
+ let infoNode = node.node.getChild(Type.CodeInfo);
1636
+ if (infoNode) info = input.read(infoNode.from, infoNode.to);
1637
+ }
1638
+ let parser = codeParser(info);
1639
+ if (parser) return {
1640
+ parser,
1641
+ overlay: (node) => node.type.id == Type.CodeText,
1642
+ bracketed: id == Type.FencedCode
1643
+ };
1644
+ } else if (htmlParser && (id == Type.HTMLBlock || id == Type.HTMLTag || id == Type.CommentBlock)) return {
1645
+ parser: htmlParser,
1646
+ overlay: leftOverSpace(node.node, node.from, node.to)
1647
+ };
1648
+ return null;
1649
+ }) };
1650
+ }
1651
+ const StrikethroughDelim = {
1652
+ resolve: "Strikethrough",
1653
+ mark: "StrikethroughMark"
1654
+ };
1655
+ /**
1656
+ An extension that implements
1657
+ [GFM-style](https://github.github.com/gfm/#strikethrough-extension-)
1658
+ Strikethrough syntax using `~~` delimiters.
1659
+ */
1660
+ const Strikethrough = {
1661
+ defineNodes: [{
1662
+ name: "Strikethrough",
1663
+ style: { "Strikethrough/...": tags.strikethrough }
1664
+ }, {
1665
+ name: "StrikethroughMark",
1666
+ style: tags.processingInstruction
1667
+ }],
1668
+ parseInline: [{
1669
+ name: "Strikethrough",
1670
+ parse(cx, next, pos) {
1671
+ if (next != 126 || cx.char(pos + 1) != 126 || cx.char(pos + 2) == 126) return -1;
1672
+ let before = cx.slice(pos - 1, pos), after = cx.slice(pos + 2, pos + 3);
1673
+ let sBefore = /\s|^$/.test(before), sAfter = /\s|^$/.test(after);
1674
+ let pBefore = Punctuation.test(before), pAfter = Punctuation.test(after);
1675
+ return cx.addDelimiter(StrikethroughDelim, pos, pos + 2, !sAfter && (!pAfter || sBefore || pBefore), !sBefore && (!pBefore || sAfter || pAfter));
1676
+ },
1677
+ after: "Emphasis"
1678
+ }]
1679
+ };
1680
+ function parseRow(cx, line, startI = 0, elts, offset = 0) {
1681
+ let count = 0, first = true, cellStart = -1, cellEnd = -1, esc = false;
1682
+ let parseCell = () => {
1683
+ elts.push(cx.elt("TableCell", offset + cellStart, offset + cellEnd, cx.parser.parseInline(line.slice(cellStart, cellEnd), offset + cellStart)));
1684
+ };
1685
+ for (let i = startI; i < line.length; i++) {
1686
+ let next = line.charCodeAt(i);
1687
+ if (next == 124 && !esc) {
1688
+ if (!first || cellStart > -1) count++;
1689
+ first = false;
1690
+ if (elts) {
1691
+ if (cellStart > -1) parseCell();
1692
+ elts.push(cx.elt("TableDelimiter", i + offset, i + offset + 1));
1693
+ }
1694
+ cellStart = cellEnd = -1;
1695
+ } else if (esc || next != 32 && next != 9) {
1696
+ if (cellStart < 0) cellStart = i;
1697
+ cellEnd = i + 1;
1698
+ }
1699
+ esc = !esc && next == 92;
1700
+ }
1701
+ if (cellStart > -1) {
1702
+ count++;
1703
+ if (elts) parseCell();
1704
+ }
1705
+ return count;
1706
+ }
1707
+ function hasPipe(str, start) {
1708
+ for (let i = start; i < str.length; i++) {
1709
+ let next = str.charCodeAt(i);
1710
+ if (next == 124) return true;
1711
+ if (next == 92) i++;
1712
+ }
1713
+ return false;
1714
+ }
1715
+ const delimiterLine = /^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
1716
+ var TableParser = class {
1717
+ constructor() {
1718
+ this.rows = null;
1719
+ }
1720
+ nextLine(cx, line, leaf) {
1721
+ if (this.rows == null) {
1722
+ this.rows = false;
1723
+ let lineText;
1724
+ if ((line.next == 45 || line.next == 58 || line.next == 124) && delimiterLine.test(lineText = line.text.slice(line.pos))) {
1725
+ let firstRow = [];
1726
+ if (parseRow(cx, leaf.content, 0, firstRow, leaf.start) == parseRow(cx, lineText, 0)) this.rows = [cx.elt("TableHeader", leaf.start, leaf.start + leaf.content.length, firstRow), cx.elt("TableDelimiter", cx.lineStart + line.pos, cx.lineStart + line.text.length)];
1727
+ }
1728
+ } else if (this.rows) {
1729
+ let content = [];
1730
+ parseRow(cx, line.text, line.pos, content, cx.lineStart);
1731
+ this.rows.push(cx.elt("TableRow", cx.lineStart + line.pos, cx.lineStart + line.text.length, content));
1732
+ }
1733
+ return false;
1734
+ }
1735
+ finish(cx, leaf) {
1736
+ if (!this.rows) return false;
1737
+ cx.addLeafElement(leaf, cx.elt("Table", leaf.start, leaf.start + leaf.content.length, this.rows));
1738
+ return true;
1739
+ }
1740
+ };
1741
+ /**
1742
+ This extension provides
1743
+ [GFM-style](https://github.github.com/gfm/#tables-extension-)
1744
+ tables, using syntax like this:
1745
+
1746
+ ```
1747
+ | head 1 | head 2 |
1748
+ | --- | --- |
1749
+ | cell 1 | cell 2 |
1750
+ ```
1751
+ */
1752
+ const Table = {
1753
+ defineNodes: [
1754
+ {
1755
+ name: "Table",
1756
+ block: true
1757
+ },
1758
+ {
1759
+ name: "TableHeader",
1760
+ style: { "TableHeader/...": tags.heading }
1761
+ },
1762
+ "TableRow",
1763
+ {
1764
+ name: "TableCell",
1765
+ style: tags.content
1766
+ },
1767
+ {
1768
+ name: "TableDelimiter",
1769
+ style: tags.processingInstruction
1770
+ }
1771
+ ],
1772
+ parseBlock: [{
1773
+ name: "Table",
1774
+ leaf(_, leaf) {
1775
+ return hasPipe(leaf.content, 0) ? new TableParser() : null;
1776
+ },
1777
+ endLeaf(cx, line, leaf) {
1778
+ if (leaf.parsers.some((p) => p instanceof TableParser) || !hasPipe(line.text, line.basePos)) return false;
1779
+ let next = cx.peekLine();
1780
+ return delimiterLine.test(next) && parseRow(cx, line.text, line.basePos) == parseRow(cx, next, line.basePos);
1781
+ },
1782
+ before: "SetextHeading"
1783
+ }]
1784
+ };
1785
+ var TaskParser = class {
1786
+ nextLine() {
1787
+ return false;
1788
+ }
1789
+ finish(cx, leaf) {
1790
+ cx.addLeafElement(leaf, cx.elt("Task", leaf.start, leaf.start + leaf.content.length, [cx.elt("TaskMarker", leaf.start, leaf.start + 3), ...cx.parser.parseInline(leaf.content.slice(3), leaf.start + 3)]));
1791
+ return true;
1792
+ }
1793
+ };
1794
+ /**
1795
+ Extension providing
1796
+ [GFM-style](https://github.github.com/gfm/#task-list-items-extension-)
1797
+ task list items, where list items can be prefixed with `[ ]` or
1798
+ `[x]` to add a checkbox.
1799
+ */
1800
+ const TaskList = {
1801
+ defineNodes: [{
1802
+ name: "Task",
1803
+ block: true,
1804
+ style: tags.list
1805
+ }, {
1806
+ name: "TaskMarker",
1807
+ style: tags.atom
1808
+ }],
1809
+ parseBlock: [{
1810
+ name: "TaskList",
1811
+ leaf(cx, leaf) {
1812
+ return /^\[[ xX]\][ \t]/.test(leaf.content) && cx.parentType().name == "ListItem" ? new TaskParser() : null;
1813
+ },
1814
+ after: "SetextHeading"
1815
+ }]
1816
+ };
1817
+ const autolinkRE = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy;
1818
+ const urlRE = /[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy;
1819
+ const lastTwoDomainWords = /[\w-]+\.[\w-]+($|[/:])/;
1820
+ const emailRE = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy;
1821
+ const xmppResourceRE = /\/[a-zA-Z\d@.]+/gy;
1822
+ function count(str, from, to, ch) {
1823
+ let result = 0;
1824
+ for (let i = from; i < to; i++) if (str[i] == ch) result++;
1825
+ return result;
1826
+ }
1827
+ function autolinkURLEnd(text, from) {
1828
+ urlRE.lastIndex = from;
1829
+ let m = urlRE.exec(text);
1830
+ if (!m || lastTwoDomainWords.exec(m[0])[0].indexOf("_") > -1) return -1;
1831
+ let end = from + m[0].length;
1832
+ for (;;) {
1833
+ let last = text[end - 1], m;
1834
+ if (/[?!.,:*_~]/.test(last) || last == ")" && count(text, from, end, ")") > count(text, from, end, "(")) end--;
1835
+ else if (last == ";" && (m = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(text.slice(from, end)))) end = from + m.index;
1836
+ else break;
1837
+ }
1838
+ return end;
1839
+ }
1840
+ function autolinkEmailEnd(text, from) {
1841
+ emailRE.lastIndex = from;
1842
+ let m = emailRE.exec(text);
1843
+ if (!m) return -1;
1844
+ let last = m[0][m[0].length - 1];
1845
+ return last == "_" || last == "-" ? -1 : from + m[0].length - (last == "." ? 1 : 0);
1846
+ }
1847
+ /**
1848
+ Extension bundle containing [`Table`](#Table),
1849
+ [`TaskList`](#TaskList), [`Strikethrough`](#Strikethrough), and
1850
+ [`Autolink`](#Autolink).
1851
+ */
1852
+ const GFM = [
1853
+ Table,
1854
+ TaskList,
1855
+ Strikethrough,
1856
+ { parseInline: [{
1857
+ name: "Autolink",
1858
+ parse(cx, next, absPos) {
1859
+ let pos = absPos - cx.offset;
1860
+ if (pos && /\w/.test(cx.text[pos - 1])) return -1;
1861
+ autolinkRE.lastIndex = pos;
1862
+ let m = autolinkRE.exec(cx.text), end = -1;
1863
+ if (!m) return -1;
1864
+ if (m[1] || m[2]) {
1865
+ end = autolinkURLEnd(cx.text, pos + m[0].length);
1866
+ if (end > -1 && cx.hasOpenLink) end = pos + /([^\[\]]|\[[^\]]*\])*/.exec(cx.text.slice(pos, end))[0].length;
1867
+ } else if (m[3]) end = autolinkEmailEnd(cx.text, pos);
1868
+ else {
1869
+ end = autolinkEmailEnd(cx.text, pos + m[0].length);
1870
+ if (end > -1 && m[0] == "xmpp:") {
1871
+ xmppResourceRE.lastIndex = end;
1872
+ m = xmppResourceRE.exec(cx.text);
1873
+ if (m) end = m.index + m[0].length;
1874
+ }
1875
+ }
1876
+ if (end < 0) return -1;
1877
+ cx.addElement(cx.elt("URL", absPos, end + cx.offset));
1878
+ return end + cx.offset;
1879
+ }
1880
+ }] }
1881
+ ];
1882
+ function parseSubSuper(ch, node, mark) {
1883
+ return (cx, next, pos) => {
1884
+ if (next != ch || cx.char(pos + 1) == ch) return -1;
1885
+ let elts = [cx.elt(mark, pos, pos + 1)];
1886
+ for (let i = pos + 1; i < cx.end; i++) {
1887
+ let next = cx.char(i);
1888
+ if (next == ch) return cx.addElement(cx.elt(node, pos, i + 1, elts.concat(cx.elt(mark, i, i + 1))));
1889
+ if (next == 92) elts.push(cx.elt("Escape", i, i++ + 2));
1890
+ if (space(next)) break;
1891
+ }
1892
+ return -1;
1893
+ };
1894
+ }
1895
+ /**
1896
+ Extension providing
1897
+ [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
1898
+ superscript using `^` markers.
1899
+ */
1900
+ const Superscript = {
1901
+ defineNodes: [{
1902
+ name: "Superscript",
1903
+ style: tags.special(tags.content)
1904
+ }, {
1905
+ name: "SuperscriptMark",
1906
+ style: tags.processingInstruction
1907
+ }],
1908
+ parseInline: [{
1909
+ name: "Superscript",
1910
+ parse: parseSubSuper(94, "Superscript", "SuperscriptMark")
1911
+ }]
1912
+ };
1913
+ /**
1914
+ Extension providing
1915
+ [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
1916
+ subscript using `~` markers.
1917
+ */
1918
+ const Subscript = {
1919
+ defineNodes: [{
1920
+ name: "Subscript",
1921
+ style: tags.special(tags.content)
1922
+ }, {
1923
+ name: "SubscriptMark",
1924
+ style: tags.processingInstruction
1925
+ }],
1926
+ parseInline: [{
1927
+ name: "Subscript",
1928
+ parse: parseSubSuper(126, "Subscript", "SubscriptMark")
1929
+ }]
1930
+ };
1931
+ /**
1932
+ Extension that parses two colons with only letters, underscores,
1933
+ and numbers between them as `Emoji` nodes.
1934
+ */
1935
+ const Emoji = {
1936
+ defineNodes: [{
1937
+ name: "Emoji",
1938
+ style: tags.character
1939
+ }],
1940
+ parseInline: [{
1941
+ name: "Emoji",
1942
+ parse(cx, next, pos) {
1943
+ let match;
1944
+ if (next != 58 || !(match = /^[a-zA-Z_0-9]+:/.exec(cx.slice(pos + 1, cx.end)))) return -1;
1945
+ return cx.addElement(cx.elt("Emoji", pos, pos + 1 + match[0].length));
1946
+ }
1947
+ }]
1948
+ };
1949
+ //#endregion
1950
+ export { Emoji, GFM, MarkdownParser, Subscript, Superscript, parseCode, parser };
1951
+
1952
+ //# sourceMappingURL=index.js.map