{"name":"markdown-link-check","version":"3.13.0","keywords":["markdown","md","link","hyperlink","href","check","checker"],"author":{"name":"Thomas Cort","email":"linuxgeek@gmail.com"},"license":"ISC","_id":"markdown-link-check@3.13.0","maintainers":[{"name":"tcort","email":"linuxgeek@gmail.com"}],"homepage":"https://github.com/tcort/markdown-link-check#readme","bugs":{"url":"https://github.com/tcort/markdown-link-check/issues"},"bin":{"markdown-link-check":"markdown-link-check"},"dist":{"shasum":"c64e33d77131305eed96b58cb73220bad543a684","tarball":"http://registry-npm.ywwl.com/markdown-link-check/download/markdown-link-check-3.13.0.tgz","fileCount":5,"integrity":"sha512-WbQpSeezvUZYT2jPbn8vyqmILQ4aQ/9haj2fj135cbfpnT1/DBvc34626GacGR5Tx7+8bmKWstWXxtBSp6OQGQ==","signatures":[{"sig":"MEUCIQDWndst5z47U62ea/gw3phcbV2LSslSOGT5gwThuityjgIgDlvD4hLidP2mGnO0tVfZzLi3I+RjG6dEe+GKryNwhgY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30173,"size":9389,"noattachment":false,"key":"/markdown-link-check/-/markdown-link-check-3.13.0.tgz"},"main":"index.js","gitHead":"c1ca441d9b096e8b6e217249cd9c17f11f8d2068","scripts":{"test":"mocha -R spec --exit","pretest":"eslint ."},"_npmUser":{"name":"tcort","email":"linuxgeek@gmail.com"},"repository":{"url":"git://github.com/tcort/markdown-link-check.git","type":"git"},"_npmVersion":"10.7.0","description":"checks the all of the hyperlinks in a markdown text to determine if they are alive or dead","directories":{},"_nodeVersion":"18.20.4","dependencies":{"async":"^3.2.6","chalk":"^5.3.0","needle":"^3.3.1","progress":"^2.0.3","commander":"^12.1.0","link-check":"^5.4.0","proxy-agent":"^6.4.0","xmlbuilder2":"^3.1.1","markdown-link-extractor":"^4.0.2"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.8.2","eslint":"^9.14.0","express":"^4.21.1","globals":"^15.12.0","expect.js":"^0.3.1","@eslint/js":"^9.14.0"},"_npmOperationalInternal":{"tmp":"tmp/markdown-link-check_3.13.0_1730811819076_0.5353223635508526","host":"s3://npm-registry-packages"},"readme":"[![Releases](https://img.shields.io/github/v/tag/tcort/markdown-link-check.svg?sort=semver)](https://github.com/tcort/markdown-link-check/releases)\n[![Stars](https://img.shields.io/github/stars/tcort/markdown-link-check)](https://github.com/tcort/markdown-link-check/stargazers)\n[![Forks](https://img.shields.io/github/forks/tcort/markdown-link-check)](https://github.com/tcort/markdown-link-check/network/members)\n[![Test library workflow status](https://github.com/tcort/markdown-link-check/actions/workflows/ci.yml/badge.svg)](https://github.com/tcort/markdown-link-check/actions/workflows/ci.yml)\n[![License](https://img.shields.io/github/license/tcort/markdown-link-check)](https://github.com/tcort/markdown-link-check/blob/master/LICENSE.md)\n\n# markdown-link-check\n\nExtracts links from markdown texts and checks whether each link is\nalive (`200 OK`) or dead. `mailto:` links are also validated.\n\n## Installation\n\nTo add the module to your project, run:\n\n```shell\nnpm install --save-dev markdown-link-check\n```\n\nTo install the command line tool globally, run:\n\n```shell\nnpm install -g markdown-link-check\n```\n\n---\n\n## Run using Docker\n\nDocker images are built with each release. Use the `stable` tag for the current stable release.\n\nAdd current directory with your `README.md` file as read only volume to `docker run`:\n\n```shell\ndocker run -v .:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md\n```\n\nAlternatively, if you wish to target a specific release, images are tagged with semantic versions (i.e. `3`, `3.8`, `3.8.3`)\n\n## Run in a GitHub action\n\nPlease head on to [github-action-markdown-link-check](https://github.com/tcort/github-action-markdown-link-check).\n\n## Run as a pre-commit hook\n\nTo run as a [pre-commit hook](https://pre-commit.com):\n\n```\n- repo: https://github.com/tcort/markdown-link-check\n  rev: ...\n  hooks:\n    - id: markdown-link-check\n      args: [-q]\n```\n\n## Run in a GitLab pipeline\n\n```yaml\nlinkchecker:\n  stage: test\n  image:\n    name: ghcr.io/tcort/markdown-link-check:3.11.2\n    entrypoint: [\"/bin/sh\", \"-c\"]\n  script:\n    - markdown-link-check ./docs\n  rules:\n    - changes:\n      - \"**/*.md\"\n```\n\n## Run in other tools\n\n- [Mega-Linter](https://megalinter.io/latest/): Linters aggregator [including markdown-link-check](https://megalinter.io/latest/descriptors/markdown_markdown_link_check/)\n\n## API\n\n### markdownLinkCheck(markdown, [opts,] callback)\n\nGiven a string containing `markdown` formatted text and a `callback`,\nextract all of the links and check if they're alive or dead. Call the\n`callback` with `(err, results)`\n\nParameters:\n\n* `markdown` string containing markdown formatted text.\n* `opts` optional options object containing any of the following optional fields:\n  * `showProgressBar` enable an ASCII progress bar.\n  * `timeout` timeout in [ms](https://www.npmjs.com/package/ms) format. (e.g. `\"2000ms\"`, `20s`, `1m`). Default `10s`.\n  * `httpHeaders` to apply URL specific headers, see example below.\n  * `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/ }]`\n  * `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}}/\"}]`. You can add `\"global\": true` to use a global regular expression to replace all instances.\n  * `projectBaseUrl` the URL to use for `{{BASEURL}}` replacement\n  * `ignoreDisable` if this is `true` then disable comments are ignored.\n  * `retryOn429` if this is `true` then retry request when response is an HTTP code 429 after the duration indicated by `retry-after` header.\n  * `retryCount` the number of retries to be made on a 429 response. Default `2`.\n  * `fallbackRetryDelay` the delay in [ms](https://www.npmjs.com/package/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`.\n  * `aliveStatusCodes` a list of HTTP codes to consider as alive.\n    Example: `[200,206]`\n  * `reporters` an array of reporter functions to use for outputting results. If not specified, default output will be generated (useful when using the API programmatically). Available built-in reporters can be imported from the command-line tool.\n* `callback` function which accepts `(err, results)`.\n  * `err` an Error object when the operation cannot be completed, otherwise `null`.\n  * `results` an array of objects with the following properties:\n    * `link` the `link` provided as input\n    * `status` a string set to either `alive`, `ignored` or `dead`.\n    * `statusCode` the HTTP status code. Set to `0` if no HTTP status code was returned (e.g. when the server is down).\n    * `err` any connection error that occurred, otherwise `null`.\n\n#### Disable comments\n\nYou can write html comments to disable markdown-link-check for parts of the text.\n\n`<!-- markdown-link-check-disable -->` disables markdown link check.\n`<!-- markdown-link-check-enable -->` reenables markdown link check.\n`<!-- markdown-link-check-disable-next-line -->` disables markdown link check for the next line.\n`<!-- markdown-link-check-disable-line -->` disables markdown link check for this line.\n\n## Examples\n\n### Module\n\n**Basic usage:**\n\n```js\n'use strict';\n\nvar markdownLinkCheck = require('markdown-link-check');\n\nmarkdownLinkCheck('[example](http://example.com)', function (err, results) {\n    if (err) {\n        console.error('Error', err);\n        return;\n    }\n    results.forEach(function (result) {\n        console.log('%s is %s', result.link, result.status);\n    });\n});\n```\n\n**With options, for example using URL specific headers:**\n\n```js\n'use strict';\n\nvar markdownLinkCheck = require('markdown-link-check');\n\nmarkdownLinkCheck('[example](http://example.com)', { httpHeaders: [{ urls: ['http://example.com'], headers: { 'Authorization': 'Basic Zm9vOmJhcg==' }}] }, function (err, results) {\n    if (err) {\n        console.error('Error', err);\n        return;\n    }\n    results.forEach(function (result) {\n        console.log('%s is %s', result.link, result.status);\n    });\n});\n```\n\n### Command Line Tool\n\nThe command line tool optionally takes 1 argument, the file name or http/https URL.\nIf not supplied, the tool reads from standard input.\n\n#### Check links from a markdown file hosted on the web\n\n```shell\nmarkdown-link-check https://github.com/tcort/markdown-link-check/blob/master/README.md\n```\n\n#### Check links from a local markdown file\n\n```shell\nmarkdown-link-check ./README.md\n```\n\n#### Check links from a local markdown folder (recursive)\n\nThis checks all files in folder `./docs` with file extension `*.md`:\n\n```shell\nmarkdown-link-check ./docs\n```\n\nThe files can also be searched for and filtered manually:\n\n```shell\nfind . -name \\*.md -print0 | xargs -0 -n1 markdown-link-check\n```\n\n#### Usage\n\n```shell\nUsage: markdown-link-check [options] [filenamesOrDirectorynamesOrUrls...]\n\nOptions:\n  -V, --version           output the version number\n  -p, --progress          show progress bar\n  -c, --config [config]   apply a config file (JSON), holding e.g. url specific header configuration\n  -q, --quiet             displays errors only\n  -v, --verbose           displays detailed error information\n  -i, --ignore <paths>    ignore input paths including an ignore path\n  -a, --alive <code>      comma separated list of HTTP codes to be considered as alive\n  -r, --retry             retry after the duration indicated in 'retry-after' header when HTTP code is 429\n  --reporters <names>     specify reporters to use\n  --projectBaseUrl <url>  the URL to use for {{BASEURL}} replacement\n  --junit-output <file>   output file for JUnit XML report (only used with junit reporter)\n  -h, --help              display help for command\n```\n\n##### Reporters\n\n`markdown-link-check` supports multiple output reporters to format the results of link checking:\n\n###### Default Reporter\n\nThe default reporter outputs results to the console with colored status indicators:\n\n```shell\nmarkdown-link-check README.md\n```\n\nOutput format:\n\n```text\n  ✓ https://example.com/valid-link\n  ✖ https://example.com/broken-link\n  / https://example.com/ignored-link\n\n  3 links checked.\n\n  ERROR: 1 dead links found!\n```\n\n###### JUnit Reporter\n\nThe JUnit reporter generates XML output compatible with JUnit test result format, useful for CI/CD integration:\n\n```shell\nmarkdown-link-check --reporters junit README.md\n```\n\nTo specify a custom output file:\n\n```shell\nmarkdown-link-check --reporters junit --junit-output results.xml README.md\n```\n\nIf no output file is specified, the results are written to `junit-results.xml` by default.\n\n###### Multiple Reporters\n\nYou can use multiple reporters simultaneously by specifying them in a comma-separated list:\n\n```shell\nmarkdown-link-check --reporters default,junit README.md\n```\n\nThis will output to both the console (default reporter) and generate a JUnit XML file.\n\n##### Config file format\n\n`config.json`:\n\n* `ignorePatterns`: An array of objects holding regular expressions which a link is checked against and skipped for checking in case of a match.\n* `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). This parameter supports named regex groups the same way as `string.replace` [method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement) in node.\n* `httpHeaders`: The headers are only applied to links where the link **starts with** one of the supplied URLs in the `urls` section.\n* `timeout` timeout in [ms](https://www.npmjs.com/package/ms) format. (e.g. `\"2000ms\"`, `20s`, `1m`). Default `10s`.\n* `retryOn429` if this is `true` then retry request when response is an HTTP code 429 after the duration indicated by `retry-after` header.\n* `retryCount` the number of retries to be made on a 429 response. Default `2`.\n* `fallbackRetryDelay` the delay in [ms](https://www.npmjs.com/package/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`.\n* `aliveStatusCodes` a list of HTTP codes to consider as alive.\n* `projectBaseUrl` the URL to use for `{{BASEURL}}` replacement\n\n**Example:**\n\n```json\n{\n  \"projectBaseUrl\":\"${workspaceFolder}\",\n  \"ignorePatterns\": [\n    {\n      \"pattern\": \"^http://example.net\"\n    }\n  ],\n  \"replacementPatterns\": [\n    {\n      \"pattern\": \"^.attachments\",\n      \"replacement\": \"file://some/conventional/folder/.attachments\"\n    },\n    {\n      \"pattern\": \"^/\",\n      \"replacement\": \"{{BASEURL}}/\"\n    },\n    {\n      \"pattern\": \"%20\",\n      \"replacement\": \"-\",\n      \"global\": true\n    },\n    {\n      \"pattern\": \"images/(?<filename>.*)\",\n      \"replacement\": \"assets/$<filename>\"\n    }\n  ],\n  \"httpHeaders\": [\n    {\n      \"urls\": [\"https://example.com\"],\n      \"headers\": {\n        \"Authorization\": \"Basic Zm9vOmJhcg==\",\n        \"Foo\": \"Bar\"\n      }\n    }\n  ],\n  \"timeout\": \"20s\",\n  \"retryOn429\": true,\n  \"retryCount\": 5,\n  \"fallbackRetryDelay\": \"30s\",\n  \"aliveStatusCodes\": [200, 206]\n}\n```\n\n## Testing\n\n```shell\nnpm test\n```\n\n## License\n\nSee [LICENSE.md](https://github.com/tcort/markdown-link-check/blob/master/LICENSE.md)\n","publish_time":1730811819291,"_cnpm_publish_time":1730811819291,"dist-tags":{"latest":"3.15.0"}}