Skip to content

Detect URL, Email, Hashtag and Mention from plain-text and convert into HTML hyperlink

License

Notifications You must be signed in to change notification settings

meyt/linkable.js

Repository files navigation

linkable-js

Build Status Coverage Status

Detect URL, Email, Hashtag and Mention from plain-text and convert into HTML clickable hyperlink.

Install

$ npm install --save linkable

Usage

Demo

  import Linkable from 'linkable'

  const text = 'This is test with a #hashtag from @linkable on github.com'
  const linkable = new Linkable()
  console.log(
    linkable.replaceLinks(text)
  )

Output:

This is test with <a href="/hashtag/#hashtag">#hashtag</a> from <a href="/@linkable">@linkable</a> on <a href="http://github.com">github.com</a>

Options

for more details see src/index.js file

const options = {
  mentionStyle: 'twitter',
  replaceHashtag: replaceHashtag,
  replaceMention: replaceMention,
  replaceUrl: replaceUrl,
  replaceEmail: replaceEmail
}

About

Detect URL, Email, Hashtag and Mention from plain-text and convert into HTML hyperlink

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published