Extracts links from markdown texts and checks whether each link is
alive (200 OK) or dead.
To add the module to your project, run:
npm install --save markdown-link-check
To install the command line tool globally, run:
npm install -g markdown-link-check
Given a string containing markdown formatted text and a callback,
extract all of the links and check if they're alive or dead. Call the
callback with (err, results)
Parameters:
markdownstring containing markdown formatted text.callbackfunction which accepts(err, results).erran Error object when the operation cannot be completed, otherwisenull.resultsan array of objects with the following properties:linkthelinkprovided as inputstatusa string set to eitheraliveordead.statusCodethe HTTP status code. Set to0if no HTTP status code was returned (e.g. when the server is down).errany connection error that occurred, otherwisenull.
'use strict';
var markdownLinkCheck = require('markdown-link-check');
markdownLinkCheck('[example](http://example.com)', function (err, results) {
if (err) {
console.error('Error', err);
return;
}
results.forEach(function (result) {
console.log('%s is %s', result.link, result.status);
});
});
The command line tool optionally takes 1 argument, the file name or http/https URL. If not supplied, the tool reads from standard input.
markdown-link-check ./README.md
markdown-link-check https://github.com/tcort/markdown-link-check/blob/master/README.md
cat *.md | markdown-link-check
npm test
See LICENSE.md