plugin to change links and images to references with separate definitions
Installations
npm install remark-reference-links
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
20.5.1
NPM Version
9.8.0
Statistics
26 Stars
136 Commits
3 Forks
9 Watching
1 Branches
15 Contributors
Updated on 29 Sept 2024
Bundle Size
1.16 kB
Minified
623.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
20,639,999
Last day
-23.2%
14,861
Compared to previous day
Last week
-0.5%
105,039
Compared to previous week
Last month
78.2%
398,716
Compared to previous month
Last year
114.8%
6,482,407
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
remark-reference-links
remark plugin to change links and images to references with separate definitions.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Security
- Related
- Contribute
- License
What is this?
This package is a unified (remark) plugin to turn links ([text](url)
)
and images (![alt](url)
) into references ([text][id]
, ![alt][id]
) and
definitions ([id]: url
).
When should I use this?
This project is useful when you want to transform markdown and prefer that it uses references and definitions. Long URLs in source code can make reading markdown difficult. References and definitions improve that by moving those URLs into definitions, outside of paragraphs.
This plugin is very similar to the alternative
remark-defsplit
.
The difference is that that plugin generates identifiers based on hostnames of
URLs and places definitions at the end of each section, whereas this plugin
generates numeric identifiers at the end of the document.
A different plugin, remark-inline-links
, does the
inverse: turn references and definitions into links and images.
Install
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install remark-reference-links
In Deno with esm.sh
:
1import remarkReferenceLinks from 'https://esm.sh/remark-reference-links@7'
In browsers with esm.sh
:
1<script type="module"> 2 import remarkReferenceLinks from 'https://esm.sh/remark-reference-links@7?bundle' 3</script>
Use
Say we have the following file example.md
:
1# Pluto 2 3[![Build](https://github.com/solar-system/pluto/workflows/main/badge.svg)](https://github.com/solar-system/pluto/actions) 4 5## History 6 7In the 1840s, 8[Urbain Le Verrier](https://wikipedia.org/wiki/Urbain_Le_Verrier) used 9Newtonian mechanics to predict the position of the then-undiscovered planet 10[Neptune](https://wikipedia.org/wiki/Neptune) after analyzing perturbations 11in the orbit of [Uranus](https://wikipedia.org/wiki/Uranus).
And our module example.js
looks as follows:
1import {remark} from 'remark' 2import remarkReferenceLinks from 'remark-reference-links' 3import {read} from 'to-vfile' 4 5const file = await remark() 6 .use(remarkReferenceLinks) 7 .process(await read('example.md')) 8 9console.log(String(file))
…then running node example.js
yields:
1# Pluto 2 3[![Build][2]][1] 4 5## History 6 7In the 1840s, 8[Urbain Le Verrier][3] used 9Newtonian mechanics to predict the position of the then-undiscovered planet 10[Neptune][4] after analyzing perturbations 11in the orbit of [Uranus][5]. 12 13[1]: https://github.com/solar-system/pluto/actions 14 15[2]: https://github.com/solar-system/pluto/workflows/main/badge.svg 16 17[3]: https://wikipedia.org/wiki/Urbain_Le_Verrier 18 19[4]: https://wikipedia.org/wiki/Neptune 20 21[5]: https://wikipedia.org/wiki/Uranus
👉 Note: observe that definitions are added at the end of the document and that IDs are numeric identifiers.
API
This package exports no identifiers.
The default export is remarkReferenceLinks
.
unified().use(remarkReferenceLinks)
Change links and images to references with separate definitions.
Parameters
There are no parameters.
Returns
Transform (Transformer
).
Types
This package is fully typed with TypeScript. It exports no additional options.
Compatibility
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, remark-reference-links@^7
,
compatible with Node.js 16.
This plugin works with unified
version 3+ and remark
version 4+.
Security
Use of remark-reference-links
does not involve rehype (hast)
or user content so there are no openings for cross-site scripting
(XSS) attacks.
Related
remark-defsplit
— transform links and images into references and definitions with numeric IDsremark-inline-links
— transform references and definitions into normal links and images
Contribute
See contributing.md
in remarkjs/.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
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/remarkjs/.github/security.md:1
- Info: Found linked content: github.com/remarkjs/.github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/remarkjs/.github/security.md:1
- Info: Found text in security policy: github.com/remarkjs/.github/security.md:1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/bb.yml:1
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkjs/remark-reference-links/bb.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkjs/remark-reference-links/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkjs/remark-reference-links/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkjs/remark-reference-links/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 5.0.0 not signed: https://api.github.com/repos/remarkjs/remark-reference-links/releases/24750900
- Warn: release artifact 4.0.4 not signed: https://api.github.com/repos/remarkjs/remark-reference-links/releases/18015989
- Warn: release artifact 5.0.0 does not have provenance: https://api.github.com/repos/remarkjs/remark-reference-links/releases/24750900
- Warn: release artifact 4.0.4 does not have provenance: https://api.github.com/repos/remarkjs/remark-reference-links/releases/18015989
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Score
3.7
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to remark-reference-links
@mcansh/remark-definition-links
This plugin is based on [remark-reference-links][reference-links] and [remark-defsplit][defsplit] in that it converts inline links to a definition list, but unlike remark-defsplit it puts them all at the bottom
remark-lint-no-shortcut-reference-link
remark-lint rule to warn when shortcut reference links are used
remark-html
remark plugin to compile Markdown to HTML
remark-lint-no-unneeded-full-reference-link
remark-lint rule to warn when full reference links are used if they can be collapsed