Custom rule for markdownlint to validate relative links.
## 📜 About **markdownlint-rule-relative-links** is a [markdownlint](https://github.com/DavidAnson/markdownlint) custom rule to validate relative links. It ensures that relative links (using `file:` protocol) are working and not "dead" which means that it exists in the file system of the project that uses `markdownlint`. ### Example File structure: ```txt ├── abc.txt └── awesome.md ``` With `awesome.md` content: ```md [abc](./abc.txt) [Dead link](./dead.txt) ``` Running `markdownlint-cli2` with `markdownlint-rule-relative-links` will output: ```sh awesome.md:3 relative-links Relative links should be valid [Link "./dead.txt" is dead] ``` ### Related links - [DavidAnson/markdownlint#253](https://github.com/DavidAnson/markdownlint/issues/253) - [DavidAnson/markdownlint#121](https://github.com/DavidAnson/markdownlint/issues/121) - [nschonni/markdownlint-valid-links](https://github.com/nschonni/markdownlint-valid-links) ## Prerequisites - [Node.js](https://nodejs.org/) >= 16.0.0 ## Installation ```sh npm install --save-dev markdownlint-rule-relative-links ``` ## Configuration There are various ways `markdownlint` can be configured using objects, config files etc. For more information on `markdownlint` configuration refer [options.config](https://github.com/DavidAnson/markdownlint#optionsconfig). We recommend configuring `markdownlint-cli2` over `markdownlint-cli` for compatibility with the `vscode-markdownlint` plugin. `.markdownlint-cli2.jsonc` ```json { "config": { "default": true, "relative-links": true }, "globs": ["**/*.{md,mdx}"], "ignores": ["**/node_modules"], "customRules": ["markdownlint-rule-relative-links"] } ``` `package.json` ```json { "scripts": { "lint:markdown": "markdownlint-cli2" } } ``` ## Usage ```sh npm run lint:markdown ``` ## 💡 Contributing Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake. The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file. ## 📄 License [MIT](./LICENSE)