Sunday, April 28, 2024
HomejQueryConvert Plain Textual content URL Into Hyperlink - jQuery Feedify

Convert Plain Textual content URL Into Hyperlink – jQuery Feedify


Feedify is a tiny and quick Textual content To Hyperlink converter that robotically transforms plain textual content URLs into hyperlinks. Helps common hyperlinks (http, https, ftp, and so forth.), Twitter @username, Twitter #hashtags, and e-mail addresses.

As well as, the plugin additionally has the flexibility to encode and escape unsafe characters (like <, >, “, ‘, &, and so forth.) to stop XSS assaults.

See Additionally:

Easy methods to use it:

1. Obtain and cargo the jQuery.feedify.js after jQuery.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/jQuery.feedify.js"></script>

2. Initialize the Feediy on the goal textual content.

<!-- Output -->
Hello my twitter account is <a href="http://twitter.com/#!/jqueryscript">@jqueryscript</a>. 

I wrote <a href="http://twitter.com/#!/search?q=%23jQuery">#jQuery</a> articles on <a href="https://www.jqueryscript.web">https://www.jqueryscript.web</a>

Contact me at <a href="mailto:[email protected]">[email protected]</a>

This under script shouldn't be going to execute due to encoding

&lt;script&gt;alert('hi there');&lt;/script&gt;

3. Add your personal textual content sample utilizing regex.

lt : {
  regex : /(<)/g,
  template : '&lt;'
},
gt : {
  regex : /(>)/g,
  template : '&gt;'
},
dq : {
  regex : /(")/g,
  template : '&quot;'
},
sq : {
  regex : /(')/g,
  template : '&#x27;'
},
hyperlink : file)://[-A-Z0-9+&@#/%?=~_,
consumer : {
  regex : /((?:^|[^a-zA-Z0-9_!#$%&*@@]|RT:?))([@@])([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?/g,
  template : '$1<a href="http://twitter.com/#!/$3$4">@$3$4</a>'
},
hash : s)#(w+)/g,
  template : '$1<a href="http://twitter.com/#!/search?q=%23$2">#$2</a>'
,
e-mail : {
  regex : /([a-zA-Z0-9._-][email protected][a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi,
  template : '<a href="mailto:$1">$1</a>'
}

This superior jQuery plugin is developed by SodhanaLibrary. For extra Superior Usages, please examine the demo web page or go to the official web site.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments