remark-reference-links
remark plugin to transform links and images into references and definitions.
Note!
This plugin is ready for the new parser in remark (remarkjs/remark#536
). No change is needed: it works exactly the same now as it did before!
Install
npm:
npm install remark-reference-links
Use
Say we have the following file, example.md
:
[foo](http://example.com "Example Domain"), [foo](http://example.com "Example Domain"), [bar](http://example.com "Example Domain").
![foo](http://example.com "Example Domain"), ![foo](http://example.com "Example Domain"), ![bar](http://example.com "Example Domain").
And our script, example.js
, looks as follows:
var fs = require('fs')
var remark = require('remark')
var links = require('remark-reference-links')
remark()
.use(links)
.process(fs.readFileSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
Now, running node example
yields:
[foo][1], [foo][1], [bar][1].
![foo][1], ![foo][1], ![bar][1].
[1]: http://example.com "Example Domain"
API
remark().use(referenceLinks)
Plugin to transform links and images into references and definitions.
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-inline-links
— Reverse ofremark-reference-links
, thus rewriting references and definitions into normal links and imagesremark-defsplit
— Practically the same asremark-inline-links
, but with URI-based identifiers instead of numerical onesremark-unlink
— Remove all links, references and definitions
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.