hl-md

1.0.5 • Public • Published

Logo

Markdown Link Validator

A lib that reads a markdown file and looks for hyperlinks in it, returning a list of them and their respective HTTP status.

NPM Version Build StatusDownloads Stats

Lib that allows to read and analyze files in markdown format, and then check whether or not there are links. Return a list containing each link found and validate the HTTP status of them.

Install

Before installing, download and install Node.js. Node.js 6.0.0 or higher is required.

If this is a brand new project, make sure to create a package.json first with the command:

npm init

Installation is done using the npm install command:

npm install -g hl-md

Demo

For instance, if you have in your markdown file something like this:

## Title example

<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quam, velit reiciendis? Repellendus corrupti perspiciatis libero, fuga officia mollitia cupiditate in quia ipsa accusantium dicta quo perferendis doloremque, voluptatum enim ipsum?
</p>

[Link to Status 200 Test](https://httpstat.us/200)

[Link to Status 404 Test](https://httpstat.us/404)

And run:

hl-md ./"filePath"/"file.md"

It will return in you terminal:

Job done!
Links list: [
  { 'Link to Status 200 Test': 'https://httpstat.us/200' },
  { 'Link to Status 404 Test': 'https://httpstat.us/404' }
]

If you add "validate" at the end, like this:

hl-md ./"filePath"/"file.md" validate

It will return in you terminal the links followed by its HTTP status:

Job done!
 Valaidated links [
{ 'Link to Status 200 Test': 'https://httpstat.us/200', status: 200 },
{ 'Link to Status 404 Test': 'https://httpstat.us/404', status: 404 }
]

Configuration for Development

  1. Clone the repo

    git clone https://github.com/acn3to/hl-md.git
  2. Install NPM packages

    npm install
  3. Use:

    npm run cli ./files/text1.md

    To get links list:

    Job done!
    Links list: [
    { 'Link to Status 200 Test': 'https://httpstat.us/200' },
    { 'Link to Status 404 Test': 'https://httpstat.us/404' },
    { 'Link to Status 300 Test': 'https://httpstat.us/300' },
    { 'Link to Status 500 Test': 'https://httpstat.us/500' },
    { 'Link to Status 201 Test': 'https://httpstat.us/201' }
    ]
    

    Or:

    npm run cli ./files/text1.md validate

    To get links already validated:

    Job done!
    Valaidated links [
    { 'Link to Status 200 Test': 'https://httpstat.us/200', status: 200 },
    { 'Link to Status 404 Test': 'https://httpstat.us/404', status: 404 },
    { 'Link to Status 300 Test': 'https://httpstat.us/300', status: 300 },
    { 'Link to Status 500 Test': 'https://httpstat.us/500', status: 500 },
    { 'Link to Status 201 Test': 'https://httpstat.us/201', status: 201 }
    ]
  4. Run unit tests:

    npm test

Dependencies and Structure

  • Node-fetch (to make the requests)

  • Chalk (to color the terminal output)

    Dev:

    • Jest (to unit tests)
├── files
│   └──text1.md
├── tests
│   ├── files
│   │   ├── text1.md
│   │   └── text2.md
│   └── index.test.js
├── babel.config.json
├── cli.js
├── http-validation.js
├── index.js
├── package.json
├── package-lock.json
├── README.md

Meta

Arnaldo Neto

Distributed under the 'ISC' license. See LICENSE for more information.

Contributing

  1. fork the project (https://github.com/acn3to/hl-md)
  2. Create a branch for your changes (git checkout -b feature/fooBar)
  3. Do the commit (git commit -m 'Add some fooBar')
  4. Push (git push origin feature/fooBar)
  5. Create a new Pull Request

Package Sidebar

Install

npm i hl-md

Weekly Downloads

5

Version

1.0.5

License

ISC

Unpacked Size

29.5 kB

Total Files

11

Last publish

Collaborators

  • acn3to