mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Allow options.markdownItFactory to be implemented asynchronously so the markdown-it parser import can be deferred.
This commit is contained in:
parent
d4b981bcb3
commit
44c302fe0b
6 changed files with 448 additions and 249 deletions
12
README.md
12
README.md
|
@ -580,14 +580,22 @@ declaring the dependency and returning an instance from this factory. If any
|
|||
[`markdown-it` plugins][markdown-it-plugin] are needed, they should be `use`d by
|
||||
the caller before returning the `markdown-it` instance.
|
||||
|
||||
For compatibility with previous versions of `markdownlint`, this function can be
|
||||
implemented like:
|
||||
For compatibility with previous versions of `markdownlint`, this function should
|
||||
be similar to:
|
||||
|
||||
```javascript
|
||||
import markdownIt from "markdown-it";
|
||||
const markdownItFactory = () => markdownIt({ "html": true });
|
||||
```
|
||||
|
||||
When an asynchronous implementation of `lint` is being invoked (e.g., via
|
||||
`markdownlint/async` or `markdownlint/promise`), this function can return a
|
||||
`Promise` in order to defer the import of `markdown-it`:
|
||||
|
||||
```javascript
|
||||
const markdownItFactory = () => import("markdown-it").then((module) => module.default({ "html": true }));
|
||||
```
|
||||
|
||||
> Note that this function is only invoked when a `markdown-it` parser is
|
||||
> needed. None of the built-in rules use the `markdown-it` parser, so it is only
|
||||
> invoked when one or more [custom rules][custom-rules] are present that use the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue