🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

autolinks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autolinks

Automatically turn URL's into links

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Automatically turn URLs into links

Installation

To use locally

npm install autolinks

To use the command line tool autolinks

npm install -g autolinks

Example

var autolinks = require('autolinks');

var s = 'my email is dave@daveeddy.com and my homepage is http://www.daveeddy.com';
console.log(s);
console.log('html => %s', autolinks(s));
console.log('html attrs => %s', autolinks(s, 'html', {title: "hello"}));
console.log('markdown => %s', autolinks(s, 'markdown'));

yields

my email is dave@daveeddy.com and my homepage is http://www.daveeddy.com
html => my email is <a href="mailto:dave@daveeddy.com">dave@daveeddy.com</a> and my homepage is <a href="http://www.daveeddy.com">http://www.daveeddy.com</a>
html => my email is <a title="hello" href="mailto:dave@daveeddy.com">dave@daveeddy.com</a> and my homepage is <a title="hello" href="http://www.daveeddy.com">http://www.daveeddy.com</a>
markdown => my email is [dave@daveeddy.com](mailto:dave@daveeddy.com) and my homepage is [http://www.daveeddy.com](http://www.daveeddy.com)

Usage

autolinks(s, [fmt], [opts])

  • s: the string to parse
  • fmt: an optional format string (markdown, html, etc.) html is default
  • opts: a list of options; in HTML, a dictionary of additional HTML attributes with their respective values

returns the parsed string

Command Line

$ echo 'a link to google http://www.google.com here' | autolinks
a link to google <a href="http://www.google.com">http://www.google.com</a> here
$ echo 'a link to google http://www.google.com here' | autolinks markdown
a link to google [http://www.google.com](http://www.google.com) here

License

MIT License

FAQs

Package last updated on 02 Nov 2015

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