Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-validate-links

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-validate-links

Validate links to headings and files in markdown

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

:warning: mdast is currently being renamed to remark :warning:

This means all plug-ins and relating projects change too, causing many changes across the ecosystem. Expect the dust to settle in roughly a day.

See this project at the previous stable commit c4a51d1.

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

Example of how remark-validate-links looks on screen

Use remark-validate-links together with remark and remark-slug:

npm install --global remark remark-slug 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).

Then, to run remark-validate-links on example.md and readme.md:

remark -u remark-slug -u remark-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 remark.

Configuration

You can pass a repository, containing anything package.jsons 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. E.g., https://github.com/foo/bar/blob/master/example.md becomes example.md.

You can define this repository in .remarkrc or package.json files too. An example .remarkrc file could look as follows:

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

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 24 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc