@farvardin/lezer-parser-markdown 1.6.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/README.md ADDED
@@ -0,0 +1,719 @@
1
+ <!-- /README.md is generated from /src/README.md -->
2
+
3
+ # @farvardin/lezer-parser-markdown
4
+
5
+ This is an incremental ~~Markdown~~ txt2tags parser that integrates well with the
6
+ [Lezer](https://lezer.codemirror.net/) parser system.
7
+
8
+ Note that this only _parses_ the document, producing a data structure
9
+ that represents its syntactic form, and doesn't help with outputting
10
+ HTML. Also, in order to be single-pass and incremental, it doesn't do
11
+ some things that a conforming CommonMark parser is expected to
12
+ do—specifically, it doesn't validate link references, so it'll parse
13
+ `[a][b]` and similar as a link, even if no `[b]` reference is
14
+ declared.
15
+
16
+ The
17
+ [@farvardin/codemirror-lang-markdown](https://github.com/farvardin/codemirror-lang-markdown)
18
+ package integrates this parser with CodeMirror to provide ~~Markdown~~ txt2tags editor support.
19
+
20
+ The code is licensed under an MIT license.
21
+
22
+ ## Interface
23
+ <dl>
24
+ <dt id="user-content-parser">
25
+ <code><strong><a href="#user-content-parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
26
+
27
+ <dd><p>The default CommonMark parser.</p>
28
+ </dd>
29
+ </dl>
30
+ <dl>
31
+ <dt id="user-content-markdownparser">
32
+ <h4>
33
+ <code>class</code>
34
+ <a href="#user-content-markdownparser">MarkdownParser</a> <code>extends <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a></code></h4>
35
+ </dt>
36
+
37
+ <dd><p>A Markdown parser configuration.</p>
38
+ <dl><dt id="user-content-markdownparser.nodeset">
39
+ <code><strong><a href="#user-content-markdownparser.nodeset">nodeSet</a></strong>: <a href="https://lezer.codemirror.net/docs/ref/#common.NodeSet">NodeSet</a></code></dt>
40
+
41
+ <dd><p>The parser's syntax <a href="https://lezer.codemirror.net/docs/ref/#common.NodeSet">node
42
+ types</a>.</p>
43
+ </dd><dt id="user-content-markdownparser.configure">
44
+ <code><strong><a href="#user-content-markdownparser.configure">configure</a></strong>(<a id="user-content-markdownparser.configure^spec" href="#user-content-markdownparser.configure^spec">spec</a>: <a href="#user-content-markdownextension">MarkdownExtension</a>) → <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
45
+
46
+ <dd><p>Reconfigure the parser.</p>
47
+ </dd><dt id="user-content-markdownparser.parseinline">
48
+ <code><strong><a href="#user-content-markdownparser.parseinline">parseInline</a></strong>(<a id="user-content-markdownparser.parseinline^text" href="#user-content-markdownparser.parseinline^text">text</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a id="user-content-markdownparser.parseinline^offset" href="#user-content-markdownparser.parseinline^offset">offset</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="#user-content-element">Element</a>[]</code></dt>
49
+
50
+ <dd><p>Parse the given piece of inline text at the given offset,
51
+ returning an array of <a href="#user-content-element"><code>Element</code></a> objects representing
52
+ the inline content.</p>
53
+ </dd></dl>
54
+
55
+ </dd>
56
+ </dl>
57
+ <dl>
58
+ <dt id="user-content-markdownconfig">
59
+ <h4>
60
+ <code>interface</code>
61
+ <a href="#user-content-markdownconfig">MarkdownConfig</a></h4>
62
+ </dt>
63
+
64
+ <dd><p>Objects of this type are used to
65
+ <a href="#user-content-markdownparser.configure">configure</a> the Markdown parser.</p>
66
+ <dl><dt id="user-content-markdownconfig.props">
67
+ <code><strong><a href="#user-content-markdownconfig.props">props</a></strong>&#8288;?: readonly <a href="https://lezer.codemirror.net/docs/ref/#common.NodePropSource">NodePropSource</a>[]</code></dt>
68
+
69
+ <dd><p>Node props to add to the parser's node set.</p>
70
+ </dd><dt id="user-content-markdownconfig.definenodes">
71
+ <code><strong><a href="#user-content-markdownconfig.definenodes">defineNodes</a></strong>&#8288;?: readonly (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="#user-content-nodespec">NodeSpec</a>)[]</code></dt>
72
+
73
+ <dd><p>Define new <a href="#user-content-nodespec">node types</a> for use in parser extensions.</p>
74
+ </dd><dt id="user-content-markdownconfig.parseblock">
75
+ <code><strong><a href="#user-content-markdownconfig.parseblock">parseBlock</a></strong>&#8288;?: readonly <a href="#user-content-blockparser">BlockParser</a>[]</code></dt>
76
+
77
+ <dd><p>Define additional <a href="#user-content-blockparser">block parsing</a> logic.</p>
78
+ </dd><dt id="user-content-markdownconfig.parseinline">
79
+ <code><strong><a href="#user-content-markdownconfig.parseinline">parseInline</a></strong>&#8288;?: readonly <a href="#user-content-inlineparser">InlineParser</a>[]</code></dt>
80
+
81
+ <dd><p>Define new <a href="#user-content-inlineparser">inline parsing</a> logic.</p>
82
+ </dd><dt id="user-content-markdownconfig.remove">
83
+ <code><strong><a href="#user-content-markdownconfig.remove">remove</a></strong>&#8288;?: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[]</code></dt>
84
+
85
+ <dd><p>Remove the named parsers from the configuration.</p>
86
+ </dd><dt id="user-content-markdownconfig.wrap">
87
+ <code><strong><a href="#user-content-markdownconfig.wrap">wrap</a></strong>&#8288;?: <a href="https://lezer.codemirror.net/docs/ref/#common.ParseWrapper">ParseWrapper</a></code></dt>
88
+
89
+ <dd><p>Add a parse wrapper (such as a <a href="#user-content-common.parsemixed">mixed-language
90
+ parser</a>) to this parser.</p>
91
+ </dd></dl>
92
+
93
+ </dd>
94
+ </dl>
95
+ <dl>
96
+ <dt id="user-content-markdownextension">
97
+ <code>type</code>
98
+ <code><strong><a href="#user-content-markdownextension">MarkdownExtension</a></strong> = <a href="#user-content-markdownconfig">MarkdownConfig</a> | readonly <a href="#user-content-markdownextension">MarkdownExtension</a>[]</code>
99
+ </dt>
100
+
101
+ <dd><p>To make it possible to group extensions together into bigger
102
+ extensions (such as the <a href="#user-content-gfm">Github-flavored Markdown</a>
103
+ extension), <a href="#user-content-markdownparser.configure">reconfiguration</a> accepts
104
+ nested arrays of <a href="#user-content-markdownconfig">config</a> objects.</p>
105
+ </dd>
106
+ </dl>
107
+ <dl>
108
+ <dt id="user-content-parsecode">
109
+ <code><strong><a href="#user-content-parsecode">parseCode</a></strong>(<a id="user-content-parsecode^config" href="#user-content-parsecode^config">config</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>) → <a href="#user-content-markdownextension">MarkdownExtension</a></code></dt>
110
+
111
+ <dd><p>Create a Markdown extension to enable nested parsing on code
112
+ blocks and/or embedded HTML.</p>
113
+ <dl><dt id="user-content-parsecode^config">
114
+ <code><strong><a href="#user-content-parsecode^config">config</a></strong></code></dt>
115
+
116
+ <dd><dl><dt id="user-content-parsecode^config.codeparser">
117
+ <code><strong><a href="#user-content-parsecode^config.codeparser">codeParser</a></strong>&#8288;?: fn(<a id="user-content-parsecode^config.codeparser^info" href="#user-content-parsecode^config.codeparser^info">info</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>) → <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
118
+
119
+ <dd><p>When provided, this will be used to parse the content of code
120
+ blocks. <code>info</code> is the string after the opening <code>```</code> marker,
121
+ or the empty string if there is no such info or this is an
122
+ indented code block. If there is a parser available for the
123
+ code, it should return a function that can construct the
124
+ <a href="https://lezer.codemirror.net/docs/ref/#common.PartialParse">parse</a>.</p>
125
+ </dd><dt id="user-content-parsecode^config.htmlparser">
126
+ <code><strong><a href="#user-content-parsecode^config.htmlparser">htmlParser</a></strong>&#8288;?: <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a></code></dt>
127
+
128
+ <dd><p>The parser used to parse HTML tags (both block and inline).</p>
129
+ </dd></dl></dd></dl></dd>
130
+ </dl>
131
+
132
+ ### GitHub Flavored Markdown
133
+ <dl>
134
+ <dt id="user-content-gfm">
135
+ <code><strong><a href="#user-content-gfm">GFM</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a>[]</code></dt>
136
+
137
+ <dd><p>Extension bundle containing <a href="#user-content-table"><code>Table</code></a>,
138
+ <a href="#user-content-tasklist"><code>TaskList</code></a>, <a href="#user-content-strikethrough"><code>Strikethrough</code></a>, and
139
+ <a href="#user-content-autolink"><code>Autolink</code></a>.</p>
140
+ </dd>
141
+ </dl>
142
+ <dl>
143
+ <dt id="user-content-table">
144
+ <code><strong><a href="#user-content-table">Table</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
145
+
146
+ <dd><p>This extension provides
147
+ <a href="https://github.github.com/gfm/#tables-extension-">GFM-style</a>
148
+ tables, using syntax like this:</p>
149
+ <pre><code>| head 1 | head 2 |
150
+ | --- | --- |
151
+ | cell 1 | cell 2 |
152
+ </code></pre>
153
+ </dd>
154
+ </dl>
155
+ <dl>
156
+ <dt id="user-content-tasklist">
157
+ <code><strong><a href="#user-content-tasklist">TaskList</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
158
+
159
+ <dd><p>Extension providing
160
+ <a href="https://github.github.com/gfm/#task-list-items-extension-">GFM-style</a>
161
+ task list items, where list items can be prefixed with <code>[ ]</code> or
162
+ <code>[x]</code> to add a checkbox.</p>
163
+ </dd>
164
+ </dl>
165
+ <dl>
166
+ <dt id="user-content-strikethrough">
167
+ <code><strong><a href="#user-content-strikethrough">Strikethrough</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
168
+
169
+ <dd><p>An extension that implements
170
+ <a href="https://github.github.com/gfm/#strikethrough-extension-">GFM-style</a>
171
+ Strikethrough syntax using <code>~~</code> delimiters.</p>
172
+ </dd>
173
+ </dl>
174
+ <dl>
175
+ <dt id="user-content-autolink">
176
+ <code><strong><a href="#user-content-autolink">Autolink</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
177
+
178
+ <dd><p>Extension that implements autolinking for
179
+ <code>www.</code>/<code>http://</code>/<code>https://</code>/<code>mailto:</code>/<code>xmpp:</code> URLs and email
180
+ addresses.</p>
181
+ </dd>
182
+ </dl>
183
+
184
+ ### Other extensions
185
+ <dl>
186
+ <dt id="user-content-subscript">
187
+ <code><strong><a href="#user-content-subscript">Subscript</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
188
+
189
+ <dd><p>Extension providing
190
+ <a href="https://pandoc.org/MANUAL.html#superscripts-and-subscripts">Pandoc-style</a>
191
+ subscript using <code>~</code> markers.</p>
192
+ </dd>
193
+ </dl>
194
+ <dl>
195
+ <dt id="user-content-superscript">
196
+ <code><strong><a href="#user-content-superscript">Superscript</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
197
+
198
+ <dd><p>Extension providing
199
+ <a href="https://pandoc.org/MANUAL.html#superscripts-and-subscripts">Pandoc-style</a>
200
+ superscript using <code>^</code> markers.</p>
201
+ </dd>
202
+ </dl>
203
+ <dl>
204
+ <dt id="user-content-emoji">
205
+ <code><strong><a href="#user-content-emoji">Emoji</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
206
+
207
+ <dd><p>Extension that parses two colons with only letters, underscores,
208
+ and numbers between them as <code>Emoji</code> nodes.</p>
209
+ </dd>
210
+ </dl>
211
+
212
+ ### Extension
213
+
214
+ The parser can, to a certain extent, be extended to handle additional
215
+ syntax.
216
+ <dl>
217
+ <dt id="user-content-nodespec">
218
+ <h4>
219
+ <code>interface</code>
220
+ <a href="#user-content-nodespec">NodeSpec</a></h4>
221
+ </dt>
222
+
223
+ <dd><p>Used in the <a href="#user-content-markdownconfig.definenodes">configuration</a> to define
224
+ new <a href="https://lezer.codemirror.net/docs/ref/#common.NodeType">syntax node
225
+ types</a>.</p>
226
+ <dl><dt id="user-content-nodespec.name">
227
+ <code><strong><a href="#user-content-nodespec.name">name</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
228
+
229
+ <dd><p>The node's name.</p>
230
+ </dd><dt id="user-content-nodespec.block">
231
+ <code><strong><a href="#user-content-nodespec.block">block</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
232
+
233
+ <dd><p>Should be set to true if this type represents a block node.</p>
234
+ </dd><dt id="user-content-nodespec.composite">
235
+ <code><strong><a href="#user-content-nodespec.composite">composite</a></strong>&#8288;?: fn(<a id="user-content-nodespec.composite^cx" href="#user-content-nodespec.composite^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-nodespec.composite^line" href="#user-content-nodespec.composite^line">line</a>: <a href="#user-content-line">Line</a>, <a id="user-content-nodespec.composite^value" href="#user-content-nodespec.composite^value">value</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
236
+
237
+ <dd><p>If this is a composite block, this should hold a function that,
238
+ at the start of a new line where that block is active, checks
239
+ whether the composite block should continue (return value) and
240
+ optionally <a href="#user-content-line.movebase">adjusts</a> the line's base position
241
+ and <a href="#user-content-line.addmarker">registers</a> nodes for any markers involved
242
+ in the block's syntax.</p>
243
+ </dd><dt id="user-content-nodespec.style">
244
+ <code><strong><a href="#user-content-nodespec.style">style</a></strong>&#8288;?: <a href="https://lezer.codemirror.net/docs/ref/#highlight.Tag">Tag</a> | readonly <a href="https://lezer.codemirror.net/docs/ref/#highlight.Tag">Tag</a>[] | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>&lt;<a href="https://lezer.codemirror.net/docs/ref/#highlight.Tag">Tag</a> | readonly <a href="https://lezer.codemirror.net/docs/ref/#highlight.Tag">Tag</a>[]&gt;</code></dt>
245
+
246
+ <dd><p>Add highlighting tag information for this node. The value of
247
+ this property may either by a tag or array of tags to assign
248
+ directly to this node, or an object in the style of
249
+ <a href="https://lezer.codemirror.net/docs/ref/#highlight.styleTags"><code>styleTags</code></a>'s
250
+ argument to assign more complicated rules.</p>
251
+ </dd></dl>
252
+
253
+ </dd>
254
+ </dl>
255
+ <dl>
256
+ <dt id="user-content-blockcontext">
257
+ <h4>
258
+ <code>class</code>
259
+ <a href="#user-content-blockcontext">BlockContext</a> <code>implements <a href="https://lezer.codemirror.net/docs/ref/#common.PartialParse">PartialParse</a></code></h4>
260
+ </dt>
261
+
262
+ <dd><p>Block-level parsing functions get access to this context object.</p>
263
+ <dl><dt id="user-content-blockcontext.linestart">
264
+ <code><strong><a href="#user-content-blockcontext.linestart">lineStart</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
265
+
266
+ <dd><p>The start of the current line.</p>
267
+ </dd><dt id="user-content-blockcontext.parser">
268
+ <code><strong><a href="#user-content-blockcontext.parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
269
+
270
+ <dd><p>The parser configuration used.</p>
271
+ </dd><dt id="user-content-blockcontext.depth">
272
+ <code><strong><a href="#user-content-blockcontext.depth">depth</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
273
+
274
+ <dd><p>The number of parent blocks surrounding the current block.</p>
275
+ </dd><dt id="user-content-blockcontext.parenttype">
276
+ <code><strong><a href="#user-content-blockcontext.parenttype">parentType</a></strong>(<a id="user-content-blockcontext.parenttype^depth" href="#user-content-blockcontext.parenttype^depth">depth</a>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> = this.depth - 1) → <a href="https://lezer.codemirror.net/docs/ref/#common.NodeType">NodeType</a></code></dt>
277
+
278
+ <dd><p>Get the type of the parent block at the given depth. When no
279
+ depth is passed, return the type of the innermost parent.</p>
280
+ </dd><dt id="user-content-blockcontext.nextline">
281
+ <code><strong><a href="#user-content-blockcontext.nextline">nextLine</a></strong>() → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
282
+
283
+ <dd><p>Move to the next input line. This should only be called by
284
+ (non-composite) <a href="#user-content-blockparser.parse">block parsers</a> that consume
285
+ the line directly, or leaf block parser
286
+ <a href="#user-content-leafblockparser.nextline"><code>nextLine</code></a> methods when they
287
+ consume the current line (and return true).</p>
288
+ </dd><dt id="user-content-blockcontext.peekline">
289
+ <code><strong><a href="#user-content-blockcontext.peekline">peekLine</a></strong>() → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
290
+
291
+ <dd><p>Retrieve the text of the line after the current one, without
292
+ actually moving the context's current line forward.</p>
293
+ </dd><dt id="user-content-blockcontext.prevlineend">
294
+ <code><strong><a href="#user-content-blockcontext.prevlineend">prevLineEnd</a></strong>() → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
295
+
296
+ <dd><p>The end position of the previous line.</p>
297
+ </dd><dt id="user-content-blockcontext.startcomposite">
298
+ <code><strong><a href="#user-content-blockcontext.startcomposite">startComposite</a></strong>(<a id="user-content-blockcontext.startcomposite^type" href="#user-content-blockcontext.startcomposite^type">type</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a id="user-content-blockcontext.startcomposite^start" href="#user-content-blockcontext.startcomposite^start">start</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-blockcontext.startcomposite^value" href="#user-content-blockcontext.startcomposite^value">value</a>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> = 0)</code></dt>
299
+
300
+ <dd><p>Start a composite block. Should only be called from <a href="#user-content-blockparser.parse">block
301
+ parser functions</a> that return null.</p>
302
+ </dd><dt id="user-content-blockcontext.addelement">
303
+ <code><strong><a href="#user-content-blockcontext.addelement">addElement</a></strong>(<a id="user-content-blockcontext.addelement^elt" href="#user-content-blockcontext.addelement^elt">elt</a>: <a href="#user-content-element">Element</a>)</code></dt>
304
+
305
+ <dd><p>Add a block element. Can be called by <a href="#user-content-blockparser.parse">block
306
+ parsers</a>.</p>
307
+ </dd><dt id="user-content-blockcontext.addleafelement">
308
+ <code><strong><a href="#user-content-blockcontext.addleafelement">addLeafElement</a></strong>(<a id="user-content-blockcontext.addleafelement^leaf" href="#user-content-blockcontext.addleafelement^leaf">leaf</a>: <a href="#user-content-leafblock">LeafBlock</a>, <a id="user-content-blockcontext.addleafelement^elt" href="#user-content-blockcontext.addleafelement^elt">elt</a>: <a href="#user-content-element">Element</a>)</code></dt>
309
+
310
+ <dd><p>Add a block element from a <a href="#user-content-leafblockparser">leaf parser</a>. This
311
+ makes sure any extra composite block markup (such as blockquote
312
+ markers) inside the block are also added to the syntax tree.</p>
313
+ </dd><dt id="user-content-blockcontext.elt">
314
+ <code><strong><a href="#user-content-blockcontext.elt">elt</a></strong>(<a id="user-content-blockcontext.elt^type" href="#user-content-blockcontext.elt^type">type</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a id="user-content-blockcontext.elt^from" href="#user-content-blockcontext.elt^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-blockcontext.elt^to" href="#user-content-blockcontext.elt^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-blockcontext.elt^children" href="#user-content-blockcontext.elt^children">children</a>&#8288;?: readonly <a href="#user-content-element">Element</a>[]) → <a href="#user-content-element">Element</a></code><div><code><strong><a href="#user-content-blockcontext.elt">elt</a></strong>(<a id="user-content-blockcontext.elt^tree" href="#user-content-blockcontext.elt^tree">tree</a>: <a href="https://lezer.codemirror.net/docs/ref/#common.Tree">Tree</a>, <a id="user-content-blockcontext.elt^at" href="#user-content-blockcontext.elt^at">at</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="#user-content-element">Element</a></code></div></dt>
315
+
316
+ <dd><p>Create an <a href="#user-content-element"><code>Element</code></a> object to represent some syntax
317
+ node.</p>
318
+ </dd></dl>
319
+
320
+ </dd>
321
+ </dl>
322
+ <dl>
323
+ <dt id="user-content-blockparser">
324
+ <h4>
325
+ <code>interface</code>
326
+ <a href="#user-content-blockparser">BlockParser</a></h4>
327
+ </dt>
328
+
329
+ <dd><p>Block parsers handle block-level structure. There are three
330
+ general types of block parsers:</p>
331
+ <ul>
332
+ <li>
333
+ <p>Composite block parsers, which handle things like lists and
334
+ blockquotes. These define a <a href="#user-content-blockparser.parse"><code>parse</code></a> method
335
+ that <a href="#user-content-blockcontext.startcomposite">starts</a> a composite block
336
+ and returns null when it recognizes its syntax.</p>
337
+ </li>
338
+ <li>
339
+ <p>Eager leaf block parsers, used for things like code or HTML
340
+ blocks. These can unambiguously recognize their content from its
341
+ first line. They define a <a href="#user-content-blockparser.parse"><code>parse</code></a> method
342
+ that, if it recognizes the construct,
343
+ <a href="#user-content-blockcontext.nextline">moves</a> the current line forward to the
344
+ line beyond the end of the block,
345
+ <a href="#user-content-blockcontext.addelement">add</a> a syntax node for the block, and
346
+ return true.</p>
347
+ </li>
348
+ <li>
349
+ <p>Leaf block parsers that observe a paragraph-like construct as it
350
+ comes in, and optionally decide to handle it at some point. This
351
+ is used for &quot;setext&quot; (underlined) headings and link references.
352
+ These define a <a href="#user-content-blockparser.leaf"><code>leaf</code></a> method that checks
353
+ the first line of the block and returns a
354
+ <a href="#user-content-leafblockparser"><code>LeafBlockParser</code></a> object if it wants to
355
+ observe that block.</p>
356
+ </li>
357
+ </ul>
358
+ <dl><dt id="user-content-blockparser.name">
359
+ <code><strong><a href="#user-content-blockparser.name">name</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
360
+
361
+ <dd><p>The name of the parser. Can be used by other block parsers to
362
+ <a href="#user-content-blockparser.before">specify</a> precedence.</p>
363
+ </dd><dt id="user-content-blockparser.parse">
364
+ <code><strong><a href="#user-content-blockparser.parse">parse</a></strong>&#8288;?: fn(<a id="user-content-blockparser.parse^cx" href="#user-content-blockparser.parse^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-blockparser.parse^line" href="#user-content-blockparser.parse^line">line</a>: <a href="#user-content-line">Line</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
365
+
366
+ <dd><p>The eager parse function, which can look at the block's first
367
+ line and return <code>false</code> to do nothing, <code>true</code> if it has parsed
368
+ (and <a href="#user-content-blockcontext.nextline">moved past</a> a block), or <code>null</code> if
369
+ it has started a composite block.</p>
370
+ </dd><dt id="user-content-blockparser.leaf">
371
+ <code><strong><a href="#user-content-blockparser.leaf">leaf</a></strong>&#8288;?: fn(<a id="user-content-blockparser.leaf^cx" href="#user-content-blockparser.leaf^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-blockparser.leaf^leaf" href="#user-content-blockparser.leaf^leaf">leaf</a>: <a href="#user-content-leafblock">LeafBlock</a>) → <a href="#user-content-leafblockparser">LeafBlockParser</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
372
+
373
+ <dd><p>A leaf parse function. If no <a href="#user-content-blockparser.parse">regular</a> parse
374
+ functions match for a given line, its content will be
375
+ accumulated for a paragraph-style block. This method can return
376
+ an <a href="#user-content-leafblockparser">object</a> that overrides that style of
377
+ parsing in some situations.</p>
378
+ </dd><dt id="user-content-blockparser.endleaf">
379
+ <code><strong><a href="#user-content-blockparser.endleaf">endLeaf</a></strong>&#8288;?: fn(<a id="user-content-blockparser.endleaf^cx" href="#user-content-blockparser.endleaf^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-blockparser.endleaf^line" href="#user-content-blockparser.endleaf^line">line</a>: <a href="#user-content-line">Line</a>, <a id="user-content-blockparser.endleaf^leaf" href="#user-content-blockparser.endleaf^leaf">leaf</a>: <a href="#user-content-leafblock">LeafBlock</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
380
+
381
+ <dd><p>Some constructs, such as code blocks or newly started
382
+ blockquotes, can interrupt paragraphs even without a blank line.
383
+ If your construct can do this, provide a predicate here that
384
+ recognizes lines that should end a paragraph (or other non-eager
385
+ <a href="#user-content-blockparser.leaf">leaf block</a>).</p>
386
+ </dd><dt id="user-content-blockparser.before">
387
+ <code><strong><a href="#user-content-blockparser.before">before</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
388
+
389
+ <dd><p>When given, this parser will be installed directly before the
390
+ block parser with the given name. The default configuration
391
+ defines block parsers with names LinkReference, IndentedCode,
392
+ FencedCode, Blockquote, HorizontalRule, BulletList, OrderedList,
393
+ ATXHeading, HTMLBlock, and SetextHeading.</p>
394
+ </dd><dt id="user-content-blockparser.after">
395
+ <code><strong><a href="#user-content-blockparser.after">after</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
396
+
397
+ <dd><p>When given, the parser will be installed directly <em>after</em> the
398
+ parser with the given name.</p>
399
+ </dd></dl>
400
+
401
+ </dd>
402
+ </dl>
403
+ <dl>
404
+ <dt id="user-content-leafblockparser">
405
+ <h4>
406
+ <code>interface</code>
407
+ <a href="#user-content-leafblockparser">LeafBlockParser</a></h4>
408
+ </dt>
409
+
410
+ <dd><p>Objects that are used to <a href="#user-content-blockparser.leaf">override</a>
411
+ paragraph-style blocks should conform to this interface.</p>
412
+ <dl><dt id="user-content-leafblockparser.nextline">
413
+ <code><strong><a href="#user-content-leafblockparser.nextline">nextLine</a></strong>(<a id="user-content-leafblockparser.nextline^cx" href="#user-content-leafblockparser.nextline^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-leafblockparser.nextline^line" href="#user-content-leafblockparser.nextline^line">line</a>: <a href="#user-content-line">Line</a>, <a id="user-content-leafblockparser.nextline^leaf" href="#user-content-leafblockparser.nextline^leaf">leaf</a>: <a href="#user-content-leafblock">LeafBlock</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
414
+
415
+ <dd><p>Update the parser's state for the next line, and optionally
416
+ finish the block. This is not called for the first line (the
417
+ object is constructed at that line), but for any further lines.
418
+ When it returns <code>true</code>, the block is finished. It is okay for
419
+ the function to <a href="#user-content-blockcontext.nextline">consume</a> the current
420
+ line or any subsequent lines when returning true.</p>
421
+ </dd><dt id="user-content-leafblockparser.finish">
422
+ <code><strong><a href="#user-content-leafblockparser.finish">finish</a></strong>(<a id="user-content-leafblockparser.finish^cx" href="#user-content-leafblockparser.finish^cx">cx</a>: <a href="#user-content-blockcontext">BlockContext</a>, <a id="user-content-leafblockparser.finish^leaf" href="#user-content-leafblockparser.finish^leaf">leaf</a>: <a href="#user-content-leafblock">LeafBlock</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
423
+
424
+ <dd><p>Called when the block is finished by external circumstances
425
+ (such as a blank line or the <a href="#user-content-blockparser.endleaf">start</a> of
426
+ another construct). If this parser can handle the block up to
427
+ its current position, it should
428
+ <a href="#user-content-blockcontext.addleafelement">finish</a> the block and return
429
+ true.</p>
430
+ </dd></dl>
431
+
432
+ </dd>
433
+ </dl>
434
+ <dl>
435
+ <dt id="user-content-line">
436
+ <h4>
437
+ <code>class</code>
438
+ <a href="#user-content-line">Line</a></h4>
439
+ </dt>
440
+
441
+ <dd><p>Data structure used during block-level per-line parsing.</p>
442
+ <dl><dt id="user-content-line.text">
443
+ <code><strong><a href="#user-content-line.text">text</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
444
+
445
+ <dd><p>The line's full text.</p>
446
+ </dd><dt id="user-content-line.baseindent">
447
+ <code><strong><a href="#user-content-line.baseindent">baseIndent</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
448
+
449
+ <dd><p>The base indent provided by the composite contexts (that have
450
+ been handled so far).</p>
451
+ </dd><dt id="user-content-line.basepos">
452
+ <code><strong><a href="#user-content-line.basepos">basePos</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
453
+
454
+ <dd><p>The string position corresponding to the base indent.</p>
455
+ </dd><dt id="user-content-line.pos">
456
+ <code><strong><a href="#user-content-line.pos">pos</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
457
+
458
+ <dd><p>The position of the next non-whitespace character beyond any
459
+ list, blockquote, or other composite block markers.</p>
460
+ </dd><dt id="user-content-line.indent">
461
+ <code><strong><a href="#user-content-line.indent">indent</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
462
+
463
+ <dd><p>The column of the next non-whitespace character.</p>
464
+ </dd><dt id="user-content-line.next">
465
+ <code><strong><a href="#user-content-line.next">next</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
466
+
467
+ <dd><p>The character code of the character after <code>pos</code>.</p>
468
+ </dd><dt id="user-content-line.skipspace">
469
+ <code><strong><a href="#user-content-line.skipspace">skipSpace</a></strong>(<a id="user-content-line.skipspace^from" href="#user-content-line.skipspace^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
470
+
471
+ <dd><p>Skip whitespace after the given position, return the position of
472
+ the next non-space character or the end of the line if there's
473
+ only space after <code>from</code>.</p>
474
+ </dd><dt id="user-content-line.movebase">
475
+ <code><strong><a href="#user-content-line.movebase">moveBase</a></strong>(<a id="user-content-line.movebase^to" href="#user-content-line.movebase^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code></dt>
476
+
477
+ <dd><p>Move the line's base position forward to the given position.
478
+ This should only be called by composite <a href="#user-content-blockparser.parse">block
479
+ parsers</a> or <a href="#user-content-nodespec.composite">markup skipping
480
+ functions</a>.</p>
481
+ </dd><dt id="user-content-line.movebasecolumn">
482
+ <code><strong><a href="#user-content-line.movebasecolumn">moveBaseColumn</a></strong>(<a id="user-content-line.movebasecolumn^indent" href="#user-content-line.movebasecolumn^indent">indent</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code></dt>
483
+
484
+ <dd><p>Move the line's base position forward to the given <em>column</em>.</p>
485
+ </dd><dt id="user-content-line.addmarker">
486
+ <code><strong><a href="#user-content-line.addmarker">addMarker</a></strong>(<a id="user-content-line.addmarker^elt" href="#user-content-line.addmarker^elt">elt</a>: <a href="#user-content-element">Element</a>)</code></dt>
487
+
488
+ <dd><p>Store a composite-block-level marker. Should be called from
489
+ <a href="#user-content-nodespec.composite">markup skipping functions</a> when they
490
+ consume any non-whitespace characters.</p>
491
+ </dd><dt id="user-content-line.countindent">
492
+ <code><strong><a href="#user-content-line.countindent">countIndent</a></strong>(<a id="user-content-line.countindent^to" href="#user-content-line.countindent^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-line.countindent^from" href="#user-content-line.countindent^from">from</a>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> = 0, <a id="user-content-line.countindent^indent" href="#user-content-line.countindent^indent">indent</a>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> = 0) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
493
+
494
+ <dd><p>Find the column position at <code>to</code>, optionally starting at a given
495
+ position and column.</p>
496
+ </dd><dt id="user-content-line.findcolumn">
497
+ <code><strong><a href="#user-content-line.findcolumn">findColumn</a></strong>(<a id="user-content-line.findcolumn^goal" href="#user-content-line.findcolumn^goal">goal</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
498
+
499
+ <dd><p>Find the position corresponding to the given column.</p>
500
+ </dd></dl>
501
+
502
+ </dd>
503
+ </dl>
504
+ <dl>
505
+ <dt id="user-content-leafblock">
506
+ <h4>
507
+ <code>class</code>
508
+ <a href="#user-content-leafblock">LeafBlock</a></h4>
509
+ </dt>
510
+
511
+ <dd><p>Data structure used to accumulate a block's content during <a href="#user-content-blockparser.leaf">leaf
512
+ block parsing</a>.</p>
513
+ <dl><dt id="user-content-leafblock.parsers">
514
+ <code><strong><a href="#user-content-leafblock.parsers">parsers</a></strong>: <a href="#user-content-leafblockparser">LeafBlockParser</a>[]</code></dt>
515
+
516
+ <dd><p>The block parsers active for this block.</p>
517
+ </dd><dt id="user-content-leafblock.start">
518
+ <code><strong><a href="#user-content-leafblock.start">start</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
519
+
520
+ <dd><p>The start position of the block.</p>
521
+ </dd><dt id="user-content-leafblock.content">
522
+ <code><strong><a href="#user-content-leafblock.content">content</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
523
+
524
+ <dd><p>The block's text content.</p>
525
+ </dd></dl>
526
+
527
+ </dd>
528
+ </dl>
529
+ <dl>
530
+ <dt id="user-content-inlinecontext">
531
+ <h4>
532
+ <code>class</code>
533
+ <a href="#user-content-inlinecontext">InlineContext</a></h4>
534
+ </dt>
535
+
536
+ <dd><p>Inline parsing functions get access to this context, and use it to
537
+ read the content and emit syntax nodes.</p>
538
+ <dl><dt id="user-content-inlinecontext.parser">
539
+ <code><strong><a href="#user-content-inlinecontext.parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
540
+
541
+ <dd><p>The parser that is being used.</p>
542
+ </dd><dt id="user-content-inlinecontext.text">
543
+ <code><strong><a href="#user-content-inlinecontext.text">text</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
544
+
545
+ <dd><p>The text of this inline section.</p>
546
+ </dd><dt id="user-content-inlinecontext.offset">
547
+ <code><strong><a href="#user-content-inlinecontext.offset">offset</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
548
+
549
+ <dd><p>The starting offset of the section in the document.</p>
550
+ </dd><dt id="user-content-inlinecontext.char">
551
+ <code><strong><a href="#user-content-inlinecontext.char">char</a></strong>(<a id="user-content-inlinecontext.char^pos" href="#user-content-inlinecontext.char^pos">pos</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
552
+
553
+ <dd><p>Get the character code at the given (document-relative)
554
+ position.</p>
555
+ </dd><dt id="user-content-inlinecontext.end">
556
+ <code><strong><a href="#user-content-inlinecontext.end">end</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
557
+
558
+ <dd><p>The position of the end of this inline section.</p>
559
+ </dd><dt id="user-content-inlinecontext.slice">
560
+ <code><strong><a href="#user-content-inlinecontext.slice">slice</a></strong>(<a id="user-content-inlinecontext.slice^from" href="#user-content-inlinecontext.slice^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlinecontext.slice^to" href="#user-content-inlinecontext.slice^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
561
+
562
+ <dd><p>Get a substring of this inline section. Again uses
563
+ document-relative positions.</p>
564
+ </dd><dt id="user-content-inlinecontext.adddelimiter">
565
+ <code><strong><a href="#user-content-inlinecontext.adddelimiter">addDelimiter</a></strong>(<a id="user-content-inlinecontext.adddelimiter^type" href="#user-content-inlinecontext.adddelimiter^type">type</a>: <a href="#user-content-delimitertype">DelimiterType</a>, <a id="user-content-inlinecontext.adddelimiter^from" href="#user-content-inlinecontext.adddelimiter^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlinecontext.adddelimiter^to" href="#user-content-inlinecontext.adddelimiter^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlinecontext.adddelimiter^open" href="#user-content-inlinecontext.adddelimiter^open">open</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a id="user-content-inlinecontext.adddelimiter^close" href="#user-content-inlinecontext.adddelimiter^close">close</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
566
+
567
+ <dd><p>Add a <a href="#user-content-delimitertype">delimiter</a> at this given position. <code>open</code>
568
+ and <code>close</code> indicate whether this delimiter is opening, closing,
569
+ or both. Returns the end of the delimiter, for convenient
570
+ returning from <a href="#user-content-inlineparser.parse">parse functions</a>.</p>
571
+ </dd><dt id="user-content-inlinecontext.hasopenlink">
572
+ <code><strong><a href="#user-content-inlinecontext.hasopenlink">hasOpenLink</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
573
+
574
+ <dd><p>Returns true when there is an unmatched link or image opening
575
+ token before the current position.</p>
576
+ </dd><dt id="user-content-inlinecontext.addelement">
577
+ <code><strong><a href="#user-content-inlinecontext.addelement">addElement</a></strong>(<a id="user-content-inlinecontext.addelement^elt" href="#user-content-inlinecontext.addelement^elt">elt</a>: <a href="#user-content-element">Element</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
578
+
579
+ <dd><p>Add an inline element. Returns the end of the element.</p>
580
+ </dd><dt id="user-content-inlinecontext.findopeningdelimiter">
581
+ <code><strong><a href="#user-content-inlinecontext.findopeningdelimiter">findOpeningDelimiter</a></strong>(<a id="user-content-inlinecontext.findopeningdelimiter^type" href="#user-content-inlinecontext.findopeningdelimiter^type">type</a>: <a href="#user-content-delimitertype">DelimiterType</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
582
+
583
+ <dd><p>Find an opening delimiter of the given type. Returns <code>null</code> if
584
+ no delimiter is found, or an index that can be passed to
585
+ <a href="#user-content-inlinecontext.takecontent"><code>takeContent</code></a> otherwise.</p>
586
+ </dd><dt id="user-content-inlinecontext.takecontent">
587
+ <code><strong><a href="#user-content-inlinecontext.takecontent">takeContent</a></strong>(<a id="user-content-inlinecontext.takecontent^startindex" href="#user-content-inlinecontext.takecontent^startindex">startIndex</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="#user-content-element">Element</a>[]</code></dt>
588
+
589
+ <dd><p>Remove all inline elements and delimiters starting from the
590
+ given index (which you should get from
591
+ <a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>,
592
+ resolve delimiters inside of them, and return them as an array
593
+ of elements.</p>
594
+ </dd><dt id="user-content-inlinecontext.getdelimiterat">
595
+ <code><strong><a href="#user-content-inlinecontext.getdelimiterat">getDelimiterAt</a></strong>(<a id="user-content-inlinecontext.getdelimiterat^index" href="#user-content-inlinecontext.getdelimiterat^index">index</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → {from: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, to: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, type: <a href="#user-content-delimitertype">DelimiterType</a>} | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
596
+
597
+ <dd><p>Return the delimiter at the given index. Mostly useful to get
598
+ additional info out of a delimiter index returned by
599
+ <a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>.
600
+ Returns null if there is no delimiter at this index.</p>
601
+ </dd><dt id="user-content-inlinecontext.skipspace">
602
+ <code><strong><a href="#user-content-inlinecontext.skipspace">skipSpace</a></strong>(<a id="user-content-inlinecontext.skipspace^from" href="#user-content-inlinecontext.skipspace^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
603
+
604
+ <dd><p>Skip space after the given (document) position, returning either
605
+ the position of the next non-space character or the end of the
606
+ section.</p>
607
+ </dd><dt id="user-content-inlinecontext.elt">
608
+ <code><strong><a href="#user-content-inlinecontext.elt">elt</a></strong>(<a id="user-content-inlinecontext.elt^type" href="#user-content-inlinecontext.elt^type">type</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a id="user-content-inlinecontext.elt^from" href="#user-content-inlinecontext.elt^from">from</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlinecontext.elt^to" href="#user-content-inlinecontext.elt^to">to</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlinecontext.elt^children" href="#user-content-inlinecontext.elt^children">children</a>&#8288;?: readonly <a href="#user-content-element">Element</a>[]) → <a href="#user-content-element">Element</a></code><div><code><strong><a href="#user-content-inlinecontext.elt">elt</a></strong>(<a id="user-content-inlinecontext.elt^tree" href="#user-content-inlinecontext.elt^tree">tree</a>: <a href="https://lezer.codemirror.net/docs/ref/#common.Tree">Tree</a>, <a id="user-content-inlinecontext.elt^at" href="#user-content-inlinecontext.elt^at">at</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="#user-content-element">Element</a></code></div></dt>
609
+
610
+ <dd><p>Create an <a href="#user-content-element"><code>Element</code></a> for a syntax node.</p>
611
+ </dd><dt id="user-content-inlinecontext^linkstart">
612
+ <code>static <strong><a href="#user-content-inlinecontext^linkstart">linkStart</a></strong>: <a href="#user-content-delimitertype">DelimiterType</a></code></dt>
613
+
614
+ <dd><p>The opening delimiter type used by the standard link parser.</p>
615
+ </dd><dt id="user-content-inlinecontext^imagestart">
616
+ <code>static <strong><a href="#user-content-inlinecontext^imagestart">imageStart</a></strong>: <a href="#user-content-delimitertype">DelimiterType</a></code></dt>
617
+
618
+ <dd><p>Opening delimiter type used for standard images.</p>
619
+ </dd></dl>
620
+
621
+ </dd>
622
+ </dl>
623
+ <dl>
624
+ <dt id="user-content-inlineparser">
625
+ <h4>
626
+ <code>interface</code>
627
+ <a href="#user-content-inlineparser">InlineParser</a></h4>
628
+ </dt>
629
+
630
+ <dd><p>Inline parsers are called for every character of parts of the
631
+ document that are parsed as inline content.</p>
632
+ <dl><dt id="user-content-inlineparser.name">
633
+ <code><strong><a href="#user-content-inlineparser.name">name</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
634
+
635
+ <dd><p>This parser's name, which can be used by other parsers to
636
+ <a href="#user-content-inlineparser.before">indicate</a> a relative precedence.</p>
637
+ </dd><dt id="user-content-inlineparser.parse">
638
+ <code><strong><a href="#user-content-inlineparser.parse">parse</a></strong>(<a id="user-content-inlineparser.parse^cx" href="#user-content-inlineparser.parse^cx">cx</a>: <a href="#user-content-inlinecontext">InlineContext</a>, <a id="user-content-inlineparser.parse^next" href="#user-content-inlineparser.parse^next">next</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a id="user-content-inlineparser.parse^pos" href="#user-content-inlineparser.parse^pos">pos</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
639
+
640
+ <dd><p>The parse function. Gets the next character and its position as
641
+ arguments. Should return -1 if it doesn't handle the character,
642
+ or add some <a href="#user-content-inlinecontext.addelement">element</a> or
643
+ <a href="#user-content-inlinecontext.adddelimiter">delimiter</a> and return the end
644
+ position of the content it parsed if it can.</p>
645
+ </dd><dt id="user-content-inlineparser.before">
646
+ <code><strong><a href="#user-content-inlineparser.before">before</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
647
+
648
+ <dd><p>When given, this parser will be installed directly before the
649
+ parser with the given name. The default configuration defines
650
+ inline parsers with names Escape, Entity, InlineCode, HTMLTag,
651
+ Emphasis, HardBreak, Link, and Image. When no <code>before</code> or
652
+ <code>after</code> property is given, the parser is added to the end of the
653
+ list.</p>
654
+ </dd><dt id="user-content-inlineparser.after">
655
+ <code><strong><a href="#user-content-inlineparser.after">after</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
656
+
657
+ <dd><p>When given, the parser will be installed directly <em>after</em> the
658
+ parser with the given name.</p>
659
+ </dd></dl>
660
+
661
+ </dd>
662
+ </dl>
663
+ <dl>
664
+ <dt id="user-content-delimitertype">
665
+ <h4>
666
+ <code>interface</code>
667
+ <a href="#user-content-delimitertype">DelimiterType</a></h4>
668
+ </dt>
669
+
670
+ <dd><p>Delimiters are used during inline parsing to store the positions
671
+ of things that <em>might</em> be delimiters, if another matching
672
+ delimiter is found. They are identified by objects with these
673
+ properties.</p>
674
+ <dl><dt id="user-content-delimitertype.resolve">
675
+ <code><strong><a href="#user-content-delimitertype.resolve">resolve</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
676
+
677
+ <dd><p>If this is given, the delimiter should be matched automatically
678
+ when a piece of inline content is finished. Such delimiters will
679
+ be matched with delimiters of the same type according to their
680
+ <a href="#user-content-inlinecontext.adddelimiter">open and close</a> properties. When a
681
+ match is found, the content between the delimiters is wrapped in
682
+ a node whose name is given by the value of this property.</p>
683
+ <p>When this isn't given, you need to match the delimiter eagerly
684
+ using the <a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>
685
+ and <a href="#user-content-inlinecontext.takecontent"><code>takeContent</code></a> methods.</p>
686
+ </dd><dt id="user-content-delimitertype.mark">
687
+ <code><strong><a href="#user-content-delimitertype.mark">mark</a></strong>&#8288;?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
688
+
689
+ <dd><p>If the delimiter itself should, when matched, create a syntax
690
+ node, set this to the name of the syntax node.</p>
691
+ </dd></dl>
692
+
693
+ </dd>
694
+ </dl>
695
+ <dl>
696
+ <dt id="user-content-element">
697
+ <h4>
698
+ <code>class</code>
699
+ <a href="#user-content-element">Element</a></h4>
700
+ </dt>
701
+
702
+ <dd><p>Elements are used to compose syntax nodes during parsing.</p>
703
+ <dl><dt id="user-content-element.type">
704
+ <code><strong><a href="#user-content-element.type">type</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
705
+
706
+ <dd><p>The node's
707
+ <a href="https://lezer.codemirror.net/docs/ref/#common.NodeType.id">id</a>.</p>
708
+ </dd><dt id="user-content-element.from">
709
+ <code><strong><a href="#user-content-element.from">from</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
710
+
711
+ <dd><p>The start of the node, as an offset from the start of the document.</p>
712
+ </dd><dt id="user-content-element.to">
713
+ <code><strong><a href="#user-content-element.to">to</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></dt>
714
+
715
+ <dd><p>The end of the node.</p>
716
+ </dd></dl>
717
+
718
+ </dd>
719
+ </dl>