autolinker
Advanced tools
Comparing version 0.12.5 to 0.13.1
/*! | ||
* Autolinker.js | ||
* 0.12.5 | ||
* 0.13.1 | ||
* | ||
@@ -10,2 +10,2 @@ * Copyright(c) 2014 Gregory Jacobs <greg@greg-jacobs.com> | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.Autolinker=b()}(this,function(){var a=function(b){a.Util.assign(this,b)};return a.prototype={constructor:a,urls:!0,email:!0,twitter:!0,newWindow:!0,stripPrefix:!0,className:"",htmlCharacterEntitiesRegex:/( | |<|<|>|>)/gi,matcherRegex:function(){var a=/(^|[^\w])@(\w{1,15})/,b=/(?:[\-;:&=\+\$,\w\.]+@)/,c=/(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/,d=/(?:www\.)/,e=/[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/,f=/\.(?:international|construction|contractors|enterprises|photography|productions|foundation|immobilien|industries|management|properties|technology|christmas|community|directory|education|equipment|institute|marketing|solutions|vacations|bargains|boutique|builders|catering|cleaning|clothing|computer|democrat|diamonds|graphics|holdings|lighting|partners|plumbing|supplies|training|ventures|academy|careers|company|cruises|domains|exposed|flights|florist|gallery|guitars|holiday|kitchen|neustar|okinawa|recipes|rentals|reviews|shiksha|singles|support|systems|agency|berlin|camera|center|coffee|condos|dating|estate|events|expert|futbol|kaufen|luxury|maison|monash|museum|nagoya|photos|repair|report|social|supply|tattoo|tienda|travel|viajes|villas|vision|voting|voyage|actor|build|cards|cheap|codes|dance|email|glass|house|mango|ninja|parts|photo|shoes|solar|today|tokyo|tools|watch|works|aero|arpa|asia|best|bike|blue|buzz|camp|club|cool|coop|farm|fish|gift|guru|info|jobs|kiwi|kred|land|limo|link|menu|mobi|moda|name|pics|pink|post|qpon|rich|ruhr|sexy|tips|vote|voto|wang|wien|wiki|zone|bar|bid|biz|cab|cat|ceo|com|edu|gov|int|kim|mil|net|onl|org|pro|pub|red|tel|uno|wed|xxx|xyz|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)\b/,g=/(?:[\-A-Za-z0-9+&@#\/%?=~_()|!:,.;'\$\*]*[\-A-Za-z0-9+&@#\/%=~_()|'\$\*])?/;return new RegExp(["(",a.source,")","|","(",b.source,e.source,f.source,")","|","(","(?:","(?:",c.source,e.source,")","|","(?:","(.?//)?",d.source,e.source,")","|","(?:","(.?//)?",e.source,f.source,")",")",g.source,")"].join(""),"gi")}(),invalidProtocolRelMatchRegex:/^[\w]\/\//,charBeforeProtocolRelMatchRegex:/^(.)?\/\//,link:function(b){var c=this,d=this.getHtmlParser(),e=this.htmlCharacterEntitiesRegex,f=0,g=[];return d.parse(b,{processHtmlNode:function(a,b,c){"a"===b&&(c?f=Math.max(f-1,0):f++),g.push(a)},processTextNode:function(b){if(0===f)for(var d=a.Util.splitAndCapture(b,e),h=0,i=d.length;i>h;h++){var j=d[h],k=c.processTextNode(j);g.push(k)}else g.push(b)}}),g.join("")},getHtmlParser:function(){var b=this.htmlParser;return b||(b=this.htmlParser=new a.HtmlParser),b},getTagBuilder:function(){var b=this.tagBuilder;return b||(b=this.tagBuilder=new a.AnchorTagBuilder({newWindow:this.newWindow,truncate:this.truncate,className:this.className})),b},processTextNode:function(a){var b=this;return a.replace(this.matcherRegex,function(a){var c=b.processCandidateMatch.apply(b,arguments);if(c){var d=b.createMatchReturnVal(c.match,c.matchStr);return c.prefixStr+d+c.suffixStr}return a})},processCandidateMatch:function(b,c,d,e,f,g,h,i){var j,k=h||i,l="",m="";if(!this.isValidMatch(c,f,g,k))return null;if(this.matchHasUnbalancedClosingParen(b)&&(b=b.substr(0,b.length-1),m=")"),f)j=new a.match.Email({matchedText:b,email:f});else if(c)d&&(l=d,b=b.slice(1)),j=new a.match.Twitter({matchedText:b,twitterHandle:e});else{if(k){var n=k.match(this.charBeforeProtocolRelMatchRegex)[1]||"";n&&(l=n,b=b.slice(1))}j=new a.match.Url({matchedText:b,url:b,protocolRelativeMatch:k,stripPrefix:this.stripPrefix})}return{prefixStr:l,suffixStr:m,matchStr:b,match:j}},isValidMatch:function(a,b,c,d){return a&&!this.twitter||b&&!this.email||c&&!this.urls||c&&-1===c.indexOf(".")||c&&/^[A-Za-z]{3,9}:/.test(c)&&!/:.*?[A-Za-z]/.test(c)||d&&this.invalidProtocolRelMatchRegex.test(d)?!1:!0},matchHasUnbalancedClosingParen:function(a){var b=a.charAt(a.length-1);if(")"===b){var c=a.match(/\(/g),d=a.match(/\)/g),e=c&&c.length||0,f=d&&d.length||0;if(f>e)return!0}return!1},createMatchReturnVal:function(b,c){var d;if(this.replaceFn&&(d=this.replaceFn.call(this,this,b)),"string"==typeof d)return d;if(d===!1)return c;if(d instanceof a.HtmlTag)return d.toString();var e=this.getTagBuilder(),f=e.build(b);return f.toString()}},a.link=function(b,c){var d=new a(c);return d.link(b)},a.match={},a.Util={abstractMethod:function(){throw"abstract"},assign:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},extend:function(b,c){var d=b.prototype,e=function(){};e.prototype=d;var f;f=c.hasOwnProperty("constructor")?c.constructor:function(){d.constructor.apply(this,arguments)};var g=f.prototype=new e;return g.constructor=f,g.superclass=d,delete c.constructor,a.Util.assign(g,c),f},ellipsis:function(a,b,c){return a.length>b&&(c=null==c?"..":c,a=a.substring(0,b-c.length)+c),a},indexOf:function(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},splitAndCapture:function(a,b){if(!b.global)throw new Error("`splitRegex` must have the 'g' flag set");for(var c,d=[],e=0;c=b.exec(a);)d.push(a.substring(e,c.index)),d.push(c[0]),e=c.index+c[0].length;return d.push(a.substring(e)),d}},a.HtmlParser=a.Util.extend(Object,{htmlRegex:function(){var a=/[0-9a-zA-Z:]+/,b=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,c=/(?:".*?"|'.*?'|[^'"=<>`\s]+)/,d=b.source+"(?:\\s*=\\s*"+c.source+")?";return new RegExp(["<(?:!|(/))?","("+a.source+")","(?:","\\s+","(?:",d,"|",c.source+")",")*","\\s*/?",">"].join(""),"g")}(),parse:function(a,b){b=b||{};for(var c,d=b.processHtmlNode||function(){},e=b.processTextNode||function(){},f=this.htmlRegex,g=0;null!==(c=f.exec(a));){var h=c[0],i=c[2],j=!!c[1],k=a.substring(g,c.index);k&&e(k),d(h,i,j),g=c.index+h.length}if(g<a.length){var l=a.substring(g);l&&e(l)}}}),a.HtmlTag=a.Util.extend(Object,{whitespaceRegex:/\s+/,constructor:function(b){a.Util.assign(this,b),this.innerHtml=this.innerHtml||this.innerHTML},setTagName:function(a){return this.tagName=a,this},getTagName:function(){return this.tagName||""},setAttr:function(a,b){var c=this.getAttrs();return c[a]=b,this},getAttr:function(a){return this.getAttrs()[a]},setAttrs:function(b){var c=this.getAttrs();return a.Util.assign(c,b),this},getAttrs:function(){return this.attrs||(this.attrs={})},setClass:function(a){return this.setAttr("class",a)},addClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);c=h.shift();)-1===f(g,c)&&g.push(c);return this.getAttrs()["class"]=g.join(" "),this},removeClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);g.length&&(c=h.shift());){var i=f(g,c);-1!==i&&g.splice(i,1)}return this.getAttrs()["class"]=g.join(" "),this},getClass:function(){return this.getAttrs()["class"]||""},hasClass:function(a){return-1!==(" "+this.getClass()+" ").indexOf(" "+a+" ")},setInnerHtml:function(a){return this.innerHtml=a,this},getInnerHtml:function(){return this.innerHtml||""},toString:function(){var a=this.getTagName(),b=this.buildAttrsStr();return b=b?" "+b:"",["<",a,b,">",this.getInnerHtml(),"</",a,">"].join("")},buildAttrsStr:function(){if(!this.attrs)return"";var a=this.getAttrs(),b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+'="'+a[c]+'"');return b.join(" ")}}),a.AnchorTagBuilder=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},build:function(b){var c=new a.HtmlTag({tagName:"a",attrs:this.createAttrs(b.getType(),b.getAnchorHref()),innerHtml:this.processAnchorText(b.getAnchorText())});return c},createAttrs:function(a,b){var c={href:b},d=this.createCssClass(a);return d&&(c["class"]=d),this.newWindow&&(c.target="_blank"),c},createCssClass:function(a){var b=this.className;return b?b+" "+b+"-"+a:""},processAnchorText:function(a){return a=this.doTruncate(a)},doTruncate:function(b){return a.Util.ellipsis(b,this.truncate||Number.POSITIVE_INFINITY)}}),a.match.Match=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getMatchedText:function(){return this.matchedText},getAnchorHref:a.Util.abstractMethod,getAnchorText:a.Util.abstractMethod}),a.match.Email=a.Util.extend(a.match.Match,{getType:function(){return"email"},getEmail:function(){return this.email},getAnchorHref:function(){return"mailto:"+this.email},getAnchorText:function(){return this.email}}),a.match.Twitter=a.Util.extend(a.match.Match,{getType:function(){return"twitter"},getTwitterHandle:function(){return this.twitterHandle},getAnchorHref:function(){return"https://twitter.com/"+this.twitterHandle},getAnchorText:function(){return"@"+this.twitterHandle}}),a.match.Url=a.Util.extend(a.match.Match,{urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,checkForProtocolRegex:/^[A-Za-z]{3,9}:/,getType:function(){return"url"},getUrl:function(){var a=this.url;return this.protocolRelativeMatch||this.checkForProtocolRegex.test(a)||(a=this.url="http://"+a),a},getAnchorHref:function(){var a=this.getUrl();return a.replace(/&/g,"&")},getAnchorText:function(){var a=this.getUrl();return this.protocolRelativeMatch&&(a=this.stripProtocolRelativePrefix(a)),this.stripPrefix&&(a=this.stripUrlPrefix(a)),a=this.removeTrailingSlash(a)},stripUrlPrefix:function(a){return a.replace(this.urlPrefixRegex,"")},stripProtocolRelativePrefix:function(a){return a.replace(this.protocolRelativeRegex,"")},removeTrailingSlash:function(a){return"/"===a.charAt(a.length-1)&&(a=a.slice(0,-1)),a}}),a}); | ||
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.Autolinker=b()}(this,function(){var a=function(b){a.Util.assign(this,b),this.matchValidator=new a.MatchValidator};return a.prototype={constructor:a,urls:!0,email:!0,twitter:!0,newWindow:!0,stripPrefix:!0,className:"",htmlCharacterEntitiesRegex:/( | |<|<|>|>)/gi,matcherRegex:function(){var a=/(^|[^\w])@(\w{1,15})/,b=/(?:[\-;:&=\+\$,\w\.]+@)/,c=/(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/,d=/(?:www\.)/,e=/[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/,f=/\.(?:international|construction|contractors|enterprises|photography|productions|foundation|immobilien|industries|management|properties|technology|christmas|community|directory|education|equipment|institute|marketing|solutions|vacations|bargains|boutique|builders|catering|cleaning|clothing|computer|democrat|diamonds|graphics|holdings|lighting|partners|plumbing|supplies|training|ventures|academy|careers|company|cruises|domains|exposed|flights|florist|gallery|guitars|holiday|kitchen|neustar|okinawa|recipes|rentals|reviews|shiksha|singles|support|systems|agency|berlin|camera|center|coffee|condos|dating|estate|events|expert|futbol|kaufen|luxury|maison|monash|museum|nagoya|photos|repair|report|social|supply|tattoo|tienda|travel|viajes|villas|vision|voting|voyage|actor|build|cards|cheap|codes|dance|email|glass|house|mango|ninja|parts|photo|shoes|solar|today|tokyo|tools|watch|works|aero|arpa|asia|best|bike|blue|buzz|camp|club|cool|coop|farm|fish|gift|guru|info|jobs|kiwi|kred|land|limo|link|menu|mobi|moda|name|pics|pink|post|qpon|rich|ruhr|sexy|tips|vote|voto|wang|wien|wiki|zone|bar|bid|biz|cab|cat|ceo|com|edu|gov|int|kim|mil|net|onl|org|pro|pub|red|tel|uno|wed|xxx|xyz|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)\b/,g=/[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]?!:,.;]*[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]]/;return new RegExp(["(",a.source,")","|","(",b.source,e.source,f.source,")","|","(","(?:","(",c.source,e.source,")","|","(?:","(.?//)?",d.source,e.source,")","|","(?:","(.?//)?",e.source,f.source,")",")","(?:"+g.source+")?",")"].join(""),"gi")}(),charBeforeProtocolRelMatchRegex:/^(.)?\/\//,link:function(b){var c=this,d=this.getHtmlParser(),e=this.htmlCharacterEntitiesRegex,f=0,g=[];return d.parse(b,{processHtmlNode:function(a,b,c){"a"===b&&(c?f=Math.max(f-1,0):f++),g.push(a)},processTextNode:function(b){if(0===f)for(var d=a.Util.splitAndCapture(b,e),h=0,i=d.length;i>h;h++){var j=d[h],k=c.processTextNode(j);g.push(k)}else g.push(b)}}),g.join("")},getHtmlParser:function(){var b=this.htmlParser;return b||(b=this.htmlParser=new a.HtmlParser),b},getTagBuilder:function(){var b=this.tagBuilder;return b||(b=this.tagBuilder=new a.AnchorTagBuilder({newWindow:this.newWindow,truncate:this.truncate,className:this.className})),b},processTextNode:function(a){var b=this;return a.replace(this.matcherRegex,function(a,c,d,e,f,g,h,i,j){var k=b.processCandidateMatch(a,c,d,e,f,g,h,i,j);if(k){var l=b.createMatchReturnVal(k.match,k.matchStr);return k.prefixStr+l+k.suffixStr}return a})},processCandidateMatch:function(b,c,d,e,f,g,h,i,j){var k,l=i||j,m="",n="";if(c&&!this.twitter||f&&!this.email||g&&!this.urls||!this.matchValidator.isValidMatch(g,h,l))return null;if(this.matchHasUnbalancedClosingParen(b)&&(b=b.substr(0,b.length-1),n=")"),f)k=new a.match.Email({matchedText:b,email:f});else if(c)d&&(m=d,b=b.slice(1)),k=new a.match.Twitter({matchedText:b,twitterHandle:e});else{if(l){var o=l.match(this.charBeforeProtocolRelMatchRegex)[1]||"";o&&(m=o,b=b.slice(1))}k=new a.match.Url({matchedText:b,url:b,protocolRelativeMatch:l,stripPrefix:this.stripPrefix})}return{prefixStr:m,suffixStr:n,matchStr:b,match:k}},matchHasUnbalancedClosingParen:function(a){var b=a.charAt(a.length-1);if(")"===b){var c=a.match(/\(/g),d=a.match(/\)/g),e=c&&c.length||0,f=d&&d.length||0;if(f>e)return!0}return!1},createMatchReturnVal:function(b,c){var d;if(this.replaceFn&&(d=this.replaceFn.call(this,this,b)),"string"==typeof d)return d;if(d===!1)return c;if(d instanceof a.HtmlTag)return d.toString();var e=this.getTagBuilder(),f=e.build(b);return f.toString()}},a.link=function(b,c){var d=new a(c);return d.link(b)},a.match={},a.Util={abstractMethod:function(){throw"abstract"},assign:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},extend:function(b,c){var d=b.prototype,e=function(){};e.prototype=d;var f;f=c.hasOwnProperty("constructor")?c.constructor:function(){d.constructor.apply(this,arguments)};var g=f.prototype=new e;return g.constructor=f,g.superclass=d,delete c.constructor,a.Util.assign(g,c),f},ellipsis:function(a,b,c){return a.length>b&&(c=null==c?"..":c,a=a.substring(0,b-c.length)+c),a},indexOf:function(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},splitAndCapture:function(a,b){if(!b.global)throw new Error("`splitRegex` must have the 'g' flag set");for(var c,d=[],e=0;c=b.exec(a);)d.push(a.substring(e,c.index)),d.push(c[0]),e=c.index+c[0].length;return d.push(a.substring(e)),d}},a.HtmlParser=a.Util.extend(Object,{htmlRegex:function(){var a=/[0-9a-zA-Z:]+/,b=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,c=/(?:".*?"|'.*?'|[^'"=<>`\s]+)/,d=b.source+"(?:\\s*=\\s*"+c.source+")?";return new RegExp(["<(?:!|(/))?","("+a.source+")","(?:","\\s+","(?:",d,"|",c.source+")",")*","\\s*/?",">"].join(""),"g")}(),parse:function(a,b){b=b||{};for(var c,d=b.processHtmlNode||function(){},e=b.processTextNode||function(){},f=this.htmlRegex,g=0;null!==(c=f.exec(a));){var h=c[0],i=c[2],j=!!c[1],k=a.substring(g,c.index);k&&e(k),d(h,i,j),g=c.index+h.length}if(g<a.length){var l=a.substring(g);l&&e(l)}}}),a.HtmlTag=a.Util.extend(Object,{whitespaceRegex:/\s+/,constructor:function(b){a.Util.assign(this,b),this.innerHtml=this.innerHtml||this.innerHTML},setTagName:function(a){return this.tagName=a,this},getTagName:function(){return this.tagName||""},setAttr:function(a,b){var c=this.getAttrs();return c[a]=b,this},getAttr:function(a){return this.getAttrs()[a]},setAttrs:function(b){var c=this.getAttrs();return a.Util.assign(c,b),this},getAttrs:function(){return this.attrs||(this.attrs={})},setClass:function(a){return this.setAttr("class",a)},addClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);c=h.shift();)-1===f(g,c)&&g.push(c);return this.getAttrs()["class"]=g.join(" "),this},removeClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);g.length&&(c=h.shift());){var i=f(g,c);-1!==i&&g.splice(i,1)}return this.getAttrs()["class"]=g.join(" "),this},getClass:function(){return this.getAttrs()["class"]||""},hasClass:function(a){return-1!==(" "+this.getClass()+" ").indexOf(" "+a+" ")},setInnerHtml:function(a){return this.innerHtml=a,this},getInnerHtml:function(){return this.innerHtml||""},toString:function(){var a=this.getTagName(),b=this.buildAttrsStr();return b=b?" "+b:"",["<",a,b,">",this.getInnerHtml(),"</",a,">"].join("")},buildAttrsStr:function(){if(!this.attrs)return"";var a=this.getAttrs(),b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+'="'+a[c]+'"');return b.join(" ")}}),a.MatchValidator=a.Util.extend(Object,{invalidProtocolRelMatchRegex:/^[\w]\/\//,hasFullProtocolRegex:/^[A-Za-z]{3,9}:\/\//,hasProtocolPrefixRegex:/^[A-Za-z]{3,9}:/,hasWordCharAfterProtocolRegex:/:.*?[A-Za-z]/,isValidMatch:function(a,b,c){return this.urlMatchDoesNotHaveProtocolOrDot(a,b)||this.urlMatchDoesNotHaveAtLeastOneWordChar(a)||this.isInvalidProtocolRelativeMatch(c)?!1:!0},urlMatchDoesNotHaveProtocolOrDot:function(a,b){return a&&(!b||!this.hasFullProtocolRegex.test(b))&&-1===a.indexOf(".")},urlMatchDoesNotHaveAtLeastOneWordChar:function(a){return a&&this.hasProtocolPrefixRegex.test(a)&&!this.hasWordCharAfterProtocolRegex.test(a)},isInvalidProtocolRelativeMatch:function(a){return a&&this.invalidProtocolRelMatchRegex.test(a)}}),a.AnchorTagBuilder=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},build:function(b){var c=new a.HtmlTag({tagName:"a",attrs:this.createAttrs(b.getType(),b.getAnchorHref()),innerHtml:this.processAnchorText(b.getAnchorText())});return c},createAttrs:function(a,b){var c={href:b},d=this.createCssClass(a);return d&&(c["class"]=d),this.newWindow&&(c.target="_blank"),c},createCssClass:function(a){var b=this.className;return b?b+" "+b+"-"+a:""},processAnchorText:function(a){return a=this.doTruncate(a)},doTruncate:function(b){return a.Util.ellipsis(b,this.truncate||Number.POSITIVE_INFINITY)}}),a.match.Match=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getMatchedText:function(){return this.matchedText},getAnchorHref:a.Util.abstractMethod,getAnchorText:a.Util.abstractMethod}),a.match.Email=a.Util.extend(a.match.Match,{getType:function(){return"email"},getEmail:function(){return this.email},getAnchorHref:function(){return"mailto:"+this.email},getAnchorText:function(){return this.email}}),a.match.Twitter=a.Util.extend(a.match.Match,{getType:function(){return"twitter"},getTwitterHandle:function(){return this.twitterHandle},getAnchorHref:function(){return"https://twitter.com/"+this.twitterHandle},getAnchorText:function(){return"@"+this.twitterHandle}}),a.match.Url=a.Util.extend(a.match.Match,{urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,checkForProtocolRegex:/^[A-Za-z]{3,9}:/,getType:function(){return"url"},getUrl:function(){var a=this.url;return this.protocolRelativeMatch||this.checkForProtocolRegex.test(a)||(a=this.url="http://"+a),a},getAnchorHref:function(){var a=this.getUrl();return a.replace(/&/g,"&")},getAnchorText:function(){var a=this.getUrl();return this.protocolRelativeMatch&&(a=this.stripProtocolRelativePrefix(a)),this.stripPrefix&&(a=this.stripUrlPrefix(a)),a=this.removeTrailingSlash(a)},stripUrlPrefix:function(a){return a.replace(this.urlPrefixRegex,"")},stripProtocolRelativePrefix:function(a){return a.replace(this.protocolRelativeRegex,"")},removeTrailingSlash:function(a){return"/"===a.charAt(a.length-1)&&(a=a.slice(0,-1)),a}}),a}); |
@@ -1,1 +0,1 @@ | ||
Ext.data.JsonP.Autolinker({"tagname":"class","name":"Autolinker","autodetected":{},"files":[{"filename":"Autolinker.js","href":"Autolinker.html#Autolinker"}],"extends":null,"members":[{"name":"className","tagname":"cfg","owner":"Autolinker","id":"cfg-className","meta":{}},{"name":"email","tagname":"cfg","owner":"Autolinker","id":"cfg-email","meta":{}},{"name":"newWindow","tagname":"cfg","owner":"Autolinker","id":"cfg-newWindow","meta":{}},{"name":"replaceFn","tagname":"cfg","owner":"Autolinker","id":"cfg-replaceFn","meta":{}},{"name":"stripPrefix","tagname":"cfg","owner":"Autolinker","id":"cfg-stripPrefix","meta":{}},{"name":"truncate","tagname":"cfg","owner":"Autolinker","id":"cfg-truncate","meta":{}},{"name":"twitter","tagname":"cfg","owner":"Autolinker","id":"cfg-twitter","meta":{}},{"name":"urls","tagname":"cfg","owner":"Autolinker","id":"cfg-urls","meta":{}},{"name":"charBeforeProtocolRelMatchRegex","tagname":"property","owner":"Autolinker","id":"property-charBeforeProtocolRelMatchRegex","meta":{"private":true}},{"name":"htmlCharacterEntitiesRegex","tagname":"property","owner":"Autolinker","id":"property-htmlCharacterEntitiesRegex","meta":{"private":true}},{"name":"htmlParser","tagname":"property","owner":"Autolinker","id":"property-htmlParser","meta":{"private":true}},{"name":"invalidProtocolRelMatchRegex","tagname":"property","owner":"Autolinker","id":"property-invalidProtocolRelMatchRegex","meta":{"private":true}},{"name":"matcherRegex","tagname":"property","owner":"Autolinker","id":"property-matcherRegex","meta":{"private":true}},{"name":"tagBuilder","tagname":"property","owner":"Autolinker","id":"property-tagBuilder","meta":{"private":true}},{"name":"constructor","tagname":"method","owner":"Autolinker","id":"method-constructor","meta":{}},{"name":"createMatchReturnVal","tagname":"method","owner":"Autolinker","id":"method-createMatchReturnVal","meta":{"private":true}},{"name":"getHtmlParser","tagname":"method","owner":"Autolinker","id":"method-getHtmlParser","meta":{"protected":true}},{"name":"getTagBuilder","tagname":"method","owner":"Autolinker","id":"method-getTagBuilder","meta":{}},{"name":"isValidMatch","tagname":"method","owner":"Autolinker","id":"method-isValidMatch","meta":{"private":true}},{"name":"link","tagname":"method","owner":"Autolinker","id":"method-link","meta":{}},{"name":"matchHasUnbalancedClosingParen","tagname":"method","owner":"Autolinker","id":"method-matchHasUnbalancedClosingParen","meta":{"private":true}},{"name":"processTextNode","tagname":"method","owner":"Autolinker","id":"method-processTextNode","meta":{"private":true}},{"name":"link","tagname":"method","owner":"Autolinker","id":"static-method-link","meta":{"static":true}}],"alternateClassNames":[],"aliases":{},"id":"class-Autolinker","short_doc":"Utility class used to process a given string of text, and wrap the URLs, email addresses, and Twitter handles in\nthe ...","component":false,"superclasses":[],"subclasses":[],"mixedInto":[],"mixins":[],"parentMixins":[],"requires":[],"uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Files</h4><div class='dependency'><a href='source/Autolinker.html#Autolinker' target='_blank'>Autolinker.js</a></div></pre><div class='doc-contents'><p>Utility class used to process a given string of text, and wrap the URLs, email addresses, and Twitter handles in\nthe appropriate anchor (<a>) tags to turn them into links.</p>\n\n<p>Any of the configuration options may be provided in an Object (map) provided to the Autolinker constructor, which\nwill configure how the <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">link()</a> method will process the links.</p>\n\n<p>For example:</p>\n\n<pre><code>var autolinker = new Autolinker( {\n newWindow : false,\n truncate : 30\n} );\n\nvar html = autolinker.link( \"Joe went to www.yahoo.com\" );\n// produces: 'Joe went to <a href=\"http://www.yahoo.com\">yahoo.com</a>'\n</code></pre>\n\n<p>The <a href=\"#!/api/Autolinker-static-method-link\" rel=\"Autolinker-static-method-link\" class=\"docClass\">static link()</a> method may also be used to inline options into a single call, which may\nbe more convenient for one-off uses. For example:</p>\n\n<pre><code>var html = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Joe went to www.yahoo.com\", {\n newWindow : false,\n truncate : 30\n} );\n// produces: 'Joe went to <a href=\"http://www.yahoo.com\">yahoo.com</a>'\n</code></pre>\n\n<h2>Custom Replacements of Links</h2>\n\n<p>If the configuration options do not provide enough flexibility, a <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a> may be provided to fully customize\nthe output of Autolinker. This function is called once for each URL/Email/Twitter handle match that is encountered.</p>\n\n<p>For example:</p>\n\n<pre><code>var input = \"...\"; // string with URLs, Email Addresses, and Twitter Handles\n\nvar linkedText = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( input, {\n replaceFn : function( autolinker, match ) {\n console.log( \"href = \", match.getAnchorHref() );\n console.log( \"text = \", match.getAnchorText() );\n\n switch( match.getType() ) {\n case 'url' : \n console.log( \"url: \", match.getUrl() );\n\n if( match.getUrl().indexOf( 'mysite.com' ) === -1 ) {\n var tag = autolinker.getTagBuilder().build( match ); // returns an `<a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a>` instance, which provides mutator methods for easy changes\n tag.setAttr( 'rel', 'nofollow' );\n tag.addClass( 'external-link' );\n\n return tag;\n\n } else {\n return true; // let Autolinker perform its normal anchor tag replacement\n }\n\n case 'email' :\n var email = match.getEmail();\n console.log( \"email: \", email );\n\n if( email === \"my@own.address\" ) {\n return false; // don't auto-link this particular email address; leave as-is\n } else {\n return; // no return value will have Autolinker perform its normal anchor tag replacement (same as returning `true`)\n }\n\n case 'twitter' :\n var twitterHandle = match.getTwitterHandle();\n console.log( twitterHandle );\n\n return '<a href=\"http://newplace.to.link.twitter.handles.to/\">' + twitterHandle + '</a>';\n }\n }\n} );\n</code></pre>\n\n<p>The function may return the following values:</p>\n\n<ul>\n<li><code>true</code> (Boolean): Allow Autolinker to replace the match as it normally would.</li>\n<li><code>false</code> (Boolean): Do not replace the current match at all - leave as-is.</li>\n<li>Any String: If a string is returned from the function, the string will be used directly as the replacement HTML for\nthe match.</li>\n<li>An <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a> instance, which can be used to build/modify an HTML tag before writing out its HTML text.</li>\n</ul>\n\n</div><div class='members'><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-cfg'>Config options</h3><div class='subsection'><div id='cfg-className' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-className' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-className' class='name expandable'>className</a> : String<span class=\"signature\"></span></div><div class='description'><div class='short'>A CSS class name to add to the generated links. ...</div><div class='long'><p>A CSS class name to add to the generated links. This class will be added to all links, as well as this class\nplus url/email/twitter suffixes for styling url/email/twitter links differently.</p>\n\n<p>For example, if this config is provided as \"myLink\", then:</p>\n\n<ul>\n<li>URL links will have the CSS classes: \"myLink myLink-url\"</li>\n<li>Email links will have the CSS classes: \"myLink myLink-email\", and</li>\n<li>Twitter links will have the CSS classes: \"myLink myLink-twitter\"</li>\n</ul>\n\n<p>Defaults to: <code>""</code></p></div></div></div><div id='cfg-email' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-email' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-email' class='name expandable'>email</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if email addresses should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if email addresses should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-newWindow' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-newWindow' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-newWindow' class='name expandable'>newWindow</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if the links should open in a new window, false otherwise. ...</div><div class='long'><p><code>true</code> if the links should open in a new window, <code>false</code> otherwise.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-replaceFn' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-replaceFn' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-replaceFn' class='name expandable'>replaceFn</a> : Function<span class=\"signature\"></span></div><div class='description'><div class='short'>A function to individually process each URL/Email/Twitter match found in the input string. ...</div><div class='long'><p>A function to individually process each URL/Email/Twitter match found in the input string.</p>\n\n<p>See the class's description for usage.</p>\n\n<p>This function is called with the following parameters:</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>autolinker</span> : <a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a><div class='sub-desc'><p>The Autolinker instance, which may be used to retrieve child objects from (such\n as the instance's <a href=\"#!/api/Autolinker-method-getTagBuilder\" rel=\"Autolinker-method-getTagBuilder\" class=\"docClass\">tag builder</a>).</p>\n</div></li><li><span class='pre'>match</span> : <a href=\"#!/api/Autolinker.match.Match\" rel=\"Autolinker.match.Match\" class=\"docClass\">Autolinker.match.Match</a><div class='sub-desc'><p>The Match instance which can be used to retrieve information about the\n <a href=\"#!/api/Autolinker.match.Url\" rel=\"Autolinker.match.Url\" class=\"docClass\">URL</a>/<a href=\"#!/api/Autolinker.match.Email\" rel=\"Autolinker.match.Email\" class=\"docClass\">email</a>/<a href=\"#!/api/Autolinker.match.Twitter\" rel=\"Autolinker.match.Twitter\" class=\"docClass\">Twitter</a>\n match that the <code>replaceFn</code> is currently processing.</p>\n</div></li></ul></div></div></div><div id='cfg-stripPrefix' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-stripPrefix' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-stripPrefix' class='name expandable'>stripPrefix</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,\nfalse oth...</div><div class='long'><p><code>true</code> if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,\n<code>false</code> otherwise.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-truncate' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-truncate' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-truncate' class='name expandable'>truncate</a> : Number<span class=\"signature\"></span></div><div class='description'><div class='short'>A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of\na link. ...</div><div class='long'><p>A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of\na link. If the URL/email/twitter is over this number of characters, it will be truncated to this length by\nadding a two period ellipsis ('..') to the end of the string.</p>\n\n<p>For example: A url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters might look\nsomething like this: 'yahoo.com/some/long/pat..'</p>\n</div></div></div><div id='cfg-twitter' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-twitter' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-twitter' class='name expandable'>twitter</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if Twitter handles (\"@example\") should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if Twitter handles (\"@example\") should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-urls' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-urls' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-urls' class='name expandable'>urls</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if miscellaneous URLs should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if miscellaneous URLs should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div></div></div><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-property'>Properties</h3><div class='subsection'><div id='property-charBeforeProtocolRelMatchRegex' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-charBeforeProtocolRelMatchRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-charBeforeProtocolRelMatchRegex' class='name expandable'>charBeforeProtocolRelMatchRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression used to retrieve the character before a protocol-relative URL match. ...</div><div class='long'><p>The regular expression used to retrieve the character before a protocol-relative URL match.</p>\n\n<p>This is used in conjunction with the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>, which needs to grab the character before a protocol-relative\n'//' due to the lack of a negative look-behind in JavaScript regular expressions. The character before the match is stripped\nfrom the URL.</p>\n<p>Defaults to: <code>/^(.)?\\/\\//</code></p></div></div></div><div id='property-htmlCharacterEntitiesRegex' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-htmlCharacterEntitiesRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-htmlCharacterEntitiesRegex' class='name expandable'>htmlCharacterEntitiesRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression that matches common HTML character entities. ...</div><div class='long'><p>The regular expression that matches common HTML character entities.</p>\n\n<p>Ignoring & as it could be part of a query string -- handling it separately.</p>\n<p>Defaults to: <code>/(&nbsp;|&#160;|&lt;|&#60;|&gt;|&#62;)/gi</code></p></div></div></div><div id='property-htmlParser' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-htmlParser' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-htmlParser' class='name expandable'>htmlParser</a> : <a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a><span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The HtmlParser instance used to skip over HTML tags, while finding text nodes to process. ...</div><div class='long'><p>The HtmlParser instance used to skip over HTML tags, while finding text nodes to process. This is lazily instantiated\nin the <a href=\"#!/api/Autolinker-method-getHtmlParser\" rel=\"Autolinker-method-getHtmlParser\" class=\"docClass\">getHtmlParser</a> method.</p>\n</div></div></div><div id='property-invalidProtocolRelMatchRegex' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-invalidProtocolRelMatchRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-invalidProtocolRelMatchRegex' class='name expandable'>invalidProtocolRelMatchRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression used to check a potential protocol-relative URL match, coming from the matcherRegex. ...</div><div class='long'><p>The regular expression used to check a potential protocol-relative URL match, coming from the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>.\nA protocol-relative URL is, for example, \"//yahoo.com\"</p>\n\n<p>This regular expression is used in conjunction with the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>, and checks to see if there is a word character\nbefore the '//' in order to determine if we should actually autolink a protocol-relative URL. This is needed because there\nis no negative look-behind in JavaScript regular expressions.</p>\n\n<p>For instance, we want to autolink something like \"//google.com\", but we don't want to autolink something\nlike \"abc//google.com\"</p>\n<p>Defaults to: <code>/^[\\w]\\/\\//</code></p></div></div></div><div id='property-matcherRegex' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-matcherRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-matcherRegex' class='name expandable'>matcherRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression that matches URLs, email addresses, and Twitter handles. ...</div><div class='long'><p>The regular expression that matches URLs, email addresses, and Twitter handles.</p>\n\n<p>This regular expression has the following capturing groups:</p>\n\n<ol>\n<li>Group that is used to determine if there is a Twitter handle match (i.e. \\@someTwitterUser). Simply check for its\nexistence to determine if there is a Twitter handle match. The next couple of capturing groups give information\nabout the Twitter handle match.</li>\n<li>The whitespace character before the \\@sign in a Twitter handle. This is needed because there are no lookbehinds in\nJS regular expressions, and can be used to reconstruct the original string in a replace().</li>\n<li>The Twitter handle itself in a Twitter match. If the match is '@someTwitterUser', the handle is 'someTwitterUser'.</li>\n<li>Group that matches an email address. Used to determine if the match is an email address, as well as holding the full\naddress. Ex: 'me@my.com'</li>\n<li>Group that matches a URL in the input text. Ex: 'http://google.com', 'www.google.com', or just 'google.com'.\nThis also includes a path, url parameters, or hash anchors. Ex: google.com/path/to/file?q1=1&q2=2#myAnchor</li>\n<li>A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a\nprotocol-relative match. We need to know the character before the '//' in order to determine if it is a valid match\nor the // was in a string we don't want to auto-link.</li>\n<li>A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a\nprotocol-relative match. See #6 for more info.</li>\n</ol>\n\n</div></div></div><div id='property-tagBuilder' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-tagBuilder' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-tagBuilder' class='name expandable'>tagBuilder</a> : <a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a><span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The AnchorTagBuilder instance used to build the URL/email/Twitter replacement anchor tags. ...</div><div class='long'><p>The AnchorTagBuilder instance used to build the URL/email/Twitter replacement anchor tags. This is lazily instantiated\nin the <a href=\"#!/api/Autolinker-method-getTagBuilder\" rel=\"Autolinker-method-getTagBuilder\" class=\"docClass\">getTagBuilder</a> method.</p>\n</div></div></div></div></div><div class='members-section'><h3 class='members-title icon-method'>Methods</h3><div class='subsection'><div class='definedBy'>Defined By</div><h4 class='members-subtitle'>Instance methods</h3><div id='method-constructor' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-constructor' target='_blank' class='view-source'>view source</a></div><strong class='new-keyword'>new</strong><a href='#!/api/Autolinker-method-constructor' class='name expandable'>Autolinker</a>( <span class='pre'>[config]</span> ) : <a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a><span class=\"signature\"></span></div><div class='description'><div class='short'> ...</div><div class='long'>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>config</span> : Object (optional)<div class='sub-desc'><p>The configuration options for the Autolinker instance, specified in an Object (map).</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-createMatchReturnVal' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-createMatchReturnVal' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-createMatchReturnVal' class='name expandable'>createMatchReturnVal</a>( <span class='pre'>match, matchStr</span> ) : String<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Creates the return string value for a given match in the input string, for the processTextNode method. ...</div><div class='long'><p>Creates the return string value for a given match in the input string, for the <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a> method.</p>\n\n<p>This method handles the <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a>, if one was provided.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>match</span> : <a href=\"#!/api/Autolinker.match.Match\" rel=\"Autolinker.match.Match\" class=\"docClass\">Autolinker.match.Match</a><div class='sub-desc'><p>The Match object that represents the match.</p>\n</div></li><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The original match string, after having been preprocessed to fix match edge cases (see\n the <code>prefixStr</code> and <code>suffixStr</code> vars in <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a>.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The string that the <code>match</code> should be replaced with. This is usually the anchor tag string, but\n may be the <code>matchStr</code> itself if the match is not to be replaced.</p>\n</div></li></ul></div></div></div><div id='method-getHtmlParser' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-getHtmlParser' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-getHtmlParser' class='name expandable'>getHtmlParser</a>( <span class='pre'></span> ) : <a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a><span class=\"signature\"><span class='protected' >protected</span></span></div><div class='description'><div class='short'>Lazily instantiates and returns the htmlParser instance for this Autolinker instance. ...</div><div class='long'><p>Lazily instantiates and returns the <a href=\"#!/api/Autolinker-property-htmlParser\" rel=\"Autolinker-property-htmlParser\" class=\"docClass\">htmlParser</a> instance for this Autolinker instance.</p>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-getTagBuilder' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-getTagBuilder' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-getTagBuilder' class='name expandable'>getTagBuilder</a>( <span class='pre'></span> ) : <a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a><span class=\"signature\"></span></div><div class='description'><div class='short'>Returns the tagBuilder instance for this Autolinker instance, lazily instantiating it\nif it does not yet exist. ...</div><div class='long'><p>Returns the <a href=\"#!/api/Autolinker-property-tagBuilder\" rel=\"Autolinker-property-tagBuilder\" class=\"docClass\">tagBuilder</a> instance for this Autolinker instance, lazily instantiating it\nif it does not yet exist.</p>\n\n<p>This method may be used in a <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a> to generate the <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">HtmlTag</a> instance that\nAutolinker would normally generate, and then allow for modifications before returning it. For example:</p>\n\n<pre><code>var html = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Test google.com\", {\n replaceFn : function( autolinker, match ) {\n var tag = autolinker.getTagBuilder().build( match ); // returns an <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a> instance\n tag.setAttr( 'rel', 'nofollow' );\n\n return tag;\n }\n} );\n\n// generated html:\n// Test <a href=\"http://google.com\" target=\"_blank\" rel=\"nofollow\">google.com</a>\n</code></pre>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-isValidMatch' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-isValidMatch' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-isValidMatch' class='name expandable'>isValidMatch</a>( <span class='pre'>twitterMatch, emailAddressMatch, urlMatch, protocolRelativeMatch</span> ) : Boolean<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Determines if a given match found by processTextNode is valid. ...</div><div class='long'><p>Determines if a given match found by <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a> is valid. Will return <code>false</code> for:</p>\n\n<p>1) Disabled link types (i.e. having a Twitter match, but <a href=\"#!/api/Autolinker-cfg-twitter\" rel=\"Autolinker-cfg-twitter\" class=\"docClass\">twitter</a> matching is disabled)\n2) URL matches which do not have at least have one period ('.') in the domain name (effectively skipping over\n matches like \"abc:def\")\n3) A protocol-relative url match (a URL beginning with '//') whose previous character is a word character\n (effectively skipping over strings like \"abc//google.com\")</p>\n\n<p>Otherwise, returns <code>true</code>.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>twitterMatch</span> : String<div class='sub-desc'><p>The matched Twitter handle, if there was one. Will be empty string if the match is not a\n Twitter match.</p>\n</div></li><li><span class='pre'>emailAddressMatch</span> : String<div class='sub-desc'><p>The matched Email address, if there was one. Will be empty string if the match is not\n an Email address match.</p>\n</div></li><li><span class='pre'>urlMatch</span> : String<div class='sub-desc'><p>The matched URL, if there was one. Will be an empty string if the match is not a URL match.</p>\n</div></li><li><span class='pre'>protocolRelativeMatch</span> : String<div class='sub-desc'><p>The protocol-relative string for a URL match (i.e. '//'), possibly with a preceding\n character (ex, a space, such as: ' //', or a letter, such as: 'a//'). The match is invalid if there is a word character\n preceding the '//'.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>Boolean</span><div class='sub-desc'><p><code>true</code> if the match given is valid and should be processed, or <code>false</code> if the match is invalid and/or\n should just not be processed (such as, if it's a Twitter match, but <a href=\"#!/api/Autolinker-cfg-twitter\" rel=\"Autolinker-cfg-twitter\" class=\"docClass\">twitter</a> matching is disabled}.</p>\n</div></li></ul></div></div></div><div id='method-link' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-link' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-link' class='name expandable'>link</a>( <span class='pre'>textOrHtml</span> ) : String<span class=\"signature\"></span></div><div class='description'><div class='short'>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML. ...</div><div class='long'><p>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML.\nDoes not link URLs found within HTML tags.</p>\n\n<p>For instance, if given the text: <code>You should go to http://www.yahoo.com</code>, then the result\nwill be <code>You should go to &lt;a href=\"http://www.yahoo.com\"&gt;http://www.yahoo.com&lt;/a&gt;</code></p>\n\n<p>This method finds the text around any HTML elements in the input <code>textOrHtml</code>, which will be the text that is processed.\nAny original HTML elements will be left as-is, as well as the text that is already wrapped in anchor (<a>) tags.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>textOrHtml</span> : String<div class='sub-desc'><p>The HTML or text to link URLs, email addresses, and Twitter handles within.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The HTML, with URLs/emails/Twitter handles automatically linked.</p>\n</div></li></ul></div></div></div><div id='method-matchHasUnbalancedClosingParen' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-matchHasUnbalancedClosingParen' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-matchHasUnbalancedClosingParen' class='name expandable'>matchHasUnbalancedClosingParen</a>( <span class='pre'>matchStr</span> ) : Boolean<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Determines if a match found has an unmatched closing parenthesis. ...</div><div class='long'><p>Determines if a match found has an unmatched closing parenthesis. If so, this parenthesis will be removed\nfrom the match itself, and appended after the generated anchor tag in <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a>.</p>\n\n<p>A match may have an extra closing parenthesis at the end of the match because the regular expression must include parenthesis\nfor URLs such as \"wikipedia.com/something_(disambiguation)\", which should be auto-linked.</p>\n\n<p>However, an extra parenthesis <em>will</em> be included when the URL itself is wrapped in parenthesis, such as in the case of\n\"(wikipedia.com/something_(disambiguation))\". In this case, the last closing parenthesis should <em>not</em> be part of the URL\nitself, and this method will return <code>true</code>.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The full match string from the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>Boolean</span><div class='sub-desc'><p><code>true</code> if there is an unbalanced closing parenthesis at the end of the <code>matchStr</code>, <code>false</code> otherwise.</p>\n</div></li></ul></div></div></div><div id='method-processTextNode' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-processTextNode' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-processTextNode' class='name expandable'>processTextNode</a>( <span class='pre'>text</span> ) : String<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Process the text that lies inbetween HTML tags. ...</div><div class='long'><p>Process the text that lies inbetween HTML tags. This method does the actual wrapping of URLs with\nanchor tags.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>text</span> : String<div class='sub-desc'><p>The text to auto-link.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The text with anchor tags auto-filled.</p>\n</div></li></ul></div></div></div></div><div class='subsection'><div class='definedBy'>Defined By</div><h4 class='members-subtitle'>Static methods</h3><div id='static-method-link' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-static-method-link' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-static-method-link' class='name expandable'>link</a>( <span class='pre'>html, [options]</span> ) : String<span class=\"signature\"><span class='static' >static</span></span></div><div class='description'><div class='short'>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML. ...</div><div class='long'><p>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML.\nDoes not link URLs found within HTML tags.</p>\n\n<p>For instance, if given the text: <code>You should go to http://www.yahoo.com</code>, then the result\nwill be <code>You should go to &lt;a href=\"http://www.yahoo.com\"&gt;http://www.yahoo.com&lt;/a&gt;</code></p>\n\n<p>Example:</p>\n\n<pre><code>var linkedText = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Go to google.com\", { newWindow: false } );\n// Produces: \"Go to <a href=\"http://google.com\">google.com</a>\"\n</code></pre>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>html</span> : String<div class='sub-desc'><p>The HTML text to link URLs within.</p>\n</div></li><li><span class='pre'>options</span> : Object (optional)<div class='sub-desc'><p>Any of the configuration options for the Autolinker class, specified in an Object (map).\n See the class description for an example call.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The HTML text, with URLs automatically linked</p>\n</div></li></ul></div></div></div></div></div></div></div>","meta":{}}); | ||
Ext.data.JsonP.Autolinker({"tagname":"class","name":"Autolinker","autodetected":{},"files":[{"filename":"Autolinker.js","href":"Autolinker.html#Autolinker"}],"extends":null,"members":[{"name":"className","tagname":"cfg","owner":"Autolinker","id":"cfg-className","meta":{}},{"name":"email","tagname":"cfg","owner":"Autolinker","id":"cfg-email","meta":{}},{"name":"newWindow","tagname":"cfg","owner":"Autolinker","id":"cfg-newWindow","meta":{}},{"name":"replaceFn","tagname":"cfg","owner":"Autolinker","id":"cfg-replaceFn","meta":{}},{"name":"stripPrefix","tagname":"cfg","owner":"Autolinker","id":"cfg-stripPrefix","meta":{}},{"name":"truncate","tagname":"cfg","owner":"Autolinker","id":"cfg-truncate","meta":{}},{"name":"twitter","tagname":"cfg","owner":"Autolinker","id":"cfg-twitter","meta":{}},{"name":"urls","tagname":"cfg","owner":"Autolinker","id":"cfg-urls","meta":{}},{"name":"charBeforeProtocolRelMatchRegex","tagname":"property","owner":"Autolinker","id":"property-charBeforeProtocolRelMatchRegex","meta":{"private":true}},{"name":"htmlCharacterEntitiesRegex","tagname":"property","owner":"Autolinker","id":"property-htmlCharacterEntitiesRegex","meta":{"private":true}},{"name":"htmlParser","tagname":"property","owner":"Autolinker","id":"property-htmlParser","meta":{"private":true}},{"name":"matchValidator","tagname":"property","owner":"Autolinker","id":"property-matchValidator","meta":{"private":true}},{"name":"matcherRegex","tagname":"property","owner":"Autolinker","id":"property-matcherRegex","meta":{"private":true}},{"name":"tagBuilder","tagname":"property","owner":"Autolinker","id":"property-tagBuilder","meta":{"private":true}},{"name":"constructor","tagname":"method","owner":"Autolinker","id":"method-constructor","meta":{}},{"name":"createMatchReturnVal","tagname":"method","owner":"Autolinker","id":"method-createMatchReturnVal","meta":{"private":true}},{"name":"getHtmlParser","tagname":"method","owner":"Autolinker","id":"method-getHtmlParser","meta":{"protected":true}},{"name":"getTagBuilder","tagname":"method","owner":"Autolinker","id":"method-getTagBuilder","meta":{}},{"name":"link","tagname":"method","owner":"Autolinker","id":"method-link","meta":{}},{"name":"matchHasUnbalancedClosingParen","tagname":"method","owner":"Autolinker","id":"method-matchHasUnbalancedClosingParen","meta":{"private":true}},{"name":"processCandidateMatch","tagname":"method","owner":"Autolinker","id":"method-processCandidateMatch","meta":{"private":true}},{"name":"processTextNode","tagname":"method","owner":"Autolinker","id":"method-processTextNode","meta":{"private":true}},{"name":"link","tagname":"method","owner":"Autolinker","id":"static-method-link","meta":{"static":true}}],"alternateClassNames":[],"aliases":{},"id":"class-Autolinker","short_doc":"Utility class used to process a given string of text, and wrap the URLs, email addresses, and Twitter handles in\nthe ...","component":false,"superclasses":[],"subclasses":[],"mixedInto":[],"mixins":[],"parentMixins":[],"requires":[],"uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Files</h4><div class='dependency'><a href='source/Autolinker.html#Autolinker' target='_blank'>Autolinker.js</a></div></pre><div class='doc-contents'><p>Utility class used to process a given string of text, and wrap the URLs, email addresses, and Twitter handles in\nthe appropriate anchor (<a>) tags to turn them into links.</p>\n\n<p>Any of the configuration options may be provided in an Object (map) provided to the Autolinker constructor, which\nwill configure how the <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">link()</a> method will process the links.</p>\n\n<p>For example:</p>\n\n<pre><code>var autolinker = new Autolinker( {\n newWindow : false,\n truncate : 30\n} );\n\nvar html = autolinker.link( \"Joe went to www.yahoo.com\" );\n// produces: 'Joe went to <a href=\"http://www.yahoo.com\">yahoo.com</a>'\n</code></pre>\n\n<p>The <a href=\"#!/api/Autolinker-static-method-link\" rel=\"Autolinker-static-method-link\" class=\"docClass\">static link()</a> method may also be used to inline options into a single call, which may\nbe more convenient for one-off uses. For example:</p>\n\n<pre><code>var html = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Joe went to www.yahoo.com\", {\n newWindow : false,\n truncate : 30\n} );\n// produces: 'Joe went to <a href=\"http://www.yahoo.com\">yahoo.com</a>'\n</code></pre>\n\n<h2>Custom Replacements of Links</h2>\n\n<p>If the configuration options do not provide enough flexibility, a <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a> may be provided to fully customize\nthe output of Autolinker. This function is called once for each URL/Email/Twitter handle match that is encountered.</p>\n\n<p>For example:</p>\n\n<pre><code>var input = \"...\"; // string with URLs, Email Addresses, and Twitter Handles\n\nvar linkedText = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( input, {\n replaceFn : function( autolinker, match ) {\n console.log( \"href = \", match.getAnchorHref() );\n console.log( \"text = \", match.getAnchorText() );\n\n switch( match.getType() ) {\n case 'url' : \n console.log( \"url: \", match.getUrl() );\n\n if( match.getUrl().indexOf( 'mysite.com' ) === -1 ) {\n var tag = autolinker.getTagBuilder().build( match ); // returns an `<a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a>` instance, which provides mutator methods for easy changes\n tag.setAttr( 'rel', 'nofollow' );\n tag.addClass( 'external-link' );\n\n return tag;\n\n } else {\n return true; // let Autolinker perform its normal anchor tag replacement\n }\n\n case 'email' :\n var email = match.getEmail();\n console.log( \"email: \", email );\n\n if( email === \"my@own.address\" ) {\n return false; // don't auto-link this particular email address; leave as-is\n } else {\n return; // no return value will have Autolinker perform its normal anchor tag replacement (same as returning `true`)\n }\n\n case 'twitter' :\n var twitterHandle = match.getTwitterHandle();\n console.log( twitterHandle );\n\n return '<a href=\"http://newplace.to.link.twitter.handles.to/\">' + twitterHandle + '</a>';\n }\n }\n} );\n</code></pre>\n\n<p>The function may return the following values:</p>\n\n<ul>\n<li><code>true</code> (Boolean): Allow Autolinker to replace the match as it normally would.</li>\n<li><code>false</code> (Boolean): Do not replace the current match at all - leave as-is.</li>\n<li>Any String: If a string is returned from the function, the string will be used directly as the replacement HTML for\nthe match.</li>\n<li>An <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a> instance, which can be used to build/modify an HTML tag before writing out its HTML text.</li>\n</ul>\n\n</div><div class='members'><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-cfg'>Config options</h3><div class='subsection'><div id='cfg-className' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-className' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-className' class='name expandable'>className</a> : String<span class=\"signature\"></span></div><div class='description'><div class='short'>A CSS class name to add to the generated links. ...</div><div class='long'><p>A CSS class name to add to the generated links. This class will be added to all links, as well as this class\nplus url/email/twitter suffixes for styling url/email/twitter links differently.</p>\n\n<p>For example, if this config is provided as \"myLink\", then:</p>\n\n<ul>\n<li>URL links will have the CSS classes: \"myLink myLink-url\"</li>\n<li>Email links will have the CSS classes: \"myLink myLink-email\", and</li>\n<li>Twitter links will have the CSS classes: \"myLink myLink-twitter\"</li>\n</ul>\n\n<p>Defaults to: <code>""</code></p></div></div></div><div id='cfg-email' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-email' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-email' class='name expandable'>email</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if email addresses should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if email addresses should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-newWindow' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-newWindow' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-newWindow' class='name expandable'>newWindow</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if the links should open in a new window, false otherwise. ...</div><div class='long'><p><code>true</code> if the links should open in a new window, <code>false</code> otherwise.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-replaceFn' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-replaceFn' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-replaceFn' class='name expandable'>replaceFn</a> : Function<span class=\"signature\"></span></div><div class='description'><div class='short'>A function to individually process each URL/Email/Twitter match found in the input string. ...</div><div class='long'><p>A function to individually process each URL/Email/Twitter match found in the input string.</p>\n\n<p>See the class's description for usage.</p>\n\n<p>This function is called with the following parameters:</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>autolinker</span> : <a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a><div class='sub-desc'><p>The Autolinker instance, which may be used to retrieve child objects from (such\n as the instance's <a href=\"#!/api/Autolinker-method-getTagBuilder\" rel=\"Autolinker-method-getTagBuilder\" class=\"docClass\">tag builder</a>).</p>\n</div></li><li><span class='pre'>match</span> : <a href=\"#!/api/Autolinker.match.Match\" rel=\"Autolinker.match.Match\" class=\"docClass\">Autolinker.match.Match</a><div class='sub-desc'><p>The Match instance which can be used to retrieve information about the\n <a href=\"#!/api/Autolinker.match.Url\" rel=\"Autolinker.match.Url\" class=\"docClass\">URL</a>/<a href=\"#!/api/Autolinker.match.Email\" rel=\"Autolinker.match.Email\" class=\"docClass\">email</a>/<a href=\"#!/api/Autolinker.match.Twitter\" rel=\"Autolinker.match.Twitter\" class=\"docClass\">Twitter</a>\n match that the <code>replaceFn</code> is currently processing.</p>\n</div></li></ul></div></div></div><div id='cfg-stripPrefix' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-stripPrefix' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-stripPrefix' class='name expandable'>stripPrefix</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,\nfalse oth...</div><div class='long'><p><code>true</code> if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,\n<code>false</code> otherwise.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-truncate' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-truncate' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-truncate' class='name expandable'>truncate</a> : Number<span class=\"signature\"></span></div><div class='description'><div class='short'>A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of\na link. ...</div><div class='long'><p>A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of\na link. If the URL/email/twitter is over this number of characters, it will be truncated to this length by\nadding a two period ellipsis ('..') to the end of the string.</p>\n\n<p>For example: A url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters might look\nsomething like this: 'yahoo.com/some/long/pat..'</p>\n</div></div></div><div id='cfg-twitter' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-twitter' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-twitter' class='name expandable'>twitter</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if Twitter handles (\"@example\") should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if Twitter handles (\"@example\") should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div><div id='cfg-urls' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-cfg-urls' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-cfg-urls' class='name expandable'>urls</a> : Boolean<span class=\"signature\"></span></div><div class='description'><div class='short'>true if miscellaneous URLs should be automatically linked, false if they should not be. ...</div><div class='long'><p><code>true</code> if miscellaneous URLs should be automatically linked, <code>false</code> if they should not be.</p>\n<p>Defaults to: <code>true</code></p></div></div></div></div></div><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-property'>Properties</h3><div class='subsection'><div id='property-charBeforeProtocolRelMatchRegex' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-charBeforeProtocolRelMatchRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-charBeforeProtocolRelMatchRegex' class='name expandable'>charBeforeProtocolRelMatchRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression used to retrieve the character before a protocol-relative URL match. ...</div><div class='long'><p>The regular expression used to retrieve the character before a protocol-relative URL match.</p>\n\n<p>This is used in conjunction with the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>, which needs to grab the character before a protocol-relative\n'//' due to the lack of a negative look-behind in JavaScript regular expressions. The character before the match is stripped\nfrom the URL.</p>\n<p>Defaults to: <code>/^(.)?\\/\\//</code></p></div></div></div><div id='property-htmlCharacterEntitiesRegex' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-htmlCharacterEntitiesRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-htmlCharacterEntitiesRegex' class='name expandable'>htmlCharacterEntitiesRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression that matches common HTML character entities. ...</div><div class='long'><p>The regular expression that matches common HTML character entities.</p>\n\n<p>Ignoring & as it could be part of a query string -- handling it separately.</p>\n<p>Defaults to: <code>/(&nbsp;|&#160;|&lt;|&#60;|&gt;|&#62;)/gi</code></p></div></div></div><div id='property-htmlParser' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-htmlParser' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-htmlParser' class='name expandable'>htmlParser</a> : <a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a><span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The HtmlParser instance used to skip over HTML tags, while finding text nodes to process. ...</div><div class='long'><p>The HtmlParser instance used to skip over HTML tags, while finding text nodes to process. This is lazily instantiated\nin the <a href=\"#!/api/Autolinker-method-getHtmlParser\" rel=\"Autolinker-method-getHtmlParser\" class=\"docClass\">getHtmlParser</a> method.</p>\n</div></div></div><div id='property-matchValidator' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-matchValidator' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-matchValidator' class='name expandable'>matchValidator</a> : <a href=\"#!/api/Autolinker.MatchValidator\" rel=\"Autolinker.MatchValidator\" class=\"docClass\">Autolinker.MatchValidator</a><span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The MatchValidator object, used to filter out any false positives from the matcherRegex. ...</div><div class='long'><p>The MatchValidator object, used to filter out any false positives from the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>. See\n<a href=\"#!/api/Autolinker.MatchValidator\" rel=\"Autolinker.MatchValidator\" class=\"docClass\">Autolinker.MatchValidator</a> for details.</p>\n</div></div></div><div id='property-matcherRegex' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-matcherRegex' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-matcherRegex' class='name expandable'>matcherRegex</a> : RegExp<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The regular expression that matches URLs, email addresses, and Twitter handles. ...</div><div class='long'><p>The regular expression that matches URLs, email addresses, and Twitter handles.</p>\n\n<p>This regular expression has the following capturing groups:</p>\n\n<ol>\n<li>Group that is used to determine if there is a Twitter handle match (i.e. \\@someTwitterUser). Simply check for its\nexistence to determine if there is a Twitter handle match. The next couple of capturing groups give information\nabout the Twitter handle match.</li>\n<li>The whitespace character before the \\@sign in a Twitter handle. This is needed because there are no lookbehinds in\nJS regular expressions, and can be used to reconstruct the original string in a replace().</li>\n<li>The Twitter handle itself in a Twitter match. If the match is '@someTwitterUser', the handle is 'someTwitterUser'.</li>\n<li>Group that matches an email address. Used to determine if the match is an email address, as well as holding the full\naddress. Ex: 'me@my.com'</li>\n<li>Group that matches a URL in the input text. Ex: 'http://google.com', 'www.google.com', or just 'google.com'.\nThis also includes a path, url parameters, or hash anchors. Ex: google.com/path/to/file?q1=1&q2=2#myAnchor</li>\n<li>Group that matches a protocol URL (i.e. 'http://google.com'). This is used to match protocol URLs with just a single\nword, like 'http://localhost', where we won't double check that the domain name has at least one '.' in it.</li>\n<li>A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a\nprotocol-relative match. We need to know the character before the '//' in order to determine if it is a valid match\nor the // was in a string we don't want to auto-link.</li>\n<li>A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a\nprotocol-relative match. See #6 for more info.</li>\n</ol>\n\n</div></div></div><div id='property-tagBuilder' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-property-tagBuilder' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-property-tagBuilder' class='name expandable'>tagBuilder</a> : <a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a><span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>The AnchorTagBuilder instance used to build the URL/email/Twitter replacement anchor tags. ...</div><div class='long'><p>The AnchorTagBuilder instance used to build the URL/email/Twitter replacement anchor tags. This is lazily instantiated\nin the <a href=\"#!/api/Autolinker-method-getTagBuilder\" rel=\"Autolinker-method-getTagBuilder\" class=\"docClass\">getTagBuilder</a> method.</p>\n</div></div></div></div></div><div class='members-section'><h3 class='members-title icon-method'>Methods</h3><div class='subsection'><div class='definedBy'>Defined By</div><h4 class='members-subtitle'>Instance methods</h3><div id='method-constructor' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-constructor' target='_blank' class='view-source'>view source</a></div><strong class='new-keyword'>new</strong><a href='#!/api/Autolinker-method-constructor' class='name expandable'>Autolinker</a>( <span class='pre'>[config]</span> ) : <a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a><span class=\"signature\"></span></div><div class='description'><div class='short'> ...</div><div class='long'>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>config</span> : Object (optional)<div class='sub-desc'><p>The configuration options for the Autolinker instance, specified in an Object (map).</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker\" rel=\"Autolinker\" class=\"docClass\">Autolinker</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-createMatchReturnVal' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-createMatchReturnVal' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-createMatchReturnVal' class='name expandable'>createMatchReturnVal</a>( <span class='pre'>match, matchStr</span> ) : String<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Creates the return string value for a given match in the input string, for the processTextNode method. ...</div><div class='long'><p>Creates the return string value for a given match in the input string, for the <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a> method.</p>\n\n<p>This method handles the <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a>, if one was provided.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>match</span> : <a href=\"#!/api/Autolinker.match.Match\" rel=\"Autolinker.match.Match\" class=\"docClass\">Autolinker.match.Match</a><div class='sub-desc'><p>The Match object that represents the match.</p>\n</div></li><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The original match string, after having been preprocessed to fix match edge cases (see\n the <code>prefixStr</code> and <code>suffixStr</code> vars in <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a>.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The string that the <code>match</code> should be replaced with. This is usually the anchor tag string, but\n may be the <code>matchStr</code> itself if the match is not to be replaced.</p>\n</div></li></ul></div></div></div><div id='method-getHtmlParser' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-getHtmlParser' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-getHtmlParser' class='name expandable'>getHtmlParser</a>( <span class='pre'></span> ) : <a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a><span class=\"signature\"><span class='protected' >protected</span></span></div><div class='description'><div class='short'>Lazily instantiates and returns the htmlParser instance for this Autolinker instance. ...</div><div class='long'><p>Lazily instantiates and returns the <a href=\"#!/api/Autolinker-property-htmlParser\" rel=\"Autolinker-property-htmlParser\" class=\"docClass\">htmlParser</a> instance for this Autolinker instance.</p>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker.HtmlParser\" rel=\"Autolinker.HtmlParser\" class=\"docClass\">Autolinker.HtmlParser</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-getTagBuilder' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-getTagBuilder' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-getTagBuilder' class='name expandable'>getTagBuilder</a>( <span class='pre'></span> ) : <a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a><span class=\"signature\"></span></div><div class='description'><div class='short'>Returns the tagBuilder instance for this Autolinker instance, lazily instantiating it\nif it does not yet exist. ...</div><div class='long'><p>Returns the <a href=\"#!/api/Autolinker-property-tagBuilder\" rel=\"Autolinker-property-tagBuilder\" class=\"docClass\">tagBuilder</a> instance for this Autolinker instance, lazily instantiating it\nif it does not yet exist.</p>\n\n<p>This method may be used in a <a href=\"#!/api/Autolinker-cfg-replaceFn\" rel=\"Autolinker-cfg-replaceFn\" class=\"docClass\">replaceFn</a> to generate the <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">HtmlTag</a> instance that\nAutolinker would normally generate, and then allow for modifications before returning it. For example:</p>\n\n<pre><code>var html = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Test google.com\", {\n replaceFn : function( autolinker, match ) {\n var tag = autolinker.getTagBuilder().build( match ); // returns an <a href=\"#!/api/Autolinker.HtmlTag\" rel=\"Autolinker.HtmlTag\" class=\"docClass\">Autolinker.HtmlTag</a> instance\n tag.setAttr( 'rel', 'nofollow' );\n\n return tag;\n }\n} );\n\n// generated html:\n// Test <a href=\"http://google.com\" target=\"_blank\" rel=\"nofollow\">google.com</a>\n</code></pre>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Autolinker.AnchorTagBuilder\" rel=\"Autolinker.AnchorTagBuilder\" class=\"docClass\">Autolinker.AnchorTagBuilder</a></span><div class='sub-desc'>\n</div></li></ul></div></div></div><div id='method-link' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-link' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-link' class='name expandable'>link</a>( <span class='pre'>textOrHtml</span> ) : String<span class=\"signature\"></span></div><div class='description'><div class='short'>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML. ...</div><div class='long'><p>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML.\nDoes not link URLs found within HTML tags.</p>\n\n<p>For instance, if given the text: <code>You should go to http://www.yahoo.com</code>, then the result\nwill be <code>You should go to &lt;a href=\"http://www.yahoo.com\"&gt;http://www.yahoo.com&lt;/a&gt;</code></p>\n\n<p>This method finds the text around any HTML elements in the input <code>textOrHtml</code>, which will be the text that is processed.\nAny original HTML elements will be left as-is, as well as the text that is already wrapped in anchor (<a>) tags.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>textOrHtml</span> : String<div class='sub-desc'><p>The HTML or text to link URLs, email addresses, and Twitter handles within (depending on if\n the <a href=\"#!/api/Autolinker-cfg-urls\" rel=\"Autolinker-cfg-urls\" class=\"docClass\">urls</a>, <a href=\"#!/api/Autolinker-cfg-email\" rel=\"Autolinker-cfg-email\" class=\"docClass\">email</a>, and <a href=\"#!/api/Autolinker-cfg-twitter\" rel=\"Autolinker-cfg-twitter\" class=\"docClass\">twitter</a> options are enabled).</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The HTML, with URLs/emails/Twitter handles automatically linked.</p>\n</div></li></ul></div></div></div><div id='method-matchHasUnbalancedClosingParen' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-matchHasUnbalancedClosingParen' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-matchHasUnbalancedClosingParen' class='name expandable'>matchHasUnbalancedClosingParen</a>( <span class='pre'>matchStr</span> ) : Boolean<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Determines if a match found has an unmatched closing parenthesis. ...</div><div class='long'><p>Determines if a match found has an unmatched closing parenthesis. If so, this parenthesis will be removed\nfrom the match itself, and appended after the generated anchor tag in <a href=\"#!/api/Autolinker-method-processTextNode\" rel=\"Autolinker-method-processTextNode\" class=\"docClass\">processTextNode</a>.</p>\n\n<p>A match may have an extra closing parenthesis at the end of the match because the regular expression must include parenthesis\nfor URLs such as \"wikipedia.com/something_(disambiguation)\", which should be auto-linked.</p>\n\n<p>However, an extra parenthesis <em>will</em> be included when the URL itself is wrapped in parenthesis, such as in the case of\n\"(wikipedia.com/something_(disambiguation))\". In this case, the last closing parenthesis should <em>not</em> be part of the URL\nitself, and this method will return <code>true</code>.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The full match string from the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>Boolean</span><div class='sub-desc'><p><code>true</code> if there is an unbalanced closing parenthesis at the end of the <code>matchStr</code>, <code>false</code> otherwise.</p>\n</div></li></ul></div></div></div><div id='method-processCandidateMatch' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-processCandidateMatch' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-processCandidateMatch' class='name expandable'>processCandidateMatch</a>( <span class='pre'>matchStr, twitterMatch, twitterHandlePrefixWhitespaceChar, twitterHandle, emailAddressMatch, urlMatch, protocolUrlMatch, wwwProtocolRelativeMatch, tldProtocolRelativeMatch</span> ) : Object<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Processes a candidate match from the matcherRegex. ...</div><div class='long'><p>Processes a candidate match from the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>.</p>\n\n<p>Not all matches found by the regex are actual URL/email/Twitter matches, as determined by the <a href=\"#!/api/Autolinker-property-matchValidator\" rel=\"Autolinker-property-matchValidator\" class=\"docClass\">matchValidator</a>. In\nthis case, the method returns <code>null</code>. Otherwise, a valid Object with <code>prefixStr</code>, <code>match</code>, and <code>suffixStr</code> is returned.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The full match that was found by the <a href=\"#!/api/Autolinker-property-matcherRegex\" rel=\"Autolinker-property-matcherRegex\" class=\"docClass\">matcherRegex</a>.</p>\n</div></li><li><span class='pre'>twitterMatch</span> : String<div class='sub-desc'><p>The matched text of a Twitter handle, if the match is a Twitter match.</p>\n</div></li><li><span class='pre'>twitterHandlePrefixWhitespaceChar</span> : String<div class='sub-desc'><p>The whitespace char before the sign in a Twitter handle match. This\n is needed because of no lookbehinds in JS regexes, and is need to re-include the character for the anchor tag replacement.</p>\n</div></li><li><span class='pre'>twitterHandle</span> : String<div class='sub-desc'><p>The actual Twitter user (i.e the word after the sign in a Twitter match).</p>\n</div></li><li><span class='pre'>emailAddressMatch</span> : String<div class='sub-desc'><p>The matched email address for an email address match.</p>\n</div></li><li><span class='pre'>urlMatch</span> : String<div class='sub-desc'><p>The matched URL string for a URL match.</p>\n</div></li><li><span class='pre'>protocolUrlMatch</span> : String<div class='sub-desc'><p>The match URL string for a protocol match. Ex: 'http://yahoo.com'. This is used to match\n something like 'http://localhost', where we won't double check that the domain name has at least one '.' in it.</p>\n</div></li><li><span class='pre'>wwwProtocolRelativeMatch</span> : String<div class='sub-desc'><p>The '//' for a protocol-relative match from a 'www' url, with the character that\n comes before the '//'.</p>\n</div></li><li><span class='pre'>tldProtocolRelativeMatch</span> : String<div class='sub-desc'><p>The '//' for a protocol-relative match from a TLD (top level domain) match, with\n the character that comes before the '//'.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>Object</span><div class='sub-desc'><p>A \"match description object\". This will be <code>null</code> if the match was invalid, or if a match type is disabled.\n Otherwise, this will be an Object (map) with the following properties:</p>\n<ul><li><span class='pre'>prefixStr</span> : String<div class='sub-desc'><p>The char(s) that should be prepended to the replacement string. These are char(s) that\n were needed to be included from the regex match that were ignored by processing code, and should be re-inserted into\n the replacement stream.</p>\n</div></li><li><span class='pre'>suffixStr</span> : String<div class='sub-desc'><p>The char(s) that should be appended to the replacement string. These are char(s) that\n were needed to be included from the regex match that were ignored by processing code, and should be re-inserted into\n the replacement stream.</p>\n</div></li><li><span class='pre'>matchStr</span> : String<div class='sub-desc'><p>The <code>matchStr</code>, fixed up to remove characters that are no longer needed (which have been\n added to <code>prefixStr</code> and <code>suffixStr</code>).</p>\n</div></li><li><span class='pre'>match</span> : <a href=\"#!/api/Autolinker.match.Match\" rel=\"Autolinker.match.Match\" class=\"docClass\">Autolinker.match.Match</a><div class='sub-desc'><p>The Match object that represents the match that was found.</p>\n</div></li></ul></div></li></ul></div></div></div><div id='method-processTextNode' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-method-processTextNode' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-method-processTextNode' class='name expandable'>processTextNode</a>( <span class='pre'>text</span> ) : String<span class=\"signature\"><span class='private' >private</span></span></div><div class='description'><div class='short'>Process the text that lies inbetween HTML tags. ...</div><div class='long'><p>Process the text that lies inbetween HTML tags. This method does the actual wrapping of URLs with\nanchor tags.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>text</span> : String<div class='sub-desc'><p>The text to auto-link.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The text with anchor tags auto-filled.</p>\n</div></li></ul></div></div></div></div><div class='subsection'><div class='definedBy'>Defined By</div><h4 class='members-subtitle'>Static methods</h3><div id='static-method-link' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Autolinker'>Autolinker</span><br/><a href='source/Autolinker.html#Autolinker-static-method-link' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Autolinker-static-method-link' class='name expandable'>link</a>( <span class='pre'>textOrHtml, [options]</span> ) : String<span class=\"signature\"><span class='static' >static</span></span></div><div class='description'><div class='short'>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML. ...</div><div class='long'><p>Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML.\nDoes not link URLs found within HTML tags.</p>\n\n<p>For instance, if given the text: <code>You should go to http://www.yahoo.com</code>, then the result\nwill be <code>You should go to &lt;a href=\"http://www.yahoo.com\"&gt;http://www.yahoo.com&lt;/a&gt;</code></p>\n\n<p>Example:</p>\n\n<pre><code>var linkedText = <a href=\"#!/api/Autolinker-method-link\" rel=\"Autolinker-method-link\" class=\"docClass\">Autolinker.link</a>( \"Go to google.com\", { newWindow: false } );\n// Produces: \"Go to <a href=\"http://google.com\">google.com</a>\"\n</code></pre>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>textOrHtml</span> : String<div class='sub-desc'><p>The HTML or text to find URLs, email addresses, and Twitter handles within (depending on if\n the <a href=\"#!/api/Autolinker-cfg-urls\" rel=\"Autolinker-cfg-urls\" class=\"docClass\">urls</a>, <a href=\"#!/api/Autolinker-cfg-email\" rel=\"Autolinker-cfg-email\" class=\"docClass\">email</a>, and <a href=\"#!/api/Autolinker-cfg-twitter\" rel=\"Autolinker-cfg-twitter\" class=\"docClass\">twitter</a> options are enabled).</p>\n</div></li><li><span class='pre'>options</span> : Object (optional)<div class='sub-desc'><p>Any of the configuration options for the Autolinker class, specified in an Object (map).\n See the class description for an example call.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'>String</span><div class='sub-desc'><p>The HTML text, with URLs automatically linked</p>\n</div></li></ul></div></div></div></div></div></div></div>","meta":{}}); |
@@ -0,0 +0,0 @@ !function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; |
@@ -6,8 +6,16 @@ /*global require, module */ | ||
var exec = require( 'child_process' ).exec; | ||
var banner = createBanner(); | ||
var distPath = 'dist/Autolinker.js'; | ||
var minDistPath = 'dist/Autolinker.min.js'; | ||
// Tasks | ||
grunt.registerTask( 'default', [ 'jshint', 'build', 'jasmine' ] ); | ||
grunt.registerTask( 'build', [ 'concat:development', 'umd', 'uglify:production' ] ); | ||
grunt.registerTask( 'test', [ 'build', 'jasmine' ] ); | ||
grunt.registerTask( 'doc', "Builds the documentation.", [ 'jshint', 'jsduck' ] ); | ||
grunt.registerTask( 'serve', [ 'connect:server:keepalive' ] ); | ||
// Project configuration. | ||
// Project configuration | ||
var exec = require( 'child_process' ).exec, | ||
banner = createBanner(), | ||
distPath = 'dist/Autolinker.js', | ||
minDistPath = 'dist/Autolinker.min.js'; | ||
grunt.initConfig( { | ||
@@ -52,2 +60,3 @@ pkg: grunt.file.readJSON( 'package.json' ), | ||
'src/HtmlTag.js', | ||
'src/MatchValidator.js', | ||
'src/AnchorTagBuilder.js', | ||
@@ -108,10 +117,4 @@ 'src/match/Match.js', | ||
grunt.loadNpmTasks( 'grunt-umd' ); | ||
// Tasks | ||
grunt.registerTask( 'default', [ 'jshint', 'build', 'jasmine' ] ); | ||
grunt.registerTask( 'build', [ 'concat:development', 'umd', 'uglify:production' ] ); | ||
grunt.registerTask( 'test', [ 'build', 'jasmine' ] ); | ||
grunt.registerTask( 'doc', "Builds the documentation.", [ 'jshint', 'jsduck' ] ); | ||
grunt.registerTask( 'serve', [ 'connect:server:keepalive' ] ); | ||
/** | ||
@@ -118,0 +121,0 @@ * Creates the banner comment with license header that is placed over the concatenated/minified files. |
{ | ||
"name": "autolinker", | ||
"version": "0.12.5", | ||
"version": "0.13.1", | ||
"description": "Utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML", | ||
@@ -5,0 +5,0 @@ "main": "dist/Autolinker.js", |
@@ -94,2 +94,4 @@ /** | ||
Autolinker.Util.assign( this, cfg ); // assign the properties of `cfg` onto the Autolinker instance. Prototype properties will be used for missing configs. | ||
this.matchValidator = new Autolinker.MatchValidator(); | ||
}; | ||
@@ -207,6 +209,8 @@ | ||
* This also includes a path, url parameters, or hash anchors. Ex: google.com/path/to/file?q1=1&q2=2#myAnchor | ||
* 6. A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a | ||
* 6. Group that matches a protocol URL (i.e. 'http://google.com'). This is used to match protocol URLs with just a single | ||
* word, like 'http://localhost', where we won't double check that the domain name has at least one '.' in it. | ||
* 7. A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a | ||
* protocol-relative match. We need to know the character before the '//' in order to determine if it is a valid match | ||
* or the // was in a string we don't want to auto-link. | ||
* 7. A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a | ||
* 8. A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a | ||
* protocol-relative match. See #6 for more info. | ||
@@ -219,3 +223,3 @@ */ | ||
protocolRegex = /(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/, // match protocol, allow in format http:// or mailto: | ||
protocolRegex = /(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/, // match protocol, allow in format "http://" or "mailto:". However, do not match the first part of something like 'link:http://www.google.com' (i.e. don't match "link:") | ||
wwwRegex = /(?:www\.)/, // starting with 'www.' | ||
@@ -225,5 +229,5 @@ domainNameRegex = /[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/, // anything looking at all like a domain, non-unicode domains, not ending in a period | ||
// Allow optional path, query string, and hash anchor, not ending in the following characters: "!:,.;" | ||
// Allow optional path, query string, and hash anchor, not ending in the following characters: "?!:,.;" | ||
// http://blog.codinghorror.com/the-problem-with-urls/ | ||
urlSuffixRegex = /(?:[\-A-Za-z0-9+&@#\/%?=~_()|!:,.;'\$\*]*[\-A-Za-z0-9+&@#\/%=~_()|'\$\*])?/; // note: optional part of the full regex | ||
urlSuffixRegex = /[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]?!:,.;]*[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]]/; | ||
@@ -249,3 +253,3 @@ return new RegExp( [ | ||
'(?:', // parens to cover match for protocol (optional), and domain | ||
'(?:', // non-capturing paren for a protocol-prefixed url (ex: http://google.com) | ||
'(', // *** Capturing group $6, for a protocol-prefixed url (ex: http://google.com) | ||
protocolRegex.source, | ||
@@ -258,3 +262,3 @@ domainNameRegex.source, | ||
'(?:', // non-capturing paren for a 'www.' prefixed url (ex: www.google.com) | ||
'(.?//)?', // *** Capturing group $6 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character | ||
'(.?//)?', // *** Capturing group $7 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character | ||
wwwRegex.source, | ||
@@ -267,3 +271,3 @@ domainNameRegex.source, | ||
'(?:', // non-capturing paren for known a TLD url (ex: google.com) | ||
'(.?//)?', // *** Capturing group $7 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character | ||
'(.?//)?', // *** Capturing group $8 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character | ||
domainNameRegex.source, | ||
@@ -274,3 +278,3 @@ tldRegex.source, | ||
urlSuffixRegex.source, // match for path, query string, and/or hash anchor | ||
'(?:' + urlSuffixRegex.source + ')?', // match for path, query string, and/or hash anchor - optional | ||
')' | ||
@@ -282,18 +286,2 @@ ].join( "" ), 'gi' ); | ||
* @private | ||
* @property {RegExp} invalidProtocolRelMatchRegex | ||
* | ||
* The regular expression used to check a potential protocol-relative URL match, coming from the {@link #matcherRegex}. | ||
* A protocol-relative URL is, for example, "//yahoo.com" | ||
* | ||
* This regular expression is used in conjunction with the {@link #matcherRegex}, and checks to see if there is a word character | ||
* before the '//' in order to determine if we should actually autolink a protocol-relative URL. This is needed because there | ||
* is no negative look-behind in JavaScript regular expressions. | ||
* | ||
* For instance, we want to autolink something like "//google.com", but we don't want to autolink something | ||
* like "abc//google.com" | ||
*/ | ||
invalidProtocolRelMatchRegex : /^[\w]\/\//, | ||
/** | ||
* @private | ||
* @property {RegExp} charBeforeProtocolRelMatchRegex | ||
@@ -311,2 +299,10 @@ * | ||
* @private | ||
* @property {Autolinker.MatchValidator} matchValidator | ||
* | ||
* The MatchValidator object, used to filter out any false positives from the {@link #matcherRegex}. See | ||
* {@link Autolinker.MatchValidator} for details. | ||
*/ | ||
/** | ||
* @private | ||
* @property {Autolinker.HtmlParser} htmlParser | ||
@@ -450,4 +446,4 @@ * | ||
return text.replace( this.matcherRegex, function( matchStr, $1, $2, $3, $4, $5, $6, $7 ) { | ||
var matchDescObj = me.processCandidateMatch.apply( me, arguments ); // match description object | ||
return text.replace( this.matcherRegex, function( matchStr, $1, $2, $3, $4, $5, $6, $7, $8 ) { | ||
var matchDescObj = me.processCandidateMatch( matchStr, $1, $2, $3, $4, $5, $6, $7, $8 ); // match description object | ||
@@ -471,3 +467,3 @@ // Return out with no changes for match types that are disabled (url, email, twitter), or for matches that are | ||
* | ||
* Not all matches found by the regex are actual URL/email/Twitter matches, as determined by {@link #isValidMatch}. In | ||
* Not all matches found by the regex are actual URL/email/Twitter matches, as determined by the {@link #matchValidator}. In | ||
* this case, the method returns `null`. Otherwise, a valid Object with `prefixStr`, `match`, and `suffixStr` is returned. | ||
@@ -483,2 +479,4 @@ * | ||
* @param {String} urlMatch The matched URL string for a URL match. | ||
* @param {String} protocolUrlMatch The match URL string for a protocol match. Ex: 'http://yahoo.com'. This is used to match | ||
* something like 'http://localhost', where we won't double check that the domain name has at least one '.' in it. | ||
* @param {String} wwwProtocolRelativeMatch The '//' for a protocol-relative match from a 'www' url, with the character that | ||
@@ -503,3 +501,3 @@ * comes before the '//'. | ||
matchStr, twitterMatch, twitterHandlePrefixWhitespaceChar, twitterHandle, | ||
emailAddressMatch, urlMatch, wwwProtocolRelativeMatch, tldProtocolRelativeMatch | ||
emailAddressMatch, urlMatch, protocolUrlMatch, wwwProtocolRelativeMatch, tldProtocolRelativeMatch | ||
) { | ||
@@ -515,3 +513,6 @@ var protocolRelativeMatch = wwwProtocolRelativeMatch || tldProtocolRelativeMatch, | ||
// invalid (false positives from the matcherRegex, which can't use look-behinds since they are unavailable in JS). | ||
if( !this.isValidMatch( twitterMatch, emailAddressMatch, urlMatch, protocolRelativeMatch ) ) { | ||
if( | ||
( twitterMatch && !this.twitter ) || ( emailAddressMatch && !this.email ) || ( urlMatch && !this.urls ) || | ||
!this.matchValidator.isValidMatch( urlMatch, protocolUrlMatch, protocolRelativeMatch ) | ||
) { | ||
return null; | ||
@@ -569,42 +570,3 @@ } | ||
/** | ||
* Determines if a given match found by {@link #processTextNode} is valid. Will return `false` for: | ||
* | ||
* 1) Disabled link types (i.e. having a Twitter match, but {@link #twitter} matching is disabled) | ||
* 2) URL matches which do not have at least have one period ('.') in the domain name (effectively skipping over | ||
* matches like "abc:def") | ||
* 3) A protocol-relative url match (a URL beginning with '//') whose previous character is a word character | ||
* (effectively skipping over strings like "abc//google.com") | ||
* | ||
* Otherwise, returns `true`. | ||
* | ||
* @private | ||
* @param {String} twitterMatch The matched Twitter handle, if there was one. Will be empty string if the match is not a | ||
* Twitter match. | ||
* @param {String} emailAddressMatch The matched Email address, if there was one. Will be empty string if the match is not | ||
* an Email address match. | ||
* @param {String} urlMatch The matched URL, if there was one. Will be an empty string if the match is not a URL match. | ||
* @param {String} protocolRelativeMatch The protocol-relative string for a URL match (i.e. '//'), possibly with a preceding | ||
* character (ex, a space, such as: ' //', or a letter, such as: 'a//'). The match is invalid if there is a word character | ||
* preceding the '//'. | ||
* @return {Boolean} `true` if the match given is valid and should be processed, or `false` if the match is invalid and/or | ||
* should just not be processed (such as, if it's a Twitter match, but {@link #twitter} matching is disabled}. | ||
*/ | ||
isValidMatch : function( twitterMatch, emailAddressMatch, urlMatch, protocolRelativeMatch ) { | ||
if( | ||
( twitterMatch && !this.twitter ) || ( emailAddressMatch && !this.email ) || ( urlMatch && !this.urls ) || | ||
( urlMatch && urlMatch.indexOf( '.' ) === -1 ) || // At least one period ('.') must exist in the URL match for us to consider it an actual URL | ||
( urlMatch && /^[A-Za-z]{3,9}:/.test( urlMatch ) && !/:.*?[A-Za-z]/.test( urlMatch ) ) || // At least one letter character must exist in the domain name after a protocol match. Ex: skip over something like "git:1.0" | ||
( protocolRelativeMatch && this.invalidProtocolRelMatchRegex.test( protocolRelativeMatch ) ) // a protocol-relative match which has a word character in front of it (so we can skip something like "abc//google.com") | ||
) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
/** | ||
* Determines if a match found has an unmatched closing parenthesis. If so, this parenthesis will be removed | ||
@@ -611,0 +573,0 @@ * from the match itself, and appended after the generated anchor tag in {@link #processTextNode}. |
@@ -32,2 +32,8 @@ /*global Autolinker, _, describe, beforeEach, afterEach, it, expect */ | ||
} ); | ||
it( "should automatically link localhost URLs when there is a protocol", function() { | ||
var result = autolinker.link( "Joe went to http://localhost today" ); | ||
expect( result ).toBe( 'Joe went to <a href="http://localhost">localhost</a> today' ); | ||
} ); | ||
@@ -89,2 +95,8 @@ | ||
it( "should automatically link a localhost URL with a port number and a path", function() { | ||
var result = autolinker.link( "Joe went to http://localhost:8000/page today." ); | ||
expect( result ).toBe( 'Joe went to <a href="http://localhost:8000/page">localhost:8000/page</a> today.' ); | ||
} ); | ||
it( "should automatically link URLs with a port number and a query string", function() { | ||
@@ -96,2 +108,8 @@ var result = autolinker.link( "Joe went to http://yahoo.com:8000?page=index today." ); | ||
it( "should automatically link a localhost URL with a port number and a query string", function() { | ||
var result = autolinker.link( "Joe went to http://localhost:8000?page=index today." ); | ||
expect( result ).toBe( 'Joe went to <a href="http://localhost:8000?page=index">localhost:8000?page=index</a> today.' ); | ||
} ); | ||
it( "should automatically link URLs with a port number and a hash string", function() { | ||
@@ -103,2 +121,8 @@ var result = autolinker.link( "Joe went to http://yahoo.com:8000#page=index today." ); | ||
it( "should automatically link a localhost URL with a port number and a hash string", function() { | ||
var result = autolinker.link( "Joe went to http://localhost:8000#page=index today." ); | ||
expect( result ).toBe( 'Joe went to <a href="http://localhost:8000#page=index">localhost:8000#page=index</a> today.' ); | ||
} ); | ||
it( "should NOT automatically link strings of the form 'git:d' (using the heuristic that the domain name does not have a '.' in it)", function() { | ||
@@ -140,14 +164,24 @@ var result = autolinker.link( 'Something like git:d should not be linked as a URL' ); | ||
'END:VEVENT', | ||
'END:VCALENDAR' | ||
'END:VCALENDAR', | ||
'START:123:SOMETHING' | ||
]; | ||
var i, len = strings.length, str; | ||
for( var i = 0, len = strings.length; i < len; i++ ) { | ||
expect( autolinker.link( strings[ i ] ) ).toBe( strings[ i ] ); // none should be autolinked | ||
// Test with just the strings themselves. | ||
for( i = 0; i < len; i++ ) { | ||
str = strings[ i ]; | ||
expect( autolinker.link( str ) ).toBe( str ); // none should be autolinked | ||
} | ||
// Test with the strings surrounded by other text | ||
for( i = 0; i < len; i++ ) { | ||
str = strings[ i ]; | ||
expect( autolinker.link( 'test ' + str + ' test' ) ).toBe( 'test ' + str + ' test' ); // none should be autolinked | ||
} | ||
} ); | ||
it( "should NOT include preceding : introductions without a space", function() { | ||
it( "should NOT include preceding ':' introductions without a space", function() { | ||
var result = autolinker.link( 'the link:http://example.com/' ); | ||
expect( result ).toBe( 'the link:<a href="http://example.com/">example.com</a>' ); | ||
}); | ||
} ); | ||
@@ -360,2 +394,3 @@ } ); | ||
it( "should include * in URLs", function() { | ||
@@ -372,2 +407,3 @@ var result = autolinker.link( "Google from wayback http://wayback.archive.org/web/*/http://google.com" ); | ||
it( "should include ' in URLs", function() { | ||
@@ -383,2 +419,8 @@ var result = autolinker.link( "You are a star http://en.wikipedia.org/wiki/You're_a_Star/" ); | ||
} ); | ||
it( "should include [ and ] in URLs with query strings", function() { | ||
var result = autolinker.link( "Go to https://example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6 today" ); | ||
expect( result ).toBe( 'Go to <a href="https://example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6">example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6</a> today' ); | ||
} ); | ||
@@ -385,0 +427,0 @@ } ); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3159418
472
4871