$ cnpm install mdast-util-definitions
mdast utility to get definitions by identifier
.
Supports funky keys, like __proto__
or toString
.
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install mdast-util-definitions
import {remark} from 'remark'
import {definitions} from 'mdast-util-definitions'
const tree = remark().parse('[example]: https://example.com "Example"')
const definition = definitions(tree)
definition('example')
// => {type: 'definition', 'title': 'Example', …}
definition('foo')
// => null
This package exports the following identifiers: definitions
.
There is no default export.
definitions(tree)
Create a cache of all definitions in tree
.
Uses CommonMark precedence: prefers the first definitions for duplicate definitions.
definition(identifier)
identifier
(string
) — Identifier of definition.Node?
— Definition, if found.
Use of mdast-util-definitions
does not involve hast or user
content so there are no openings for cross-site scripting (XSS) attacks.
Additionally, safe guards are in place to protect against prototype poisoning.
unist-util-index
— index property values or computed keys to nodesSee contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
Copyright 2013 - present © cnpmjs.org