npm.io
6.0.0 • Published 9 months agoCLI

urls-md

Licence
MIT
Version
6.0.0
Deps
5
Size
6 kB
Vulns
0
Weekly
0
Stars
90

urls-md

Convert URLs to Markdown links and images

Extracts URLs from textGets their article title → Creates Markdown links and images

Useful for when you have a linkdump and want them in Markdown.

From

Lorem ipsum dolor sit amet
http://updates.html5rocks.com/2014/01/Yo-Polymer-A-Whirlwind-Tour-Of-Web-Component-Tooling
Magnis dis parturient montes.
Lorem http://codelittle.com/tag/yeoman/
https://github.global.ssl.fastly.net/images/modules/logos_page/GitHub-Mark.png

To

[Yo Polymer – A Whirlwind Tour Of Web Component Tooling](http://updates.html5rocks.com/2014/01/Yo-Polymer-A-Whirlwind-Tour-Of-Web-Component-Tooling)

[How To Use Yeoman](http://codelittle.com/tag/yeoman/)

![](https://github.global.ssl.fastly.net/images/modules/logos_page/GitHub-Mark.png)

Install

npm install urls-md

Usage

import urlsMd from 'urls-md';

const urls = await urlsMd('Lorem ipsum http://codelittle.com/tag/yeoman/');

console.log(urls);
//=>  ['[How To Use Yeoman](http://codelittle.com/tag/yeoman/)']

API

urlsMd(text)
text

Type: string

Text containing URLs to convert to Markdown links and images.

Returns a Promise<string[]> with an array of Markdown formatted links and images.

CLI

npm install --global urls-md
urls-md --help

  Usage
    urls-md <file>
    cat <file> | urls-md

You can also easily run through multiple files using shell scripting. In this example using ZSH syntax:

# Loops through all .txt files in the current directory and outputs the converted files with .md extension
for f (*.txt) { urls-md $f > $f.md }