Socket
Socket
Sign inDemoInstall

mdast-util-definitions

Package Overview
Dependencies
4
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mdast-util-definitions

mdast utility to find definition nodes in a tree


Version published
Weekly downloads
6.7M
decreased by-0.09%
Maintainers
2
Install size
59.7 kB
Created
Weekly downloads
 

Package description

What is mdast-util-definitions?

The mdast-util-definitions npm package is a utility for working with Markdown Abstract Syntax Tree (MDAST) data structures. It provides a way to look up and manage definitions in a MDAST, which is useful when working with markdown documents in a programmatic way. This can include tasks like parsing, manipulating, or inspecting markdown content.

What are mdast-util-definitions's main functionalities?

Definition lookup

This feature allows you to look up definitions in a MDAST by their identifier. It's useful for resolving references in markdown documents, such as links or images, to their corresponding definitions.

const definitions = require('mdast-util-definitions');
const ast = { /* some MDAST */ };
const definition = definitions(ast);

console.log(definition('referenceId'));

Other packages similar to mdast-util-definitions

Readme

Source

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(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

Keywords

FAQs

Last updated on 03 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc