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