Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

mdast-util-definitions

1.2.3 • Public • Published

mdast-util-definitions Build Status Coverage Status Chat

Get definitions in MDAST nodes by identifier. Supports funky keys, like __proto__ or toString.

Installation

npm:

npm install mdast-util-definitions

Usage

var remark = require('remark')
var definitions = require('mdast-util-definitions')
 
var ast = remark().parse('[example]: http://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 to use CommonMark precedence: ignore later found definitions for duplicate definitions. The default behaviour is to prefer the last found definition.

Returns

Function

definition(identifier)

Parameters
  • identifier (string) — Identifier of definition.
Returns

Node? — Definition, if found.

Contribute

See contributing.md in syntax-tree/mdast for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

install

npm i mdast-util-definitions

Downloadsweekly downloads

161,912

version

1.2.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability