# @raulingg/md-links

> This library allows you to find links within markdown files

Latest version **0.5.2** (published 2021-10-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install @raulingg/md-links
pnpm add @raulingg/md-links
yarn add @raulingg/md-links
bun add @raulingg/md-links
```

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.5.2 |
| Published | 2021-10-02 |
| First published | 2019-06-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Raul Quispe |
| Maintainers | raulingg |
| Keywords | markdown, links, node |

## Links

- npm: https://www.npmjs.com/package/@raulingg/md-links
- Repository: https://github.com/raulingg/md-links
- Homepage: https://github.com/raulingg/md-links#readme
- Issues: https://github.com/raulingg/md-links/issues
- npm.io page: https://npm.io/package/@raulingg/md-links

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.5.2 (latest) — 2021-10-02
- 0.5.1 — 2019-07-22
- 0.5.0 — 2019-07-22
- 0.4.0 — 2019-06-24
- 0.3.0 — 2019-06-23

## README

# Markdown Links

> This repository is an implementation of this [proposal](https://github.com/Laboratoria/LIM008-fe-md-links)

[![Node.js CI](https://github.com/raulingg/md-links/actions/workflows/node.js.yml/badge.svg)](https://github.com/raulingg/md-links/actions/workflows/node.js.yml)
[![Coverage Status](https://coveralls.io/repos/github/raulingg/md-links/badge.svg?branch=master)](https://coveralls.io/github/raulingg/md-links?branch=master)

Find all links included in a markdown file or in all markdown files inside a folder.

## Installation

to install globally

`npm install -g @raulingg/md-links`

to install as a dependency in your project

`npm install @raulingg/md-links`

## Usage

- Requiring dependency

  ```js
  const mdLinks = require('@raulingg/md-links')

  mdLinks('path/to/file.md')
    .then(mdlink => {
      // Return an object with two methods data and stats

      // data() return an array with results
      mdlink.data().forEach(item => {
        console.log(item.path, item.href, item.text)
      })
    });

  // find links in all markdown files inside a directory
  mdLinks('path/to/directory').data().then(data => {});
  ```

- Importing using ES6

  ```js
  import mdLinks from require('@raulingg/md-links')

  const mdlink = await mdLinks('path/to/file.md')
  const results = mdlink.data()

  // do whatever you want
  ```

- validate broken links

  ```js
  mdLinks('path/to/file.md', { validate: true}).then((mdlink) => {
    mdlink.data().forEach((item) => {
      console.log(item.path, item.text, item.href, item.status, item.statusCode)
    })
  });
  ```

- Get stats

  ```js
  /**
   * Stats Object
   * {
   *    total: <#linksFound>
   *    unique: <#LinksUnique>
   *    broken: <#LinksBroken>
   * }
   */
  mdLinks('path/to/file.md').then(mdlink => mdlink.stats());

  // get stats from broken links
  mdLinks('path/to/file.md', { validate: true}).then(mdlink => mdlink.stats());
  ```

### CLI

- Basic usage

  ```sh
  # single file
  md-links <path/to/file.md>

  # scan all markdown files in directory
  md-links <path/to/directory>
  ```

- Adding a validation option (--validate or -val)

  ```sh
  md-links <path/to/directory> --validate
  ```

- Get stats about how many links and broken links exist

  ```sh
  md-links <path/to/directory> --stats

  # validate and return stats
  md-links <path/to/directory> --validate --stats
  ```

## Markdown file

### Extensions supported

- .md
- .markdown

### Format supported

- Basic Cases

  ```md
  [valid link](http://test.com)
  [test-link@test.com](http://test.com/test-link?djdjd&)
  [title (parenthesis)](http://www.test.com)
  [title with
  linebreak](http://test.com)
  ```

- Extra Cases

  ```md
  [[extra sq bracket](https://test.com?g=154&fh=!445?)
  ```

- Video Case

  Find image and video url

  ```md
  [![Solution Temperature converter](https://i.ytimg.com/vi/Ix6VLiBcABw/0.jpg)](https://www.youtube.com/watch?v=Ix6VLiBcABw)

  ```

- Unsupported Cases

  ```md
  [extra sq bracket - invalid]](https://test.com)

  [link with linebreak - invalid](http:
  //test.com)
  ```

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