Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/node-autolinks
Automatically turn URL's into links
https://github.com/bahamas10/node-autolinks
Last synced: about 2 months ago
JSON representation
Automatically turn URL's into links
- Host: GitHub
- URL: https://github.com/bahamas10/node-autolinks
- Owner: bahamas10
- Created: 2013-05-13T21:32:34.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-02T19:26:56.000Z (about 9 years ago)
- Last Synced: 2024-10-05T06:55:19.108Z (3 months ago)
- Language: JavaScript
- Size: 184 KB
- Stars: 4
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
autolinks
=========Automatically turn URLs into links
Installation
------------To use locally
npm install autolinks
To use the command line tool `autolinks`
npm install -g autolinks
Example
-------``` js
var autolinks = require('autolinks');var s = 'my email is [email protected] 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 [email protected] and my homepage is http://www.daveeddy.com
html => my email is [email protected] and my homepage is http://www.daveeddy.com
html => my email is [email protected] and my homepage is http://www.daveeddy.com
markdown => my email is [[email protected]](mailto:[email protected]) 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 valuesreturns the parsed string
Command Line
------------$ echo 'a link to google http://www.google.com here' | autolinks
a link to google http://www.google.com 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) hereLicense
-------MIT License