Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-link-extractor

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-link-extractor

extracts links from markdown texts

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75K
increased by5.32%
Maintainers
1
Weekly downloads
 
Created
Source

Extracts links from markdown texts.

Installation

$ npm install --save markdown-link-extractor

API

markdownLinkExtractor(markdown, extended=false)

Parameters:

  • markdown text in markdown format.
  • extended enables extended output. Returns an object with metadata rather than the URL as a string (when extended===false)

Returns:

  • an array containing the URLs from the links found.
  • when extended === false array contains strings
  • when extended === true array contains objects

Examples

const { readFileSync } = require('fs');
const markdownLinkExtractor = require('markdown-link-extractor');

const markdown = readFileSync('README.md', {encoding: 'utf8'});

const links = markdownLinkExtractor(markdown, false);
links.forEach(link => console.log(link));

const details = markdownLinkExtractor(markdown, true);
details.forEach(detail => console.log(detail));

Extended output format:

{ type: 'link',
  raw:
   '[LICENSE.md](https://github.com/tcort/markdown-link-extractor/blob/master/LICENSE.md)',
  href:
   'https://github.com/tcort/markdown-link-extractor/blob/master/LICENSE.md',
  title: null,
  text: 'LICENSE.md',
  tokens: [ { type: 'text', raw: 'LICENSE.md', text: 'LICENSE.md' } ] }

Testing

npm test

License

See LICENSE.md

Keywords

FAQs

Package last updated on 21 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc