# mdast-validate-links

> Validate links to headings and files in markdown

Latest version **1.1.1** (published 2015-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install mdast-validate-links
pnpm add mdast-validate-links
yarn add mdast-validate-links
bun add mdast-validate-links
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2015-09-18 |
| First published | 2015-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 126 |
| Author | Titus Wormer |
| Maintainers | wooorm |
| Keywords | validate, link, reference, file, heading, mdast |

## Links

- npm: https://www.npmjs.com/package/mdast-validate-links
- Repository: https://github.com/wooorm/mdast-validate-links
- Homepage: https://github.com/wooorm/mdast-validate-links#readme
- Issues: https://github.com/wooorm/mdast-validate-links/issues
- npm.io page: https://npm.io/package/mdast-validate-links

## Dependencies (6)

- [propose](https://npm.io/package/propose.md) 0.0.5
- [urljoin](https://npm.io/package/urljoin.md) ^0.1.5
- [mdast-slug](https://npm.io/package/mdast-slug.md) ^2.0.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^1.0.0
- [github-url-to-object](https://npm.io/package/github-url-to-object.md) ^1.5.2
- [mdast-util-definitions](https://npm.io/package/mdast-util-definitions.md) ^1.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2015-09-18
- 1.1.0 — 2015-09-07
- 1.0.0 — 2015-08-20
- 0.3.1 — 2015-07-27
- 0.3.0 — 2015-07-26
- 0.2.1 — 2015-07-19
- 0.2.0 — 2015-07-19
- 0.1.0 — 2015-07-18

## README

# mdast-validate-links [![Build Status](https://img.shields.io/travis/wooorm/mdast-validate-links.svg)](https://travis-ci.org/wooorm/mdast-validate-links) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/mdast-validate-links.svg)](https://codecov.io/github/wooorm/mdast-validate-links)

[**mdast**](https://github.com/wooorm/mdast) 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](#installation)
*   [Command line](#command-line)
*   [Programmatic](#programmatic)
*   [Configuration](#configuration)
*   [Related](#related)
*   [License](#license)

## Installation

[npm](https://docs.npmjs.com/cli/install):

```bash
npm install mdast-validate-links
```

## Command line

![Example of how mdast-validate-links looks on screen](https://cdn.rawgit.com/wooorm/mdast-validate-links/master/screenshot.png)

Use **mdast-validate-links** together with [**mdast**](https://github.com/wooorm/mdast)
and [**mdast-slug**](https://github.com/wooorm/mdast-slug):

```bash
npm install --global mdast mdast-slug mdast-validate-links
```

Let’s say `readme.md` is this document, and `example.md` looks as follows:

```md
# 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).
```

Then, to run **mdast-validate-links** on `example.md` and `readme.md`:

```bash
mdast -u mdast-slug -u mdast-validate-links example.md
#
# Yields:
#
# example.md
#   3:11  warning  Link to unknown heading: `world`
#   5:27  warning  Link to unknown heading in `readme.md`: `foo`
#
# ✖ 2 problems (0 errors, 2 warnings)
```

## Programmatic

This plug-in is **not** available on the API of mdast.

## Configuration

You can pass a `repository`, containing anything `package.json`s
[`repository`](https://docs.npmjs.com/files/package.json#repository) can
handle. If this is omitted, **mdast-validate-links** will try
the `package.json` in your current working directory.

```bash
mdast --use 'validate-links=repository:"foo/bar"' example.md
```

When a repository is given or detected, links to GitHub are normalized
to the file-system. E.g., `https://github.com/foo/bar/blob/master/example.md`
becomes `example.md`.

You can define this repository in `.mdastrc` or `package.json` [files](https://github.com/wooorm/mdast/blob/master/doc/mdastrc.5.md)
too. An example `.mdastrc` file could look as follows:

```json
{
  "plugins": {
    "slug": {
      "library": "github"
    },
    "validate-links": {
      "repository": "foo/bar"
    }
  }
}
```

## Related

*   [`mdast-lint`](https://github.com/wooorm/mdast-lint)
    — Markdown code style linter.

## License

[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)

---
_Source: https://npm.io/package/mdast-validate-links · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
