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

@raulingg/md-links

v0.5.2

Published

This library allows you to find links within markdown files

Downloads

2

Readme

Markdown Links

This repository is an implementation of this proposal

Node.js CI Coverage Status

Find all links included in a markdown file or in all markdown files inside a folder.

Installation

to install globally

npm install -g @raulingg/md-links

to install as a dependency in your project

npm install @raulingg/md-links

Usage

  • Requiring dependency

    const mdLinks = require('@raulingg/md-links')
    
    mdLinks('path/to/file.md')
      .then(mdlink => {
        // Return an object with two methods data and stats
    
        // data() return an array with results
        mdlink.data().forEach(item => {
          console.log(item.path, item.href, item.text)
        })
      });
    
    // find links in all markdown files inside a directory
    mdLinks('path/to/directory').data().then(data => {});
  • Importing using ES6

    import mdLinks from require('@raulingg/md-links')
    
    const mdlink = await mdLinks('path/to/file.md')
    const results = mdlink.data()
    
    // do whatever you want
  • validate broken links

    mdLinks('path/to/file.md', { validate: true}).then((mdlink) => {
      mdlink.data().forEach((item) => {
        console.log(item.path, item.text, item.href, item.status, item.statusCode)
      })
    });
  • Get stats

    /**
     * Stats Object
     * {
     *    total: <#linksFound>
     *    unique: <#LinksUnique>
     *    broken: <#LinksBroken>
     * }
     */
    mdLinks('path/to/file.md').then(mdlink => mdlink.stats());
    
    // get stats from broken links
    mdLinks('path/to/file.md', { validate: true}).then(mdlink => mdlink.stats());

CLI

  • Basic usage

    # single file
    md-links <path/to/file.md>
    
    # scan all markdown files in directory
    md-links <path/to/directory>
  • Adding a validation option (--validate or -val)

    md-links <path/to/directory> --validate
  • Get stats about how many links and broken links exist

    md-links <path/to/directory> --stats
    
    # validate and return stats
    md-links <path/to/directory> --validate --stats

Markdown file

Extensions supported

  • .md
  • .markdown

Format supported

  • Basic Cases

    [valid link](http://test.com)
    [[email protected]](http://test.com/test-link?djdjd&)
    [title (parenthesis)](http://www.test.com)
    [title with
    linebreak](http://test.com)
  • Extra Cases

    [[extra sq bracket](https://test.com?g=154&fh=!445?)
  • Video Case

    Find image and video url

    [![Solution Temperature converter](https://i.ytimg.com/vi/Ix6VLiBcABw/0.jpg)](https://www.youtube.com/watch?v=Ix6VLiBcABw)
    
  • Unsupported Cases

    [extra sq bracket - invalid]](https://test.com)
    
    [link with linebreak - invalid](http:
    //test.com)