1.1.1 • Published 1 year ago
md-link-extractor v1.1.1
md-link-extractor
This is a simple npm package to extract all the links from a markdown file. This package have zero dependencies.
Installation
npm install md-link-extractorUsage
const { extractMdLinks } = require('md-link-extractor');
const links = extractMdLinks('# my md file\n [link](https://www.google.com)');
console.log(links);Output
[
{
text: 'link',
href: 'https://www.google.com',
line: ' [link](https://www.google.com)',
raw: '[link](https://www.google.com)',
type: 'link',
format: '[]()',
},
];API
extractMdLinks(markdown: string): Link[]
markdown- The markdown string from which links will be extracted.- Returns an array of
Linkobjects. Linkobject has the following properties:text- The text of the link.href- The href of the link.line- The line from which the link was extracted.raw- The raw link string.type- The type of the link. It can belink,email.format- The format of the link. It can be[](),<>,(),raw.
Test
npm testLicense
See the LICENSE file for license rights and limitations.
Author
GitHub Repository
- md-link-extractor drop a star if you like it.