Premier commit déjà bien avancé
This commit is contained in:
261
frontend/node_modules/@lezer/markdown/CHANGELOG.md
generated
vendored
Normal file
261
frontend/node_modules/@lezer/markdown/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,261 @@
|
||||
## 1.6.0 (2025-11-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When a composite block adds a node while ending, make sure the composite node covers that end token.
|
||||
|
||||
### New features
|
||||
|
||||
Export the opening delimiters used for standard links and images, so that extension code can look for them.
|
||||
|
||||
## 1.5.1 (2025-10-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `findOpeningDelimiter` could return the position of a close delimiter.
|
||||
|
||||
## 1.5.0 (2025-10-18)
|
||||
|
||||
### New features
|
||||
|
||||
A `getDelimiterAt` method on inline contexts makes it possible to get information about opening delimiters.
|
||||
|
||||
## 1.4.3 (2025-04-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Run the HTML parser on HTML comment blocks, since those may include non-comment content at their end.
|
||||
|
||||
## 1.4.2 (2025-02-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Move some dependencies to dev dependencies.
|
||||
|
||||
## 1.4.1 (2025-02-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure TypeScript's new resolution styles can find the type declarations for the CommonJS files.
|
||||
|
||||
## 1.4.0 (2025-01-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression in the autolink extension that made it fail to match some kinds of email addresses.
|
||||
|
||||
### New features
|
||||
|
||||
The new `BlockContext.peekLine` method can be used to scan the line ahead of the current one.
|
||||
|
||||
## 1.3.2 (2024-10-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a quadratic slowdown in the Autolink extension on parsing text containing extremely long words.
|
||||
|
||||
## 1.3.1 (2024-09-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix emphasis parsing to properly test for punctuation on platforms that support regular expression unicode categories.
|
||||
|
||||
Fix an issue where dashes right after a paragraph weren't parsed as horizontal rules when setext headers are disabled.
|
||||
|
||||
## 1.3.0 (2024-04-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
GFM autolinks will no longer include the closing bracket of a surrounding link or image.
|
||||
|
||||
### New features
|
||||
|
||||
`InlineContext.hasOpenLink` can now be used to query whether there is an unclosed link or image marker before the current token.
|
||||
|
||||
## 1.2.0 (2023-12-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Properly require whitespace before link titles. Parse autolinks as their own nodes
|
||||
|
||||
### New features
|
||||
|
||||
Wrap autolinks in an `Autolink` syntax node, rather than just `URL`, and exclude the wrapping angle brackets from the `URL` nodes.
|
||||
|
||||
## 1.1.2 (2023-12-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that could cause blockquote markers to be attached to the wrong parent node, causing them to overlap with sibling syntax nodes.
|
||||
|
||||
## 1.1.1 (2023-11-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure GFM autolinking accepts URLs like test.co.uk
|
||||
|
||||
Fix a bug in `Autolink` that made it fail to accept some URLs with hyphens.
|
||||
|
||||
## 1.1.0 (2023-08-03)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Autolink` extension (included in the `GFM` extension bundle) marks some types of URLs even without angle brackets.
|
||||
|
||||
## 1.0.5 (2023-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix another issue in reuse of nodes when the input has gaps.
|
||||
|
||||
## 1.0.4 (2023-06-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix another bug in incremental parsing across input gaps.
|
||||
|
||||
## 1.0.3 (2023-06-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Only parse list items as tasks when there is whitespace after the checkbox brackets. Remove an unnecessary regexp operator
|
||||
|
||||
Fix a crash doing an incremental parse on input ranges with gaps between them.
|
||||
|
||||
## 1.0.2 (2022-09-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
In the stikethrough extension, ignore opening marks with a space after and closing marks with a space before them.
|
||||
|
||||
## 1.0.1 (2022-06-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash that could occur when there were gaps in the parseable ranges right at the start of a line.
|
||||
|
||||
## 1.0.0 (2022-06-06)
|
||||
|
||||
### New features
|
||||
|
||||
First stable version.
|
||||
|
||||
## 0.16.1 (2022-05-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that prevented style tags from built-in extensions from being applied.
|
||||
|
||||
## 0.16.0 (2022-04-20)
|
||||
|
||||
### New features
|
||||
|
||||
This package now attached highlighting information to its syntax tree.
|
||||
|
||||
It is now possible to include highlighting information when defining nodes in extensions via `NodeSpec.style`.
|
||||
|
||||
## 0.15.6 (2022-03-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where GFM tables occurring directly below a paragraph weren't recognized.
|
||||
|
||||
## 0.15.5 (2022-02-18)
|
||||
|
||||
### New features
|
||||
|
||||
The `BlockContext` type now has a `depth` property providing the amount of parent nodes, and a `parentType` method allowing code to inspect the type of those nodes.
|
||||
|
||||
## 0.15.4 (2022-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix compatibility fallback for engines with RegExp `\p` support.
|
||||
|
||||
## 0.15.3 (2021-12-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where, if there were multiple extensions passed to the editor, the `wrap` option got dropped from the resulting configuration.
|
||||
|
||||
## 0.15.2 (2021-11-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where an ordered list item after a nested bullet list would get treated as part of the bullet list item.
|
||||
|
||||
## 0.15.1 (2021-10-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `endLeafBlock` configuration to be ignored by the parser.
|
||||
|
||||
## 0.15.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The module name has changed from `lezer-markdown` to `@lezer/markdown`.
|
||||
|
||||
`MarkdownParser` now extends `Parser` and follows its interface.
|
||||
|
||||
The Markdown parser no longer has its own support for nested parsing (but can be wrapped with `parseCode` to get a similar effect).
|
||||
|
||||
### New features
|
||||
|
||||
The new `parseCode` function can be used to set up a mixed-language parser for Markdown.
|
||||
|
||||
## 0.14.5 (2021-05-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue were continued paragraph lines starting with tabs could cause the parser to create a tree with invalid node positions.
|
||||
|
||||
## 0.14.4 (2021-03-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where an unterminated nested code block could call a nested parser with a start position beyond the end of the document.
|
||||
|
||||
Fix a bug where the parser could return an invalid tree when `forceFinish` was called during a nested parse.
|
||||
|
||||
## 0.14.3 (2021-02-22)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`parseInline` has been moved to `MarkdownParser` so that it can also be called from an inline context.
|
||||
|
||||
### New features
|
||||
|
||||
Heading nodes now have different types based on their level.
|
||||
|
||||
The `elt` helper method can now be called with a `Tree` to wrap the result of a nested parse in an element.
|
||||
|
||||
The `startNested` method is now exported.
|
||||
|
||||
## 0.14.2 (2021-02-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`BlockParser.parse`'s exported type was missing an argument.
|
||||
|
||||
Fix a bug that would cause incorrect offsets for children nested two deep in an element passed to `BlockContext.addElement`.
|
||||
|
||||
## 0.14.1 (2021-02-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix table parsing when header cells are empty.
|
||||
|
||||
## 0.14.0 (2021-02-10)
|
||||
|
||||
### New features
|
||||
|
||||
Add an extension interface. The `configure` method now takes more options, allowing client code to define new syntax node types and parse logic.
|
||||
|
||||
Add extensions for subscript, superscript, strikethrough, tables, and task lists to the distribution.
|
||||
|
||||
## 0.13.0 (2020-12-04)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
21
frontend/node_modules/@lezer/markdown/LICENSE
generated
vendored
Normal file
21
frontend/node_modules/@lezer/markdown/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2020 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
725
frontend/node_modules/@lezer/markdown/README.md
generated
vendored
Normal file
725
frontend/node_modules/@lezer/markdown/README.md
generated
vendored
Normal file
@ -0,0 +1,725 @@
|
||||
<!-- /README.md is generated from /src/README.md -->
|
||||
|
||||
# @lezer/markdown
|
||||
|
||||
This is an incremental Markdown ([CommonMark](https://commonmark.org/)
|
||||
with support for extension) parser that integrates well with the
|
||||
[Lezer](https://lezer.codemirror.net/) parser system. It does not in
|
||||
fact use the Lezer runtime (that runs LR parsers, and Markdown can't
|
||||
really be parsed that way), but it produces Lezer-style compact syntax
|
||||
trees and consumes fragments of such trees for its incremental
|
||||
parsing.
|
||||
|
||||
Note that this only _parses_ the document, producing a data structure
|
||||
that represents its syntactic form, and doesn't help with outputting
|
||||
HTML. Also, in order to be single-pass and incremental, it doesn't do
|
||||
some things that a conforming CommonMark parser is expected to
|
||||
do—specifically, it doesn't validate link references, so it'll parse
|
||||
`[a][b]` and similar as a link, even if no `[b]` reference is
|
||||
declared.
|
||||
|
||||
The
|
||||
[@codemirror/lang-markdown](https://github.com/codemirror/lang-markdown)
|
||||
package integrates this parser with CodeMirror to provide Markdown
|
||||
editor support.
|
||||
|
||||
The code is licensed under an MIT license.
|
||||
|
||||
## Interface
|
||||
<dl>
|
||||
<dt id="user-content-parser">
|
||||
<code><strong><a href="#user-content-parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
|
||||
|
||||
<dd><p>The default CommonMark parser.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-markdownparser">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-markdownparser">MarkdownParser</a> <code>extends <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a></code></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>A Markdown parser configuration.</p>
|
||||
<dl><dt id="user-content-markdownparser.nodeset">
|
||||
<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>
|
||||
|
||||
<dd><p>The parser's syntax <a href="https://lezer.codemirror.net/docs/ref/#common.NodeSet">node
|
||||
types</a>.</p>
|
||||
</dd><dt id="user-content-markdownparser.configure">
|
||||
<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>
|
||||
|
||||
<dd><p>Reconfigure the parser.</p>
|
||||
</dd><dt id="user-content-markdownparser.parseinline">
|
||||
<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>
|
||||
|
||||
<dd><p>Parse the given piece of inline text at the given offset,
|
||||
returning an array of <a href="#user-content-element"><code>Element</code></a> objects representing
|
||||
the inline content.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-markdownconfig">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-markdownconfig">MarkdownConfig</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Objects of this type are used to
|
||||
<a href="#user-content-markdownparser.configure">configure</a> the Markdown parser.</p>
|
||||
<dl><dt id="user-content-markdownconfig.props">
|
||||
<code><strong><a href="#user-content-markdownconfig.props">props</a></strong>⁠?: readonly <a href="https://lezer.codemirror.net/docs/ref/#common.NodePropSource">NodePropSource</a>[]</code></dt>
|
||||
|
||||
<dd><p>Node props to add to the parser's node set.</p>
|
||||
</dd><dt id="user-content-markdownconfig.definenodes">
|
||||
<code><strong><a href="#user-content-markdownconfig.definenodes">defineNodes</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>Define new <a href="#user-content-nodespec">node types</a> for use in parser extensions.</p>
|
||||
</dd><dt id="user-content-markdownconfig.parseblock">
|
||||
<code><strong><a href="#user-content-markdownconfig.parseblock">parseBlock</a></strong>⁠?: readonly <a href="#user-content-blockparser">BlockParser</a>[]</code></dt>
|
||||
|
||||
<dd><p>Define additional <a href="#user-content-blockparser">block parsing</a> logic.</p>
|
||||
</dd><dt id="user-content-markdownconfig.parseinline">
|
||||
<code><strong><a href="#user-content-markdownconfig.parseinline">parseInline</a></strong>⁠?: readonly <a href="#user-content-inlineparser">InlineParser</a>[]</code></dt>
|
||||
|
||||
<dd><p>Define new <a href="#user-content-inlineparser">inline parsing</a> logic.</p>
|
||||
</dd><dt id="user-content-markdownconfig.remove">
|
||||
<code><strong><a href="#user-content-markdownconfig.remove">remove</a></strong>⁠?: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[]</code></dt>
|
||||
|
||||
<dd><p>Remove the named parsers from the configuration.</p>
|
||||
</dd><dt id="user-content-markdownconfig.wrap">
|
||||
<code><strong><a href="#user-content-markdownconfig.wrap">wrap</a></strong>⁠?: <a href="https://lezer.codemirror.net/docs/ref/#common.ParseWrapper">ParseWrapper</a></code></dt>
|
||||
|
||||
<dd><p>Add a parse wrapper (such as a <a href="#user-content-common.parsemixed">mixed-language
|
||||
parser</a>) to this parser.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-markdownextension">
|
||||
<code>type</code>
|
||||
<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>
|
||||
</dt>
|
||||
|
||||
<dd><p>To make it possible to group extensions together into bigger
|
||||
extensions (such as the <a href="#user-content-gfm">Github-flavored Markdown</a>
|
||||
extension), <a href="#user-content-markdownparser.configure">reconfiguration</a> accepts
|
||||
nested arrays of <a href="#user-content-markdownconfig">config</a> objects.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-parsecode">
|
||||
<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>
|
||||
|
||||
<dd><p>Create a Markdown extension to enable nested parsing on code
|
||||
blocks and/or embedded HTML.</p>
|
||||
<dl><dt id="user-content-parsecode^config">
|
||||
<code><strong><a href="#user-content-parsecode^config">config</a></strong></code></dt>
|
||||
|
||||
<dd><dl><dt id="user-content-parsecode^config.codeparser">
|
||||
<code><strong><a href="#user-content-parsecode^config.codeparser">codeParser</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>When provided, this will be used to parse the content of code
|
||||
blocks. <code>info</code> is the string after the opening <code>```</code> marker,
|
||||
or the empty string if there is no such info or this is an
|
||||
indented code block. If there is a parser available for the
|
||||
code, it should return a function that can construct the
|
||||
<a href="https://lezer.codemirror.net/docs/ref/#common.PartialParse">parse</a>.</p>
|
||||
</dd><dt id="user-content-parsecode^config.htmlparser">
|
||||
<code><strong><a href="#user-content-parsecode^config.htmlparser">htmlParser</a></strong>⁠?: <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a></code></dt>
|
||||
|
||||
<dd><p>The parser used to parse HTML tags (both block and inline).</p>
|
||||
</dd></dl></dd></dl></dd>
|
||||
</dl>
|
||||
|
||||
### GitHub Flavored Markdown
|
||||
<dl>
|
||||
<dt id="user-content-gfm">
|
||||
<code><strong><a href="#user-content-gfm">GFM</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a>[]</code></dt>
|
||||
|
||||
<dd><p>Extension bundle containing <a href="#user-content-table"><code>Table</code></a>,
|
||||
<a href="#user-content-tasklist"><code>TaskList</code></a>, <a href="#user-content-strikethrough"><code>Strikethrough</code></a>, and
|
||||
<a href="#user-content-autolink"><code>Autolink</code></a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-table">
|
||||
<code><strong><a href="#user-content-table">Table</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>This extension provides
|
||||
<a href="https://github.github.com/gfm/#tables-extension-">GFM-style</a>
|
||||
tables, using syntax like this:</p>
|
||||
<pre><code>| head 1 | head 2 |
|
||||
| --- | --- |
|
||||
| cell 1 | cell 2 |
|
||||
</code></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-tasklist">
|
||||
<code><strong><a href="#user-content-tasklist">TaskList</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>Extension providing
|
||||
<a href="https://github.github.com/gfm/#task-list-items-extension-">GFM-style</a>
|
||||
task list items, where list items can be prefixed with <code>[ ]</code> or
|
||||
<code>[x]</code> to add a checkbox.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-strikethrough">
|
||||
<code><strong><a href="#user-content-strikethrough">Strikethrough</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>An extension that implements
|
||||
<a href="https://github.github.com/gfm/#strikethrough-extension-">GFM-style</a>
|
||||
Strikethrough syntax using <code>~~</code> delimiters.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-autolink">
|
||||
<code><strong><a href="#user-content-autolink">Autolink</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>Extension that implements autolinking for
|
||||
<code>www.</code>/<code>http://</code>/<code>https://</code>/<code>mailto:</code>/<code>xmpp:</code> URLs and email
|
||||
addresses.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
### Other extensions
|
||||
<dl>
|
||||
<dt id="user-content-subscript">
|
||||
<code><strong><a href="#user-content-subscript">Subscript</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>Extension providing
|
||||
<a href="https://pandoc.org/MANUAL.html#superscripts-and-subscripts">Pandoc-style</a>
|
||||
subscript using <code>~</code> markers.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-superscript">
|
||||
<code><strong><a href="#user-content-superscript">Superscript</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>Extension providing
|
||||
<a href="https://pandoc.org/MANUAL.html#superscripts-and-subscripts">Pandoc-style</a>
|
||||
superscript using <code>^</code> markers.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-emoji">
|
||||
<code><strong><a href="#user-content-emoji">Emoji</a></strong>: <a href="#user-content-markdownconfig">MarkdownConfig</a></code></dt>
|
||||
|
||||
<dd><p>Extension that parses two colons with only letters, underscores,
|
||||
and numbers between them as <code>Emoji</code> nodes.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
### Extension
|
||||
|
||||
The parser can, to a certain extent, be extended to handle additional
|
||||
syntax.
|
||||
<dl>
|
||||
<dt id="user-content-nodespec">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-nodespec">NodeSpec</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Used in the <a href="#user-content-markdownconfig.definenodes">configuration</a> to define
|
||||
new <a href="https://lezer.codemirror.net/docs/ref/#common.NodeType">syntax node
|
||||
types</a>.</p>
|
||||
<dl><dt id="user-content-nodespec.name">
|
||||
<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>
|
||||
|
||||
<dd><p>The node's name.</p>
|
||||
</dd><dt id="user-content-nodespec.block">
|
||||
<code><strong><a href="#user-content-nodespec.block">block</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>Should be set to true if this type represents a block node.</p>
|
||||
</dd><dt id="user-content-nodespec.composite">
|
||||
<code><strong><a href="#user-content-nodespec.composite">composite</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>If this is a composite block, this should hold a function that,
|
||||
at the start of a new line where that block is active, checks
|
||||
whether the composite block should continue (return value) and
|
||||
optionally <a href="#user-content-line.movebase">adjusts</a> the line's base position
|
||||
and <a href="#user-content-line.addmarker">registers</a> nodes for any markers involved
|
||||
in the block's syntax.</p>
|
||||
</dd><dt id="user-content-nodespec.style">
|
||||
<code><strong><a href="#user-content-nodespec.style">style</a></strong>⁠?: <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><<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>[]></code></dt>
|
||||
|
||||
<dd><p>Add highlighting tag information for this node. The value of
|
||||
this property may either by a tag or array of tags to assign
|
||||
directly to this node, or an object in the style of
|
||||
<a href="https://lezer.codemirror.net/docs/ref/#highlight.styleTags"><code>styleTags</code></a>'s
|
||||
argument to assign more complicated rules.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-blockcontext">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-blockcontext">BlockContext</a> <code>implements <a href="https://lezer.codemirror.net/docs/ref/#common.PartialParse">PartialParse</a></code></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Block-level parsing functions get access to this context object.</p>
|
||||
<dl><dt id="user-content-blockcontext.linestart">
|
||||
<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>
|
||||
|
||||
<dd><p>The start of the current line.</p>
|
||||
</dd><dt id="user-content-blockcontext.parser">
|
||||
<code><strong><a href="#user-content-blockcontext.parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
|
||||
|
||||
<dd><p>The parser configuration used.</p>
|
||||
</dd><dt id="user-content-blockcontext.depth">
|
||||
<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>
|
||||
|
||||
<dd><p>The number of parent blocks surrounding the current block.</p>
|
||||
</dd><dt id="user-content-blockcontext.parenttype">
|
||||
<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>⁠?: <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>
|
||||
|
||||
<dd><p>Get the type of the parent block at the given depth. When no
|
||||
depth is passed, return the type of the innermost parent.</p>
|
||||
</dd><dt id="user-content-blockcontext.nextline">
|
||||
<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>
|
||||
|
||||
<dd><p>Move to the next input line. This should only be called by
|
||||
(non-composite) <a href="#user-content-blockparser.parse">block parsers</a> that consume
|
||||
the line directly, or leaf block parser
|
||||
<a href="#user-content-leafblockparser.nextline"><code>nextLine</code></a> methods when they
|
||||
consume the current line (and return true).</p>
|
||||
</dd><dt id="user-content-blockcontext.peekline">
|
||||
<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>
|
||||
|
||||
<dd><p>Retrieve the text of the line after the current one, without
|
||||
actually moving the context's current line forward.</p>
|
||||
</dd><dt id="user-content-blockcontext.prevlineend">
|
||||
<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>
|
||||
|
||||
<dd><p>The end position of the previous line.</p>
|
||||
</dd><dt id="user-content-blockcontext.startcomposite">
|
||||
<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>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> = 0)</code></dt>
|
||||
|
||||
<dd><p>Start a composite block. Should only be called from <a href="#user-content-blockparser.parse">block
|
||||
parser functions</a> that return null.</p>
|
||||
</dd><dt id="user-content-blockcontext.addelement">
|
||||
<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>
|
||||
|
||||
<dd><p>Add a block element. Can be called by <a href="#user-content-blockparser.parse">block
|
||||
parsers</a>.</p>
|
||||
</dd><dt id="user-content-blockcontext.addleafelement">
|
||||
<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>
|
||||
|
||||
<dd><p>Add a block element from a <a href="#user-content-leafblockparser">leaf parser</a>. This
|
||||
makes sure any extra composite block markup (such as blockquote
|
||||
markers) inside the block are also added to the syntax tree.</p>
|
||||
</dd><dt id="user-content-blockcontext.elt">
|
||||
<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>⁠?: 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>
|
||||
|
||||
<dd><p>Create an <a href="#user-content-element"><code>Element</code></a> object to represent some syntax
|
||||
node.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-blockparser">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-blockparser">BlockParser</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Block parsers handle block-level structure. There are three
|
||||
general types of block parsers:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Composite block parsers, which handle things like lists and
|
||||
blockquotes. These define a <a href="#user-content-blockparser.parse"><code>parse</code></a> method
|
||||
that <a href="#user-content-blockcontext.startcomposite">starts</a> a composite block
|
||||
and returns null when it recognizes its syntax.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Eager leaf block parsers, used for things like code or HTML
|
||||
blocks. These can unambiguously recognize their content from its
|
||||
first line. They define a <a href="#user-content-blockparser.parse"><code>parse</code></a> method
|
||||
that, if it recognizes the construct,
|
||||
<a href="#user-content-blockcontext.nextline">moves</a> the current line forward to the
|
||||
line beyond the end of the block,
|
||||
<a href="#user-content-blockcontext.addelement">add</a> a syntax node for the block, and
|
||||
return true.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Leaf block parsers that observe a paragraph-like construct as it
|
||||
comes in, and optionally decide to handle it at some point. This
|
||||
is used for "setext" (underlined) headings and link references.
|
||||
These define a <a href="#user-content-blockparser.leaf"><code>leaf</code></a> method that checks
|
||||
the first line of the block and returns a
|
||||
<a href="#user-content-leafblockparser"><code>LeafBlockParser</code></a> object if it wants to
|
||||
observe that block.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<dl><dt id="user-content-blockparser.name">
|
||||
<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>
|
||||
|
||||
<dd><p>The name of the parser. Can be used by other block parsers to
|
||||
<a href="#user-content-blockparser.before">specify</a> precedence.</p>
|
||||
</dd><dt id="user-content-blockparser.parse">
|
||||
<code><strong><a href="#user-content-blockparser.parse">parse</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>The eager parse function, which can look at the block's first
|
||||
line and return <code>false</code> to do nothing, <code>true</code> if it has parsed
|
||||
(and <a href="#user-content-blockcontext.nextline">moved past</a> a block), or <code>null</code> if
|
||||
it has started a composite block.</p>
|
||||
</dd><dt id="user-content-blockparser.leaf">
|
||||
<code><strong><a href="#user-content-blockparser.leaf">leaf</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>A leaf parse function. If no <a href="#user-content-blockparser.parse">regular</a> parse
|
||||
functions match for a given line, its content will be
|
||||
accumulated for a paragraph-style block. This method can return
|
||||
an <a href="#user-content-leafblockparser">object</a> that overrides that style of
|
||||
parsing in some situations.</p>
|
||||
</dd><dt id="user-content-blockparser.endleaf">
|
||||
<code><strong><a href="#user-content-blockparser.endleaf">endLeaf</a></strong>⁠?: 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>
|
||||
|
||||
<dd><p>Some constructs, such as code blocks or newly started
|
||||
blockquotes, can interrupt paragraphs even without a blank line.
|
||||
If your construct can do this, provide a predicate here that
|
||||
recognizes lines that should end a paragraph (or other non-eager
|
||||
<a href="#user-content-blockparser.leaf">leaf block</a>).</p>
|
||||
</dd><dt id="user-content-blockparser.before">
|
||||
<code><strong><a href="#user-content-blockparser.before">before</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>When given, this parser will be installed directly before the
|
||||
block parser with the given name. The default configuration
|
||||
defines block parsers with names LinkReference, IndentedCode,
|
||||
FencedCode, Blockquote, HorizontalRule, BulletList, OrderedList,
|
||||
ATXHeading, HTMLBlock, and SetextHeading.</p>
|
||||
</dd><dt id="user-content-blockparser.after">
|
||||
<code><strong><a href="#user-content-blockparser.after">after</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>When given, the parser will be installed directly <em>after</em> the
|
||||
parser with the given name.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-leafblockparser">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-leafblockparser">LeafBlockParser</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Objects that are used to <a href="#user-content-blockparser.leaf">override</a>
|
||||
paragraph-style blocks should conform to this interface.</p>
|
||||
<dl><dt id="user-content-leafblockparser.nextline">
|
||||
<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>
|
||||
|
||||
<dd><p>Update the parser's state for the next line, and optionally
|
||||
finish the block. This is not called for the first line (the
|
||||
object is constructed at that line), but for any further lines.
|
||||
When it returns <code>true</code>, the block is finished. It is okay for
|
||||
the function to <a href="#user-content-blockcontext.nextline">consume</a> the current
|
||||
line or any subsequent lines when returning true.</p>
|
||||
</dd><dt id="user-content-leafblockparser.finish">
|
||||
<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>
|
||||
|
||||
<dd><p>Called when the block is finished by external circumstances
|
||||
(such as a blank line or the <a href="#user-content-blockparser.endleaf">start</a> of
|
||||
another construct). If this parser can handle the block up to
|
||||
its current position, it should
|
||||
<a href="#user-content-blockcontext.addleafelement">finish</a> the block and return
|
||||
true.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-line">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-line">Line</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Data structure used during block-level per-line parsing.</p>
|
||||
<dl><dt id="user-content-line.text">
|
||||
<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>
|
||||
|
||||
<dd><p>The line's full text.</p>
|
||||
</dd><dt id="user-content-line.baseindent">
|
||||
<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>
|
||||
|
||||
<dd><p>The base indent provided by the composite contexts (that have
|
||||
been handled so far).</p>
|
||||
</dd><dt id="user-content-line.basepos">
|
||||
<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>
|
||||
|
||||
<dd><p>The string position corresponding to the base indent.</p>
|
||||
</dd><dt id="user-content-line.pos">
|
||||
<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>
|
||||
|
||||
<dd><p>The position of the next non-whitespace character beyond any
|
||||
list, blockquote, or other composite block markers.</p>
|
||||
</dd><dt id="user-content-line.indent">
|
||||
<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>
|
||||
|
||||
<dd><p>The column of the next non-whitespace character.</p>
|
||||
</dd><dt id="user-content-line.next">
|
||||
<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>
|
||||
|
||||
<dd><p>The character code of the character after <code>pos</code>.</p>
|
||||
</dd><dt id="user-content-line.skipspace">
|
||||
<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>
|
||||
|
||||
<dd><p>Skip whitespace after the given position, return the position of
|
||||
the next non-space character or the end of the line if there's
|
||||
only space after <code>from</code>.</p>
|
||||
</dd><dt id="user-content-line.movebase">
|
||||
<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>
|
||||
|
||||
<dd><p>Move the line's base position forward to the given position.
|
||||
This should only be called by composite <a href="#user-content-blockparser.parse">block
|
||||
parsers</a> or <a href="#user-content-nodespec.composite">markup skipping
|
||||
functions</a>.</p>
|
||||
</dd><dt id="user-content-line.movebasecolumn">
|
||||
<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>
|
||||
|
||||
<dd><p>Move the line's base position forward to the given <em>column</em>.</p>
|
||||
</dd><dt id="user-content-line.addmarker">
|
||||
<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>
|
||||
|
||||
<dd><p>Store a composite-block-level marker. Should be called from
|
||||
<a href="#user-content-nodespec.composite">markup skipping functions</a> when they
|
||||
consume any non-whitespace characters.</p>
|
||||
</dd><dt id="user-content-line.countindent">
|
||||
<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>⁠?: <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>⁠?: <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>
|
||||
|
||||
<dd><p>Find the column position at <code>to</code>, optionally starting at a given
|
||||
position and column.</p>
|
||||
</dd><dt id="user-content-line.findcolumn">
|
||||
<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>
|
||||
|
||||
<dd><p>Find the position corresponding to the given column.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-leafblock">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-leafblock">LeafBlock</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Data structure used to accumulate a block's content during <a href="#user-content-blockparser.leaf">leaf
|
||||
block parsing</a>.</p>
|
||||
<dl><dt id="user-content-leafblock.parsers">
|
||||
<code><strong><a href="#user-content-leafblock.parsers">parsers</a></strong>: <a href="#user-content-leafblockparser">LeafBlockParser</a>[]</code></dt>
|
||||
|
||||
<dd><p>The block parsers active for this block.</p>
|
||||
</dd><dt id="user-content-leafblock.start">
|
||||
<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>
|
||||
|
||||
<dd><p>The start position of the block.</p>
|
||||
</dd><dt id="user-content-leafblock.content">
|
||||
<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>
|
||||
|
||||
<dd><p>The block's text content.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-inlinecontext">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-inlinecontext">InlineContext</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Inline parsing functions get access to this context, and use it to
|
||||
read the content and emit syntax nodes.</p>
|
||||
<dl><dt id="user-content-inlinecontext.parser">
|
||||
<code><strong><a href="#user-content-inlinecontext.parser">parser</a></strong>: <a href="#user-content-markdownparser">MarkdownParser</a></code></dt>
|
||||
|
||||
<dd><p>The parser that is being used.</p>
|
||||
</dd><dt id="user-content-inlinecontext.text">
|
||||
<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>
|
||||
|
||||
<dd><p>The text of this inline section.</p>
|
||||
</dd><dt id="user-content-inlinecontext.offset">
|
||||
<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>
|
||||
|
||||
<dd><p>The starting offset of the section in the document.</p>
|
||||
</dd><dt id="user-content-inlinecontext.char">
|
||||
<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>
|
||||
|
||||
<dd><p>Get the character code at the given (document-relative)
|
||||
position.</p>
|
||||
</dd><dt id="user-content-inlinecontext.end">
|
||||
<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>
|
||||
|
||||
<dd><p>The position of the end of this inline section.</p>
|
||||
</dd><dt id="user-content-inlinecontext.slice">
|
||||
<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>
|
||||
|
||||
<dd><p>Get a substring of this inline section. Again uses
|
||||
document-relative positions.</p>
|
||||
</dd><dt id="user-content-inlinecontext.adddelimiter">
|
||||
<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>
|
||||
|
||||
<dd><p>Add a <a href="#user-content-delimitertype">delimiter</a> at this given position. <code>open</code>
|
||||
and <code>close</code> indicate whether this delimiter is opening, closing,
|
||||
or both. Returns the end of the delimiter, for convenient
|
||||
returning from <a href="#user-content-inlineparser.parse">parse functions</a>.</p>
|
||||
</dd><dt id="user-content-inlinecontext.hasopenlink">
|
||||
<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>
|
||||
|
||||
<dd><p>Returns true when there is an unmatched link or image opening
|
||||
token before the current position.</p>
|
||||
</dd><dt id="user-content-inlinecontext.addelement">
|
||||
<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>
|
||||
|
||||
<dd><p>Add an inline element. Returns the end of the element.</p>
|
||||
</dd><dt id="user-content-inlinecontext.findopeningdelimiter">
|
||||
<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>
|
||||
|
||||
<dd><p>Find an opening delimiter of the given type. Returns <code>null</code> if
|
||||
no delimiter is found, or an index that can be passed to
|
||||
<a href="#user-content-inlinecontext.takecontent"><code>takeContent</code></a> otherwise.</p>
|
||||
</dd><dt id="user-content-inlinecontext.takecontent">
|
||||
<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>
|
||||
|
||||
<dd><p>Remove all inline elements and delimiters starting from the
|
||||
given index (which you should get from
|
||||
<a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>,
|
||||
resolve delimiters inside of them, and return them as an array
|
||||
of elements.</p>
|
||||
</dd><dt id="user-content-inlinecontext.getdelimiterat">
|
||||
<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>
|
||||
|
||||
<dd><p>Return the delimiter at the given index. Mostly useful to get
|
||||
additional info out of a delimiter index returned by
|
||||
<a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>.
|
||||
Returns null if there is no delimiter at this index.</p>
|
||||
</dd><dt id="user-content-inlinecontext.skipspace">
|
||||
<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>
|
||||
|
||||
<dd><p>Skip space after the given (document) position, returning either
|
||||
the position of the next non-space character or the end of the
|
||||
section.</p>
|
||||
</dd><dt id="user-content-inlinecontext.elt">
|
||||
<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>⁠?: 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>
|
||||
|
||||
<dd><p>Create an <a href="#user-content-element"><code>Element</code></a> for a syntax node.</p>
|
||||
</dd><dt id="user-content-inlinecontext^linkstart">
|
||||
<code>static <strong><a href="#user-content-inlinecontext^linkstart">linkStart</a></strong>: <a href="#user-content-delimitertype">DelimiterType</a></code></dt>
|
||||
|
||||
<dd><p>The opening delimiter type used by the standard link parser.</p>
|
||||
</dd><dt id="user-content-inlinecontext^imagestart">
|
||||
<code>static <strong><a href="#user-content-inlinecontext^imagestart">imageStart</a></strong>: <a href="#user-content-delimitertype">DelimiterType</a></code></dt>
|
||||
|
||||
<dd><p>Opening delimiter type used for standard images.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-inlineparser">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-inlineparser">InlineParser</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Inline parsers are called for every character of parts of the
|
||||
document that are parsed as inline content.</p>
|
||||
<dl><dt id="user-content-inlineparser.name">
|
||||
<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>
|
||||
|
||||
<dd><p>This parser's name, which can be used by other parsers to
|
||||
<a href="#user-content-inlineparser.before">indicate</a> a relative precedence.</p>
|
||||
</dd><dt id="user-content-inlineparser.parse">
|
||||
<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>
|
||||
|
||||
<dd><p>The parse function. Gets the next character and its position as
|
||||
arguments. Should return -1 if it doesn't handle the character,
|
||||
or add some <a href="#user-content-inlinecontext.addelement">element</a> or
|
||||
<a href="#user-content-inlinecontext.adddelimiter">delimiter</a> and return the end
|
||||
position of the content it parsed if it can.</p>
|
||||
</dd><dt id="user-content-inlineparser.before">
|
||||
<code><strong><a href="#user-content-inlineparser.before">before</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>When given, this parser will be installed directly before the
|
||||
parser with the given name. The default configuration defines
|
||||
inline parsers with names Escape, Entity, InlineCode, HTMLTag,
|
||||
Emphasis, HardBreak, Link, and Image. When no <code>before</code> or
|
||||
<code>after</code> property is given, the parser is added to the end of the
|
||||
list.</p>
|
||||
</dd><dt id="user-content-inlineparser.after">
|
||||
<code><strong><a href="#user-content-inlineparser.after">after</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>When given, the parser will be installed directly <em>after</em> the
|
||||
parser with the given name.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-delimitertype">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-delimitertype">DelimiterType</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Delimiters are used during inline parsing to store the positions
|
||||
of things that <em>might</em> be delimiters, if another matching
|
||||
delimiter is found. They are identified by objects with these
|
||||
properties.</p>
|
||||
<dl><dt id="user-content-delimitertype.resolve">
|
||||
<code><strong><a href="#user-content-delimitertype.resolve">resolve</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>If this is given, the delimiter should be matched automatically
|
||||
when a piece of inline content is finished. Such delimiters will
|
||||
be matched with delimiters of the same type according to their
|
||||
<a href="#user-content-inlinecontext.adddelimiter">open and close</a> properties. When a
|
||||
match is found, the content between the delimiters is wrapped in
|
||||
a node whose name is given by the value of this property.</p>
|
||||
<p>When this isn't given, you need to match the delimiter eagerly
|
||||
using the <a href="#user-content-inlinecontext.findopeningdelimiter"><code>findOpeningDelimiter</code></a>
|
||||
and <a href="#user-content-inlinecontext.takecontent"><code>takeContent</code></a> methods.</p>
|
||||
</dd><dt id="user-content-delimitertype.mark">
|
||||
<code><strong><a href="#user-content-delimitertype.mark">mark</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>If the delimiter itself should, when matched, create a syntax
|
||||
node, set this to the name of the syntax node.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt id="user-content-element">
|
||||
<h4>
|
||||
<code>class</code>
|
||||
<a href="#user-content-element">Element</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Elements are used to compose syntax nodes during parsing.</p>
|
||||
<dl><dt id="user-content-element.type">
|
||||
<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>
|
||||
|
||||
<dd><p>The node's
|
||||
<a href="https://lezer.codemirror.net/docs/ref/#common.NodeType.id">id</a>.</p>
|
||||
</dd><dt id="user-content-element.from">
|
||||
<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>
|
||||
|
||||
<dd><p>The start of the node, as an offset from the start of the document.</p>
|
||||
</dd><dt id="user-content-element.to">
|
||||
<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>
|
||||
|
||||
<dd><p>The end of the node.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
39
frontend/node_modules/@lezer/markdown/bin/build-readme.cjs
generated
vendored
Normal file
39
frontend/node_modules/@lezer/markdown/bin/build-readme.cjs
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
// Build github-proof readmes that contain the package's API
|
||||
// docs as HTML.
|
||||
|
||||
const {gather} = require("getdocs-ts")
|
||||
const {build} = require("builddocs")
|
||||
const {join} = require("path"), fs = require("fs")
|
||||
|
||||
let root = join(__dirname, "..")
|
||||
|
||||
function buildReadme() {
|
||||
let template = fs.readFileSync(join(root, "src", "README.md"), "utf8")
|
||||
|
||||
let placeholders = template.match(/\n@\w+(?=\n|$)/g), dummy = placeholders.join("\n\n<hr>\n\n")
|
||||
let html = build({
|
||||
mainText: dummy,
|
||||
anchorPrefix: "",
|
||||
allowUnresolvedTypes: false,
|
||||
imports: [type => {
|
||||
if (/\bcommon\b/.test(type.typeSource))
|
||||
return `https://lezer.codemirror.net/docs/ref/#common.${type.type}`
|
||||
if (/\blr\b/.test(type.typeSource))
|
||||
return `https://lezer.codemirror.net/docs/ref/#lr.${type.type}`
|
||||
if (/\bhighlight\b/.test(type.typeSource))
|
||||
return `https://lezer.codemirror.net/docs/ref/#highlight.${type.type}`
|
||||
if (type.type == "NodeSet") console.log(type.typeSource)
|
||||
}]
|
||||
}, gather({filename: join(root, "src", "index.ts"), basedir: join(root, "src"), }))
|
||||
|
||||
html = html.replace(/<\/?span.*?>/g, "")
|
||||
.replace(/id="(.*?)"/g, (_, id) => `id="user-content-${id.toLowerCase()}"`)
|
||||
.replace(/href="#(.*?)"/g, (_, id) => `href="#user-content-${id.toLowerCase()}"`)
|
||||
|
||||
let pieces = html.split("\n<hr>\n")
|
||||
|
||||
let i = 0
|
||||
return template.replace(/\n@\w+(?=\n|$)/g, _ => pieces[i++])
|
||||
}
|
||||
|
||||
fs.writeFileSync(join(root, "README.md"), buildReadme())
|
||||
16
frontend/node_modules/@lezer/markdown/build.js
generated
vendored
Normal file
16
frontend/node_modules/@lezer/markdown/build.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import {build, watch} from "@marijn/buildtool"
|
||||
import {fileURLToPath} from "url"
|
||||
import {dirname, join} from "path"
|
||||
|
||||
let tsOptions = {
|
||||
lib: ["es5", "es6"],
|
||||
target: "es6"
|
||||
}
|
||||
|
||||
let main = join(dirname(fileURLToPath(import.meta.url)), "src", "index.ts")
|
||||
|
||||
if (process.argv.includes("--watch")) {
|
||||
watch([main], [], {tsOptions})
|
||||
} else {
|
||||
build(main, {tsOptions})
|
||||
}
|
||||
2344
frontend/node_modules/@lezer/markdown/dist/index.cjs
generated
vendored
Normal file
2344
frontend/node_modules/@lezer/markdown/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
600
frontend/node_modules/@lezer/markdown/dist/index.d.cts
generated
vendored
Normal file
600
frontend/node_modules/@lezer/markdown/dist/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,600 @@
|
||||
import { PartialParse, Tree, NodeType, NodePropSource, ParseWrapper, Parser, NodeSet, Input, TreeFragment } from '@lezer/common';
|
||||
import { Tag } from '@lezer/highlight';
|
||||
|
||||
/**
|
||||
Data structure used to accumulate a block's content during [leaf
|
||||
block parsing](#BlockParser.leaf).
|
||||
*/
|
||||
declare class LeafBlock {
|
||||
/**
|
||||
The start position of the block.
|
||||
*/
|
||||
readonly start: number;
|
||||
/**
|
||||
The block's text content.
|
||||
*/
|
||||
content: string;
|
||||
/**
|
||||
The block parsers active for this block.
|
||||
*/
|
||||
parsers: LeafBlockParser[];
|
||||
}
|
||||
/**
|
||||
Data structure used during block-level per-line parsing.
|
||||
*/
|
||||
declare class Line {
|
||||
/**
|
||||
The line's full text.
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
The base indent provided by the composite contexts (that have
|
||||
been handled so far).
|
||||
*/
|
||||
baseIndent: number;
|
||||
/**
|
||||
The string position corresponding to the base indent.
|
||||
*/
|
||||
basePos: number;
|
||||
/**
|
||||
The position of the next non-whitespace character beyond any
|
||||
list, blockquote, or other composite block markers.
|
||||
*/
|
||||
pos: number;
|
||||
/**
|
||||
The column of the next non-whitespace character.
|
||||
*/
|
||||
indent: number;
|
||||
/**
|
||||
The character code of the character after `pos`.
|
||||
*/
|
||||
next: number;
|
||||
/**
|
||||
Skip whitespace after the given position, return the position of
|
||||
the next non-space character or the end of the line if there's
|
||||
only space after `from`.
|
||||
*/
|
||||
skipSpace(from: number): number;
|
||||
/**
|
||||
Move the line's base position forward to the given position.
|
||||
This should only be called by composite [block
|
||||
parsers](#BlockParser.parse) or [markup skipping
|
||||
functions](#NodeSpec.composite).
|
||||
*/
|
||||
moveBase(to: number): void;
|
||||
/**
|
||||
Move the line's base position forward to the given _column_.
|
||||
*/
|
||||
moveBaseColumn(indent: number): void;
|
||||
/**
|
||||
Store a composite-block-level marker. Should be called from
|
||||
[markup skipping functions](#NodeSpec.composite) when they
|
||||
consume any non-whitespace characters.
|
||||
*/
|
||||
addMarker(elt: Element): void;
|
||||
/**
|
||||
Find the column position at `to`, optionally starting at a given
|
||||
position and column.
|
||||
*/
|
||||
countIndent(to: number, from?: number, indent?: number): number;
|
||||
/**
|
||||
Find the position corresponding to the given column.
|
||||
*/
|
||||
findColumn(goal: number): number;
|
||||
}
|
||||
type BlockResult = boolean | null;
|
||||
/**
|
||||
Block-level parsing functions get access to this context object.
|
||||
*/
|
||||
declare class BlockContext implements PartialParse {
|
||||
/**
|
||||
The parser configuration used.
|
||||
*/
|
||||
readonly parser: MarkdownParser;
|
||||
private line;
|
||||
private atEnd;
|
||||
private fragments;
|
||||
private to;
|
||||
stoppedAt: number | null;
|
||||
/**
|
||||
The start of the current line.
|
||||
*/
|
||||
lineStart: number;
|
||||
get parsedPos(): number;
|
||||
advance(): Tree | null;
|
||||
stopAt(pos: number): void;
|
||||
private reuseFragment;
|
||||
/**
|
||||
The number of parent blocks surrounding the current block.
|
||||
*/
|
||||
get depth(): number;
|
||||
/**
|
||||
Get the type of the parent block at the given depth. When no
|
||||
depth is passed, return the type of the innermost parent.
|
||||
*/
|
||||
parentType(depth?: number): NodeType;
|
||||
/**
|
||||
Move to the next input line. This should only be called by
|
||||
(non-composite) [block parsers](#BlockParser.parse) that consume
|
||||
the line directly, or leaf block parser
|
||||
[`nextLine`](#LeafBlockParser.nextLine) methods when they
|
||||
consume the current line (and return true).
|
||||
*/
|
||||
nextLine(): boolean;
|
||||
/**
|
||||
Retrieve the text of the line after the current one, without
|
||||
actually moving the context's current line forward.
|
||||
*/
|
||||
peekLine(): string;
|
||||
private moveRangeI;
|
||||
private lineChunkAt;
|
||||
/**
|
||||
The end position of the previous line.
|
||||
*/
|
||||
prevLineEnd(): number;
|
||||
/**
|
||||
Start a composite block. Should only be called from [block
|
||||
parser functions](#BlockParser.parse) that return null.
|
||||
*/
|
||||
startComposite(type: string, start: number, value?: number): void;
|
||||
/**
|
||||
Add a block element. Can be called by [block
|
||||
parsers](#BlockParser.parse).
|
||||
*/
|
||||
addElement(elt: Element): void;
|
||||
/**
|
||||
Add a block element from a [leaf parser](#LeafBlockParser). This
|
||||
makes sure any extra composite block markup (such as blockquote
|
||||
markers) inside the block are also added to the syntax tree.
|
||||
*/
|
||||
addLeafElement(leaf: LeafBlock, elt: Element): void;
|
||||
private finish;
|
||||
private addGaps;
|
||||
/**
|
||||
Create an [`Element`](#Element) object to represent some syntax
|
||||
node.
|
||||
*/
|
||||
elt(type: string, from: number, to: number, children?: readonly Element[]): Element;
|
||||
elt(tree: Tree, at: number): Element;
|
||||
}
|
||||
/**
|
||||
Used in the [configuration](#MarkdownConfig.defineNodes) to define
|
||||
new [syntax node
|
||||
types](https://lezer.codemirror.net/docs/ref/#common.NodeType).
|
||||
*/
|
||||
interface NodeSpec {
|
||||
/**
|
||||
The node's name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Should be set to true if this type represents a block node.
|
||||
*/
|
||||
block?: boolean;
|
||||
/**
|
||||
If this is a composite block, this should hold a function that,
|
||||
at the start of a new line where that block is active, checks
|
||||
whether the composite block should continue (return value) and
|
||||
optionally [adjusts](#Line.moveBase) the line's base position
|
||||
and [registers](#Line.addMarker) nodes for any markers involved
|
||||
in the block's syntax.
|
||||
*/
|
||||
composite?(cx: BlockContext, line: Line, value: number): boolean;
|
||||
/**
|
||||
Add highlighting tag information for this node. The value of
|
||||
this property may either by a tag or array of tags to assign
|
||||
directly to this node, or an object in the style of
|
||||
[`styleTags`](https://lezer.codemirror.net/docs/ref/#highlight.styleTags)'s
|
||||
argument to assign more complicated rules.
|
||||
*/
|
||||
style?: Tag | readonly Tag[] | {
|
||||
[selector: string]: Tag | readonly Tag[];
|
||||
};
|
||||
}
|
||||
/**
|
||||
Inline parsers are called for every character of parts of the
|
||||
document that are parsed as inline content.
|
||||
*/
|
||||
interface InlineParser {
|
||||
/**
|
||||
This parser's name, which can be used by other parsers to
|
||||
[indicate](#InlineParser.before) a relative precedence.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The parse function. Gets the next character and its position as
|
||||
arguments. Should return -1 if it doesn't handle the character,
|
||||
or add some [element](#InlineContext.addElement) or
|
||||
[delimiter](#InlineContext.addDelimiter) and return the end
|
||||
position of the content it parsed if it can.
|
||||
*/
|
||||
parse(cx: InlineContext, next: number, pos: number): number;
|
||||
/**
|
||||
When given, this parser will be installed directly before the
|
||||
parser with the given name. The default configuration defines
|
||||
inline parsers with names Escape, Entity, InlineCode, HTMLTag,
|
||||
Emphasis, HardBreak, Link, and Image. When no `before` or
|
||||
`after` property is given, the parser is added to the end of the
|
||||
list.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When given, the parser will be installed directly _after_ the
|
||||
parser with the given name.
|
||||
*/
|
||||
after?: string;
|
||||
}
|
||||
/**
|
||||
Block parsers handle block-level structure. There are three
|
||||
general types of block parsers:
|
||||
|
||||
- Composite block parsers, which handle things like lists and
|
||||
blockquotes. These define a [`parse`](#BlockParser.parse) method
|
||||
that [starts](#BlockContext.startComposite) a composite block
|
||||
and returns null when it recognizes its syntax. The node type
|
||||
used by such a block must define a
|
||||
[`composite`](#NodeSpec.composite) function as well.
|
||||
|
||||
- Eager leaf block parsers, used for things like code or HTML
|
||||
blocks. These can unambiguously recognize their content from its
|
||||
first line. They define a [`parse`](#BlockParser.parse) method
|
||||
that, if it recognizes the construct,
|
||||
[moves](#BlockContext.nextLine) the current line forward to the
|
||||
line beyond the end of the block,
|
||||
[add](#BlockContext.addElement) a syntax node for the block, and
|
||||
return true.
|
||||
|
||||
- Leaf block parsers that observe a paragraph-like construct as it
|
||||
comes in, and optionally decide to handle it at some point. This
|
||||
is used for "setext" (underlined) headings and link references.
|
||||
These define a [`leaf`](#BlockParser.leaf) method that checks
|
||||
the first line of the block and returns a
|
||||
[`LeafBlockParser`](#LeafBlockParser) object if it wants to
|
||||
observe that block.
|
||||
*/
|
||||
interface BlockParser {
|
||||
/**
|
||||
The name of the parser. Can be used by other block parsers to
|
||||
[specify](#BlockParser.before) precedence.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The eager parse function, which can look at the block's first
|
||||
line and return `false` to do nothing, `true` if it has parsed
|
||||
(and [moved past](#BlockContext.nextLine) a block), or `null` if
|
||||
it has [started](#BlockContext.startComposite) a composite block.
|
||||
*/
|
||||
parse?(cx: BlockContext, line: Line): BlockResult;
|
||||
/**
|
||||
A leaf parse function. If no [regular](#BlockParser.parse) parse
|
||||
functions match for a given line, its content will be
|
||||
accumulated for a paragraph-style block. This method can return
|
||||
an [object](#LeafBlockParser) that overrides that style of
|
||||
parsing in some situations.
|
||||
*/
|
||||
leaf?(cx: BlockContext, leaf: LeafBlock): LeafBlockParser | null;
|
||||
/**
|
||||
Some constructs, such as code blocks or newly started
|
||||
blockquotes, can interrupt paragraphs even without a blank line.
|
||||
If your construct can do this, provide a predicate here that
|
||||
recognizes lines that should end a paragraph (or other non-eager
|
||||
[leaf block](#BlockParser.leaf)).
|
||||
*/
|
||||
endLeaf?(cx: BlockContext, line: Line, leaf: LeafBlock): boolean;
|
||||
/**
|
||||
When given, this parser will be installed directly before the
|
||||
block parser with the given name. The default configuration
|
||||
defines block parsers with names LinkReference, IndentedCode,
|
||||
FencedCode, Blockquote, HorizontalRule, BulletList, OrderedList,
|
||||
ATXHeading, HTMLBlock, and SetextHeading.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When given, the parser will be installed directly _after_ the
|
||||
parser with the given name.
|
||||
*/
|
||||
after?: string;
|
||||
}
|
||||
/**
|
||||
Objects that are used to [override](#BlockParser.leaf)
|
||||
paragraph-style blocks should conform to this interface.
|
||||
*/
|
||||
interface LeafBlockParser {
|
||||
/**
|
||||
Update the parser's state for the next line, and optionally
|
||||
finish the block. This is not called for the first line (the
|
||||
object is constructed at that line), but for any further lines.
|
||||
When it returns `true`, the block is finished. It is okay for
|
||||
the function to [consume](#BlockContext.nextLine) the current
|
||||
line or any subsequent lines when returning true.
|
||||
*/
|
||||
nextLine(cx: BlockContext, line: Line, leaf: LeafBlock): boolean;
|
||||
/**
|
||||
Called when the block is finished by external circumstances
|
||||
(such as a blank line or the [start](#BlockParser.endLeaf) of
|
||||
another construct). If this parser can handle the block up to
|
||||
its current position, it should
|
||||
[finish](#BlockContext.addLeafElement) the block and return
|
||||
true.
|
||||
*/
|
||||
finish(cx: BlockContext, leaf: LeafBlock): boolean;
|
||||
}
|
||||
/**
|
||||
Objects of this type are used to
|
||||
[configure](#MarkdownParser.configure) the Markdown parser.
|
||||
*/
|
||||
interface MarkdownConfig {
|
||||
/**
|
||||
Node props to add to the parser's node set.
|
||||
*/
|
||||
props?: readonly NodePropSource[];
|
||||
/**
|
||||
Define new [node types](#NodeSpec) for use in parser extensions.
|
||||
*/
|
||||
defineNodes?: readonly (string | NodeSpec)[];
|
||||
/**
|
||||
Define additional [block parsing](#BlockParser) logic.
|
||||
*/
|
||||
parseBlock?: readonly BlockParser[];
|
||||
/**
|
||||
Define new [inline parsing](#InlineParser) logic.
|
||||
*/
|
||||
parseInline?: readonly InlineParser[];
|
||||
/**
|
||||
Remove the named parsers from the configuration.
|
||||
*/
|
||||
remove?: readonly string[];
|
||||
/**
|
||||
Add a parse wrapper (such as a [mixed-language
|
||||
parser](#common.parseMixed)) to this parser.
|
||||
*/
|
||||
wrap?: ParseWrapper;
|
||||
}
|
||||
/**
|
||||
To make it possible to group extensions together into bigger
|
||||
extensions (such as the [Github-flavored Markdown](#GFM)
|
||||
extension), [reconfiguration](#MarkdownParser.configure) accepts
|
||||
nested arrays of [config](#MarkdownConfig) objects.
|
||||
*/
|
||||
type MarkdownExtension = MarkdownConfig | readonly MarkdownExtension[];
|
||||
/**
|
||||
A Markdown parser configuration.
|
||||
*/
|
||||
declare class MarkdownParser extends Parser {
|
||||
/**
|
||||
The parser's syntax [node
|
||||
types](https://lezer.codemirror.net/docs/ref/#common.NodeSet).
|
||||
*/
|
||||
readonly nodeSet: NodeSet;
|
||||
createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): PartialParse;
|
||||
/**
|
||||
Reconfigure the parser.
|
||||
*/
|
||||
configure(spec: MarkdownExtension): MarkdownParser;
|
||||
/**
|
||||
Parse the given piece of inline text at the given offset,
|
||||
returning an array of [`Element`](#Element) objects representing
|
||||
the inline content.
|
||||
*/
|
||||
parseInline(text: string, offset: number): Element[];
|
||||
}
|
||||
/**
|
||||
Elements are used to compose syntax nodes during parsing.
|
||||
*/
|
||||
declare class Element {
|
||||
/**
|
||||
The node's
|
||||
[id](https://lezer.codemirror.net/docs/ref/#common.NodeType.id).
|
||||
*/
|
||||
readonly type: number;
|
||||
/**
|
||||
The start of the node, as an offset from the start of the document.
|
||||
*/
|
||||
readonly from: number;
|
||||
/**
|
||||
The end of the node.
|
||||
*/
|
||||
readonly to: number;
|
||||
}
|
||||
/**
|
||||
Delimiters are used during inline parsing to store the positions
|
||||
of things that _might_ be delimiters, if another matching
|
||||
delimiter is found. They are identified by objects with these
|
||||
properties.
|
||||
*/
|
||||
interface DelimiterType {
|
||||
/**
|
||||
If this is given, the delimiter should be matched automatically
|
||||
when a piece of inline content is finished. Such delimiters will
|
||||
be matched with delimiters of the same type according to their
|
||||
[open and close](#InlineContext.addDelimiter) properties. When a
|
||||
match is found, the content between the delimiters is wrapped in
|
||||
a node whose name is given by the value of this property.
|
||||
|
||||
When this isn't given, you need to match the delimiter eagerly
|
||||
using the [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter)
|
||||
and [`takeContent`](#InlineContext.takeContent) methods.
|
||||
*/
|
||||
resolve?: string;
|
||||
/**
|
||||
If the delimiter itself should, when matched, create a syntax
|
||||
node, set this to the name of the syntax node.
|
||||
*/
|
||||
mark?: string;
|
||||
}
|
||||
/**
|
||||
Inline parsing functions get access to this context, and use it to
|
||||
read the content and emit syntax nodes.
|
||||
*/
|
||||
declare class InlineContext {
|
||||
/**
|
||||
The parser that is being used.
|
||||
*/
|
||||
readonly parser: MarkdownParser;
|
||||
/**
|
||||
The text of this inline section.
|
||||
*/
|
||||
readonly text: string;
|
||||
/**
|
||||
The starting offset of the section in the document.
|
||||
*/
|
||||
readonly offset: number;
|
||||
/**
|
||||
Get the character code at the given (document-relative)
|
||||
position.
|
||||
*/
|
||||
char(pos: number): number;
|
||||
/**
|
||||
The position of the end of this inline section.
|
||||
*/
|
||||
get end(): number;
|
||||
/**
|
||||
Get a substring of this inline section. Again uses
|
||||
document-relative positions.
|
||||
*/
|
||||
slice(from: number, to: number): string;
|
||||
/**
|
||||
Add a [delimiter](#DelimiterType) at this given position. `open`
|
||||
and `close` indicate whether this delimiter is opening, closing,
|
||||
or both. Returns the end of the delimiter, for convenient
|
||||
returning from [parse functions](#InlineParser.parse).
|
||||
*/
|
||||
addDelimiter(type: DelimiterType, from: number, to: number, open: boolean, close: boolean): number;
|
||||
/**
|
||||
Returns true when there is an unmatched link or image opening
|
||||
token before the current position.
|
||||
*/
|
||||
get hasOpenLink(): boolean;
|
||||
/**
|
||||
Add an inline element. Returns the end of the element.
|
||||
*/
|
||||
addElement(elt: Element): number;
|
||||
/**
|
||||
Find an opening delimiter of the given type. Returns `null` if
|
||||
no delimiter is found, or an index that can be passed to
|
||||
[`takeContent`](#InlineContext.takeContent) otherwise.
|
||||
*/
|
||||
findOpeningDelimiter(type: DelimiterType): number | null;
|
||||
/**
|
||||
Remove all inline elements and delimiters starting from the
|
||||
given index (which you should get from
|
||||
[`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
|
||||
resolve delimiters inside of them, and return them as an array
|
||||
of elements.
|
||||
*/
|
||||
takeContent(startIndex: number): Element[];
|
||||
/**
|
||||
Return the delimiter at the given index. Mostly useful to get
|
||||
additional info out of a delimiter index returned by
|
||||
[`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
|
||||
Returns null if there is no delimiter at this index.
|
||||
*/
|
||||
getDelimiterAt(index: number): {
|
||||
from: number;
|
||||
to: number;
|
||||
type: DelimiterType;
|
||||
} | null;
|
||||
/**
|
||||
Skip space after the given (document) position, returning either
|
||||
the position of the next non-space character or the end of the
|
||||
section.
|
||||
*/
|
||||
skipSpace(from: number): number;
|
||||
/**
|
||||
Create an [`Element`](#Element) for a syntax node.
|
||||
*/
|
||||
elt(type: string, from: number, to: number, children?: readonly Element[]): Element;
|
||||
elt(tree: Tree, at: number): Element;
|
||||
/**
|
||||
The opening delimiter type used by the standard link parser.
|
||||
*/
|
||||
static linkStart: DelimiterType;
|
||||
/**
|
||||
Opening delimiter type used for standard images.
|
||||
*/
|
||||
static imageStart: DelimiterType;
|
||||
}
|
||||
/**
|
||||
The default CommonMark parser.
|
||||
*/
|
||||
declare const parser: MarkdownParser;
|
||||
|
||||
/**
|
||||
Create a Markdown extension to enable nested parsing on code
|
||||
blocks and/or embedded HTML.
|
||||
*/
|
||||
declare function parseCode(config: {
|
||||
/**
|
||||
When provided, this will be used to parse the content of code
|
||||
blocks. `info` is the string after the opening ` ``` ` marker,
|
||||
or the empty string if there is no such info or this is an
|
||||
indented code block. If there is a parser available for the
|
||||
code, it should return a function that can construct the
|
||||
[parse](https://lezer.codemirror.net/docs/ref/#common.PartialParse).
|
||||
*/
|
||||
codeParser?: (info: string) => null | Parser;
|
||||
/**
|
||||
The parser used to parse HTML tags (both block and inline).
|
||||
*/
|
||||
htmlParser?: Parser;
|
||||
}): MarkdownExtension;
|
||||
|
||||
/**
|
||||
An extension that implements
|
||||
[GFM-style](https://github.github.com/gfm/#strikethrough-extension-)
|
||||
Strikethrough syntax using `~~` delimiters.
|
||||
*/
|
||||
declare const Strikethrough: MarkdownConfig;
|
||||
/**
|
||||
This extension provides
|
||||
[GFM-style](https://github.github.com/gfm/#tables-extension-)
|
||||
tables, using syntax like this:
|
||||
|
||||
```
|
||||
| head 1 | head 2 |
|
||||
| --- | --- |
|
||||
| cell 1 | cell 2 |
|
||||
```
|
||||
*/
|
||||
declare const Table: MarkdownConfig;
|
||||
/**
|
||||
Extension providing
|
||||
[GFM-style](https://github.github.com/gfm/#task-list-items-extension-)
|
||||
task list items, where list items can be prefixed with `[ ]` or
|
||||
`[x]` to add a checkbox.
|
||||
*/
|
||||
declare const TaskList: MarkdownConfig;
|
||||
/**
|
||||
Extension that implements autolinking for
|
||||
`www.`/`http://`/`https://`/`mailto:`/`xmpp:` URLs and email
|
||||
addresses.
|
||||
*/
|
||||
declare const Autolink: MarkdownConfig;
|
||||
/**
|
||||
Extension bundle containing [`Table`](#Table),
|
||||
[`TaskList`](#TaskList), [`Strikethrough`](#Strikethrough), and
|
||||
[`Autolink`](#Autolink).
|
||||
*/
|
||||
declare const GFM: MarkdownConfig[];
|
||||
/**
|
||||
Extension providing
|
||||
[Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
superscript using `^` markers.
|
||||
*/
|
||||
declare const Superscript: MarkdownConfig;
|
||||
/**
|
||||
Extension providing
|
||||
[Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
subscript using `~` markers.
|
||||
*/
|
||||
declare const Subscript: MarkdownConfig;
|
||||
/**
|
||||
Extension that parses two colons with only letters, underscores,
|
||||
and numbers between them as `Emoji` nodes.
|
||||
*/
|
||||
declare const Emoji: MarkdownConfig;
|
||||
|
||||
export { Autolink, BlockContext, type BlockParser, type DelimiterType, Element, Emoji, GFM, InlineContext, type InlineParser, LeafBlock, type LeafBlockParser, Line, type MarkdownConfig, type MarkdownExtension, MarkdownParser, type NodeSpec, Strikethrough, Subscript, Superscript, Table, TaskList, parseCode, parser };
|
||||
600
frontend/node_modules/@lezer/markdown/dist/index.d.ts
generated
vendored
Normal file
600
frontend/node_modules/@lezer/markdown/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,600 @@
|
||||
import { PartialParse, Tree, NodeType, NodePropSource, ParseWrapper, Parser, NodeSet, Input, TreeFragment } from '@lezer/common';
|
||||
import { Tag } from '@lezer/highlight';
|
||||
|
||||
/**
|
||||
Data structure used to accumulate a block's content during [leaf
|
||||
block parsing](#BlockParser.leaf).
|
||||
*/
|
||||
declare class LeafBlock {
|
||||
/**
|
||||
The start position of the block.
|
||||
*/
|
||||
readonly start: number;
|
||||
/**
|
||||
The block's text content.
|
||||
*/
|
||||
content: string;
|
||||
/**
|
||||
The block parsers active for this block.
|
||||
*/
|
||||
parsers: LeafBlockParser[];
|
||||
}
|
||||
/**
|
||||
Data structure used during block-level per-line parsing.
|
||||
*/
|
||||
declare class Line {
|
||||
/**
|
||||
The line's full text.
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
The base indent provided by the composite contexts (that have
|
||||
been handled so far).
|
||||
*/
|
||||
baseIndent: number;
|
||||
/**
|
||||
The string position corresponding to the base indent.
|
||||
*/
|
||||
basePos: number;
|
||||
/**
|
||||
The position of the next non-whitespace character beyond any
|
||||
list, blockquote, or other composite block markers.
|
||||
*/
|
||||
pos: number;
|
||||
/**
|
||||
The column of the next non-whitespace character.
|
||||
*/
|
||||
indent: number;
|
||||
/**
|
||||
The character code of the character after `pos`.
|
||||
*/
|
||||
next: number;
|
||||
/**
|
||||
Skip whitespace after the given position, return the position of
|
||||
the next non-space character or the end of the line if there's
|
||||
only space after `from`.
|
||||
*/
|
||||
skipSpace(from: number): number;
|
||||
/**
|
||||
Move the line's base position forward to the given position.
|
||||
This should only be called by composite [block
|
||||
parsers](#BlockParser.parse) or [markup skipping
|
||||
functions](#NodeSpec.composite).
|
||||
*/
|
||||
moveBase(to: number): void;
|
||||
/**
|
||||
Move the line's base position forward to the given _column_.
|
||||
*/
|
||||
moveBaseColumn(indent: number): void;
|
||||
/**
|
||||
Store a composite-block-level marker. Should be called from
|
||||
[markup skipping functions](#NodeSpec.composite) when they
|
||||
consume any non-whitespace characters.
|
||||
*/
|
||||
addMarker(elt: Element): void;
|
||||
/**
|
||||
Find the column position at `to`, optionally starting at a given
|
||||
position and column.
|
||||
*/
|
||||
countIndent(to: number, from?: number, indent?: number): number;
|
||||
/**
|
||||
Find the position corresponding to the given column.
|
||||
*/
|
||||
findColumn(goal: number): number;
|
||||
}
|
||||
type BlockResult = boolean | null;
|
||||
/**
|
||||
Block-level parsing functions get access to this context object.
|
||||
*/
|
||||
declare class BlockContext implements PartialParse {
|
||||
/**
|
||||
The parser configuration used.
|
||||
*/
|
||||
readonly parser: MarkdownParser;
|
||||
private line;
|
||||
private atEnd;
|
||||
private fragments;
|
||||
private to;
|
||||
stoppedAt: number | null;
|
||||
/**
|
||||
The start of the current line.
|
||||
*/
|
||||
lineStart: number;
|
||||
get parsedPos(): number;
|
||||
advance(): Tree | null;
|
||||
stopAt(pos: number): void;
|
||||
private reuseFragment;
|
||||
/**
|
||||
The number of parent blocks surrounding the current block.
|
||||
*/
|
||||
get depth(): number;
|
||||
/**
|
||||
Get the type of the parent block at the given depth. When no
|
||||
depth is passed, return the type of the innermost parent.
|
||||
*/
|
||||
parentType(depth?: number): NodeType;
|
||||
/**
|
||||
Move to the next input line. This should only be called by
|
||||
(non-composite) [block parsers](#BlockParser.parse) that consume
|
||||
the line directly, or leaf block parser
|
||||
[`nextLine`](#LeafBlockParser.nextLine) methods when they
|
||||
consume the current line (and return true).
|
||||
*/
|
||||
nextLine(): boolean;
|
||||
/**
|
||||
Retrieve the text of the line after the current one, without
|
||||
actually moving the context's current line forward.
|
||||
*/
|
||||
peekLine(): string;
|
||||
private moveRangeI;
|
||||
private lineChunkAt;
|
||||
/**
|
||||
The end position of the previous line.
|
||||
*/
|
||||
prevLineEnd(): number;
|
||||
/**
|
||||
Start a composite block. Should only be called from [block
|
||||
parser functions](#BlockParser.parse) that return null.
|
||||
*/
|
||||
startComposite(type: string, start: number, value?: number): void;
|
||||
/**
|
||||
Add a block element. Can be called by [block
|
||||
parsers](#BlockParser.parse).
|
||||
*/
|
||||
addElement(elt: Element): void;
|
||||
/**
|
||||
Add a block element from a [leaf parser](#LeafBlockParser). This
|
||||
makes sure any extra composite block markup (such as blockquote
|
||||
markers) inside the block are also added to the syntax tree.
|
||||
*/
|
||||
addLeafElement(leaf: LeafBlock, elt: Element): void;
|
||||
private finish;
|
||||
private addGaps;
|
||||
/**
|
||||
Create an [`Element`](#Element) object to represent some syntax
|
||||
node.
|
||||
*/
|
||||
elt(type: string, from: number, to: number, children?: readonly Element[]): Element;
|
||||
elt(tree: Tree, at: number): Element;
|
||||
}
|
||||
/**
|
||||
Used in the [configuration](#MarkdownConfig.defineNodes) to define
|
||||
new [syntax node
|
||||
types](https://lezer.codemirror.net/docs/ref/#common.NodeType).
|
||||
*/
|
||||
interface NodeSpec {
|
||||
/**
|
||||
The node's name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Should be set to true if this type represents a block node.
|
||||
*/
|
||||
block?: boolean;
|
||||
/**
|
||||
If this is a composite block, this should hold a function that,
|
||||
at the start of a new line where that block is active, checks
|
||||
whether the composite block should continue (return value) and
|
||||
optionally [adjusts](#Line.moveBase) the line's base position
|
||||
and [registers](#Line.addMarker) nodes for any markers involved
|
||||
in the block's syntax.
|
||||
*/
|
||||
composite?(cx: BlockContext, line: Line, value: number): boolean;
|
||||
/**
|
||||
Add highlighting tag information for this node. The value of
|
||||
this property may either by a tag or array of tags to assign
|
||||
directly to this node, or an object in the style of
|
||||
[`styleTags`](https://lezer.codemirror.net/docs/ref/#highlight.styleTags)'s
|
||||
argument to assign more complicated rules.
|
||||
*/
|
||||
style?: Tag | readonly Tag[] | {
|
||||
[selector: string]: Tag | readonly Tag[];
|
||||
};
|
||||
}
|
||||
/**
|
||||
Inline parsers are called for every character of parts of the
|
||||
document that are parsed as inline content.
|
||||
*/
|
||||
interface InlineParser {
|
||||
/**
|
||||
This parser's name, which can be used by other parsers to
|
||||
[indicate](#InlineParser.before) a relative precedence.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The parse function. Gets the next character and its position as
|
||||
arguments. Should return -1 if it doesn't handle the character,
|
||||
or add some [element](#InlineContext.addElement) or
|
||||
[delimiter](#InlineContext.addDelimiter) and return the end
|
||||
position of the content it parsed if it can.
|
||||
*/
|
||||
parse(cx: InlineContext, next: number, pos: number): number;
|
||||
/**
|
||||
When given, this parser will be installed directly before the
|
||||
parser with the given name. The default configuration defines
|
||||
inline parsers with names Escape, Entity, InlineCode, HTMLTag,
|
||||
Emphasis, HardBreak, Link, and Image. When no `before` or
|
||||
`after` property is given, the parser is added to the end of the
|
||||
list.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When given, the parser will be installed directly _after_ the
|
||||
parser with the given name.
|
||||
*/
|
||||
after?: string;
|
||||
}
|
||||
/**
|
||||
Block parsers handle block-level structure. There are three
|
||||
general types of block parsers:
|
||||
|
||||
- Composite block parsers, which handle things like lists and
|
||||
blockquotes. These define a [`parse`](#BlockParser.parse) method
|
||||
that [starts](#BlockContext.startComposite) a composite block
|
||||
and returns null when it recognizes its syntax. The node type
|
||||
used by such a block must define a
|
||||
[`composite`](#NodeSpec.composite) function as well.
|
||||
|
||||
- Eager leaf block parsers, used for things like code or HTML
|
||||
blocks. These can unambiguously recognize their content from its
|
||||
first line. They define a [`parse`](#BlockParser.parse) method
|
||||
that, if it recognizes the construct,
|
||||
[moves](#BlockContext.nextLine) the current line forward to the
|
||||
line beyond the end of the block,
|
||||
[add](#BlockContext.addElement) a syntax node for the block, and
|
||||
return true.
|
||||
|
||||
- Leaf block parsers that observe a paragraph-like construct as it
|
||||
comes in, and optionally decide to handle it at some point. This
|
||||
is used for "setext" (underlined) headings and link references.
|
||||
These define a [`leaf`](#BlockParser.leaf) method that checks
|
||||
the first line of the block and returns a
|
||||
[`LeafBlockParser`](#LeafBlockParser) object if it wants to
|
||||
observe that block.
|
||||
*/
|
||||
interface BlockParser {
|
||||
/**
|
||||
The name of the parser. Can be used by other block parsers to
|
||||
[specify](#BlockParser.before) precedence.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The eager parse function, which can look at the block's first
|
||||
line and return `false` to do nothing, `true` if it has parsed
|
||||
(and [moved past](#BlockContext.nextLine) a block), or `null` if
|
||||
it has [started](#BlockContext.startComposite) a composite block.
|
||||
*/
|
||||
parse?(cx: BlockContext, line: Line): BlockResult;
|
||||
/**
|
||||
A leaf parse function. If no [regular](#BlockParser.parse) parse
|
||||
functions match for a given line, its content will be
|
||||
accumulated for a paragraph-style block. This method can return
|
||||
an [object](#LeafBlockParser) that overrides that style of
|
||||
parsing in some situations.
|
||||
*/
|
||||
leaf?(cx: BlockContext, leaf: LeafBlock): LeafBlockParser | null;
|
||||
/**
|
||||
Some constructs, such as code blocks or newly started
|
||||
blockquotes, can interrupt paragraphs even without a blank line.
|
||||
If your construct can do this, provide a predicate here that
|
||||
recognizes lines that should end a paragraph (or other non-eager
|
||||
[leaf block](#BlockParser.leaf)).
|
||||
*/
|
||||
endLeaf?(cx: BlockContext, line: Line, leaf: LeafBlock): boolean;
|
||||
/**
|
||||
When given, this parser will be installed directly before the
|
||||
block parser with the given name. The default configuration
|
||||
defines block parsers with names LinkReference, IndentedCode,
|
||||
FencedCode, Blockquote, HorizontalRule, BulletList, OrderedList,
|
||||
ATXHeading, HTMLBlock, and SetextHeading.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When given, the parser will be installed directly _after_ the
|
||||
parser with the given name.
|
||||
*/
|
||||
after?: string;
|
||||
}
|
||||
/**
|
||||
Objects that are used to [override](#BlockParser.leaf)
|
||||
paragraph-style blocks should conform to this interface.
|
||||
*/
|
||||
interface LeafBlockParser {
|
||||
/**
|
||||
Update the parser's state for the next line, and optionally
|
||||
finish the block. This is not called for the first line (the
|
||||
object is constructed at that line), but for any further lines.
|
||||
When it returns `true`, the block is finished. It is okay for
|
||||
the function to [consume](#BlockContext.nextLine) the current
|
||||
line or any subsequent lines when returning true.
|
||||
*/
|
||||
nextLine(cx: BlockContext, line: Line, leaf: LeafBlock): boolean;
|
||||
/**
|
||||
Called when the block is finished by external circumstances
|
||||
(such as a blank line or the [start](#BlockParser.endLeaf) of
|
||||
another construct). If this parser can handle the block up to
|
||||
its current position, it should
|
||||
[finish](#BlockContext.addLeafElement) the block and return
|
||||
true.
|
||||
*/
|
||||
finish(cx: BlockContext, leaf: LeafBlock): boolean;
|
||||
}
|
||||
/**
|
||||
Objects of this type are used to
|
||||
[configure](#MarkdownParser.configure) the Markdown parser.
|
||||
*/
|
||||
interface MarkdownConfig {
|
||||
/**
|
||||
Node props to add to the parser's node set.
|
||||
*/
|
||||
props?: readonly NodePropSource[];
|
||||
/**
|
||||
Define new [node types](#NodeSpec) for use in parser extensions.
|
||||
*/
|
||||
defineNodes?: readonly (string | NodeSpec)[];
|
||||
/**
|
||||
Define additional [block parsing](#BlockParser) logic.
|
||||
*/
|
||||
parseBlock?: readonly BlockParser[];
|
||||
/**
|
||||
Define new [inline parsing](#InlineParser) logic.
|
||||
*/
|
||||
parseInline?: readonly InlineParser[];
|
||||
/**
|
||||
Remove the named parsers from the configuration.
|
||||
*/
|
||||
remove?: readonly string[];
|
||||
/**
|
||||
Add a parse wrapper (such as a [mixed-language
|
||||
parser](#common.parseMixed)) to this parser.
|
||||
*/
|
||||
wrap?: ParseWrapper;
|
||||
}
|
||||
/**
|
||||
To make it possible to group extensions together into bigger
|
||||
extensions (such as the [Github-flavored Markdown](#GFM)
|
||||
extension), [reconfiguration](#MarkdownParser.configure) accepts
|
||||
nested arrays of [config](#MarkdownConfig) objects.
|
||||
*/
|
||||
type MarkdownExtension = MarkdownConfig | readonly MarkdownExtension[];
|
||||
/**
|
||||
A Markdown parser configuration.
|
||||
*/
|
||||
declare class MarkdownParser extends Parser {
|
||||
/**
|
||||
The parser's syntax [node
|
||||
types](https://lezer.codemirror.net/docs/ref/#common.NodeSet).
|
||||
*/
|
||||
readonly nodeSet: NodeSet;
|
||||
createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): PartialParse;
|
||||
/**
|
||||
Reconfigure the parser.
|
||||
*/
|
||||
configure(spec: MarkdownExtension): MarkdownParser;
|
||||
/**
|
||||
Parse the given piece of inline text at the given offset,
|
||||
returning an array of [`Element`](#Element) objects representing
|
||||
the inline content.
|
||||
*/
|
||||
parseInline(text: string, offset: number): Element[];
|
||||
}
|
||||
/**
|
||||
Elements are used to compose syntax nodes during parsing.
|
||||
*/
|
||||
declare class Element {
|
||||
/**
|
||||
The node's
|
||||
[id](https://lezer.codemirror.net/docs/ref/#common.NodeType.id).
|
||||
*/
|
||||
readonly type: number;
|
||||
/**
|
||||
The start of the node, as an offset from the start of the document.
|
||||
*/
|
||||
readonly from: number;
|
||||
/**
|
||||
The end of the node.
|
||||
*/
|
||||
readonly to: number;
|
||||
}
|
||||
/**
|
||||
Delimiters are used during inline parsing to store the positions
|
||||
of things that _might_ be delimiters, if another matching
|
||||
delimiter is found. They are identified by objects with these
|
||||
properties.
|
||||
*/
|
||||
interface DelimiterType {
|
||||
/**
|
||||
If this is given, the delimiter should be matched automatically
|
||||
when a piece of inline content is finished. Such delimiters will
|
||||
be matched with delimiters of the same type according to their
|
||||
[open and close](#InlineContext.addDelimiter) properties. When a
|
||||
match is found, the content between the delimiters is wrapped in
|
||||
a node whose name is given by the value of this property.
|
||||
|
||||
When this isn't given, you need to match the delimiter eagerly
|
||||
using the [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter)
|
||||
and [`takeContent`](#InlineContext.takeContent) methods.
|
||||
*/
|
||||
resolve?: string;
|
||||
/**
|
||||
If the delimiter itself should, when matched, create a syntax
|
||||
node, set this to the name of the syntax node.
|
||||
*/
|
||||
mark?: string;
|
||||
}
|
||||
/**
|
||||
Inline parsing functions get access to this context, and use it to
|
||||
read the content and emit syntax nodes.
|
||||
*/
|
||||
declare class InlineContext {
|
||||
/**
|
||||
The parser that is being used.
|
||||
*/
|
||||
readonly parser: MarkdownParser;
|
||||
/**
|
||||
The text of this inline section.
|
||||
*/
|
||||
readonly text: string;
|
||||
/**
|
||||
The starting offset of the section in the document.
|
||||
*/
|
||||
readonly offset: number;
|
||||
/**
|
||||
Get the character code at the given (document-relative)
|
||||
position.
|
||||
*/
|
||||
char(pos: number): number;
|
||||
/**
|
||||
The position of the end of this inline section.
|
||||
*/
|
||||
get end(): number;
|
||||
/**
|
||||
Get a substring of this inline section. Again uses
|
||||
document-relative positions.
|
||||
*/
|
||||
slice(from: number, to: number): string;
|
||||
/**
|
||||
Add a [delimiter](#DelimiterType) at this given position. `open`
|
||||
and `close` indicate whether this delimiter is opening, closing,
|
||||
or both. Returns the end of the delimiter, for convenient
|
||||
returning from [parse functions](#InlineParser.parse).
|
||||
*/
|
||||
addDelimiter(type: DelimiterType, from: number, to: number, open: boolean, close: boolean): number;
|
||||
/**
|
||||
Returns true when there is an unmatched link or image opening
|
||||
token before the current position.
|
||||
*/
|
||||
get hasOpenLink(): boolean;
|
||||
/**
|
||||
Add an inline element. Returns the end of the element.
|
||||
*/
|
||||
addElement(elt: Element): number;
|
||||
/**
|
||||
Find an opening delimiter of the given type. Returns `null` if
|
||||
no delimiter is found, or an index that can be passed to
|
||||
[`takeContent`](#InlineContext.takeContent) otherwise.
|
||||
*/
|
||||
findOpeningDelimiter(type: DelimiterType): number | null;
|
||||
/**
|
||||
Remove all inline elements and delimiters starting from the
|
||||
given index (which you should get from
|
||||
[`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
|
||||
resolve delimiters inside of them, and return them as an array
|
||||
of elements.
|
||||
*/
|
||||
takeContent(startIndex: number): Element[];
|
||||
/**
|
||||
Return the delimiter at the given index. Mostly useful to get
|
||||
additional info out of a delimiter index returned by
|
||||
[`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
|
||||
Returns null if there is no delimiter at this index.
|
||||
*/
|
||||
getDelimiterAt(index: number): {
|
||||
from: number;
|
||||
to: number;
|
||||
type: DelimiterType;
|
||||
} | null;
|
||||
/**
|
||||
Skip space after the given (document) position, returning either
|
||||
the position of the next non-space character or the end of the
|
||||
section.
|
||||
*/
|
||||
skipSpace(from: number): number;
|
||||
/**
|
||||
Create an [`Element`](#Element) for a syntax node.
|
||||
*/
|
||||
elt(type: string, from: number, to: number, children?: readonly Element[]): Element;
|
||||
elt(tree: Tree, at: number): Element;
|
||||
/**
|
||||
The opening delimiter type used by the standard link parser.
|
||||
*/
|
||||
static linkStart: DelimiterType;
|
||||
/**
|
||||
Opening delimiter type used for standard images.
|
||||
*/
|
||||
static imageStart: DelimiterType;
|
||||
}
|
||||
/**
|
||||
The default CommonMark parser.
|
||||
*/
|
||||
declare const parser: MarkdownParser;
|
||||
|
||||
/**
|
||||
Create a Markdown extension to enable nested parsing on code
|
||||
blocks and/or embedded HTML.
|
||||
*/
|
||||
declare function parseCode(config: {
|
||||
/**
|
||||
When provided, this will be used to parse the content of code
|
||||
blocks. `info` is the string after the opening ` ``` ` marker,
|
||||
or the empty string if there is no such info or this is an
|
||||
indented code block. If there is a parser available for the
|
||||
code, it should return a function that can construct the
|
||||
[parse](https://lezer.codemirror.net/docs/ref/#common.PartialParse).
|
||||
*/
|
||||
codeParser?: (info: string) => null | Parser;
|
||||
/**
|
||||
The parser used to parse HTML tags (both block and inline).
|
||||
*/
|
||||
htmlParser?: Parser;
|
||||
}): MarkdownExtension;
|
||||
|
||||
/**
|
||||
An extension that implements
|
||||
[GFM-style](https://github.github.com/gfm/#strikethrough-extension-)
|
||||
Strikethrough syntax using `~~` delimiters.
|
||||
*/
|
||||
declare const Strikethrough: MarkdownConfig;
|
||||
/**
|
||||
This extension provides
|
||||
[GFM-style](https://github.github.com/gfm/#tables-extension-)
|
||||
tables, using syntax like this:
|
||||
|
||||
```
|
||||
| head 1 | head 2 |
|
||||
| --- | --- |
|
||||
| cell 1 | cell 2 |
|
||||
```
|
||||
*/
|
||||
declare const Table: MarkdownConfig;
|
||||
/**
|
||||
Extension providing
|
||||
[GFM-style](https://github.github.com/gfm/#task-list-items-extension-)
|
||||
task list items, where list items can be prefixed with `[ ]` or
|
||||
`[x]` to add a checkbox.
|
||||
*/
|
||||
declare const TaskList: MarkdownConfig;
|
||||
/**
|
||||
Extension that implements autolinking for
|
||||
`www.`/`http://`/`https://`/`mailto:`/`xmpp:` URLs and email
|
||||
addresses.
|
||||
*/
|
||||
declare const Autolink: MarkdownConfig;
|
||||
/**
|
||||
Extension bundle containing [`Table`](#Table),
|
||||
[`TaskList`](#TaskList), [`Strikethrough`](#Strikethrough), and
|
||||
[`Autolink`](#Autolink).
|
||||
*/
|
||||
declare const GFM: MarkdownConfig[];
|
||||
/**
|
||||
Extension providing
|
||||
[Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
superscript using `^` markers.
|
||||
*/
|
||||
declare const Superscript: MarkdownConfig;
|
||||
/**
|
||||
Extension providing
|
||||
[Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
subscript using `~` markers.
|
||||
*/
|
||||
declare const Subscript: MarkdownConfig;
|
||||
/**
|
||||
Extension that parses two colons with only letters, underscores,
|
||||
and numbers between them as `Emoji` nodes.
|
||||
*/
|
||||
declare const Emoji: MarkdownConfig;
|
||||
|
||||
export { Autolink, BlockContext, type BlockParser, type DelimiterType, Element, Emoji, GFM, InlineContext, type InlineParser, LeafBlock, type LeafBlockParser, Line, type MarkdownConfig, type MarkdownExtension, MarkdownParser, type NodeSpec, Strikethrough, Subscript, Superscript, Table, TaskList, parseCode, parser };
|
||||
2327
frontend/node_modules/@lezer/markdown/dist/index.js
generated
vendored
Normal file
2327
frontend/node_modules/@lezer/markdown/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
frontend/node_modules/@lezer/markdown/package.json
generated
vendored
Normal file
37
frontend/node_modules/@lezer/markdown/package.json
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@lezer/markdown",
|
||||
"version": "1.6.0",
|
||||
"description": "Incremental Markdown parser that consumes and emits Lezer trees",
|
||||
"main": "dist/index.cjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"ist": "^1.1.1",
|
||||
"mocha": "^10.2.0",
|
||||
"@lezer/html": "^1.0.0",
|
||||
"getdocs-ts": "^0.1.0",
|
||||
"builddocs": "^1.0.0",
|
||||
"@marijn/buildtool": "^0.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/highlight": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lezer-parser/markdown.git"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "node build.js --watch",
|
||||
"prepare": "node build.js",
|
||||
"test": "mocha",
|
||||
"build-readme": "node bin/build-readme.cjs"
|
||||
}
|
||||
}
|
||||
83
frontend/node_modules/@lezer/markdown/src/README.md
generated
vendored
Normal file
83
frontend/node_modules/@lezer/markdown/src/README.md
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
<!-- /README.md is generated from /src/README.md -->
|
||||
|
||||
# @lezer/markdown
|
||||
|
||||
This is an incremental Markdown ([CommonMark](https://commonmark.org/)
|
||||
with support for extension) parser that integrates well with the
|
||||
[Lezer](https://lezer.codemirror.net/) parser system. It does not in
|
||||
fact use the Lezer runtime (that runs LR parsers, and Markdown can't
|
||||
really be parsed that way), but it produces Lezer-style compact syntax
|
||||
trees and consumes fragments of such trees for its incremental
|
||||
parsing.
|
||||
|
||||
Note that this only _parses_ the document, producing a data structure
|
||||
that represents its syntactic form, and doesn't help with outputting
|
||||
HTML. Also, in order to be single-pass and incremental, it doesn't do
|
||||
some things that a conforming CommonMark parser is expected to
|
||||
do—specifically, it doesn't validate link references, so it'll parse
|
||||
`[a][b]` and similar as a link, even if no `[b]` reference is
|
||||
declared.
|
||||
|
||||
The
|
||||
[@codemirror/lang-markdown](https://github.com/codemirror/lang-markdown)
|
||||
package integrates this parser with CodeMirror to provide Markdown
|
||||
editor support.
|
||||
|
||||
The code is licensed under an MIT license.
|
||||
|
||||
## Interface
|
||||
|
||||
@parser
|
||||
|
||||
@MarkdownParser
|
||||
|
||||
@MarkdownConfig
|
||||
|
||||
@MarkdownExtension
|
||||
|
||||
@parseCode
|
||||
|
||||
### GitHub Flavored Markdown
|
||||
|
||||
@GFM
|
||||
|
||||
@Table
|
||||
|
||||
@TaskList
|
||||
|
||||
@Strikethrough
|
||||
|
||||
@Autolink
|
||||
|
||||
### Other extensions
|
||||
|
||||
@Subscript
|
||||
|
||||
@Superscript
|
||||
|
||||
@Emoji
|
||||
|
||||
### Extension
|
||||
|
||||
The parser can, to a certain extent, be extended to handle additional
|
||||
syntax.
|
||||
|
||||
@NodeSpec
|
||||
|
||||
@BlockContext
|
||||
|
||||
@BlockParser
|
||||
|
||||
@LeafBlockParser
|
||||
|
||||
@Line
|
||||
|
||||
@LeafBlock
|
||||
|
||||
@InlineContext
|
||||
|
||||
@InlineParser
|
||||
|
||||
@DelimiterType
|
||||
|
||||
@Element
|
||||
301
frontend/node_modules/@lezer/markdown/src/extension.ts
generated
vendored
Normal file
301
frontend/node_modules/@lezer/markdown/src/extension.ts
generated
vendored
Normal file
@ -0,0 +1,301 @@
|
||||
import {InlineContext, BlockContext, MarkdownConfig,
|
||||
LeafBlockParser, LeafBlock, Line, Element, space, Punctuation} from "./markdown"
|
||||
import {tags as t} from "@lezer/highlight"
|
||||
|
||||
const StrikethroughDelim = {resolve: "Strikethrough", mark: "StrikethroughMark"}
|
||||
|
||||
/// An extension that implements
|
||||
/// [GFM-style](https://github.github.com/gfm/#strikethrough-extension-)
|
||||
/// Strikethrough syntax using `~~` delimiters.
|
||||
export const Strikethrough: MarkdownConfig = {
|
||||
defineNodes: [{
|
||||
name: "Strikethrough",
|
||||
style: {"Strikethrough/...": t.strikethrough}
|
||||
}, {
|
||||
name: "StrikethroughMark",
|
||||
style: t.processingInstruction
|
||||
}],
|
||||
parseInline: [{
|
||||
name: "Strikethrough",
|
||||
parse(cx, next, pos) {
|
||||
if (next != 126 /* '~' */ || cx.char(pos + 1) != 126 || cx.char(pos + 2) == 126) return -1
|
||||
let before = cx.slice(pos - 1, pos), after = cx.slice(pos + 2, pos + 3)
|
||||
let sBefore = /\s|^$/.test(before), sAfter = /\s|^$/.test(after)
|
||||
let pBefore = Punctuation.test(before), pAfter = Punctuation.test(after)
|
||||
return cx.addDelimiter(StrikethroughDelim, pos, pos + 2,
|
||||
!sAfter && (!pAfter || sBefore || pBefore),
|
||||
!sBefore && (!pBefore || sAfter || pAfter))
|
||||
},
|
||||
after: "Emphasis"
|
||||
}]
|
||||
}
|
||||
|
||||
// Parse a line as a table row and return the row count. When `elts`
|
||||
// is given, push syntax elements for the content onto it.
|
||||
function parseRow(cx: BlockContext, line: string, startI = 0, elts?: Element[], offset = 0) {
|
||||
let count = 0, first = true, cellStart = -1, cellEnd = -1, esc = false
|
||||
let parseCell = () => {
|
||||
elts!.push(cx.elt("TableCell", offset + cellStart, offset + cellEnd,
|
||||
cx.parser.parseInline(line.slice(cellStart, cellEnd), offset + cellStart)))
|
||||
}
|
||||
|
||||
for (let i = startI; i < line.length; i++) {
|
||||
let next = line.charCodeAt(i)
|
||||
if (next == 124 /* '|' */ && !esc) {
|
||||
if (!first || cellStart > -1) count++
|
||||
first = false
|
||||
if (elts) {
|
||||
if (cellStart > -1) parseCell()
|
||||
elts.push(cx.elt("TableDelimiter", i + offset, i + offset + 1))
|
||||
}
|
||||
cellStart = cellEnd = -1
|
||||
} else if (esc || next != 32 && next != 9) {
|
||||
if (cellStart < 0) cellStart = i
|
||||
cellEnd = i + 1
|
||||
}
|
||||
esc = !esc && next == 92
|
||||
}
|
||||
if (cellStart > -1) {
|
||||
count++
|
||||
if (elts) parseCell()
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
function hasPipe(str: string, start: number) {
|
||||
for (let i = start; i < str.length; i++) {
|
||||
let next = str.charCodeAt(i)
|
||||
if (next == 124 /* '|' */) return true
|
||||
if (next == 92 /* '\\' */) i++
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const delimiterLine = /^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/
|
||||
|
||||
class TableParser implements LeafBlockParser {
|
||||
// Null means we haven't seen the second line yet, false means this
|
||||
// isn't a table, and an array means this is a table and we've
|
||||
// parsed the given rows so far.
|
||||
rows: false | null | Element[] = null
|
||||
|
||||
nextLine(cx: BlockContext, line: Line, leaf: LeafBlock) {
|
||||
if (this.rows == null) { // Second line
|
||||
this.rows = false
|
||||
let lineText
|
||||
if ((line.next == 45 || line.next == 58 || line.next == 124 /* '-:|' */) &&
|
||||
delimiterLine.test(lineText = line.text.slice(line.pos))) {
|
||||
let firstRow: Element[] = [], firstCount = parseRow(cx, leaf.content, 0, firstRow, leaf.start)
|
||||
if (firstCount == parseRow(cx, lineText, line.pos))
|
||||
this.rows = [cx.elt("TableHeader", leaf.start, leaf.start + leaf.content.length, firstRow),
|
||||
cx.elt("TableDelimiter", cx.lineStart + line.pos, cx.lineStart + line.text.length)]
|
||||
}
|
||||
} else if (this.rows) { // Line after the second
|
||||
let content: Element[] = []
|
||||
parseRow(cx, line.text, line.pos, content, cx.lineStart)
|
||||
this.rows.push(cx.elt("TableRow", cx.lineStart + line.pos, cx.lineStart + line.text.length, content))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
finish(cx: BlockContext, leaf: LeafBlock) {
|
||||
if (!this.rows) return false
|
||||
cx.addLeafElement(leaf, cx.elt("Table", leaf.start, leaf.start + leaf.content.length, this.rows as readonly Element[]))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/// This extension provides
|
||||
/// [GFM-style](https://github.github.com/gfm/#tables-extension-)
|
||||
/// tables, using syntax like this:
|
||||
///
|
||||
/// ```
|
||||
/// | head 1 | head 2 |
|
||||
/// | --- | --- |
|
||||
/// | cell 1 | cell 2 |
|
||||
/// ```
|
||||
export const Table: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
{name: "Table", block: true},
|
||||
{name: "TableHeader", style: {"TableHeader/...": t.heading}},
|
||||
"TableRow",
|
||||
{name: "TableCell", style: t.content},
|
||||
{name: "TableDelimiter", style: t.processingInstruction},
|
||||
],
|
||||
parseBlock: [{
|
||||
name: "Table",
|
||||
leaf(_, leaf) { return hasPipe(leaf.content, 0) ? new TableParser : null },
|
||||
endLeaf(cx, line, leaf) {
|
||||
if (leaf.parsers.some(p => p instanceof TableParser) || !hasPipe(line.text, line.basePos)) return false
|
||||
let next = cx.peekLine()
|
||||
return delimiterLine.test(next) && parseRow(cx, line.text, line.basePos) == parseRow(cx, next, line.basePos)
|
||||
},
|
||||
before: "SetextHeading"
|
||||
}]
|
||||
}
|
||||
|
||||
class TaskParser implements LeafBlockParser {
|
||||
nextLine() { return false }
|
||||
|
||||
finish(cx: BlockContext, leaf: LeafBlock) {
|
||||
cx.addLeafElement(leaf, cx.elt("Task", leaf.start, leaf.start + leaf.content.length, [
|
||||
cx.elt("TaskMarker", leaf.start, leaf.start + 3),
|
||||
...cx.parser.parseInline(leaf.content.slice(3), leaf.start + 3)
|
||||
]))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension providing
|
||||
/// [GFM-style](https://github.github.com/gfm/#task-list-items-extension-)
|
||||
/// task list items, where list items can be prefixed with `[ ]` or
|
||||
/// `[x]` to add a checkbox.
|
||||
export const TaskList: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
{name: "Task", block: true, style: t.list},
|
||||
{name: "TaskMarker", style: t.atom}
|
||||
],
|
||||
parseBlock: [{
|
||||
name: "TaskList",
|
||||
leaf(cx, leaf) {
|
||||
return /^\[[ xX]\][ \t]/.test(leaf.content) && cx.parentType().name == "ListItem" ? new TaskParser : null
|
||||
},
|
||||
after: "SetextHeading"
|
||||
}]
|
||||
}
|
||||
|
||||
const autolinkRE = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy
|
||||
const urlRE = /[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy
|
||||
const lastTwoDomainWords = /[\w-]+\.[\w-]+($|\/)/
|
||||
const emailRE = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy
|
||||
const xmppResourceRE = /\/[a-zA-Z\d@.]+/gy
|
||||
|
||||
function count(str: string, from: number, to: number, ch: string) {
|
||||
let result = 0
|
||||
for (let i = from; i < to; i++) if (str[i] == ch) result++
|
||||
return result
|
||||
}
|
||||
|
||||
function autolinkURLEnd(text: string, from: number) {
|
||||
urlRE.lastIndex = from
|
||||
let m = urlRE.exec(text)
|
||||
if (!m || lastTwoDomainWords.exec(m[0])![0].indexOf("_") > -1) return -1
|
||||
let end = from + m[0].length
|
||||
for (;;) {
|
||||
let last = text[end - 1], m
|
||||
if (/[?!.,:*_~]/.test(last) ||
|
||||
last == ")" && count(text, from, end, ")") > count(text, from, end, "("))
|
||||
end--
|
||||
else if (last == ";" && (m = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(text.slice(from, end))))
|
||||
end = from + m.index
|
||||
else
|
||||
break
|
||||
}
|
||||
return end
|
||||
}
|
||||
|
||||
function autolinkEmailEnd(text: string, from: number) {
|
||||
emailRE.lastIndex = from
|
||||
let m = emailRE.exec(text)
|
||||
if (!m) return -1
|
||||
let last = m[0][m[0].length - 1]
|
||||
return last == "_" || last == "-" ? -1 : from + m[0].length - (last == "." ? 1 : 0)
|
||||
}
|
||||
|
||||
/// Extension that implements autolinking for
|
||||
/// `www.`/`http://`/`https://`/`mailto:`/`xmpp:` URLs and email
|
||||
/// addresses.
|
||||
export const Autolink: MarkdownConfig = {
|
||||
parseInline: [{
|
||||
name: "Autolink",
|
||||
parse(cx, next, absPos) {
|
||||
let pos = absPos - cx.offset
|
||||
if (pos && /\w/.test(cx.text[pos - 1])) return -1
|
||||
autolinkRE.lastIndex = pos
|
||||
let m = autolinkRE.exec(cx.text), end = -1
|
||||
if (!m) return -1
|
||||
if (m[1] || m[2]) { // www., http://
|
||||
end = autolinkURLEnd(cx.text, pos + m[0].length)
|
||||
if (end > -1 && cx.hasOpenLink) {
|
||||
let noBracket = /([^\[\]]|\[[^\]]*\])*/.exec(cx.text.slice(pos, end))
|
||||
end = pos + noBracket![0].length
|
||||
}
|
||||
} else if (m[3]) { // email address
|
||||
end = autolinkEmailEnd(cx.text, pos)
|
||||
} else { // mailto:/xmpp:
|
||||
end = autolinkEmailEnd(cx.text, pos + m[0].length)
|
||||
if (end > -1 && m[0] == "xmpp:") {
|
||||
xmppResourceRE.lastIndex = end
|
||||
m = xmppResourceRE.exec(cx.text)
|
||||
if (m) end = m.index + m[0].length
|
||||
}
|
||||
}
|
||||
if (end < 0) return -1
|
||||
cx.addElement(cx.elt("URL", absPos, end + cx.offset))
|
||||
return end + cx.offset
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
/// Extension bundle containing [`Table`](#Table),
|
||||
/// [`TaskList`](#TaskList), [`Strikethrough`](#Strikethrough), and
|
||||
/// [`Autolink`](#Autolink).
|
||||
export const GFM = [Table, TaskList, Strikethrough, Autolink]
|
||||
|
||||
function parseSubSuper(ch: number, node: string, mark: string) {
|
||||
return (cx: InlineContext, next: number, pos: number) => {
|
||||
if (next != ch || cx.char(pos + 1) == ch) return -1
|
||||
let elts = [cx.elt(mark, pos, pos + 1)]
|
||||
for (let i = pos + 1; i < cx.end; i++) {
|
||||
let next = cx.char(i)
|
||||
if (next == ch)
|
||||
return cx.addElement(cx.elt(node, pos, i + 1, elts.concat(cx.elt(mark, i, i + 1))))
|
||||
if (next == 92 /* '\\' */)
|
||||
elts.push(cx.elt("Escape", i, i++ + 2))
|
||||
if (space(next)) break
|
||||
}
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension providing
|
||||
/// [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
/// superscript using `^` markers.
|
||||
export const Superscript: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
{name: "Superscript", style: t.special(t.content)},
|
||||
{name: "SuperscriptMark", style: t.processingInstruction}
|
||||
],
|
||||
parseInline: [{
|
||||
name: "Superscript",
|
||||
parse: parseSubSuper(94 /* '^' */, "Superscript", "SuperscriptMark")
|
||||
}]
|
||||
}
|
||||
|
||||
/// Extension providing
|
||||
/// [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
|
||||
/// subscript using `~` markers.
|
||||
export const Subscript: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
{name: "Subscript", style: t.special(t.content)},
|
||||
{name: "SubscriptMark", style: t.processingInstruction}
|
||||
],
|
||||
parseInline: [{
|
||||
name: "Subscript",
|
||||
parse: parseSubSuper(126 /* '~' */, "Subscript", "SubscriptMark")
|
||||
}]
|
||||
}
|
||||
|
||||
/// Extension that parses two colons with only letters, underscores,
|
||||
/// and numbers between them as `Emoji` nodes.
|
||||
export const Emoji: MarkdownConfig = {
|
||||
defineNodes: [{name: "Emoji", style: t.character}],
|
||||
parseInline: [{
|
||||
name: "Emoji",
|
||||
parse(cx, next, pos) {
|
||||
let match: RegExpMatchArray | null
|
||||
if (next != 58 /* ':' */ || !(match = /^[a-zA-Z_0-9]+:/.exec(cx.slice(pos + 1, cx.end)))) return -1
|
||||
return cx.addElement(cx.elt("Emoji", pos, pos + 1 + match[0].length))
|
||||
}
|
||||
}]
|
||||
}
|
||||
5
frontend/node_modules/@lezer/markdown/src/index.ts
generated
vendored
Normal file
5
frontend/node_modules/@lezer/markdown/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export {parser, MarkdownParser, MarkdownConfig, MarkdownExtension,
|
||||
NodeSpec, InlineParser, BlockParser, LeafBlockParser,
|
||||
Line, Element, LeafBlock, DelimiterType, BlockContext, InlineContext} from "./markdown"
|
||||
export {parseCode} from "./nest"
|
||||
export {Table, TaskList, Strikethrough, Autolink, GFM, Subscript, Superscript, Emoji} from "./extension"
|
||||
1958
frontend/node_modules/@lezer/markdown/src/markdown.ts
generated
vendored
Normal file
1958
frontend/node_modules/@lezer/markdown/src/markdown.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
46
frontend/node_modules/@lezer/markdown/src/nest.ts
generated
vendored
Normal file
46
frontend/node_modules/@lezer/markdown/src/nest.ts
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
import {SyntaxNode, Parser, Input, parseMixed, SyntaxNodeRef} from "@lezer/common"
|
||||
import {Type, MarkdownExtension} from "./markdown"
|
||||
|
||||
function leftOverSpace(node: SyntaxNode, from: number, to: number) {
|
||||
let ranges = []
|
||||
for (let n = node.firstChild, pos = from;; n = n.nextSibling) {
|
||||
let nextPos = n ? n.from : to
|
||||
if (nextPos > pos) ranges.push({from: pos, to: nextPos})
|
||||
if (!n) break
|
||||
pos = n.to
|
||||
}
|
||||
return ranges
|
||||
}
|
||||
|
||||
/// Create a Markdown extension to enable nested parsing on code
|
||||
/// blocks and/or embedded HTML.
|
||||
export function parseCode(config: {
|
||||
/// When provided, this will be used to parse the content of code
|
||||
/// blocks. `info` is the string after the opening ` ``` ` marker,
|
||||
/// or the empty string if there is no such info or this is an
|
||||
/// indented code block. If there is a parser available for the
|
||||
/// code, it should return a function that can construct the
|
||||
/// [parse](https://lezer.codemirror.net/docs/ref/#common.PartialParse).
|
||||
codeParser?: (info: string) => null | Parser
|
||||
/// The parser used to parse HTML tags (both block and inline).
|
||||
htmlParser?: Parser,
|
||||
}): MarkdownExtension {
|
||||
let {codeParser, htmlParser} = config
|
||||
let wrap = parseMixed((node: SyntaxNodeRef, input: Input) => {
|
||||
let id = node.type.id
|
||||
if (codeParser && (id == Type.CodeBlock || id == Type.FencedCode)) {
|
||||
let info = ""
|
||||
if (id == Type.FencedCode) {
|
||||
let infoNode = node.node.getChild(Type.CodeInfo)
|
||||
if (infoNode) info = input.read(infoNode.from, infoNode.to)
|
||||
}
|
||||
let parser = codeParser(info)
|
||||
if (parser)
|
||||
return {parser, overlay: node => node.type.id == Type.CodeText}
|
||||
} else if (htmlParser && (id == Type.HTMLBlock || id == Type.HTMLTag || id == Type.CommentBlock)) {
|
||||
return {parser: htmlParser, overlay: leftOverSpace(node.node, node.from, node.to)}
|
||||
}
|
||||
return null
|
||||
})
|
||||
return {wrap}
|
||||
}
|
||||
14
frontend/node_modules/@lezer/markdown/test/compare-tree.ts
generated
vendored
Normal file
14
frontend/node_modules/@lezer/markdown/test/compare-tree.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import {Tree} from "@lezer/common"
|
||||
|
||||
export function compareTree(a: Tree, b: Tree) {
|
||||
let curA = a.cursor(), curB = b.cursor()
|
||||
for (;;) {
|
||||
let mismatch = null, next = false
|
||||
if (curA.type != curB.type) mismatch = `Node type mismatch (${curA.name} vs ${curB.name})`
|
||||
else if (curA.from != curB.from) mismatch = `Start pos mismatch for ${curA.name}: ${curA.from} vs ${curB.from}`
|
||||
else if (curA.to != curB.to) mismatch = `End pos mismatch for ${curA.name}: ${curA.to} vs ${curB.to}`
|
||||
else if ((next = curA.next()) != curB.next()) mismatch = `Tree size mismatch`
|
||||
if (mismatch) throw new Error(`${mismatch}\n ${a}\n ${b}`)
|
||||
if (!next) break
|
||||
}
|
||||
}
|
||||
79
frontend/node_modules/@lezer/markdown/test/spec.ts
generated
vendored
Normal file
79
frontend/node_modules/@lezer/markdown/test/spec.ts
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
import {Tree} from "@lezer/common"
|
||||
import {MarkdownParser} from ".."
|
||||
|
||||
const abbrev: {[abbr: string]: string} = {
|
||||
__proto__: null as any,
|
||||
CB: "CodeBlock",
|
||||
FC: "FencedCode",
|
||||
Q: "Blockquote",
|
||||
HR: "HorizontalRule",
|
||||
BL: "BulletList",
|
||||
OL: "OrderedList",
|
||||
LI: "ListItem",
|
||||
H1: "ATXHeading1",
|
||||
H2: "ATXHeading2",
|
||||
H3: "ATXHeading3",
|
||||
H4: "ATXHeading4",
|
||||
H5: "ATXHeading5",
|
||||
H6: "ATXHeading6",
|
||||
SH1: "SetextHeading1",
|
||||
SH2: "SetextHeading2",
|
||||
HB: "HTMLBlock",
|
||||
PI: "ProcessingInstructionBlock",
|
||||
CMB: "CommentBlock",
|
||||
LR: "LinkReference",
|
||||
P: "Paragraph",
|
||||
Esc: "Escape",
|
||||
Ent: "Entity",
|
||||
BR: "HardBreak",
|
||||
Em: "Emphasis",
|
||||
St: "StrongEmphasis",
|
||||
Ln: "Link",
|
||||
Al: "Autolink",
|
||||
Im: "Image",
|
||||
C: "InlineCode",
|
||||
HT: "HTMLTag",
|
||||
CM: "Comment",
|
||||
Pi: "ProcessingInstruction",
|
||||
h: "HeaderMark",
|
||||
q: "QuoteMark",
|
||||
l: "ListMark",
|
||||
L: "LinkMark",
|
||||
e: "EmphasisMark",
|
||||
c: "CodeMark",
|
||||
cI: "CodeInfo",
|
||||
cT: "CodeText",
|
||||
LT: "LinkTitle",
|
||||
LL: "LinkLabel"
|
||||
}
|
||||
|
||||
export class SpecParser {
|
||||
constructor(readonly parser: MarkdownParser, readonly localAbbrev?: {[name: string]: string}) {}
|
||||
|
||||
type(name: string) {
|
||||
name = (this.localAbbrev && this.localAbbrev[name]) || abbrev[name] || name
|
||||
return this.parser.nodeSet.types.find(t => t.name == name)?.id
|
||||
}
|
||||
|
||||
parse(spec: string, specName: string) {
|
||||
let doc = "", buffer = [], stack: number[] = []
|
||||
for (let pos = 0; pos < spec.length; pos++) {
|
||||
let ch = spec[pos]
|
||||
if (ch == "{") {
|
||||
let name = /^(\w+):/.exec(spec.slice(pos + 1)), tag = name && this.type(name[1])
|
||||
if (tag == null) throw new Error(`Invalid node opening mark at ${pos} in ${specName}`)
|
||||
pos += name![0].length
|
||||
stack.push(tag, doc.length, buffer.length)
|
||||
} else if (ch == "}") {
|
||||
if (!stack.length) throw new Error(`Mismatched node close mark at ${pos} in ${specName}`)
|
||||
let bufStart = stack.pop()!, from = stack.pop()!, type = stack.pop()!
|
||||
buffer.push(type, from, doc.length, 4 + buffer.length - bufStart)
|
||||
} else {
|
||||
doc += ch
|
||||
}
|
||||
}
|
||||
if (stack.length) throw new Error(`Unclosed node in ${specName}`)
|
||||
return {tree: Tree.build({buffer, nodeSet: this.parser.nodeSet, topID: this.type("Document")!, length: doc.length}), doc}
|
||||
}
|
||||
}
|
||||
|
||||
269
frontend/node_modules/@lezer/markdown/test/test-extension.ts
generated
vendored
Normal file
269
frontend/node_modules/@lezer/markdown/test/test-extension.ts
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
import {parser as cmParser, GFM, Subscript, Superscript, Emoji} from "../dist/index.js"
|
||||
import {compareTree} from "./compare-tree.js"
|
||||
import {SpecParser} from "./spec.js"
|
||||
|
||||
const parser = cmParser.configure([GFM, Subscript, Superscript, Emoji])
|
||||
|
||||
const specParser = new SpecParser(parser, {
|
||||
__proto__: null as any,
|
||||
Th: "Strikethrough",
|
||||
tm: "StrikethroughMark",
|
||||
TB: "Table",
|
||||
TH: "TableHeader",
|
||||
TR: "TableRow",
|
||||
TC: "TableCell",
|
||||
tb: "TableDelimiter",
|
||||
T: "Task",
|
||||
t: "TaskMarker",
|
||||
Sub: "Subscript",
|
||||
sub: "SubscriptMark",
|
||||
Sup: "Superscript",
|
||||
sup: "SuperscriptMark",
|
||||
ji: "Emoji"
|
||||
})
|
||||
|
||||
function test(name: string, spec: string, p = parser) {
|
||||
it(name, () => {
|
||||
let {tree, doc} = specParser.parse(spec, name)
|
||||
compareTree(p.parse(doc), tree)
|
||||
})
|
||||
}
|
||||
|
||||
describe("Extension", () => {
|
||||
test("Tables (example 198)", `
|
||||
{TB:{TH:{tb:|} {TC:foo} {tb:|} {TC:bar} {tb:|}}
|
||||
{tb:| --- | --- |}
|
||||
{TR:{tb:|} {TC:baz} {tb:|} {TC:bim} {tb:|}}}`)
|
||||
|
||||
test("Tables (example 199)", `
|
||||
{TB:{TH:{tb:|} {TC:abc} {tb:|} {TC:defghi} {tb:|}}
|
||||
{tb::-: | -----------:}
|
||||
{TR:{TC:bar} {tb:|} {TC:baz}}}`)
|
||||
|
||||
test("Tables (example 200)", `
|
||||
{TB:{TH:{tb:|} {TC:f{Esc:\\|}oo} {tb:|}}
|
||||
{tb:| ------ |}
|
||||
{TR:{tb:|} {TC:b {C:{c:\`}\\|{c:\`}} az} {tb:|}}
|
||||
{TR:{tb:|} {TC:b {St:{e:**}{Esc:\\|}{e:**}} im} {tb:|}}}`)
|
||||
|
||||
test("Tables (example 201)", `
|
||||
{TB:{TH:{tb:|} {TC:abc} {tb:|} {TC:def} {tb:|}}
|
||||
{tb:| --- | --- |}
|
||||
{TR:{tb:|} {TC:bar} {tb:|} {TC:baz} {tb:|}}}
|
||||
{Q:{q:>} {P:bar}}`)
|
||||
|
||||
test("Tables (example 202)", `
|
||||
{TB:{TH:{tb:|} {TC:abc} {tb:|} {TC:def} {tb:|}}
|
||||
{tb:| --- | --- |}
|
||||
{TR:{tb:|} {TC:bar} {tb:|} {TC:baz} {tb:|}}
|
||||
{TR:{TC:bar}}}
|
||||
|
||||
{P:bar}`)
|
||||
|
||||
test("Tables (example 203)", `
|
||||
{P:| abc | def |
|
||||
| --- |
|
||||
| bar |}`)
|
||||
|
||||
test("Tables (example 204)", `
|
||||
{TB:{TH:{tb:|} {TC:abc} {tb:|} {TC:def} {tb:|}}
|
||||
{tb:| --- | --- |}
|
||||
{TR:{tb:|} {TC:bar} {tb:|}}
|
||||
{TR:{tb:|} {TC:bar} {tb:|} {TC:baz} {tb:|} {TC:boo} {tb:|}}}`)
|
||||
|
||||
test("Tables (example 205)", `
|
||||
{TB:{TH:{tb:|} {TC:abc} {tb:|} {TC:def} {tb:|}}
|
||||
{tb:| --- | --- |}}`)
|
||||
|
||||
test("Tables (in blockquote)", `
|
||||
{Q:{q:>} {TB:{TH:{tb:|} {TC:one} {tb:|} {TC:two} {tb:|}}
|
||||
{q:>} {tb:| --- | --- |}
|
||||
{q:>} {TR:{tb:|} {TC:123} {tb:|} {TC:456} {tb:|}}}
|
||||
{q:>}
|
||||
{q:>} {P:Okay}}`)
|
||||
|
||||
test("Tables (empty header)", `
|
||||
{TB:{TH:{tb:|} {tb:|} {tb:|}}
|
||||
{tb:| :-: | :-: |}
|
||||
{TR:{tb:|} {TC:One} {tb:|} {TC:Two} {tb:|}}}`)
|
||||
|
||||
test("Tables (end paragraph)", `
|
||||
{P:Hello}
|
||||
{TB:{TH:{tb:|} {TC:foo} {tb:|} {TC:bar} {tb:|}}
|
||||
{tb:| --- | --- |}
|
||||
{TR:{tb:|} {TC:baz} {tb:|} {TC:bim} {tb:|}}}`)
|
||||
|
||||
test("Tables (invalid tables don't end paragraph)", `
|
||||
{P:Hello
|
||||
| abc | def |
|
||||
| --- |
|
||||
| bar |}`)
|
||||
|
||||
test("Task list (example 279)", `
|
||||
{BL:{LI:{l:-} {T:{t:[ ]} foo}}
|
||||
{LI:{l:-} {T:{t:[x]} bar}}}`)
|
||||
|
||||
test("Task list (example 280)", `
|
||||
{BL:{LI:{l:-} {T:{t:[x]} foo}
|
||||
{BL:{LI:{l:-} {T:{t:[ ]} bar}}
|
||||
{LI:{l:-} {T:{t:[x]} baz}}}}
|
||||
{LI:{l:-} {T:{t:[ ]} bim}}}`)
|
||||
|
||||
test("Autolink (example 622)", `
|
||||
{P:{URL:www.commonmark.org}}`)
|
||||
|
||||
test("Autolink (example 623)", `
|
||||
{P:Visit {URL:www.commonmark.org/help} for more information.}`)
|
||||
|
||||
test("Autolink (example 624)", `
|
||||
{P:Visit {URL:www.commonmark.org}.}
|
||||
|
||||
{P:Visit {URL:www.commonmark.org/a.b}.}`)
|
||||
|
||||
test("Autolink (example 625)", `
|
||||
{P:{URL:www.google.com/search?q=Markup+(business)}}
|
||||
|
||||
{P:{URL:www.google.com/search?q=Markup+(business)}))}
|
||||
|
||||
{P:({URL:www.google.com/search?q=Markup+(business)})}
|
||||
|
||||
{P:({URL:www.google.com/search?q=Markup+(business)}}`)
|
||||
|
||||
test("Autolink (example 626)", `
|
||||
{P:{URL:www.google.com/search?q=(business))+ok}}`)
|
||||
|
||||
test("Autolink (example 627)", `
|
||||
{P:{URL:www.google.com/search?q=commonmark&hl=en}}
|
||||
|
||||
{P:{URL:www.google.com/search?q=commonmark}{Entity:&hl;}}`)
|
||||
|
||||
test("Autolink (example 628)", `
|
||||
{P:{URL:www.commonmark.org/he}<lp}`)
|
||||
|
||||
test("Autolink (example 629)", `
|
||||
{P:{URL:http://commonmark.org}}
|
||||
|
||||
{P:(Visit {URL:https://encrypted.google.com/search?q=Markup+(business)})}`)
|
||||
|
||||
test("Autolink (example 630)", `
|
||||
{P:{URL:foo@bar.baz}}`)
|
||||
|
||||
test("Autolink (example 631)", `
|
||||
{P:hello@mail+xyz.example isn't valid, but {URL:hello+xyz@mail.example} is.}`)
|
||||
|
||||
test("Autolink (example 632)", `
|
||||
{P:{URL:a.b-c_d@a.b}}
|
||||
|
||||
{P:{URL:a.b-c_d@a.b}.}
|
||||
|
||||
{P:a.b-c_d@a.b-}
|
||||
|
||||
{P:a.b-c_d@a.b_}`)
|
||||
|
||||
test("Autolink (example 633)", `
|
||||
{P:{URL:mailto:foo@bar.baz}}
|
||||
|
||||
{P:{URL:mailto:a.b-c_d@a.b}}
|
||||
|
||||
{P:{URL:mailto:a.b-c_d@a.b}.}
|
||||
|
||||
{P:{URL:mailto:a.b-c_d@a.b}/}
|
||||
|
||||
{P:mailto:a.b-c_d@a.b-}
|
||||
|
||||
{P:mailto:a.b-c_d@a.b_}
|
||||
|
||||
{P:{URL:xmpp:foo@bar.baz}}
|
||||
|
||||
{P:{URL:xmpp:foo@bar.baz}.}`)
|
||||
|
||||
test("Autolink (example 634)", `
|
||||
{P:{URL:xmpp:foo@bar.baz/txt}}
|
||||
|
||||
{P:{URL:xmpp:foo@bar.baz/txt@bin}}
|
||||
|
||||
{P:{URL:xmpp:foo@bar.baz/txt@bin.com}}`)
|
||||
|
||||
test("Autolink (example 635)", `
|
||||
{P:{URL:xmpp:foo@bar.baz/txt}/bin}`)
|
||||
|
||||
test("Task list (in ordered list)", `
|
||||
{OL:{LI:{l:1.} {T:{t:[X]} Okay}}}`)
|
||||
|
||||
test("Task list (versus table)", `
|
||||
{BL:{LI:{l:-} {TB:{TH:{TC:[ ] foo} {tb:|} {TC:bar}}
|
||||
{tb:--- | ---}}}}`)
|
||||
|
||||
test("Task list (versus setext header)", `
|
||||
{OL:{LI:{l:1.} {SH1:{Ln:{L:[}X{L:]}} foo
|
||||
{h:===}}}}`)
|
||||
|
||||
test("Strikethrough (example 491)", `
|
||||
{P:{Th:{tm:~~}Hi{tm:~~}} Hello, world!}`)
|
||||
|
||||
test("Strikethrough (example 492)", `
|
||||
{P:This ~~has a}
|
||||
|
||||
{P:new paragraph~~.}`)
|
||||
|
||||
test("Strikethrough (nested)", `
|
||||
{P:Nesting {St:{e:**}with {Th:{tm:~~}emphasis{tm:~~}}{e:**}}.}`)
|
||||
|
||||
test("Strikethrough (overlapping)", `
|
||||
{P:One {St:{e:**}two ~~three{e:**}} four~~}
|
||||
|
||||
{P:One {Th:{tm:~~}two **three{tm:~~}} four**}`)
|
||||
|
||||
test("Strikethrough (escaped)", `
|
||||
{P:A {Esc:\\~}~b c~~}`)
|
||||
|
||||
test("Strikethrough around spaces", `
|
||||
{P:One ~~ two~~ three {Th:{tm:~~}.foo.{tm:~~}} a~~.foo.~~a {Th:{tm:~~}blah{tm:~~}}.}`)
|
||||
|
||||
test("Subscript", `
|
||||
{P:One {Sub:{sub:~}two{sub:~}} {Em:{e:*}one {Sub:{sub:~}two{sub:~}}{e:*}}}`)
|
||||
|
||||
test("Subscript (no spaces)", `
|
||||
{P:One ~two three~}`)
|
||||
|
||||
test("Subscript (escapes)", `
|
||||
{P:One {Sub:{sub:~}two{Esc:\\ }th{Esc:\\~}ree{sub:~}}}`)
|
||||
|
||||
test("Superscript", `
|
||||
{P:One {Sup:{sup:^}two{sup:^}} {Em:{e:*}one {Sup:{sup:^}two{sup:^}}{e:*}}}`)
|
||||
|
||||
test("Superscript (no spaces)", `
|
||||
{P:One ^two three^}`)
|
||||
|
||||
test("Superscript (escapes)", `
|
||||
{P:One {Sup:{sup:^}two{Esc:\\ }th{Esc:\\^}ree{sup:^}}}`)
|
||||
|
||||
test("Emoji", `
|
||||
{P:Hello {ji::smile:} {ji::100:}}`)
|
||||
|
||||
test("Emoji (format)", `
|
||||
{P:Hello :smi le: :1.00: ::}`)
|
||||
|
||||
test("Disable syntax", `
|
||||
{BL:{LI:{l:-} {P:List still {Em:{e:*}works{e:*}}}}}
|
||||
|
||||
{P:> No quote, no ^sup^}
|
||||
|
||||
{P:No setext either
|
||||
===}`, parser.configure({remove: ["Superscript", "Blockquote", "SetextHeading"]}))
|
||||
|
||||
test("Autolink (.co.uk)", `
|
||||
{P:{URL:www.blah.co.uk/path}}`)
|
||||
|
||||
test("Autolink (email .co.uk)", `
|
||||
{P:{URL:foo@bar.co.uk}}`)
|
||||
|
||||
test("Autolink (http://www.foo-bar.com/)", `
|
||||
{P:{URL:http://www.foo-bar.com/}}`)
|
||||
|
||||
test("Autolink (exclude underscores)", `
|
||||
{P:http://www.foo_/ http://foo_.com}`)
|
||||
|
||||
test("Autolink (in image)", `
|
||||
{P:{Im:{L:![}Link: {URL:http://foo.com/}{L:]}{L:(}{URL:x.jpg}{L:)}}}`)
|
||||
})
|
||||
259
frontend/node_modules/@lezer/markdown/test/test-incremental.ts
generated
vendored
Normal file
259
frontend/node_modules/@lezer/markdown/test/test-incremental.ts
generated
vendored
Normal file
@ -0,0 +1,259 @@
|
||||
import {Tree, TreeFragment} from "@lezer/common"
|
||||
import ist from "ist"
|
||||
import {parser} from "../dist/index.js"
|
||||
import {compareTree} from "./compare-tree.js"
|
||||
|
||||
let doc1 = `
|
||||
Header
|
||||
---
|
||||
One **two**
|
||||
three *four*
|
||||
five.
|
||||
|
||||
> Start of quote
|
||||
>
|
||||
> 1. Nested list
|
||||
>
|
||||
> 2. More content
|
||||
> inside the [list][link]
|
||||
>
|
||||
> Continued item
|
||||
>
|
||||
> ~~~
|
||||
> Block of code
|
||||
> ~~~
|
||||
>
|
||||
> 3. And so on
|
||||
|
||||
[link]: /ref
|
||||
[another]: /one
|
||||
And a final paragraph.
|
||||
***
|
||||
The end.
|
||||
`
|
||||
|
||||
type ChangeSpec = {from: number, to?: number, insert?: string}[]
|
||||
|
||||
class State {
|
||||
constructor(readonly doc: string,
|
||||
readonly tree: Tree,
|
||||
readonly fragments: readonly TreeFragment[]) {}
|
||||
|
||||
static start(doc: string) {
|
||||
let tree = parser.parse(doc)
|
||||
return new State(doc, tree, TreeFragment.addTree(tree))
|
||||
}
|
||||
|
||||
update(changes: ChangeSpec, reparse = true) {
|
||||
let changed = [], doc = this.doc, off = 0
|
||||
for (let {from, to = from, insert = ""} of changes) {
|
||||
doc = doc.slice(0, from) + insert + doc.slice(to)
|
||||
changed.push({fromA: from - off, toA: to - off, fromB: from, toB: from + insert.length})
|
||||
off += insert.length - (to - from)
|
||||
}
|
||||
let fragments = TreeFragment.applyChanges(this.fragments, changed, 2)
|
||||
if (!reparse) return new State(doc, Tree.empty, fragments)
|
||||
let tree = parser.parse(doc, fragments)
|
||||
return new State(doc, tree, TreeFragment.addTree(tree, fragments))
|
||||
}
|
||||
}
|
||||
|
||||
let _state1: State | null = null, state1 = () => _state1 || (_state1 = State.start(doc1))
|
||||
|
||||
function overlap(a: Tree, b: Tree) {
|
||||
let inA = new Set<Tree>(), shared = 0, sharingTo = 0
|
||||
for (let cur = a.cursor(); cur.next();) if (cur.tree) inA.add(cur.tree)
|
||||
for (let cur = b.cursor(); cur.next();) if (cur.tree && inA.has(cur.tree) && cur.type.is("Block") && cur.from >= sharingTo) {
|
||||
shared += cur.to - cur.from
|
||||
sharingTo = cur.to
|
||||
}
|
||||
return Math.round(shared * 100 / b.length)
|
||||
}
|
||||
|
||||
function testChange(change: ChangeSpec, reuse = 10) {
|
||||
let state = state1().update(change)
|
||||
compareTree(state.tree, parser.parse(state.doc))
|
||||
if (reuse) ist(overlap(state.tree, state1().tree), reuse, ">")
|
||||
}
|
||||
|
||||
describe("Markdown incremental parsing", () => {
|
||||
it("can produce the proper tree", () => {
|
||||
// Replace 'three' with 'bears'
|
||||
let state = state1().update([{from: 24, to: 29, insert: "bears"}])
|
||||
compareTree(state.tree, state1().tree)
|
||||
})
|
||||
|
||||
it("reuses nodes from the previous parse", () => {
|
||||
// Replace 'three' with 'bears'
|
||||
let state = state1().update([{from: 24, to: 29, insert: "bears"}])
|
||||
ist(overlap(state1().tree, state.tree), 80, ">")
|
||||
})
|
||||
|
||||
it("can reuse content for a change in a block context", () => {
|
||||
// Replace 'content' with 'monkeys'
|
||||
let state = state1().update([{from: 92, to: 99, insert: "monkeys"}])
|
||||
compareTree(state.tree, state1().tree)
|
||||
ist(overlap(state1().tree, state.tree), 20, ">")
|
||||
})
|
||||
|
||||
it("can handle deleting a quote mark", () => testChange([{from: 82, to: 83}]))
|
||||
|
||||
it("can handle adding to a quoted block", () => testChange([{from: 37, insert: "> "}, {from: 45, insert: "> "}]))
|
||||
|
||||
it("can handle a change in a post-linkref paragraph", () => testChange([{from: 249, to: 251}]))
|
||||
|
||||
it("can handle a change in a paragraph-adjacent linkrefs", () => testChange([{from: 230, to: 231}]))
|
||||
|
||||
it("can deal with multiple changes applied separately", () => {
|
||||
let state = state1().update([{from: 190, to: 191}], false).update([{from: 30, insert: "hi\n\nyou"}])
|
||||
compareTree(state.tree, parser.parse(state.doc))
|
||||
ist(overlap(state.tree, state1().tree), 20, ">")
|
||||
})
|
||||
|
||||
it("works when a change happens directly after a block", () => testChange([{from: 150, to: 167}]))
|
||||
|
||||
it("works when a change deletes a blank line after a paragraph", () => testChange([{from: 207, to: 213}]))
|
||||
|
||||
it("doesn't get confused by removing paragraph-breaking markup", () => testChange([{from: 264, to: 265}]))
|
||||
|
||||
function r(n: number) { return Math.floor(Math.random() * n) }
|
||||
function rStr(len: number) {
|
||||
let result = "", chars = "\n>x-"
|
||||
while (result.length < len) result += chars[r(chars.length)]
|
||||
return result
|
||||
}
|
||||
|
||||
it("survives random changes", () => {
|
||||
for (let i = 0, l = doc1.length; i < 20; i++) {
|
||||
let c = 1 + r(4), changes = []
|
||||
for (let i = 0, rFrom = 0; i < c; i++) {
|
||||
let rTo = rFrom + Math.floor((l - rFrom) / (c - i))
|
||||
let from = rFrom + r(rTo - rFrom - 1), to = r(2) == 1 ? from : from + r(Math.min(rTo - from, 20))
|
||||
let iR = r(3), insert = iR == 0 && from != to ? "" : iR == 1 ? "\n\n" : rStr(r(5) + 1)
|
||||
changes.push({from, to, insert})
|
||||
l += insert.length - (to - from)
|
||||
rFrom = to + insert.length
|
||||
}
|
||||
testChange(changes, 0)
|
||||
}
|
||||
})
|
||||
|
||||
it("can handle large documents", () => {
|
||||
let doc = doc1.repeat(50)
|
||||
let state = State.start(doc)
|
||||
let newState = state.update([{from: doc.length >> 1, insert: "a\n\nb"}])
|
||||
ist(overlap(state.tree, newState.tree), 90, ">")
|
||||
})
|
||||
|
||||
it("properly re-parses a continued indented code block", () => {
|
||||
let state = State.start(`
|
||||
One paragraph to create a bit of string length here
|
||||
|
||||
Code
|
||||
Block
|
||||
|
||||
|
||||
|
||||
Another paragraph that is long enough to create a fragment
|
||||
`).update([{from: 76, insert: " "}])
|
||||
compareTree(state.tree, parser.parse(state.doc))
|
||||
})
|
||||
|
||||
it("properly re-parses a continued list", () => {
|
||||
let state = State.start(`
|
||||
One paragraph to create a bit of string length here
|
||||
|
||||
* List
|
||||
|
||||
|
||||
|
||||
More content
|
||||
|
||||
Another paragraph that is long enough to create a fragment
|
||||
`).update([{from: 65, insert: " * "}])
|
||||
compareTree(state.tree, parser.parse(state.doc))
|
||||
})
|
||||
|
||||
it("can recover from incremental parses that stop in the middle of a list", () => {
|
||||
let doc = `
|
||||
1. I am a list item with ***some* emphasized
|
||||
content inside** and the parser hopefully stops
|
||||
parsing after me.
|
||||
|
||||
2. Oh no the list continues.
|
||||
`
|
||||
let parse = parser.startParse(doc), tree
|
||||
parse.advance()
|
||||
ist(parse.parsedPos, doc.length, "<")
|
||||
parse.stopAt(parse.parsedPos)
|
||||
while (!(tree = parse.advance())) {}
|
||||
let state = new State(doc, tree, TreeFragment.addTree(tree)).update([])
|
||||
ist(state.tree.topNode.lastChild!.from, 1)
|
||||
})
|
||||
|
||||
it("can reuse list items", () => {
|
||||
let start = State.start(" - List item\n".repeat(100))
|
||||
let state = start.update([{from: 18, to: 19}])
|
||||
ist(overlap(start.tree, state.tree), 80, ">")
|
||||
})
|
||||
|
||||
it("returns a tree starting at the first range", () => {
|
||||
let result = parser.parse("foo\n\nbar", [], [{from: 5, to: 8}])
|
||||
ist(result.toString(), "Document(Paragraph)")
|
||||
ist(result.length, 3)
|
||||
ist(result.positions[0], 0)
|
||||
})
|
||||
|
||||
it("Allows gaps in the input", () => {
|
||||
let doc = `
|
||||
The first X *y* X<
|
||||
|
||||
>X paragraph.
|
||||
|
||||
- And *a X<*>X list*
|
||||
`
|
||||
let tree = parser.parse(doc, [], [{from: 0, to: 11}, {from: 12, to: 17}, {from: 23, to: 46}, {from: 51, to: 58}])
|
||||
ist(tree.toString(),
|
||||
"Document(Paragraph(Emphasis(EmphasisMark,EmphasisMark)),BulletList(ListItem(ListMark,Paragraph(Emphasis(EmphasisMark,EmphasisMark)))))")
|
||||
ist(tree.length, doc.length)
|
||||
let top = tree.topNode, first = top.firstChild!
|
||||
ist(first.name, "Paragraph")
|
||||
ist(first.from, 1)
|
||||
ist(first.to, 34)
|
||||
let last = top.lastChild!.lastChild!.lastChild!, em = last.lastChild!
|
||||
ist(last.name, "Paragraph")
|
||||
ist(last.from, 39)
|
||||
ist(last.to, 57)
|
||||
ist(em.name, "Emphasis")
|
||||
ist(em.from, 43)
|
||||
ist(em.to, 57)
|
||||
})
|
||||
|
||||
it("can reuse nodes at the end of the document", () => {
|
||||
let doc = `* List item
|
||||
|
||||
~~~js
|
||||
function foo() {
|
||||
return false
|
||||
}
|
||||
~~~
|
||||
`
|
||||
let tree = parser.parse(doc)
|
||||
let ins = 11
|
||||
let doc2 = doc.slice(0, ins) + "\n* " + doc.slice(ins)
|
||||
let fragments = TreeFragment.applyChanges(TreeFragment.addTree(tree), [{fromA: ins, toA: ins, fromB: ins, toB: ins + 3}])
|
||||
let tree2 = parser.parse(doc2, fragments)
|
||||
ist(tree2.topNode.lastChild!.tree, tree.topNode.lastChild!.tree)
|
||||
})
|
||||
|
||||
it("places reused nodes at the right position when there are gaps before them", () => {
|
||||
let doc = " {{}}\nb\n{{}}"
|
||||
let ast1 = parser.parse(doc, undefined, [{from: 0, to: 1}, {from: 5, to: 8}])
|
||||
let frag = TreeFragment.applyChanges(TreeFragment.addTree(ast1), [{fromA: 0, toA: 0, fromB: 0, toB: 1}])
|
||||
let ast2 = parser.parse(" " + doc, frag, [{from: 0, to: 2}, {from: 6, to: 9}])
|
||||
ist(ast2.toString(), "Document(Paragraph)")
|
||||
let p = ast2.topNode.firstChild!
|
||||
ist(p.from, 7)
|
||||
ist(p.to, 8)
|
||||
})
|
||||
})
|
||||
3568
frontend/node_modules/@lezer/markdown/test/test-markdown.ts
generated
vendored
Normal file
3568
frontend/node_modules/@lezer/markdown/test/test-markdown.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
86
frontend/node_modules/@lezer/markdown/test/test-nesting.ts
generated
vendored
Normal file
86
frontend/node_modules/@lezer/markdown/test/test-nesting.ts
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
import {Tree, NodeProp} from "@lezer/common"
|
||||
import {parser as html} from "@lezer/html"
|
||||
import ist from "ist"
|
||||
import {parser, parseCode} from "../dist/index.js"
|
||||
|
||||
let full = parser.configure(parseCode({
|
||||
codeParser(str) { return !str || str == "html" ? html : null },
|
||||
htmlParser: html.configure({dialect: "noMatch"})
|
||||
}))
|
||||
|
||||
function findMounts(tree: Tree) {
|
||||
let result = []
|
||||
for (let cur = tree.cursor(); cur.next();) {
|
||||
let mount = cur.tree?.prop(NodeProp.mounted)
|
||||
if (mount) result.push({at: cur.from, mount})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function test(doc: string, ...nest: [string, ...number[]][]) {
|
||||
return () => {
|
||||
let tree = full.parse(doc), mounts = findMounts(tree)
|
||||
ist(mounts.length, nest.length)
|
||||
nest.forEach(([repr, ...ranges], i) => {
|
||||
let {mount, at} = mounts[i]
|
||||
ist(mount.tree.toString(), "Document(" + repr + ")")
|
||||
ist(mount.overlay!.map(r => (r.from + at) + "," + (r.to + at)).join(), ranges.join())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
describe("Code parsing", () => {
|
||||
it("parses HTML blocks", test(`
|
||||
Paragraph
|
||||
|
||||
<div id=x>
|
||||
Hello & goodbye
|
||||
</div>`, ["Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag),Text,EntityReference,Text,CloseTag(StartCloseTag,TagName,EndTag))", 12, 51]))
|
||||
|
||||
it("parses inline HTML", test(
|
||||
`Paragraph with <em>inline tags</em> in it.`,
|
||||
["Element(OpenTag(StartTag,TagName,EndTag))", 15, 19],
|
||||
["CloseTag(StartCloseTag,TagName,EndTag)", 30, 35]))
|
||||
|
||||
it("parses indented code", test(`
|
||||
Paragraph.
|
||||
|
||||
<!doctype html>
|
||||
Hi
|
||||
`, ["DoctypeDecl,Text", 17, 33, 37, 39]))
|
||||
|
||||
it("parses fenced code", test(`
|
||||
Okay
|
||||
|
||||
~~~
|
||||
<p>
|
||||
Hey
|
||||
</p>
|
||||
~~~`, ["Element(OpenTag(StartTag,TagName,EndTag),Text,CloseTag(StartCloseTag,TagName,EndTag))", 11, 25]))
|
||||
|
||||
it("allows gaps in fenced code", test(`
|
||||
- >~~~
|
||||
><!doctype html>
|
||||
>yay
|
||||
> ~~~`, ["DoctypeDecl,Text", 11, 27, 30, 33]))
|
||||
|
||||
it("passes fenced code info", test(`
|
||||
~~~html
|
||||
»
|
||||
~~~
|
||||
|
||||
~~~python
|
||||
False
|
||||
~~~`, ["EntityReference", 9, 16]))
|
||||
|
||||
it("can parse disjoint ranges", () => {
|
||||
let tree = parser.parse(`==foo\n==\n==ba==r\n==`, undefined,
|
||||
[{from: 2, to: 6}, {from: 8, to: 9}, {from: 11, to: 13}, {from: 15, to: 17}])
|
||||
ist(tree.toString(), "Document(Paragraph,Paragraph)")
|
||||
ist(tree.length, 15)
|
||||
ist(tree.topNode.firstChild!.from, 0)
|
||||
ist(tree.topNode.firstChild!.to, 3)
|
||||
ist(tree.topNode.lastChild!.from, 9)
|
||||
ist(tree.topNode.lastChild!.to, 14)
|
||||
})
|
||||
})
|
||||
12
frontend/node_modules/@lezer/markdown/test/tsconfig.json
generated
vendored
Normal file
12
frontend/node_modules/@lezer/markdown/test/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2017"],
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"strict": true,
|
||||
"target": "es6",
|
||||
"newLine": "lf",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": ["*.ts"]
|
||||
}
|
||||
14
frontend/node_modules/@lezer/markdown/tsconfig.json
generated
vendored
Normal file
14
frontend/node_modules/@lezer/markdown/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2017"],
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"strict": true,
|
||||
"target": "es6",
|
||||
"module": "es2015",
|
||||
"newLine": "lf",
|
||||
"stripInternal": true,
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": ["src/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user