Tool that reads and analizes Markdown files, to verify its links and report some statistics.
Content
npm install markdown-links-analyzer
-
path
: Absolute or relative path of the file or folder. -
options
: An object with the following property:-
validate
: A boolean which indicates whether or not to validate the links found.
-
const mdLinks = require("markdown-links-analyzer");
mdLinks("./some/example.md")
.then(links => {
// => [{ href, text, file }]
})
.catch((e) => console.log(e.message));
mdLinks("./some/example.md", { validate: true })
.then(links => {
// => [{ href, text, file, status, ok }]
})
.catch((e) => console.log(e.message));
It is executed as follows through the terminal:
By deafult it doesn't validates the links found, it just identifies them and prints them along with the path where they were found.
--validate
With the --validate
option, an HTTP request is made for each link found to verify if it works or not.
The output includes the status: ok
or fail
of each url and their status code.
--stats
With the --stats
option you can get the general statistics about the links found.
You can also combine --stats
and --validate
to get the statistics from the links validation.
--help
md-links --help
With this option, you can get a list of all the available commands and a guide on how to use them.
npm install
npm link
md-links ./some-file
.
├── README.md
├── package.json
├── package-lock.json
├── .gitignore
├── src
| ├── mdLinks.js
| ├── cli.js
| └── mdFile.js
| └── validate.js
└── test
└── test.js