Code Monkey home page Code Monkey logo

markdown-link-check's Introduction

markdown-link-check

Extracts links from markdown texts and checks whether each link is alive (200 OK) or dead. mailto: links are validated with isemail.

Installation

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

API

markdownLinkCheck(markdown, [opts,] callback)

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:

  • markdown string containing markdown formatted text.
  • opts optional options object containing any of the following optional fields:
  • baseUrl the base URL for relative links.
  • showProgressBar enable an ASCII progress bar.
  • callback function which accepts (err, results).
  • err an Error object when the operation cannot be completed, otherwise null.
  • results an array of objects with the following properties:
  • link the link provided as input
  • status a string set to either alive or dead.
  • statusCode the HTTP status code. Set to 0 if no HTTP status code was returned (e.g. when the server is down).
  • err any connection error that occurred, otherwise null.

Examples

Module

'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);
    });
});

Command Line Tool

The command line tool optionally takes 1 argument, the file name or http/https URL. If not supplied, the tool reads from standard input.

Check links from a local markdown file

markdown-link-check ./README.md

Check links from a markdown file hosted on the web

markdown-link-check https://github.com/tcort/markdown-link-check/blob/master/README.md

Check links from standard input

cat *.md | markdown-link-check

Usage


  Usage: markdown-link-check [options] [filenameOrUrl]

  Options:

    -h, --help      output usage information
    -p, --progress  show progress bar

Testing

npm test

License

See LICENSE.md

markdown-link-check's People

Contributors

ellerbrock avatar mikz avatar tcort avatar

Watchers

 avatar

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.