Projects STRLCPY kitsec-core Files
🤬
..
types Loading last commit info...
index.js
license
package.json
readme.md
readme.md

mdast-util-definitions

[Build]build [Coverage]coverage [Downloads]downloads [Size]size [Sponsors]collective [Backers]collective [Chat]chat

mdast utility to get definitions by identifier.

Supports funky keys, like __proto__ or toString.

Install

npm:

npm install mdast-util-definitions

npm with TypeScript support:

npm install mdast-util-definitions @types/mdast

Use

var remark = require('remark')
var definitions = require('mdast-util-definitions')

var ast = remark().parse('[example]: https://example.com "Example"')

var definition = definitions(ast)

definition('example')
// => {type: 'definition', 'title': 'Example', ...}

definition('foo')
// => null

API

definitions(tree)

Create a cache of all definitions in tree.

Uses CommonMark precedence: prefers the first definitions for duplicate definitions.

Returns

Function

definition(identifier)

Parameters
Returns

Node?Definition, if found.

Security

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.

Contribute

See 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.

License

MIT © Titus Wormer

Please wait...
Page is in error, reload to recover