https://github.com/raulingg/md-links
find and verify links within markdown files easily.
https://github.com/raulingg/md-links
broken-link-finder broken-links markdown-links nodejs
Last synced: 4 months ago
JSON representation
find and verify links within markdown files easily.
- Host: GitHub
- URL: https://github.com/raulingg/md-links
- Owner: raulingg
- License: isc
- Created: 2019-06-09T09:40:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T14:50:55.000Z (over 3 years ago)
- Last Synced: 2025-09-18T11:27:31.788Z (9 months ago)
- Topics: broken-link-finder, broken-links, markdown-links, nodejs
- Language: JavaScript
- Homepage:
- Size: 1.05 MB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 🔗 Markdown Links
[](https://github.com/raulingg/md-links/actions/workflows/node.js.yml)
[](https://coveralls.io/github/raulingg/md-links?branch=master)
> an implementation of [Md Links project](https://github.com/Laboratoria/LIM008-fe-md-links)
## Features
- Finds links in a markdown file (.md | .markdown)
- Finds links in a folder recursively.
- Validate links by making a HTTP GET request and checking the response's status code.
- Runs from CLI
---
## Installing
- globally
```sh
npm install -g @raulingg/md-links`
```
- locally, as dependency in your project
```sh
npm install @raulingg/md-links
```
---
## Using
### In a project
#### Requiring commonjs module
```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 ES module
```js
import mdLinks from require('@raulingg/md-links')
const mdlink = await mdLinks('path/to/file.md')
const results = mdlink.data()
// do whatever you want
```
#### validating 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)
})
});
```
#### Getting 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
#### Get links
```sh
# single file
md-links
# scan all markdown files in a folder
md-links
```
#### Validate links
```sh
md-links --validate
```
#### Get stats
```sh
md-links --stats
# validate and return stats
md-links --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
```md
[](https://www.youtube.com/watch?v=Ix6VLiBcABw)
```
#### Unsupported Cases
```md
[extra sq bracket - invalid]](https://test.com)
[link with linebreak - invalid](http:
//test.com)
```