mdast-util-definitions
mdast utility to find definition nodes in a tree
Last updated 5 years ago by wooorm .
MIT · Repository · Bugs · Original npm
$ cnpm install mdast-util-definitions 
SYNC missed versions from official npm registry.

mdast-util-definitions

Build Coverage Downloads Size Sponsors Backers 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(node[, options])

Create a cache of all definitions in node.

options.commonmark

boolean, default: false — Turn on (true) to use CommonMark precedence: ignore definitions found later for duplicate definitions. The default behavior is to prefer the last found definition.

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.

Related

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

Current Tags

  • 5.1.1                                ...           latest (3 years ago)

6 Versions

  • 5.1.1                                ...           3 years ago
  • 5.1.0                                ...           4 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.1                                ...           5 years ago
  • 1.2.5                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org