Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
mdast-util-definitions
Advanced tools
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.
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'));
While unist-util-visit is not specifically designed for handling definitions within markdown documents, it is a utility for traversing Unist syntax trees, which includes MDASTs. It can be used in conjunction with mdast-util-definitions for more complex operations involving visiting nodes and acting upon them, offering a broader scope of manipulation than mdast-util-definitions.
remark-parse is a part of the remark ecosystem, which is built on top of MDAST. It is used for parsing markdown into MDASTs. While it doesn't provide definition lookup functionality directly, it is a foundational tool for creating MDASTs from markdown content, which can then be used with mdast-util-definitions for definition management.
mdast utility to find definitions by identifier
.
This package is a tiny utility that lets you find definitions.
This utility can be useful because definitions can occur after the things that reference them. It’s small and protects against prototype pollution.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install mdast-util-definitions
In Deno with esm.sh
:
import {definitions} from 'https://esm.sh/mdast-util-definitions@6'
In browsers with esm.sh
:
<script type="module">
import {definitions} from 'https://esm.sh/mdast-util-definitions@6?bundle'
</script>
import {definitions} from 'mdast-util-definitions'
import {fromMarkdown} from 'mdast-util-from-markdown'
const tree = fromMarkdown('[example]: https://example.com "Example"')
const definition = definitions(tree)
definition('example')
// => {type: 'definition', 'title': 'Example', …}
definition('foo')
// => undefined
This package exports the identifier definitions
.
There is no default export.
definitions(tree)
Find definitions in tree
.
Uses CommonMark precedence, which means that earlier definitions are preferred over duplicate later definitions.
tree
(Node
)
— tree to checkGetter (GetDefinition
).
GetDefinition
Get a definition by identifier (TypeScript type).
identifier
(string
, optional)
— identifier of definitionDefinition corresponding to identifier
(Definition
) or
undefined
.
This package is fully typed with TypeScript.
It exports the additional type GetDefinition
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
mdast-util-definitions@^6
, compatible with Node.js 16.
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.
FAQs
mdast utility to find definition nodes in a tree
We found that mdast-util-definitions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.