{"id":13716677,"url":"https://github.com/syntax-tree/mdast-util-definitions","last_synced_at":"2025-10-28T12:40:35.407Z","repository":{"id":57293470,"uuid":"39273276","full_name":"syntax-tree/mdast-util-definitions","owner":"syntax-tree","description":"utility to find definition nodes in an mdast tree","archived":false,"fork":false,"pushed_at":"2023-07-08T09:56:19.000Z","size":144,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-15T20:12:01.066Z","etag":null,"topics":["definition","markdown","mdast","mdast-util","syntax-tree","unist","util"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2015-07-17T20:10:23.000Z","updated_at":"2024-11-02T04:58:19.000Z","dependencies_parsed_at":"2024-01-14T22:03:35.240Z","dependency_job_id":"8b515c99-7bea-4798-8ee0-0d752721f8c3","html_url":"https://github.com/syntax-tree/mdast-util-definitions","commit_stats":{"total_commits":128,"total_committers":4,"mean_commits":32.0,"dds":0.046875,"last_synced_commit":"e88957e37d17872ff1f153a5a427e74332579ec0"},"previous_names":["wooorm/mdast-util-definitions"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/mdast-util-definitions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-definitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-definitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-definitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-definitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/mdast-util-definitions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-definitions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262141960,"owners_count":23265644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["definition","markdown","mdast","mdast-util","syntax-tree","unist","util"],"created_at":"2024-08-03T00:01:13.223Z","updated_at":"2025-10-28T12:40:30.387Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# mdast-util-definitions\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[mdast][] utility to find definitions by `identifier`.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`definitions(tree)`](#definitionstree)\n    *   [`GetDefinition`](#getdefinition)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a tiny utility that lets you find definitions.\n\n## When should I use this?\n\nThis utility can be useful because definitions can occur after the things that\nreference them.\nIt’s small and protects against prototype pollution.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install mdast-util-definitions\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {definitions} from 'https://esm.sh/mdast-util-definitions@6'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {definitions} from 'https://esm.sh/mdast-util-definitions@6?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {definitions} from 'mdast-util-definitions'\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\nconst tree = fromMarkdown('[example]: https://example.com \"Example\"')\n\nconst definition = definitions(tree)\n\ndefinition('example')\n// =\u003e {type: 'definition', 'title': 'Example', …}\n\ndefinition('foo')\n// =\u003e undefined\n```\n\n## API\n\nThis package exports the identifier [`definitions`][api-definitions].\nThere is no default export.\n\n### `definitions(tree)`\n\nFind definitions in `tree`.\n\nUses CommonMark precedence, which means that earlier definitions are\npreferred over duplicate later definitions.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to check\n\n###### Returns\n\nGetter ([`GetDefinition`][api-getdefinition]).\n\n### `GetDefinition`\n\nGet a definition by identifier (TypeScript type).\n\n###### Parameters\n\n*   `identifier` (`string`, optional)\n    — identifier of definition\n\n###### Returns\n\nDefinition corresponding to `identifier` ([`Definition`][definition]) or\n`undefined`.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type  [`GetDefinition`][api-getdefinition].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`mdast-util-definitions@^6`, compatible with Node.js 16.\n\n## Security\n\nUse of `mdast-util-definitions` does not involve **[hast][]** or user content so\nthere are no openings for [cross-site scripting (XSS)][xss] attacks.\nAdditionally, safe guards are in place to protect against prototype poisoning.\n\n## Related\n\n*   [`unist-util-index`](https://github.com/syntax-tree/unist-util-index)\n    — index property values or computed keys to nodes\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/mdast-util-definitions/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/mdast-util-definitions/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-definitions.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/mdast-util-definitions\n\n[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-definitions.svg\n\n[downloads]: https://www.npmjs.com/package/mdast-util-definitions\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=mdast-util-definitions\n\n[size]: https://bundlejs.com/?q=mdast-util-definitions\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[definition]: https://github.com/syntax-tree/mdast#definition\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[hast]: https://github.com/syntax-tree/hast\n\n[api-definitions]: #definitionstree\n\n[api-getdefinition]: #getdefinition\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["mdast utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fmdast-util-definitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fmdast-util-definitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fmdast-util-definitions/lists"}