Anchorify
Convert all links inside a string to HTML anchor tags. It supports.
- URLs with(out) protocol.
- Detect email vs plain URLs.
- Adds
rel="noreferrer noopener"
as a security measure. - Normalizes urls without procotol or
www
. - Recognize existing anchor tags.
Installation
The code is hand-written in ES5 and is supposed to work with all major browsers. It makes use of var
over let or const
and for
over forEach
.
But you will need a commonjs module loader to make use of it.
npm i --save anchorify
Usage
const anchorify = assert // Set custom targetassert // Do not touch existing anchor tagsassert // Detect emailassert // Let browser decide the protocolassert