Package Exports
- hyperlinkify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hyperlinkify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hyperlinkify
hyperlink urls in text
Install
npm install hyperlinkify
Usage
basic example
const hyperlinkify = require('hyperlinkify')
const text = 'visit http://example.com for more info'
console.log(hyperlinkify(text))
// visit <a href="http://example.com">http://example.com</a> for more info
example with attributes
const text = 'visit http://example.com for more info'
console.log(hyperlinkify(text, {target: '_blank', 'data-foo': 'bar'}))
// visit <a href="http://example.com" target="_blank" data-foo="bar">http://example.com</a> for more info
example with conditional attributes
const text = 'hello http://example.com world http://localhost:8000'
const result = hyperlinkify(text, url => {
const attrs = {}
if (url.indexOf('localhost') === -1) {
attrs.target = '_blank'
}
return attrs
})
console.log(result)
// hello <a href="http://example.com" target="_blank">http://example.com</a> world <a href="http://localhost:8000">http://localhost:8000</a>
Test
npm test
License
MIT