Giter Club home page Giter Club logo

markdown-link-validator's Introduction

markdown-link-validator

markdown-link-validator is a CLI tool that validates all the links in your markdown files (external or internal). There are multiple tools that validate links to external urls, but none that validate relative URLs. markdown-link-validator will verify that the file you are pointing at exists in your file system. Even more, if it links to a heading in the document it will validate it exists as well!

Usage

Install it globally npm install -g markdown-link-validator or locally as a devDependency via npm install -D markdown-link-validator.

Then execute it passing the folder to analyze as the first parameter:

markdown-link-validator ./documentation

Options

markdown-link-validator ./path/to/mds [options]

Basic configuration:
  -i, --ignorePatterns path::[String]  Regex to ignore links - default: []
  -f, --flags path::String  Flags applied to the ignore pattern
  -h, --help                Show help

Miscellaneous:
  --debug                   Output debugging information

The following will analyze all the .md files found under ./docs and ignore any links that match the regular expression /https?:\/\/test\.com\/.*/gi:

markdown-link-validator ./docs -i https?:\/\/test\.com\/.* -f gi

The regular expression is passed via the -i parameter, and its flags via -f.

markdown-link-validator's People

Contributors

dependabot[bot] avatar molant avatar sarvaje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

markdown-link-validator's Issues

Add support to check Link labels

# Title

Text with a [link][asdf].


[link]: http://example.com

This markdown should report one error, because the link label doesn't exists, but it doesn't, it just check if http://example.com exists

[Proposal] Updates, fixes and new features

I think this project has unique features (ie. built-in globbing and direct md analysis without compilation to html) among competitors (ie. markdown-link-check) and is good enough to deserve a proper evolution path in next future.

For an internal open source project (a knowledge base written in markdown and powered by Raneto) I took the v1.0.1 (8 Jun 2021) of markdown-link-validator and made some changes to adapt it to our requirements: https://github.com/jenkin/markdown-link-validator/.

  1. update all dependencies and resolve all known vulnerabilities highlighted by npm audit
  2. add support to absolute local links (ie. [internal page](/path/to/page.md))
  3. [-q option] add a quiet mode to report only errors if present (see issue #6)
  4. [-e option] add support to optional .md extension (ie. for [internal page](./path/to/page) it searches also for [internal page](./path/to/page.md) or [internal page](./path/to/page/index.md)
  5. [-o option] add support to other extension checking (ie. [local asset](./path/to/image.png) (see issue #27)
  6. ignore links in code blocks and inline code
  7. add support to standalone links checking (ie. without [anchor](https...) or [anchor] https...)
  8. [-c option] ignoring failing external urls based on response status codes (added to final report)
  9. [--ignorePatternsFrom option] ignoring files by patterns taken from a file
  10. [--noEmptyFiles option] raising error if linked files are empty

No breaking changes to the API are introduced. All existing options have the same behavior and defaults and new optional features depends on options disabled by default. Only 2), 6) and 7) are opinionated and could require some discussions. All new features have tests (but I know we can improved them further).

All changes live on feature/sparkfabrik-enhancements branch. I think all of them can met a broader interest beyond our company playbook, so I propose you to review my work and consider to accept a PR and update the npm package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.