This is a textlint rule that validates image links in markdown documents. It does the following
- It ignores external link. The
RegExp
used to filter out such links is/^[a-z][a-z0-9+.-]*:/i
- For all image links, it checks that the linked image file is present at the specified location.
- Since this is a textlint rule, first install textlint by following the textlint getting started guide.
- This rule is available as an npm package and can be installed using
npm install --save-dev textlint-rule-no-dead-image-link
oryarn add --dev textlint-rule-no-dead-image-link
and thenyarn install
If you are unfamiliar with textlint then refer to configuring textlint for textlint configuration details.
Add one of the following to .textlintrc
file
- without any options
{
"rules": {
"no-dead-image-link": true
}
}
or
- with options
{
"rules": {
"no-dead-image-link": {
"image-base-path": "../docs"
}
}
}
Via CLI
textlint --rule no-dead-image-link README.md
This option takes a string input that represents the base path for all the image url's that are relative. If the value of this option itself is relative, then it is considered to be relative to the location of textlint configuration file (i.e. .textlintrc
).
MIT © Parth Patel