Link manager for Markdown files with remark.
Installation
npm:
npm install remark-bookmarks
Usage
This module allows you to manage a collection of links across Markdown files; it’s useful for use cases where you need to reference the same source several times across multiple sections of your documentation. Given the following markdown:
remark-bookmarks is on [npm]!
And we require dependencies:
const remark = require('remark')
const remarkBookmarks = require('remark-bookmarks')
We can call remark-bookmarks to provide the missing reference:
const output = remark()
.use(remarkBookmarks, {
bookmarks: {
github: 'https://github.com/remarkjs/remark-bookmarks',
npm: 'https://npmjs.com/package/remark-bookmarks'
}
})
.processSync('remark-bookmarks is on [npm]!')
.toString()
The output of this transform is below.
Note that only the npm link is inserted into this document, to avoid unnecessary references.
remark-bookmarks is on [npm]!
[npm]: https://npmjs.com/package/remark-bookmarks
API
Manage links.
By default, this module will append all of the references to the bottom of the
Markdown file, which might be problematic if you are using modules that change
whole sections of Markdown.
One such example is remark-license
.
To resolve this, we recommend that you use remark-inline-links
, which
will transform the references into inline links.
options.bookmarks
The URLs to share across Markdown documents (Object.<string>
).
References are case insensitive.
options.overwrite
Pass overwrite: true
to ensure that references are used consistently.
By default (false
), the existing references in the file will take precedence
over anything defined globally.
Related
Contribute
See contributing.md
in remarkjs/remark
for ways to get
started.
This organisation has a Code of Conduct. By interacting with this
repository, organisation, or community you agree to abide by its terms.
License
MIT © Ben Briggs