Autolinker = function( cfg ) {
	cfg = cfg || {};

	this.version = Autolinker.version;

	this.urls = this.normalizeUrlsCfg( cfg.urls );
	this.email = typeof cfg.email === 'boolean' ? cfg.email : true;
	this.twitter = typeof cfg.twitter === 'boolean' ? cfg.twitter : true;
	this.phone = typeof cfg.phone === 'boolean' ? cfg.phone : true;
	this.hashtag = cfg.hashtag || false;
	this.newWindow = typeof cfg.newWindow === 'boolean' ? cfg.newWindow : true;
	this.stripPrefix = typeof cfg.stripPrefix === 'boolean' ? cfg.stripPrefix : true;

	// Validate the value of the `hashtag` cfg.
	var hashtag = this.hashtag;
	if( hashtag !== false && hashtag !== 'twitter' && hashtag !== 'facebook' && hashtag !== 'instagram' ) {
		throw new Error( "invalid `hashtag` cfg - see docs" );
	}

	this.truncate = this.normalizeTruncateCfg( cfg.truncate );
	this.className = cfg.className || '';
	this.replaceFn = cfg.replaceFn || null;

	this.htmlParser = null;
	this.matchers = null;
	this.tagBuilder = null;
}
@class Autolinker
@extends Object

Utility class used to process a given string of text, and wrap the matches in
the appropriate anchor (&lt;a&gt;) tags to turn them into links.

Any of the configuration options may be provided in an Object (map) provided
to the Autolinker constructor, which will configure how the {@link #link link()}
method will process the links.

For example:

    var autolinker = new Autolinker( {
        newWindow : false,
        truncate  : 30
    } );

    var html = autolinker.link( "Joe went to www.yahoo.com" );
    // produces: 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>'


The {@link #static-link static link()} method may also be used to inline
options into a single call, which may be more convenient for one-off uses.
For example:

    var html = Autolinker.link( "Joe went to www.yahoo.com", {
        newWindow : false,
        truncate  : 30
    } );
    // produces: 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>'


## Custom Replacements of Links

If the configuration options do not provide enough flexibility, a {@link #replaceFn}
may be provided to fully customize the output of Autolinker. This function is
called once for each URL/Email/Phone#/Twitter Handle/Hashtag match that is
encountered.

For example:

    var input = "...";  // string with URLs, Email Addresses, Phone #s, Twitter Handles, and Hashtags

    var linkedText = Autolinker.link( input, {
        replaceFn : function( autolinker, match ) {
            console.log( "href = ", match.getAnchorHref() );
            console.log( "text = ", match.getAnchorText() );

            switch( match.getType() ) {
                case 'url' :
                    console.log( "url: ", match.getUrl() );

                    if( match.getUrl().indexOf( 'mysite.com' ) === -1 ) {
                        var tag = autolinker.getTagBuilder().build( match );  // returns an `Autolinker.HtmlTag` instance, which provides mutator methods for easy changes
                        tag.setAttr( 'rel', 'nofollow' );
                        tag.addClass( 'external-link' );

                        return tag;

                    } else {
                        return true;  // let Autolinker perform its normal anchor tag replacement
                    }

                case 'email' :
                    var email = match.getEmail();
                    console.log( "email: ", email );

                    if( email === "my@own.address" ) {
                        return false;  // don't auto-link this particular email address; leave as-is
                    } else {
                        return;  // no return value will have Autolinker perform its normal anchor tag replacement (same as returning `true`)
                    }

                case 'phone' :
                    var phoneNumber = match.getPhoneNumber();
                    console.log( phoneNumber );

                    return '<a href="http://newplace.to.link.phone.numbers.to/">' + phoneNumber + '</a>';

                case 'twitter' :
                    var twitterHandle = match.getTwitterHandle();
                    console.log( twitterHandle );

                    return '<a href="http://newplace.to.link.twitter.handles.to/">' + twitterHandle + '</a>';

                case 'hashtag' :
                    var hashtag = match.getHashtag();
                    console.log( hashtag );

                    return '<a href="http://newplace.to.link.hashtag.handles.to/">' + hashtag + '</a>';
            }
        }
    } );


The function may return the following values:

- `true` (Boolean): Allow Autolinker to replace the match as it normally
  would.
- `false` (Boolean): Do not replace the current match at all - leave as-is.
- Any String: If a string is returned from the function, the string will be
  used directly as the replacement HTML for the match.
- An {@link Autolinker.HtmlTag} instance, which can be used to build/modify
  an HTML tag before writing out its HTML text.

@constructor
@param {Object} [cfg] The configuration options for the Autolinker instance,
  specified in an Object (map).