JSPM

text-url-to-html-link

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q12275F
  • License MIT

Package Exports

  • text-url-to-html-link

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 (text-url-to-html-link) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

text-url-to-html-link

It's a simple function that fetches all the urls in a string, and transforms them into HTML links (tag )

Install

yarn add text-url-to-html-link

This package is build with Parcel Builder.

Get started

const {textUrlToHtmlLink} = require('text-url-to-html-link');
// or
import {textUrlToHtmlLink} from 'text-url-to-html-link'



const myText = `Create Share Links to send your expressions to co-workers or link to them on Twitter or your blog [ex. http://RegExr.com?2rjl6]. Built by gskinner.com with Flex 3 [adobe.com/go/flex] and Spelling Plus Library for text highlighting [gskinner.com/products/spl].`;

console.log(textUrlToHtmlLink(myText));

Result with restrictive regex:

Create Share Links to send your expressions to co-workers or link to them on Twitter or your blog [ex. <a href="http://RegExr.com?2rjl6" >http://RegExr.com?2rjl6</a>]. Built by gskinner.com with Flex 3 [adobe.com/go/flex] and Spelling Plus Library for text highlighting [gskinner.com/products/spl].

Result with less restrictive regex:

Create Share Links to send your expressions to co-workers or link to them on Twitter or your blog [ex. <a href="http://RegExr.com?2rjl6" >http://RegExr.com?2rjl6</a>]. Built by <a href="gskinner.com" >gskinner.com</a> with Flex 3 [<a href="adobe.com/go/flex" >adobe.com/go/flex</a>] and Spelling Plus Library for text highlighting [<a href="gskinner.com/products/spl" >gskinner.com/products/spl</a>].

Options

Here is signature:

textUrlToHtmlLink(text, htmlAttrs, restrictive)
  • htmlAttrs: an object of a-tag Html attributes
  • restrictive: boolean to set restrictive mode