{"id":18434339,"url":"https://github.com/remarkjs/remark-defsplit","last_synced_at":"2025-04-07T19:31:38.556Z","repository":{"id":36009888,"uuid":"40303739","full_name":"remarkjs/remark-defsplit","owner":"remarkjs","description":"plugin to change links and images to references with separate definitions","archived":false,"fork":false,"pushed_at":"2023-09-20T12:57:58.000Z","size":113,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-22T23:51:18.195Z","etag":null,"topics":["definition","image","link","markdown","reference","remark","remark-plugin"],"latest_commit_sha":null,"homepage":"https://remark.js.org","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/remarkjs.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-06T12:32:33.000Z","updated_at":"2024-11-13T11:30:51.000Z","dependencies_parsed_at":"2024-06-21T12:53:51.555Z","dependency_job_id":"fe09373d-f8ce-47d8-a8f0-60061b8db0bd","html_url":"https://github.com/remarkjs/remark-defsplit","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":"0.18000000000000005","last_synced_commit":"20582f489e28aa097b4e78081df78a578f2eded2"},"previous_names":["eush77/mdast-defsplit"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-defsplit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-defsplit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-defsplit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-defsplit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkjs","download_url":"https://codeload.github.com/remarkjs/remark-defsplit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247716298,"owners_count":20984214,"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","image","link","markdown","reference","remark","remark-plugin"],"created_at":"2024-11-06T06:03:11.516Z","updated_at":"2025-04-07T19:31:38.236Z","avatar_url":"https://github.com/remarkjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# remark-defsplit\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**[remark][]** plugin to change links and images to references with separate\ndefinitions.\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    *   [`unified().use(remarkDefsplit[, options])`](#unifieduseremarkdefsplit-options)\n    *   [`Options`](#options)\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 [unified][] ([remark][]) plugin to turn links (`[text](url)`)\nand images (`![alt](url)`) into references (`[text][id]`, `![alt][id]`) and\ndefinitions (`[id]: url`).\n\n## When should I use this?\n\nThis project is useful when you want to transform markdown and prefer that it\nuses references and definitions.\nLong URLs in source code can make reading markdown difficult.\nReferences and definitions improve that by moving those URLs into definitions,\noutside of paragraphs.\n\nThis plugin is very similar to the alternative\n[`remark-reference-links`][remark-reference-links].\nThe difference is that that plugin generates numeric identifiers at the end of\nthe document, whereas this plugin generates identifiers based on hostnames of\nURLs at the end of each section.\n\nA different plugin, [`remark-inline-links`][remark-inline-links], does the\ninverse: turn references and definitions into links and images.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install remark-defsplit\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport remarkDefsplit from 'https://esm.sh/remark-defsplit@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import remarkDefsplit from 'https://esm.sh/remark-defsplit@5?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay we have the following file `example.md`:\n\n```markdown\n# Pluto\n\n[![Build](https://github.com/solar-system/pluto/workflows/main/badge.svg)](https://github.com/solar-system/pluto/actions)\n\n## History\n\nIn the 1840s,\n[Urbain Le Verrier](https://wikipedia.org/wiki/Urbain_Le_Verrier) used\nNewtonian mechanics to predict the position of the then-undiscovered planet\n[Neptune](https://wikipedia.org/wiki/Neptune) after analyzing perturbations\nin the orbit of [Uranus](https://wikipedia.org/wiki/Uranus).\n```\n\n…and a module `example.js`:\n\n```js\nimport {remark} from 'remark'\nimport remarkDefsplit from 'remark-defsplit'\nimport {read} from 'to-vfile'\n\nconst file = await remark()\n  .use(remarkDefsplit)\n  .process(await read('example.md'))\n\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```markdown\n# Pluto\n\n[![Build][github-1]][github-2]\n\n[github-1]: https://github.com/solar-system/pluto/workflows/main/badge.svg\n\n[github-2]: https://github.com/solar-system/pluto/actions\n\n## History\n\nIn the 1840s,\n[Urbain Le Verrier][wikipedia-1] used\nNewtonian mechanics to predict the position of the then-undiscovered planet\n[Neptune][wikipedia-2] after analyzing perturbations\nin the orbit of [Uranus][wikipedia-3].\n\n[wikipedia-1]: https://wikipedia.org/wiki/Urbain_Le_Verrier\n\n[wikipedia-2]: https://wikipedia.org/wiki/Neptune\n\n[wikipedia-3]: https://wikipedia.org/wiki/Uranus\n```\n\n\u003e 👉 **Note**: observe that definitions are added at the end of each section\n\u003e and that IDs are generated based on the hostname of URLs.\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`remarkDefsplit`][api-remark-defsplit].\n\n### `unified().use(remarkDefsplit[, options])`\n\nChange links and images to references with separate definitions.\n\n###### Parameters\n\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `id` (`Array\u003cstring\u003e` or `string`, optional)\n    — IDs to use for new definitions instead of autogenerated ones;\n    when given one ID, then the first link or image will use that ID, when\n    another link or image is seen, it’ll get an autogenerated ID\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\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, `remark-defsplit@^5`,\ncompatible with Node.js 16.\n\nThis plugin works with `unified` version 6+ and `remark` version 7+.\n\n## Security\n\nUse of `remark-defsplit` does not involve **[rehype][]** (**[hast][]**) or user\ncontent so there are no openings for [cross-site scripting (XSS)][wiki-xss]\nattacks.\n\n## Related\n\n*   [`remark-reference-links`][remark-reference-links]\n    — transform links and images into references and definitions with generated\n    IDs\n*   [`remark-inline-links`][remark-inline-links]\n    — transform references and definitions into normal links and images\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways\nto 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] © Eugene Sharygin\n\n[build-badge]: https://github.com/remarkjs/remark-defsplit/workflows/main/badge.svg\n\n[build]: https://github.com/remarkjs/remark-defsplit/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-defsplit.svg\n\n[coverage]: https://codecov.io/github/remarkjs/remark-defsplit\n\n[downloads-badge]: https://img.shields.io/npm/dm/remark-defsplit.svg\n\n[downloads]: https://www.npmjs.com/package/remark-defsplit\n\n[size-badge]: https://img.shields.io/bundlejs/size/remark-defsplit\n\n[size]: https://bundlejs.com/?q=remark-defsplit\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/remarkjs/remark/discussions\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[health]: https://github.com/remarkjs/.github\n\n[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/remarkjs/.github/blob/main/support.md\n\n[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[hast]: https://github.com/syntax-tree/hast\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[remark]: https://github.com/remarkjs/remark\n\n[remark-reference-links]: https://github.com/remarkjs/remark-reference-links\n\n[remark-inline-links]: https://github.com/remarkjs/remark-inline-links\n\n[typescript]: https://www.typescriptlang.org\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[api-options]: #options\n\n[api-remark-defsplit]: #unifieduseremarkdefsplit-options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkjs%2Fremark-defsplit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkjs%2Fremark-defsplit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkjs%2Fremark-defsplit/lists"}