Package Exports
- remark-validate-links
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (remark-validate-links) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
remark-validate-links

remark plug-in to validate if links to headings and files in markdown point to existing things.
For example, this document does not have a heading named Hello
.
So if I link to that ([welcome](#hello)
), this plug-in will warn
about it.
In addition, when I link to a heading in another document
(examples/foo.md#hello
), if this file exists but the heading does not,
or if the file does not exist, this plug-in will also warn.
Linking to other files, such as LICENSE
or index.js
(when they exist)
is fine.
Table of Contents
Installation
npm:
npm install remark-validate-links
Command line
Use remark-validate-links
together with remark:
npm install --global remark-cli remark-validate-links
Let’s say readme.md
is this document, and example.md
looks as follows:
# Hello
Read more [whoops, this does not exist](#world).
This doesn’t exist either [whoops!](readme.md#foo).
But this does exist: [LICENSE](LICENSE).
So does this: [README](readme.md#installation).
Now, running remark -u validate-links .
yields:
example.md
3:11-3:48 warning Link to unknown heading: `world` remark-validate-links remark-validate-links
5:27-5:51 warning Link to unknown heading in `readme.md`: `foo` remark-validate-links remark-validate-links
readme.md: no issues found
⚠ 2 warnings
Programmatic
This plug-in is not available on the API of remark.
Configuration
You can pass a repository
, containing anything package.json
s
repository
can handle. If this is omitted,
remark-validate-links
will try the package.json
in your current working
directory.
remark --use 'validate-links=repository:"foo/bar"' example.md
When a repository is given or detected, links to GitHub are normalized
to the file-system. For example,
https://github.com/foo/bar/blob/master/example.md
becomes example.md
.
You can define this repository in configuration files too.
An example .remarkrc
file could look as follows:
{
"plugins": {
"validate-links": {
"repository": "foo/bar"
}
}
}
Integration
remark-validate-links can detect anchors on nodes through several properties on nodes:
node.data.hProperties.name
— Used byremark-html
to create aname
attribute, which anchors can link tonode.data.hProperties.id
— Used byremark-html
to create anid
attribute, which anchors can link tonode.data.id
— Used, in the future, by other tools to signal unique identifiers on nodes
Related
remark-lint
— Markdown code style linter