1.0.0 • Published 2 years ago

lib-markdown-nc v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

My first NodeJS Library - Lib Markdown

This lib was created throughout one of Alura's courses of NodeJS.

It is very simple and made for study purposes, but feel free to try it out!

What does it do?

It reads a markdown file and searches for hyperlinks in it, using regular expressions (regex) to do the trick.

For instance, if you have in your markdown file a hyperlink pointing to https://german-gender-api.deta.dev, it will show you the following response in your terminal:

npm run cli ./arquivos/texto1.md

   Lista de links:
   [ { 'German Gender API': 'https://german-gender-api.deta.dev/' } ]

It includes a title, "Lista de links" (List of links) and an array of each hyperlink and its title inside the markdown file.

How do I run it?

It's simple: simply type 'npm run cli' in your terminal, and pass the following arguments:

  1. File path, e.g., ./arquivos/texto1.md
  2. validar (optional)

As to the second argument, if you want to, you can also validate each link of the read file by adding it.

If you do so, it'll show you the hyperlinks in the file, as well as the status code of requests made on them.

npm run cli ./arquivos/texto1.md

   Links validados: 
   [
     {
       'German Gender API': 'https://german-gender-api.deta.dev/',
       status: '200 - OK'
     }
   ]   

Project Dependencies and Structure

  • node-fetch (to make the requests)
  • chalk (to color the terminal output)
├── cli.js
├── examples
│   ├── index.js
│   └── percorrendo-diretorios.js
├── http-validacao.js
├── index.js
├── package.json
├── package-lock.json
├── README.md
└── test
    └── index.test.js

What about this 'examples' folder?

It contains some tests related to my studies of JavaScript and NodeJS. Since this is not a serious library, I'll keep them there ^~^.