All Projects → tcort → Markdown Link Check

tcort / Markdown Link Check

Licence: isc
checks that all of the hyperlinks in a markdown text to determine if they are alive or dead

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Markdown Link Check

Cgx
💻🔥CLI to generate the recommended documentation/files to improve contribution (Github, Gitlab, CodeCommit and Bitbucket)
Stars: ✭ 190 (-4.04%)
Mutual labels:  markdown
Awesome
A curated list of awesome MDX resources
Stars: ✭ 195 (-1.52%)
Mutual labels:  markdown
Database
EhTagTranslation 项目的翻译数据。
Stars: ✭ 197 (-0.51%)
Mutual labels:  markdown
Cattaz
Realtime collaborative tool which can run custom applications in a Wiki page
Stars: ✭ 191 (-3.54%)
Mutual labels:  markdown
Npmvet
A simple CLI tool for vetting npm package versions
Stars: ✭ 193 (-2.53%)
Mutual labels:  checker
Nspell
📝 Hunspell compatible spell-checker
Stars: ✭ 195 (-1.52%)
Mutual labels:  checker
Alfred Mweb Workflow
搜索、打开MWeb 内部文档和外部 Markdown 文档
Stars: ✭ 188 (-5.05%)
Mutual labels:  markdown
Swagger2markup
A Swagger to AsciiDoc or Markdown converter to simplify the generation of an up-to-date RESTful API documentation by combining documentation that’s been hand-written with auto-generated API documentation.
Stars: ✭ 2,330 (+1076.77%)
Mutual labels:  markdown
Markdown
Learn how to use Markdown
Stars: ✭ 193 (-2.53%)
Mutual labels:  markdown
Hercule
♻️ Simple document transclusion, ideal for Markdown documents
Stars: ✭ 196 (-1.01%)
Mutual labels:  markdown
Pandoc Markdown Book Template
A template for creating epub books from markdown using pandoc.
Stars: ✭ 191 (-3.54%)
Mutual labels:  markdown
Docdown
A simple JSDoc to Markdown generator.
Stars: ✭ 191 (-3.54%)
Mutual labels:  markdown
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+1094.44%)
Mutual labels:  markdown
Hacktoberfest
Make your first PR! ~ A beginner-friendly repository made specifically for open source beginners. Add your profile, a blog or any program under any language (it can be anything from a hello-world program to a complex data structure algorithm) or update the existing one. Just make sure to add the file under the correct directory. Happy hacking!
Stars: ✭ 191 (-3.54%)
Mutual labels:  markdown
Evernote2md
Convert Evernote .enex files to Markdown
Stars: ✭ 193 (-2.53%)
Mutual labels:  markdown
Abricotine
Markdown editor with inline preview
Stars: ✭ 2,308 (+1065.66%)
Mutual labels:  markdown
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (-4.55%)
Mutual labels:  markdown
Bullets.vim
🔫 Bullets.vim is a Vim/NeoVim plugin for automated bullet lists.
Stars: ✭ 199 (+0.51%)
Mutual labels:  markdown
Tslide
Terminal SlideDeck, supporting markdown.
Stars: ✭ 198 (+0%)
Mutual labels:  markdown
Qimage Win
Windows 版本 Markdown 一键贴图工具,支持本地文件、截图、网络图片一键上传七牛云并返回图片引用,让 Markdown 中贴图变成一种享受。
Stars: ✭ 196 (-1.01%)
Mutual labels:  markdown

Test library workflow status

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-dev markdown-link-check

To install the command line tool globally, run:

npm install -g markdown-link-check

Run using Docker

Docker images are built with each release. Use the stable tag for the current stable release.

Add current directory with your README.md file as read only volume to docker run:

docker run -v ${PWD}:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md

Alternatively, if you wish to target a specific release, images are tagged with semantic versions (i.e. 3, 3.8, 3.8.3)

Run in a GitHub action

Please head on to github-action-markdown-link-check.

Run in other tools

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.
    • timeout timeout in zeit/ms format. (e.g. "2000ms", 20s, 1m). Default 10s.
    • httpHeaders to apply URL specific headers, see example below.
    • ignorePatterns an array of objects holding regular expressions which a link is checked against and skipped for checking in case of a match. Example: [{ pattern: /foo/ }]
    • replacementPatterns an array of objects holding regular expressions which are replaced in a link with their corresponding replacement string. This behavior allows (for example) to adapt to certain platform conventions hosting the Markdown. The special replacement {{BASEURL}} can be used to dynamically link to the base folder (used from projectBaseUrl) (for example that / points to the root of your local repository). Example: [{ pattern: /^.attachments/, replacement: "file://some/conventional/folder/.attachments" }, { pattern: ^/, replacement: "{{BASEURL}}/"}]
    • projectBaseUrl the URL to use for {{BASEURL}} replacement
    • ignoreDisable if this is true then disable comments are ignored.
    • retryOn429 if this is true then retry request when response is an HTTP code 429 after the duration indicated by retry-after header.
    • retryCount the number of retries to be made on a 429 response. Default 2.
    • fallbackRetryDelay the delay in zeit/ms format. (e.g. "2000ms", 20s, 1m) for retries on a 429 response when no retry-after header is returned or when it has an invalid value. Default is 60s.
    • aliveStatusCodes a list of HTTP codes to consider as alive. Example: [200,206]
  • 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, ignored 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.

Disable comments

You can write html comments to disable markdown-link-check for parts of the text.

<!-- markdown-link-check-disable --> disables markdown link check. <!-- markdown-link-check-enable --> reenables markdown link check. <!-- markdown-link-check-disable-next-line --> disables markdown link check for the next line. <!-- markdown-link-check-disable-line --> disables markdown link check for this line.

Examples

Module

Basic usage:

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

With options, for example using URL specific headers:

'use strict';

var markdownLinkCheck = require('markdown-link-check');

markdownLinkCheck('[example](http://example.com)', { httpHeaders: [{ urls: ['http://example.com'], headers: { 'Authorization': 'Basic Zm9vOmJhcg==' }}] }, 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 markdown file hosted on the web

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

Check links from a local markdown file

markdown-link-check ./README.md

Check links from a local markdown folder (recursive)

find . -name \*.md -exec markdown-link-check {} \;

Usage

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

Options:
  -p, --progress         show progress bar
  -c, --config [config]  apply a config file (JSON), holding e.g. url specific header configuration
  -q, --quiet            displays errors only
  -v, --verbose          displays detailed error information
  -a, --alive <code>     comma separated list of HTTP code to be considered as alive
  -r, --retry            retry after the duration indicated in 'retry-after' header when HTTP code is 429
  -h, --help             display help for command
Config file format

config.json:

  • ignorePatterns: An array of objects holding regular expressions which a link is checked against and skipped for checking in case of a match.
  • replacementPatterns: An array of objects holding regular expressions which are replaced in a link with their corresponding replacement string. This behavior allows (for example) to adapt to certain platform conventions hosting the Markdown. The special replacement {{BASEURL}} can be used to dynamically link to the current working directory (for example that / points to the root of your current working directory).
  • httpHeaders: The headers are only applied to links where the link starts with one of the supplied URLs in the urls section.
  • timeout timeout in zeit/ms format. (e.g. "2000ms", 20s, 1m). Default 10s.
  • retryOn429 if this is true then retry request when response is an HTTP code 429 after the duration indicated by retry-after header.
  • retryCount the number of retries to be made on a 429 response. Default 2.
  • fallbackRetryDelay the delay in zeit/ms format. (e.g. "2000ms", 20s, 1m) for retries on a 429 response when no retry-after header is returned or when it has an invalid value. Default is 60s.
  • aliveStatusCodes a list of HTTP codes to consider as alive.

Example:

{
  "ignorePatterns": [
    {
      "pattern": "^http://example.net"
    }
  ],
  "replacementPatterns": [
    {
      "pattern": "^.attachments",
      "replacement": "file://some/conventional/folder/.attachments"
    },
    {
      "pattern": "^/",
      "replacement": "{{BASEURL}}/"
    }
  ],
  "httpHeaders": [
    {
      "urls": ["https://example.com"],
      "headers": {
        "Authorization": "Basic Zm9vOmJhcg==",
        "Foo": "Bar"
      }
    }
  ],
  "timeout": "20s",
  "retryOn429": true,
  "retryCount": 5,
  "fallbackRetryDelay": "30s",
  "aliveStatusCodes": [200, 206]
}

Testing

npm test

License

See LICENSE.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].