# mdlinks-palvarado

> Module that checks and validates URL links in one or several markdown (*.md) files

Latest version **0.1.2** (published 2023-02-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install mdlinks-palvarado
pnpm add mdlinks-palvarado
yarn add mdlinks-palvarado
bun add mdlinks-palvarado
```

Provides the command `md-links`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-02-02 |
| First published | 2023-02-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.x |
| Dependencies | 201 |
| Unpacked size | 376 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Priscila Alvarado |
| Maintainers | prisalvarado |
| Keywords | javascript, markdown, jest |

## Links

- npm: https://www.npmjs.com/package/mdlinks-palvarado
- Repository: https://github.com/prisalvarado18/DEV002-md-links
- Homepage: https://github.com/prisalvarado18/DEV002-md-links#readme
- Issues: https://github.com/prisalvarado18/DEV002-md-links/issues
- npm.io page: https://npm.io/package/mdlinks-palvarado

## Dependencies (201)

- [co](https://npm.io/package/co.md) ^4.6.0
- [ms](https://npm.io/package/ms.md) ^2.1.2
- [has](https://npm.io/package/has.md) ^1.0.3
- [bser](https://npm.io/package/bser.md) ^2.1.1
- [exit](https://npm.io/package/exit.md) ^0.1.2
- [glob](https://npm.io/package/glob.md) ^7.2.3
- [once](https://npm.io/package/once.md) ^1.4.0
- [tmpl](https://npm.io/package/tmpl.md) ^1.0.5
- [y18n](https://npm.io/package/y18n.md) ^5.0.8
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [cliui](https://npm.io/package/cliui.md) ^8.0.1
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [execa](https://npm.io/package/execa.md) ^5.1.1
- [isexe](https://npm.io/package/isexe.md) ^2.0.0
- [jsesc](https://npm.io/package/jsesc.md) ^2.5.2
- [json5](https://npm.io/package/json5.md) ^2.2.3
- [kleur](https://npm.io/package/kleur.md) ^3.0.3
- [leven](https://npm.io/package/leven.md) ^3.1.0
- [p-try](https://npm.io/package/p-try.md) ^2.2.0
- [slash](https://npm.io/package/slash.md) ^3.0.0
- [which](https://npm.io/package/which.md) ^2.0.2
- [yargs](https://npm.io/package/yargs.md) ^17.6.2
- [braces](https://npm.io/package/braces.md) ^3.0.2
- [dedent](https://npm.io/package/dedent.md) ^0.7.0
- [expect](https://npm.io/package/expect.md) ^29.4.1
- [semver](https://npm.io/package/semver.md) ^6.3.0
- [walker](https://npm.io/package/walker.md) ^1.0.8
- [wrappy](https://npm.io/package/wrappy.md) ^1.0.2
- [ci-info](https://npm.io/package/ci-info.md) ^3.7.1
- [esprima](https://npm.io/package/esprima.md) ^4.0.1
- [esutils](https://npm.io/package/esutils.md) ^2.0.3
- [find-up](https://npm.io/package/find-up.md) ^4.1.0
- [gensync](https://npm.io/package/gensync.md) ^1.0.0-beta.2
- [globals](https://npm.io/package/globals.md) ^11.12.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.14.1
- [onetime](https://npm.io/package/onetime.md) ^5.1.2
- [p-limit](https://npm.io/package/p-limit.md) ^3.1.0
- [pirates](https://npm.io/package/pirates.md) ^4.0.5
- [pkg-dir](https://npm.io/package/pkg-dir.md) ^4.2.0
- [prompts](https://npm.io/package/prompts.md) ^2.4.2
- [resolve](https://npm.io/package/resolve.md) ^1.22.1
- [yallist](https://npm.io/package/yallist.md) ^3.1.1
- [anymatch](https://npm.io/package/anymatch.md) ^3.1.3
- [argparse](https://npm.io/package/argparse.md) ^1.0.10
- [emittery](https://npm.io/package/emittery.md) ^0.13.1
- [error-ex](https://npm.io/package/error-ex.md) ^1.3.2
- [escalade](https://npm.io/package/escalade.md) ^3.1.1
- [has-flag](https://npm.io/package/has-flag.md) ^3.0.0
- [inflight](https://npm.io/package/inflight.md) ^1.0.6
- [inherits](https://npm.io/package/inherits.md) ^2.0.4
- [jest-cli](https://npm.io/package/jest-cli.md) ^29.4.1
- [make-dir](https://npm.io/package/make-dir.md) ^3.1.0
- [mimic-fn](https://npm.io/package/mimic-fn.md) ^2.1.0
- [p-locate](https://npm.io/package/p-locate.md) ^4.1.0
- [path-key](https://npm.io/package/path-key.md) ^3.1.1
- [react-is](https://npm.io/package/react-is.md) ^18.2.0
- [regjsgen](https://npm.io/package/regjsgen.md) ^0.7.1
- [callsites](https://npm.io/package/callsites.md) ^3.1.0
- [camelcase](https://npm.io/package/camelcase.md) ^5.3.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [is-number](https://npm.io/package/is-number.md) ^7.0.0
- [is-stream](https://npm.io/package/is-stream.md) ^2.0.1
- [jest-diff](https://npm.io/package/jest-diff.md) ^29.4.1
- [jest-each](https://npm.io/package/jest-each.md) ^29.4.1
- [jest-mock](https://npm.io/package/jest-mock.md) ^29.4.1
- [jest-util](https://npm.io/package/jest-util.md) ^29.4.1
- [js-tokens](https://npm.io/package/js-tokens.md) ^4.0.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^5.1.1
- [makeerror](https://npm.io/package/makeerror.md) ^1.0.12
- [minimatch](https://npm.io/package/minimatch.md) ^3.1.2
- [picomatch](https://npm.io/package/picomatch.md) ^2.3.1
- [strip-bom](https://npm.io/package/strip-bom.md) ^4.0.0
- [type-fest](https://npm.io/package/type-fest.md) ^0.21.3
- [wrap-ansi](https://npm.io/package/wrap-ansi.md) ^7.0.0
- [ansi-regex](https://npm.io/package/ansi-regex.md) ^5.0.1
- [char-regex](https://npm.io/package/char-regex.md) ^1.0.2
- [color-name](https://npm.io/package/color-name.md) ^1.1.3
- [concat-map](https://npm.io/package/concat-map.md) ^0.0.1
- [fill-range](https://npm.io/package/fill-range.md) ^7.0.1
- [get-stream](https://npm.io/package/get-stream.md) ^6.0.1
- [micromatch](https://npm.io/package/micromatch.md) ^4.0.5
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.9
- [node-int64](https://npm.io/package/node-int64.md) ^0.4.0
- [parse-json](https://npm.io/package/parse-json.md) ^5.2.0
- [path-parse](https://npm.io/package/path-parse.md) ^1.0.7
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0
- [regenerate](https://npm.io/package/regenerate.md) ^1.4.2
- [sisteransi](https://npm.io/package/sisteransi.md) ^1.0.5
- [source-map](https://npm.io/package/source-map.md) ^0.6.1
- [sprintf-js](https://npm.io/package/sprintf-js.md) ^1.0.3
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.1
- [ansi-styles](https://npm.io/package/ansi-styles.md) ^3.2.1
- [buffer-from](https://npm.io/package/buffer-from.md) ^1.1.2
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [emoji-regex](https://npm.io/package/emoji-regex.md) ^8.0.0
- [fb-watchman](https://npm.io/package/fb-watchman.md) ^2.0.2
- [fs.realpath](https://npm.io/package/fs.realpath.md) ^1.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.10
- [imurmurhash](https://npm.io/package/imurmurhash.md) ^0.1.4
- [is-arrayish](https://npm.io/package/is-arrayish.md) ^0.2.1
- [jest-circus](https://npm.io/package/jest-circus.md) ^29.4.1
- [jest-config](https://npm.io/package/jest-config.md) ^29.4.1
- [jest-runner](https://npm.io/package/jest-runner.md) ^29.4.1
- [jest-worker](https://npm.io/package/jest-worker.md) ^29.4.1
- [locate-path](https://npm.io/package/locate-path.md) ^5.0.0
- [path-exists](https://npm.io/package/path-exists.md) ^4.0.0
- [regjsparser](https://npm.io/package/regjsparser.md) ^0.9.1
- [resolve-cwd](https://npm.io/package/resolve-cwd.md) ^3.0.0
- [signal-exit](https://npm.io/package/signal-exit.md) ^3.0.7
- [stack-utils](https://npm.io/package/stack-utils.md) ^2.0.6
- [type-detect](https://npm.io/package/type-detect.md) ^4.0.8
- [yocto-queue](https://npm.io/package/yocto-queue.md) ^0.1.0
- [ansi-escapes](https://npm.io/package/ansi-escapes.md) ^4.3.2
- [browserslist](https://npm.io/package/browserslist.md) ^4.21.4
- [caniuse-lite](https://npm.io/package/caniuse-lite.md) ^1.0.30001448
- [html-escaper](https://npm.io/package/html-escaper.md) ^2.0.2
- [import-local](https://npm.io/package/import-local.md) ^3.1.0
- [jest-resolve](https://npm.io/package/jest-resolve.md) ^29.4.1
- [jest-runtime](https://npm.io/package/jest-runtime.md) ^29.4.1
- [jest-watcher](https://npm.io/package/jest-watcher.md) ^29.4.1
- [merge-stream](https://npm.io/package/merge-stream.md) ^2.0.0
- [npm-run-path](https://npm.io/package/npm-run-path.md) ^4.0.1
- [regexpu-core](https://npm.io/package/regexpu-core.md) ^5.2.2
- [resolve-from](https://npm.io/package/resolve-from.md) ^5.0.0
- [string-width](https://npm.io/package/string-width.md) ^4.2.3
- [test-exclude](https://npm.io/package/test-exclude.md) ^6.0.0
- [yargs-parser](https://npm.io/package/yargs-parser.md) ^21.1.1
- [color-convert](https://npm.io/package/color-convert.md) ^1.9.3
- [function-bind](https://npm.io/package/function-bind.md) ^1.1.1
- [human-signals](https://npm.io/package/human-signals.md) ^2.1.0
- [jest-docblock](https://npm.io/package/jest-docblock.md) ^29.2.0
- [jest-get-type](https://npm.io/package/jest-get-type.md) ^29.2.0
- [jest-snapshot](https://npm.io/package/jest-snapshot.md) ^29.4.1
- [jest-validate](https://npm.io/package/jest-validate.md) ^29.4.1
- [node-releases](https://npm.io/package/node-releases.md) ^2.0.8
- [pretty-format](https://npm.io/package/pretty-format.md) ^29.4.1
- [shebang-regex](https://npm.io/package/shebang-regex.md) ^3.0.0
- [string-length](https://npm.io/package/string-length.md) ^4.0.2
- [balanced-match](https://npm.io/package/balanced-match.md) ^1.0.2
- [core-js-compat](https://npm.io/package/core-js-compat.md) ^3.27.2
- [detect-newline](https://npm.io/package/detect-newline.md) ^3.1.0
- [diff-sequences](https://npm.io/package/diff-sequences.md) ^29.3.1
- [is-core-module](https://npm.io/package/is-core-module.md) ^2.11.0
- [jest-haste-map](https://npm.io/package/jest-haste-map.md) ^29.4.1
- [normalize-path](https://npm.io/package/normalize-path.md) ^3.0.0
- [supports-color](https://npm.io/package/supports-color.md) ^5.5.0
- [to-regex-range](https://npm.io/package/to-regex-range.md) ^5.0.1
- [v8-to-istanbul](https://npm.io/package/v8-to-istanbul.md) ^9.0.1
- [brace-expansion](https://npm.io/package/brace-expansion.md) ^1.1.11
- [get-caller-file](https://npm.io/package/get-caller-file.md) ^2.0.5
- [is-generator-fn](https://npm.io/package/is-generator-fn.md) ^2.1.0
- [jest-regex-util](https://npm.io/package/jest-regex-util.md) ^29.2.0
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8
- [natural-compare](https://npm.io/package/natural-compare.md) ^1.4.0
- [resolve.exports](https://npm.io/package/resolve.exports.md) ^2.0.0
- [shebang-command](https://npm.io/package/shebang-command.md) ^2.0.0
- [cjs-module-lexer](https://npm.io/package/cjs-module-lexer.md) ^1.2.2
- [get-package-type](https://npm.io/package/get-package-type.md) ^0.1.0
- [istanbul-reports](https://npm.io/package/istanbul-reports.md) ^3.1.5
- [path-is-absolute](https://npm.io/package/path-is-absolute.md) ^1.0.1
- [babel-preset-jest](https://npm.io/package/babel-preset-jest.md) ^29.4.0
- [jest-message-util](https://npm.io/package/jest-message-util.md) ^29.4.1
- [jest-pnp-resolver](https://npm.io/package/jest-pnp-resolver.md) ^1.2.3
- [lines-and-columns](https://npm.io/package/lines-and-columns.md) ^1.2.4
- [require-directory](https://npm.io/package/require-directory.md) ^2.1.1
- [write-file-atomic](https://npm.io/package/write-file-atomic.md) ^5.0.0
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^1.9.0
- [jest-changed-files](https://npm.io/package/jest-changed-files.md) ^29.4.0
- [jest-leak-detector](https://npm.io/package/jest-leak-detector.md) ^29.4.1
- [jest-matcher-utils](https://npm.io/package/jest-matcher-utils.md) ^29.4.1
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.13
- [to-fast-properties](https://npm.io/package/to-fast-properties.md) ^2.0.0
- [collect-v8-coverage](https://npm.io/package/collect-v8-coverage.md) ^1.0.1
- [istanbul-lib-report](https://npm.io/package/istanbul-lib-report.md) ^3.0.0
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.13.11
- [strip-final-newline](https://npm.io/package/strip-final-newline.md) ^2.0.0
- [strip-json-comments](https://npm.io/package/strip-json-comments.md) ^3.1.1
- [electron-to-chromium](https://npm.io/package/electron-to-chromium.md) ^1.4.284
- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^1.0.5
- [babel-plugin-istanbul](https://npm.io/package/babel-plugin-istanbul.md) ^6.1.1
- [istanbul-lib-coverage](https://npm.io/package/istanbul-lib-coverage.md) ^3.2.0
- [jest-environment-node](https://npm.io/package/jest-environment-node.md) ^29.4.1
- [regenerator-transform](https://npm.io/package/regenerator-transform.md) ^0.15.1
- [update-browserslist-db](https://npm.io/package/update-browserslist-db.md) ^1.0.10
- [babel-plugin-jest-hoist](https://npm.io/package/babel-plugin-jest-hoist.md) ^29.4.0
- [is-fullwidth-code-point](https://npm.io/package/is-fullwidth-code-point.md) ^3.0.0
- [istanbul-lib-instrument](https://npm.io/package/istanbul-lib-instrument.md) ^5.2.1
- [istanbul-lib-source-maps](https://npm.io/package/istanbul-lib-source-maps.md) ^4.0.1
- [jest-resolve-dependencies](https://npm.io/package/jest-resolve-dependencies.md) ^29.4.1
- [fast-json-stable-stringify](https://npm.io/package/fast-json-stable-stringify.md) ^2.1.0
- [babel-plugin-polyfill-corejs2](https://npm.io/package/babel-plugin-polyfill-corejs2.md) ^0.3.3
- [babel-plugin-polyfill-corejs3](https://npm.io/package/babel-plugin-polyfill-corejs3.md) ^0.6.0
- [json-parse-even-better-errors](https://npm.io/package/json-parse-even-better-errors.md) ^2.3.1
- [regenerate-unicode-properties](https://npm.io/package/regenerate-unicode-properties.md) ^10.1.0
- [supports-preserve-symlinks-flag](https://npm.io/package/supports-preserve-symlinks-flag.md) ^1.0.0
- [babel-preset-current-node-syntax](https://npm.io/package/babel-preset-current-node-syntax.md) ^1.0.1
- [babel-plugin-polyfill-regenerator](https://npm.io/package/babel-plugin-polyfill-regenerator.md) ^0.4.1
- [unicode-match-property-ecmascript](https://npm.io/package/unicode-match-property-ecmascript.md) ^2.0.0
- [unicode-property-aliases-ecmascript](https://npm.io/package/unicode-property-aliases-ecmascript.md) ^2.1.0
- [unicode-match-property-value-ecmascript](https://npm.io/package/unicode-match-property-value-ecmascript.md) ^2.1.0
- [unicode-canonical-property-names-ecmascript](https://npm.io/package/unicode-canonical-property-names-ecmascript.md) ^2.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2023-02-02
- 0.1.1 — 2023-02-02
- 0.1.0 — 2023-02-02

## README

# Markdown Links

![cover](./src/assets/cover_001.png)

***

## Contents

* [1. Introduction](#1-introduction)
* [2. Summary](#2-summary)
* [3. Objectives](#3-objectives)
* [4. Project Plan](#4-project-plan)
* [5. Installation](#5-installation)
* [6. Functionality](#6-functionality)


***

## 1. Introduction

[Markdown](https://en.wikipedia.org/wiki/Markdown) is a lightweight markup language for creating formatted text using a plain-text editor. [John Gruber](https://en.wikipedia.org/wiki/John_Gruber) and [Aaron Swartz](https://en.wikipedia.org/wiki/Aaron_Swartz) created Markdown in 2004 as a markup language that is appealing to human readers in its source code form. Markdown is widely used in blogging, instant messaging, online forums, collaborative software, documentation pages, and readme files.

These `Markdown` files usually contain _links_ that are often broken or no longer valid. The latter greatly undermines the value of the information that is intended to be shared.

This project/challenge proposed by Laboratoria consists of creating a tool using [Node.js](https://nodejs.org/) which reads and analyzes files with `Markdown` format. The goal is to verify the links they contain and show the user some statistics.

## 2. Summary

This is a Node.js library that checks and validates URL links in one or several markdown (*.md) files. Furthermore, it can either be used through the Command Line Interface (CLI) or imported as a module.

## 3. Objectives
### General Objective
* Create a Node.js libreary that checks and validates URL links in one or several markdown files which can be used through the Command Line Interface (CLI) or imported as a module.

### Specific Objectives
* Create a flowchart to better visualize what needs to be done and plan tasks and goals in Github Projects.
* Create a recursive function that loops through all the files that a path points to.
* Send a promise as the library's return value.

## 4. Project Plan
### Flowchart
* Below you can see the workflow to follow to create the library.

![flowchart](./src/assets/markdown_extractor_palvarado_flowchart.png)


## 5. Installation

Once your project is initialized, you must execute the following command from your console:

```
npm i mdlinks-palvarado
```
o
```
npm install https://github.com/prisalvarado18/DEV002-md-links.git
```


## 6. Functionality

### 1) JavaScript API

The module can be **imported** into other Node.js scripts and provides the following interface:

#### `mdLinks(path, options)`

##### Arguments

* `path`: **Absolute** or **relative** path to the file or directory.
If the path passed is relative, it resolves as relative to the directory
where node is called from - _current working directory_).
* `options`: An object with **only** the following property:
   - `validate`: Boolean that determines if you want to validate the links found.

##### Return value

The function **returns a promise** (`Promise`) that **resolves to an array**
(`Array`) of objects (`Object`) where each object represents a link and contains the following properties:

With `validate:false` :

* `href`: Found URL.
* `text`: Text that appears within the link (`<a>`).
* `file`: Path where the link was found.

With `validate:true` :

* `href`: Found URL.
* `text`: Text that appears within the link (`<a>`).
* `file`: Path where the link was found.
* `status`: HTTP response status code.
* `ok`: `fail` message on failure or `ok` on success.

#### Example (results as comments)

```js
const mdLinks = require("md-links");

mdLinks("./some/example.md")
  .then(links => {
    // => [{ href, text, file }, ...]
  })
  .catch(console.error);

mdLinks("./some/example.md", { validate: true })
  .then(links => {
    // => [{ href, text, file, status, ok }, ...]
  })
  .catch(console.error);

mdLinks("./some/dir")
  .then(links => {
    // => [{ href, text, file }, ...]
  })
  .catch(console.error);
```

### 2) CLI (Command Line Interface)

The executable of this program is executed via the **terminal** as follows:

`md-links <path-to-file> [options]`

For instance:

```sh
$ md-links ./some/example.md
./some/example.md http://something.com/2/3/ Link to something 
./some/example.md https://another-example.net/some-document.html Some document
./some/example.md http://google.com/ Google
```
#### Options

##### `--validate`

If the user enters the `--validate` option, the module makes an HTTP request to find out whether the link is working or not. If the link results in a redirection to a URL that answers ok, then the link is considered as ok.

For instance:

```sh
$ md-links ./some/example.md --validate
./some/example.md http://something.com/2/3/ ok 200 Link to something
./some/example.md https://other-example.net/some-document.html fail 404 Some document
./some/example.md http://google.com/ ok 301 Google
```

In this case, the _output_ includes the word `ok` or `fail` after the URL, as well as the received response' status to the HTTP request to the entered URL.

##### `--stats`

If the user enters the `--stats` option, the output is a text with basic statistics on the links.

```sh
$ md-links ./some/example.md --stats
Total: 3
Unique: 3
```

The user can also combine `--stats` and `--validate` to get statistics that need the validation results.

```sh
$ md-links ./some/example.md --stats --validate
Total: 3
Unique: 3
Broken: 1
```

---
_Source: https://npm.io/package/mdlinks-palvarado · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
