Skip to content

A jQuery plugin that parses plain text and attempts to convert recognised patterns into links

Notifications You must be signed in to change notification settings

jarvis-js/jquery-linkify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Linkify jQuery Plugin v1.0.0 Copyright (c) 2011 Dobot. Licensed under the MIT license.

##Overview A jQuery plugin that parses plain text and attempts to match recognised patterns and interpolate them into templates.

Current recognised patterns include:

Patterns can easily be added, modified and disabled.

##Usage

var text = "I'm using using @dobot to do #awesome things for me, check him out at https://dobot.github.com/";
var linkified = $.linkify(text);

will give you:

I'm using using @dobot to do #awesome things for me, check him out at https://dobot.github.com/

##Options You can pass a hash of options as the second parameter to disable, change and add new types to the default ones:

###Disabling types To disable types, simply pass the name of the type set to false:

var text = "I'm using using @dobot to do #awesome things for me, check him out at http://dobot.github.com/";
var options = {
	user: false
}
var linkified = $.linkify(text, options);

which will turn off the twitter user type and give you:

I'm using using @dobot to do #awesome things for me, check him out at http://dobot.github.com/

###Adding types You can new types to linkify by passing a regex to match and a template to return, for example you could add a simple date type

var text = "My name is dobot and i was born on 2011/09/26";
var options = {
	dates: {
		regex: /(^|\s)(\d{4})([- /.])(\d{2})([- /.])(\d{2})/i,
		template: '$1<span class="date">$6-$4-$2</span>'
	}
}
var linkified = $.linkify(text, options);

which will re format the date and wrap it in a element to give you:

My name is dobot and i was born on 26-09-2011

##Unit tests: Unit tests are provided using jQuery's Qunit, just point your browser to tests/index.html to start the QUnit tests.

###Travis CI The project is also build and tested with Travis CI, current build status: current build status

##Changelog

  • 1.0.0: Initial release

##Issues Please report any issues/feature requests to (https://github.com/dobot/jquery-linkify/issues)

About

A jQuery plugin that parses plain text and attempts to convert recognised patterns into links

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published