Skip to content

Module that provides a JS API that parses, lists and validates the md links contained in a directory or file, it also provides a Command Line that, in addition to the above, displays its statistics.

Notifications You must be signed in to change notification settings

MarycieloParionaBernaola/Markdown-Links-Validator

 
 

Repository files navigation

Markdown Links Validator

Table of Contents


1. About The Project

Markdown-Links-Validator provides a Javascript API that parses, lists and validates the Markdown links contained in a directory or file, it also provides a Command Line that, in addition to the above, displays its statistics.

2. Flowchart

API

CLI

3. Implementation Board

MD-Links Implementation Board

4. Installation

MarycieloParionaBernaola/@md-links-validator

5. Usage

  • JavaScript API:

mdLinks(path, options)

Arguments:

  • path: relative or absolute path string to points to a directory or file.
  • options: an object { validate: true} to validate links.

Return value:

It returns an array of objects, where each object contains properties of a link.

  • href: URL found.
  • text: text that appeared within the link <a>.
  • path: path of the file where the link was found.

Example:

const mdLinks = require("md-links-validator");

mdLinks("./some/example.md")
  .then(links => {
    // => [{ href, text, file }]
  })
  .catch(console.error);

mdLinks("./some/example.md", { validate: true })
  .then(links => {
    // => [{ href, text, file, status, message }]
  })
  .catch(console.error);

mdLinks("./some/dir")
  .then(links => {
    // => [{ href, text, file }]
  })
  .catch(console.error);
  • Command Line:

The command line is run in two ways through the terminal:

To get started, run the following command line:

md-links

start-md-links

With guide:

If you select this option, the first step will be to enter a valid path (it must exist and be a string) that points to your file or directory containing markdown files, otherwise these errors will appear.

enter-path-erros-md-links

If you entered a valid path, the following options will appear:

options-md-links

Select one of those and then the result will be displayed:

options-md-links

You can select another option after that and repeat the process.

Direct way (on your own):

If you want to do it on this way, you can start all the process with the next command line and structure.

md-links <path-to-file> [options]

Options

The options are:

--validate: check status links.

If you pass --validate or --v option, the module will make an HTTP request to find out if the link works or not. If the link results in a redirect to a URL that responds "OK", then the link is considered "OK", otherwise the respective status will appear in red and if the request was rejected it will appear "FAIL".

validate-d-md-links

--stats: display statistics of total and unique links.

If you pass the option --stats or --s the output will be a text with basic statistics about the links.

stats-d-md-links

--validate --stats: display statistics of total, unique and broken links

You can also combine --stats and --validate to get needed statistics from the validation results.

validate-stats-d-md-links

About

Module that provides a JS API that parses, lists and validates the md links contained in a directory or file, it also provides a Command Line that, in addition to the above, displays its statistics.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%