This is a simple npm package to extract all the links from a markdown file. This package have zero dependencies.
npm install md-link-extractor
const { extractMdLinks } = require('md-link-extractor');
const links = extractMdLinks('# my md file\n [link](https://www.google.com)');
console.log(links);
[
{
text: 'link',
href: 'https://www.google.com',
line: ' [link](https://www.google.com)',
raw: '[link](https://www.google.com)',
type: 'link',
format: '[]()',
},
];
markdown
- The markdown string from which links will be extracted.- Returns an array of
Link
objects. Link
object 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
.
npm test
See the LICENSE file for license rights and limitations.
- md-link-extractor drop a star if you like it.