hl-md
v1.0.5
Published
A lib that reads a markdown file and looks for hyperlinks in it, returning a list of them and their respective HTTP status
Downloads
2
Readme
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.
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
Clone the repo
git clone https://github.com/acn3to/hl-md.git
Install NPM packages
npm install
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 } ]
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
Distributed under the 'ISC' license. See LICENSE
for more information.
Contributing
- fork the project (https://github.com/acn3to/hl-md)
- Create a branch for your changes (
git checkout -b feature/fooBar
) - Do the commit (
git commit -m 'Add some fooBar'
) - Push (
git push origin feature/fooBar
) - Create a new Pull Request