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