npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mahalirobles-mdlinks

v1.3.0

Published

md-links permite identificar urls que se encuentran en archivos con extensión md, permite identificar cuales de esas url encontradas estan rotas y también sacar una estadística sobre el total de los links encontrados, cuantos son únicos y cuantos estan ro

Downloads

7

Readme

Markdown Links

Diagrama de flujo

Sin titulo

Pseudocodigo

| Función | Ingresa |Proceso |Salida | | ------------- | ------------- | ------------- | ------------- | | 1. evaluatePath | Ruta (string) | Utilizar método path.isAbsolute para reconocer si la ruta es absoluta| true/false (booleano) | | 2. transformToAbsPath | Ruta (string) | Utilizar método path.resolve para convertir ruta relativa a absoluta| Ruta absoluta (string)) | | 16. recognizeIfIsFile | Ruta absoluta (string) | Utilizar método fs.lstat.isFile para reconocer si es archivo| true/false (booleano) | | 13. getFiles | Ruta absoluta (string) | Obtener todos los archivos| Array con las rutas de todos los archivos(array) | | 3. getMDContent | Ruta absoluta MD (string) | Obtener contenido del archivo markdown utilizando la libreria fs.readFile (con UTF)| Contenido(string)| | 5. convertMDToHtml | Contenido (string) | Usar librería Marked para convertir contenido a HTML| Contenido HTML(string)| | 7. extractATagAttr | HTML (string) | Utilizar librería JSDOM para obtener href y contenido de los link.| Informacion de los link(objeto)| | 8. createArrLinkObj | Informacion de los link(objeto) | Crear array, meter objeto a array.| Array con informacion de links dentro de objeto(array)| | 9. extractHref | Array con objetos(array) | Extraer href de cada objeto y guardarlo en un nuevo array| Array con href de cada link(array)| | 10. validateLink | Array con href de cada link(array) | Utilizar node-fetch para evaluar href | Array con status de cada link(array)| | 12. calculateStats | Array con links o Array con links validados (array) | Calcular total de links, unicos, y rotos.| total, unique y broken (objeto)|

Product Backlog

Sin titulo

Documentación técnica

El propósito de esta librería es que el usuario pueda obtener los links que se encuentran dentro de archivos markdown, ya sea ingresando la ruta de un archivo markdown o de carpetas que contengan archivos markdown, también brinda la opcion para verificar el status de cada link y obtener estadisticas como el total de links, cuantos son únicos o no se repiten y cuantos estan rotos.

Instalación

Para instalar esta librería tienes que ejecutar el siguiente comando:

npm i mahalirobles-mdlinks

Uso en línea de comandos

Hay cuatro opciones:

  1. Para obtener los links, ingresar md-links y la ruta del archivo o directorio.
$ md-links ./some/example.md
./some/example.md http://algo.com/2/3/ Link a algo
./some/example.md https://otra-cosa.net/algun-doc.html algún doc
./some/example.md http://google.com/ Google
  1. Para obtener los links y saber su status (si esta bien o roto), ingresar md-links, ruta del archivo o directorio y la opcion --validate.
$ md-links ./some/example.md --validate
./some/example.md http://algo.com/2/3/ ok 200 Link a algo
./some/example.md https://otra-cosa.net/algun-doc.html fail 404 algún doc
./some/example.md http://google.com/ ok 301 Google
  1. Para obtener el total de links y cuantos no se repiten, ingresar md-links, ruta del archivo o directorio y la opcion --stats.
$ md-links ./some/example.md --stats
Total: 3
Unique: 3
  1. Para obtener el total de links, cuantos no se repiten y cuantos estan rotos, ingresar md-links, ruta del archivo o directorio y las opciones --validate --stats.
$ md-links ./some/example.md --validate --stats
Total: 3
Unique: 3
Broken: 1

Uso como API

let mdLinks = require('mahalirobles-mdlinks')

Hay dos opciones:

  1. Para obtener un array con los links, ingresar mdLinks y la ruta del archivo o directorio, la ruta puedes ser absoluta o relativa.
mdLinks(./some/example.md)
.then(links => {
  // => [{ href, text, file }]
  })
.catch(console.error);
  1. Para obtener un array con los links indicando su status (si esta bien o roto), ingresar md-links, ruta del archivo o directorio y la opcion {validate:true}
mdLinks(./some/example.md, {validate:true})
.then(links => {
    // => [{ href, text, file, status, ok }]
  })
.catch(console.error);