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

linkinmark

v1.0.5

Published

Markdown link extractor for node.js

Downloads

17

Readme

Descripción

Linkin' Mark es un extractor de links desde formato Markdown. Puedes instalarlo como módulo en Node.js o implementarlo en tu página web.

Instalación

NPM

Desde la consola, posiciónate en la carpeta raíz de tu proyecto e instala el paquete npm:

$ npm install linkinmark --save

CDN

Utiliza el CDN de Linkin' Mark para no añadir peso a tu proyecto. Agrega este <script> al final del <body> en tu <hmtl>:

<script src="https://cdn.jsdelivr.net/npm/linkinmark@1/lib/md-link-extractor.min.js"></script>

Descarga directa

  1. Descarga Linkin' Mark y extrae los archivos en tu computador.

  2. Incorpora la carpeta lib, conteniendo el archivo md-link-extractor.js, en la carpeta raíz de tu proyecto.

  3. Asocia tu html con md-link-extractor.js, escribiendo el siguiente script al final de <body>:

    <script src="./lib/md-link-extractor.js"></script>

Uso

Node.js

  1. En la carpeta raíz de tu proyecto, crea un archivo index.js , conteniendo el siguiente código, indicando la ruta del archivo markdown (*.md) a analizar:

    'use strict';
    const fs = require('fs');
    const linkinmark = require('linkinkmark');
    linkinmark.extract('./<mi-archivo.md>');
  2. En tu consola, posiciónate en la carpeta raíz de tu proyecto y ejecuta index.js:

    $ node index.js
  3. El resultado será un objeto JSON, conteniendo cada link del archivo markdown seleccionado. Éste quedará guardado en un archivo en la carpeta ./data/mylinks.json:

    [
      {
        "text":"labore",
        "href":"https://en.wiktionary.org/wiki/labore"
      },
      {
        "text":"dolore",
        "href":"https://en.wiktionary.org/wiki/dolore"
      },
      {
        "text":"foo",
        "href":"http://foo.com"
      }
    ]

Browser

La versión para páginas web, requiere sólo de unas cuantas líneas de código. Al efectuar la búsqueda, Linkin' Mark devolverá los resultados en un objeto JSON. Para incorporar esta herramienta en tu página, sigue los siguientes pasos:

  1. Descarga Linkin' Mark o sigue las instrucciones más arriba para utilizar el enlace CDN en tu html.
  2. Incorpora la carpeta lib, conteniendo el archivo md-link-extractor.js, en la carpeta raíz de tu proyecto.
  3. Agrega el script al final del body de tu archivo html:
    <script src="./lib/md-link-extractor.js"></script>
    <script>
      const extract = document.getElementById('extract');
      extract.onclick = function myLinks() {
        let markdown = document.getElementById('markdown').value;
        document.getElementById('result').innerHTML = markdownLinkExtractor(markdown);
      };
    </script>

Ejemplo HTML

Puedes seguir este ejemplo:

  1. Crea un elemento <input> o <textarea> con id="markdown" en tu html.
  2. Agrega un botón con el id="extract".
  3. Por último, para poder visualizar el resultado de la búsqueda, incorpora un elemento <pre></pre> y un elemento <code></code> con id="result" anidado en su interior.
    <body>
      <h1>Extractor de Links Markdown</h1>
      <h3>Ingresa un texto en formato markdown para analizar:</h3>
      <textarea id="markdown" cols="100" rows="10"></textarea>
      <button id="extract">Extraer Links!</button>
      <h3>Resultado:</h3>
      <pre>
        <code id="result"></code>
      </pre>
    </body>

Si decides modificar los nombres de id sugeridas, recuerda verificar que coincidan con el script.

El resultado se verá así:

Autoras

Makarena Fernández, Visaka Devi y Viviana Marcelo.

Licencia

MIT