Skip to content

Instantly share code, notes, and snippets.

@jakl
Created April 3, 2014 21:41
Show Gist options
  • Save jakl/9963471 to your computer and use it in GitHub Desktop.
Save jakl/9963471 to your computer and use it in GitHub Desktop.
requirebin sketch
// require something
require('twitter-text')
require=function e(t,a,r){function n(s,l){if(!a[s]){if(!t[s]){var o="function"==typeof require&&require;if(!l&&o)return o(s,!0);if(i)return i(s,!0);throw Error("Cannot find module '"+s+"'")}var c=a[s]={exports:{}};t[s][0].call(c.exports,function(e){var a=t[s][1][e];return n(a?a:e)},c,c.exports,e,t,a,r)}return a[s].exports}for(var i="function"==typeof require&&require,s=0;r.length>s;s++)n(r[s]);return n}({OczzTA:[function(t,e){(function(){function t(t,e){return e=e||"","string"!=typeof t&&(t.global&&0>e.indexOf("g")&&(e+="g"),t.ignoreCase&&0>e.indexOf("i")&&(e+="i"),t.multiline&&0>e.indexOf("m")&&(e+="m"),t=t.source),RegExp(t.replace(/#\{(\w+)\}/g,function(t,e){var a=s.txt.regexen[e]||"";return"string"!=typeof a&&(a=a.source),a}),e)}function a(t,e){return t.replace(/#\{(\w+)\}/g,function(t,a){return e[a]||""})}function r(t,e,a){var r=String.fromCharCode(e);return a!==e&&(r+="-"+String.fromCharCode(a)),t.push(r),t}function n(t){var e={};for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a]);return e}function i(t,e,a){return a?!t||t.match(e)&&RegExp["$&"]===t:"string"==typeof t&&t.match(e)&&RegExp["$&"]===t}if(s===void 0||null===s)var s={};s.txt={},s.txt.regexen={};var l={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#39;"};s.txt.htmlEscape=function(t){return t&&t.replace(/[&"'><]/g,function(t){return l[t]})},s.txt.regexSupplant=t,s.txt.stringSupplant=a,s.txt.addCharsToCharClass=r;var o=String.fromCharCode,c=[o(32),o(133),o(160),o(5760),o(6158),o(8232),o(8233),o(8239),o(8287),o(12288)];r(c,9,13),r(c,8192,8202);var h=[o(65534),o(65279),o(65535)];r(h,8234,8238),s.txt.regexen.spaces_group=t(c.join("")),s.txt.regexen.spaces=t("["+c.join("")+"]"),s.txt.regexen.invalid_chars_group=t(h.join("")),s.txt.regexen.punct=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/,s.txt.regexen.rtl_chars=/[\u0600-\u06FF]|[\u0750-\u077F]|[\u0590-\u05FF]|[\uFE70-\uFEFF]/gm,s.txt.regexen.non_bmp_code_pairs=/[\uD800-\uDBFF][\uDC00-\uDFFF]/gm;var x=[];r(x,1024,1279),r(x,1280,1319),r(x,11744,11775),r(x,42560,42655),r(x,1425,1471),r(x,1473,1474),r(x,1476,1477),r(x,1479,1479),r(x,1488,1514),r(x,1520,1524),r(x,64274,64296),r(x,64298,64310),r(x,64312,64316),r(x,64318,64318),r(x,64320,64321),r(x,64323,64324),r(x,64326,64335),r(x,1552,1562),r(x,1568,1631),r(x,1646,1747),r(x,1749,1756),r(x,1758,1768),r(x,1770,1775),r(x,1786,1788),r(x,1791,1791),r(x,1872,1919),r(x,2208,2208),r(x,2210,2220),r(x,2276,2302),r(x,64336,64433),r(x,64467,64829),r(x,64848,64911),r(x,64914,64967),r(x,65008,65019),r(x,65136,65140),r(x,65142,65276),r(x,8204,8204),r(x,3585,3642),r(x,3648,3662),r(x,4352,4607),r(x,12592,12677),r(x,43360,43391),r(x,44032,55215),r(x,55216,55295),r(x,65441,65500),r(x,12449,12538),r(x,12540,12542),r(x,65382,65439),r(x,65392,65392),r(x,65296,65305),r(x,65313,65338),r(x,65345,65370),r(x,12353,12438),r(x,12441,12446),r(x,13312,19903),r(x,19968,40959),r(x,173824,177983),r(x,177984,178207),r(x,194560,195103),r(x,12291,12291),r(x,12293,12293),r(x,12347,12347),s.txt.regexen.nonLatinHashtagChars=t(x.join(""));var g=[];r(g,192,214),r(g,216,246),r(g,248,255),r(g,256,591),r(g,595,596),r(g,598,599),r(g,601,601),r(g,603,603),r(g,611,611),r(g,616,616),r(g,623,623),r(g,626,626),r(g,649,649),r(g,651,651),r(g,699,699),r(g,768,879),r(g,7680,7935),s.txt.regexen.latinAccentChars=t(g.join("")),s.txt.regexen.hashSigns=/[##]/,s.txt.regexen.hashtagAlpha=t(/[a-z_#{latinAccentChars}#{nonLatinHashtagChars}]/i),s.txt.regexen.hashtagAlphaNumeric=t(/[a-z0-9_#{latinAccentChars}#{nonLatinHashtagChars}]/i),s.txt.regexen.endHashtagMatch=t(/^(?:#{hashSigns}|:\/\/)/),s.txt.regexen.hashtagBoundary=t(/(?:^|$|[^&a-z0-9_#{latinAccentChars}#{nonLatinHashtagChars}])/),s.txt.regexen.validHashtag=t(/(#{hashtagBoundary})(#{hashSigns})(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi),s.txt.regexen.validMentionPrecedingChars=/(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:rt|RT|rT|Rt):?)/,s.txt.regexen.atSigns=/[@@]/,s.txt.regexen.validMentionOrList=t("(#{validMentionPrecedingChars})(#{atSigns})([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?","g"),s.txt.regexen.validReply=t(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/),s.txt.regexen.endMentionMatch=t(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/),s.txt.regexen.validUrlPrecedingChars=t(/(?:[^A-Za-z0-9@@$###{invalid_chars_group}]|^)/),s.txt.regexen.invalidUrlWithoutProtocolPrecedingChars=/[-_.\/]$/,s.txt.regexen.invalidDomainChars=a("#{punct}#{spaces_group}#{invalid_chars_group}",s.txt.regexen),s.txt.regexen.validDomainChars=t(/[^#{invalidDomainChars}]/),s.txt.regexen.validSubdomain=t(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/),s.txt.regexen.validDomainName=t(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/),s.txt.regexen.validGTLD=t(RegExp("(?:(?:academy|actor|aero|agency|arpa|asia|bar|bargains|berlin|best|bid|bike|biz|blue|boutique|build|builders|buzz|cab|camera|camp|cards|careers|cat|catering|center|ceo|cheap|christmas|cleaning|clothing|club|codes|coffee|com|community|company|computer|construction|contractors|cool|coop|cruises|dance|dating|democrat|diamonds|directory|domains|edu|education|email|enterprises|equipment|estate|events|expert|exposed|farm|fish|flights|florist|foundation|futbol|gallery|gift|glass|gov|graphics|guitars|guru|holdings|holiday|house|immobilien|industries|info|institute|int|international|jobs|kaufen|kim|kitchen|kiwi|koeln|kred|land|lighting|limo|link|luxury|management|mango|marketing|menu|mil|mobi|moda|monash|museum|nagoya|name|net|neustar|ninja|okinawa|onl|org|partners|parts|photo|photography|photos|pics|pink|plumbing|post|pro|productions|properties|pub|qpon|recipes|red|rentals|repair|report|reviews|rich|ruhr|sexy|shiksha|shoes|singles|social|solar|solutions|supplies|supply|support|systems|tattoo|technology|tel|tienda|tips|today|tokyo|tools|training|travel|uno|vacations|ventures|viajes|villas|vision|vote|voting|voto|voyage|wang|watch|wed|wien|wiki|works|xxx|xyz|zone|дети|онлайн|орг|сайт|بازار|شبكة|みんな|中信|中文网|公司|公益|在线|我爱你|政务|游戏|移动|网络|集团|삼성)(?=[^0-9a-zA-Z@]|$))")),s.txt.regexen.validCCTLD=t(RegExp("(?:(?: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|bl|bm|bn|bo|bq|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|eh|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|mf|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|ss|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|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw|мон|рф|срб|укр|қаз|الاردن|الجزائر|السعودية|المغرب|امارات|ایران|بھارت|تونس|سودان|سورية|عمان|فلسطين|قطر|مصر|مليسيا|پاکستان|भारत|বাংলা|ভারত|ਭਾਰਤ|ભારત|இந்தியா|இலங்கை|சிங்கப்பூர்|భారత్|ලංකා|ไทย|გე|中国|中國|台湾|台灣|新加坡|香港|한국)(?=[^0-9a-zA-Z@]|$))")),s.txt.regexen.validPunycode=t(/(?:xn--[0-9a-z]+)/),s.txt.regexen.validDomain=t(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/),s.txt.regexen.validAsciiDomain=t(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi),s.txt.regexen.invalidShortDomain=t(/^#{validDomainName}#{validCCTLD}$/),s.txt.regexen.validPortNumber=t(/[0-9]+/),s.txt.regexen.validGeneralUrlPathChars=t(/[a-z0-9!\*';:=\+,\.\$\/%#\[\]\-_~@|&#{latinAccentChars}]/i),s.txt.regexen.validUrlBalancedParens=t("\\((?:#{validGeneralUrlPathChars}+|(?:#{validGeneralUrlPathChars}*\\(#{validGeneralUrlPathChars}+\\)#{validGeneralUrlPathChars}*))\\)","i"),s.txt.regexen.validUrlPathEndingChars=t(/[\+\-a-z0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i),s.txt.regexen.validUrlPath=t("(?:(?:#{validGeneralUrlPathChars}*(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*#{validUrlPathEndingChars})|(?:@#{validGeneralUrlPathChars}+/))","i"),s.txt.regexen.validUrlQueryChars=/[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i,s.txt.regexen.validUrlQueryEndingChars=/[a-z0-9_&=#\/]/i,s.txt.regexen.extractUrl=t("((#{validUrlPrecedingChars})((https?:\\/\\/)?(#{validDomain})(?::(#{validPortNumber}))?(\\/#{validUrlPath}*)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))","gi"),s.txt.regexen.validTcoUrl=/^https?:\/\/t\.co\/[a-z0-9]+/i,s.txt.regexen.urlHasProtocol=/^https?:\/\//i,s.txt.regexen.urlHasHttps=/^https:\/\//i,s.txt.regexen.cashtag=/[a-z]{1,6}(?:[._][a-z]{1,2})?/i,s.txt.regexen.validCashtag=t("(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])","gi"),s.txt.regexen.validateUrlUnreserved=/[a-z0-9\-._~]/i,s.txt.regexen.validateUrlPctEncoded=/(?:%[0-9a-f]{2})/i,s.txt.regexen.validateUrlSubDelims=/[!$&'()*+,;=]/i,s.txt.regexen.validateUrlPchar=t("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|[:|@])","i"),s.txt.regexen.validateUrlScheme=/(?:[a-z][a-z0-9+\-.]*)/i,s.txt.regexen.validateUrlUserinfo=t("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*","i"),s.txt.regexen.validateUrlDecOctet=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i,s.txt.regexen.validateUrlIpv4=t(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i),s.txt.regexen.validateUrlIpv6=/(?:\[[a-f0-9:\.]+\])/i,s.txt.regexen.validateUrlIp=t("(?:#{validateUrlIpv4}|#{validateUrlIpv6})","i"),s.txt.regexen.validateUrlSubDomainSegment=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i,s.txt.regexen.validateUrlDomainSegment=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i,s.txt.regexen.validateUrlDomainTld=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i,s.txt.regexen.validateUrlDomain=t(/(?:(?:#{validateUrlSubDomainSegment]}\.)*(?:#{validateUrlDomainSegment]}\.)#{validateUrlDomainTld})/i),s.txt.regexen.validateUrlHost=t("(?:#{validateUrlIp}|#{validateUrlDomain})","i"),s.txt.regexen.validateUrlUnicodeSubDomainSegment=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,s.txt.regexen.validateUrlUnicodeDomainSegment=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,s.txt.regexen.validateUrlUnicodeDomainTld=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,s.txt.regexen.validateUrlUnicodeDomain=t(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i),s.txt.regexen.validateUrlUnicodeHost=t("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})","i"),s.txt.regexen.validateUrlPort=/[0-9]{1,5}/,s.txt.regexen.validateUrlUnicodeAuthority=t("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?","i"),s.txt.regexen.validateUrlAuthority=t("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?","i"),s.txt.regexen.validateUrlPath=t(/(\/#{validateUrlPchar}*)*/i),s.txt.regexen.validateUrlQuery=t(/(#{validateUrlPchar}|\/|\?)*/i),s.txt.regexen.validateUrlFragment=t(/(#{validateUrlPchar}|\/|\?)*/i),s.txt.regexen.validateUrlUnencoded=t("^(?:([^:/?#]+):\\/\\/)?([^/?#]*)([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");var u="tweet-url list-slug",d="tweet-url username",v="tweet-url hashtag",m="tweet-url cashtag",p={urlClass:!0,listClass:!0,usernameClass:!0,hashtagClass:!0,cashtagClass:!0,usernameUrlBase:!0,listUrlBase:!0,hashtagUrlBase:!0,cashtagUrlBase:!0,usernameUrlBlock:!0,listUrlBlock:!0,hashtagUrlBlock:!0,linkUrlBlock:!0,usernameIncludeSymbol:!0,suppressLists:!0,suppressNoFollow:!0,targetBlank:!0,suppressDataScreenName:!0,urlEntities:!0,symbolTag:!0,textWithSymbolTag:!0,urlTarget:!0,invisibleTagAttrs:!0,linkAttributeBlock:!0,linkTextBlock:!0,htmlEscapeNonEntities:!0},f={disabled:!0,readonly:!0,multiple:!0,checked:!0};s.txt.tagAttrs=function(t){var e="";for(var a in t){var r=t[a];f[a]&&(r=r?a:null),null!=r&&(e+=" "+s.txt.htmlEscape(a)+'="'+s.txt.htmlEscape(""+r)+'"')}return e},s.txt.linkToText=function(t,e,r,n){n.suppressNoFollow||(r.rel="nofollow"),n.linkAttributeBlock&&n.linkAttributeBlock(t,r),n.linkTextBlock&&(e=n.linkTextBlock(t,e));var i={text:e,attr:s.txt.tagAttrs(r)};return a("<a#{attr}>#{text}</a>",i)},s.txt.linkToTextWithSymbol=function(t,e,a,r,n){var i=n.symbolTag?"<"+n.symbolTag+">"+e+"</"+n.symbolTag+">":e;a=s.txt.htmlEscape(a);var l=n.textWithSymbolTag?"<"+n.textWithSymbolTag+">"+a+"</"+n.textWithSymbolTag+">":a;return n.usernameIncludeSymbol||!e.match(s.txt.regexen.atSigns)?s.txt.linkToText(t,i+l,r,n):i+s.txt.linkToText(t,l,r,n)},s.txt.linkToHashtag=function(t,e,a){var r=e.substring(t.indices[0],t.indices[0]+1),i=s.txt.htmlEscape(t.hashtag),l=n(a.htmlAttrs||{});return l.href=a.hashtagUrlBase+i,l.title="#"+i,l["class"]=a.hashtagClass,i.charAt(0).match(s.txt.regexen.rtl_chars)&&(l["class"]+=" rtl"),a.targetBlank&&(l.target="_blank"),s.txt.linkToTextWithSymbol(t,r,i,l,a)},s.txt.linkToCashtag=function(t,e,a){var r=s.txt.htmlEscape(t.cashtag),i=n(a.htmlAttrs||{});return i.href=a.cashtagUrlBase+r,i.title="$"+r,i["class"]=a.cashtagClass,a.targetBlank&&(i.target="_blank"),s.txt.linkToTextWithSymbol(t,"$",r,i,a)},s.txt.linkToMentionAndList=function(t,e,a){var r=e.substring(t.indices[0],t.indices[0]+1),i=s.txt.htmlEscape(t.screenName),l=s.txt.htmlEscape(t.listSlug),o=t.listSlug&&!a.suppressLists,c=n(a.htmlAttrs||{});return c["class"]=o?a.listClass:a.usernameClass,c.href=o?a.listUrlBase+i+l:a.usernameUrlBase+i,o||a.suppressDataScreenName||(c["data-screen-name"]=i),a.targetBlank&&(c.target="_blank"),s.txt.linkToTextWithSymbol(t,r,o?i+l:i,c,a)},s.txt.linkToUrl=function(t,e,a){var r=t.url,i=r,l=s.txt.htmlEscape(i),o=a.urlEntities&&a.urlEntities[r]||t;o.display_url&&(l=s.txt.linkTextWithEntity(o,a));var c=n(a.htmlAttrs||{});return r.match(s.txt.regexen.urlHasProtocol)||(r="http://"+r),c.href=r,a.targetBlank&&(c.target="_blank"),a.urlClass&&(c["class"]=a.urlClass),a.urlTarget&&(c.target=a.urlTarget),!a.title&&o.display_url&&(c.title=o.expanded_url),s.txt.linkToText(t,l,c,a)},s.txt.linkTextWithEntity=function(t,e){var r=t.display_url,n=t.expanded_url,i=r.replace(/…/g,"");if(-1!=n.indexOf(i)){var l=n.indexOf(i),o={displayUrlSansEllipses:i,beforeDisplayUrl:n.substr(0,l),afterDisplayUrl:n.substr(l+i.length),precedingEllipsis:r.match(/^…/)?"…":"",followingEllipsis:r.match(/…$/)?"…":""};for(var c in o)o.hasOwnProperty(c)&&(o[c]=s.txt.htmlEscape(o[c]));return o.invisible=e.invisibleTagAttrs,a("<span class='tco-ellipsis'>#{precedingEllipsis}<span #{invisible}>&nbsp;</span></span><span #{invisible}>#{beforeDisplayUrl}</span><span class='js-display-url'>#{displayUrlSansEllipses}</span><span #{invisible}>#{afterDisplayUrl}</span><span class='tco-ellipsis'><span #{invisible}>&nbsp;</span>#{followingEllipsis}</span>",o)}return r},s.txt.autoLinkEntities=function(t,e,a){a=n(a||{}),a.hashtagClass=a.hashtagClass||v,a.hashtagUrlBase=a.hashtagUrlBase||"https://twitter.com/#!/search?q=%23",a.cashtagClass=a.cashtagClass||m,a.cashtagUrlBase=a.cashtagUrlBase||"https://twitter.com/#!/search?q=%24",a.listClass=a.listClass||u,a.usernameClass=a.usernameClass||d,a.usernameUrlBase=a.usernameUrlBase||"https://twitter.com/",a.listUrlBase=a.listUrlBase||"https://twitter.com/",a.htmlAttrs=s.txt.extractHtmlAttrsFromOptions(a),a.invisibleTagAttrs=a.invisibleTagAttrs||"style='position:absolute;left:-9999px;'";var r,i,l;if(a.urlEntities){for(r={},i=0,l=a.urlEntities.length;l>i;i++)r[a.urlEntities[i].url]=a.urlEntities[i];a.urlEntities=r}var o="",c=0;e.sort(function(t,e){return t.indices[0]-e.indices[0]});for(var h=a.htmlEscapeNonEntities?s.txt.htmlEscape:function(t){return t},i=0;e.length>i;i++){var x=e[i];o+=h(t.substring(c,x.indices[0])),x.url?o+=s.txt.linkToUrl(x,t,a):x.hashtag?o+=s.txt.linkToHashtag(x,t,a):x.screenName?o+=s.txt.linkToMentionAndList(x,t,a):x.cashtag&&(o+=s.txt.linkToCashtag(x,t,a)),c=x.indices[1]}return o+=h(t.substring(c,t.length))},s.txt.autoLinkWithJSON=function(t,e,a){if(e.user_mentions)for(var r=0;e.user_mentions.length>r;r++)e.user_mentions[r].screenName=e.user_mentions[r].screen_name;if(e.hashtags)for(var r=0;e.hashtags.length>r;r++)e.hashtags[r].hashtag=e.hashtags[r].text;if(e.symbols)for(var r=0;e.symbols.length>r;r++)e.symbols[r].cashtag=e.symbols[r].text;var n=[];for(var i in e)n=n.concat(e[i]);return s.txt.modifyIndicesFromUnicodeToUTF16(t,n),s.txt.autoLinkEntities(t,n,a)},s.txt.extractHtmlAttrsFromOptions=function(t){var e={};for(var a in t){var r=t[a];p[a]||(f[a]&&(r=r?a:null),null!=r&&(e[a]=r))}return e},s.txt.autoLink=function(t,e){var a=s.txt.extractEntitiesWithIndices(t,{extractUrlsWithoutProtocol:!1});return s.txt.autoLinkEntities(t,a,e)},s.txt.autoLinkUsernamesOrLists=function(t,e){var a=s.txt.extractMentionsOrListsWithIndices(t);return s.txt.autoLinkEntities(t,a,e)},s.txt.autoLinkHashtags=function(t,e){var a=s.txt.extractHashtagsWithIndices(t);return s.txt.autoLinkEntities(t,a,e)},s.txt.autoLinkCashtags=function(t,e){var a=s.txt.extractCashtagsWithIndices(t);return s.txt.autoLinkEntities(t,a,e)},s.txt.autoLinkUrlsCustom=function(t,e){var a=s.txt.extractUrlsWithIndices(t,{extractUrlsWithoutProtocol:!1});return s.txt.autoLinkEntities(t,a,e)},s.txt.removeOverlappingEntities=function(t){t.sort(function(t,e){return t.indices[0]-e.indices[0]});for(var e=t[0],a=1;t.length>a;a++)e.indices[1]>t[a].indices[0]?(t.splice(a,1),a--):e=t[a]},s.txt.extractEntitiesWithIndices=function(t,e){var a=s.txt.extractUrlsWithIndices(t,e).concat(s.txt.extractMentionsOrListsWithIndices(t)).concat(s.txt.extractHashtagsWithIndices(t,{checkUrlOverlap:!1})).concat(s.txt.extractCashtagsWithIndices(t));return 0==a.length?[]:(s.txt.removeOverlappingEntities(a),a)},s.txt.extractMentions=function(t){for(var e=[],a=s.txt.extractMentionsWithIndices(t),r=0;a.length>r;r++){var n=a[r].screenName;e.push(n)}return e},s.txt.extractMentionsWithIndices=function(t){for(var e,a=[],r=s.txt.extractMentionsOrListsWithIndices(t),n=0;r.length>n;n++)e=r[n],""==e.listSlug&&a.push({screenName:e.screenName,indices:e.indices});return a},s.txt.extractMentionsOrListsWithIndices=function(t){if(!t||!t.match(s.txt.regexen.atSigns))return[];var e=[];return t.replace(s.txt.regexen.validMentionOrList,function(t,a,r,n,i,l,o){var c=o.slice(l+t.length);if(!c.match(s.txt.regexen.endMentionMatch)){i=i||"";var h=l+a.length,x=h+n.length+i.length+1;e.push({screenName:n,listSlug:i,indices:[h,x]})}}),e},s.txt.extractReplies=function(t){if(!t)return null;var e=t.match(s.txt.regexen.validReply);return!e||RegExp.rightContext.match(s.txt.regexen.endMentionMatch)?null:e[1]},s.txt.extractUrls=function(t,e){for(var a=[],r=s.txt.extractUrlsWithIndices(t,e),n=0;r.length>n;n++)a.push(r[n].url);return a},s.txt.extractUrlsWithIndices=function(t,e){if(e||(e={extractUrlsWithoutProtocol:!0}),!t||(e.extractUrlsWithoutProtocol?!t.match(/\./):!t.match(/:/)))return[];for(var a=[];s.txt.regexen.extractUrl.exec(t);){var r=RegExp.$2,n=RegExp.$3,i=RegExp.$4,l=RegExp.$5,o=RegExp.$7,c=s.txt.regexen.extractUrl.lastIndex,h=c-n.length;if(i)n.match(s.txt.regexen.validTcoUrl)&&(n=RegExp.lastMatch,c=h+n.length),a.push({url:n,indices:[h,c]});else{if(!e.extractUrlsWithoutProtocol||r.match(s.txt.regexen.invalidUrlWithoutProtocolPrecedingChars))continue;var x=null,g=!1,u=0;if(l.replace(s.txt.regexen.validAsciiDomain,function(t){var e=l.indexOf(t,u);u=e+t.length,x={url:t,indices:[h+e,h+u]},g=t.match(s.txt.regexen.invalidShortDomain),g||a.push(x)}),null==x)continue;o&&(g&&a.push(x),x.url=n.replace(l,x.url),x.indices[1]=c)}}return a},s.txt.extractHashtags=function(t){for(var e=[],a=s.txt.extractHashtagsWithIndices(t),r=0;a.length>r;r++)e.push(a[r].hashtag);return e},s.txt.extractHashtagsWithIndices=function(t,e){if(e||(e={checkUrlOverlap:!0}),!t||!t.match(s.txt.regexen.hashSigns))return[];var a=[];if(t.replace(s.txt.regexen.validHashtag,function(t,e,r,n,i,l){var o=l.slice(i+t.length);if(!o.match(s.txt.regexen.endHashtagMatch)){var c=i+e.length,h=c+n.length+1;a.push({hashtag:n,indices:[c,h]})}}),e.checkUrlOverlap){var r=s.txt.extractUrlsWithIndices(t);if(r.length>0){var n=a.concat(r);s.txt.removeOverlappingEntities(n),a=[];for(var i=0;n.length>i;i++)n[i].hashtag&&a.push(n[i])}}return a},s.txt.extractCashtags=function(t){for(var e=[],a=s.txt.extractCashtagsWithIndices(t),r=0;a.length>r;r++)e.push(a[r].cashtag);return e},s.txt.extractCashtagsWithIndices=function(t){if(!t||-1==t.indexOf("$"))return[];var e=[];return t.replace(s.txt.regexen.validCashtag,function(t,a,r,n,i){var s=i+a.length,l=s+n.length+1;e.push({cashtag:n,indices:[s,l]})}),e},s.txt.modifyIndicesFromUnicodeToUTF16=function(t,e){s.txt.convertUnicodeIndices(t,e,!1)},s.txt.modifyIndicesFromUTF16ToUnicode=function(t,e){s.txt.convertUnicodeIndices(t,e,!0)},s.txt.getUnicodeTextLength=function(t){return t.replace(s.txt.regexen.non_bmp_code_pairs," ").length},s.txt.convertUnicodeIndices=function(t,e,a){if(0!=e.length){var r=0,n=0;e.sort(function(t,e){return t.indices[0]-e.indices[0]});for(var i=0,s=e[0];t.length>r;){if(s.indices[0]==(a?r:n)){var l=s.indices[1]-s.indices[0];if(s.indices[0]=a?n:r,s.indices[1]=s.indices[0]+l,i++,i==e.length)break;s=e[i]}var o=t.charCodeAt(r);o>=55296&&56319>=o&&t.length-1>r&&(o=t.charCodeAt(r+1),o>=56320&&57343>=o&&r++),n++,r++}}},s.txt.splitTags=function(t){for(var e,a,r=t.split("<"),n=[],i=0;r.length>i;i+=1)if(a=r[i]){e=a.split(">");for(var s=0;e.length>s;s+=1)n.push(e[s])}else n.push("");return n},s.txt.hitHighlight=function(t,e,a){var r="em";if(e=e||[],a=a||{},0===e.length)return t;var n,i,l,o,c,h,x,g=a.tag||r,u=["<"+g+">","</"+g+">"],d=s.txt.splitTags(t),v="",m=0,p=d[0],f=0,U=0,b=!1,k=p,C=[];for(n=0;e.length>n;n+=1)for(i=0;e[n].length>i;i+=1)C.push(e[n][i]);for(l=0;C.length>l;l+=1){for(o=C[l],c=u[l%2],h=!1;null!=p&&o>=f+p.length;)v+=k.slice(U),b&&o===f+k.length&&(v+=c,h=!0),d[m+1]&&(v+="<"+d[m+1]+">"),f+=k.length,U=0,m+=2,p=d[m],k=p,b=!1;h||null==p?h||(h=!0,v+=c):(x=o-f,v+=k.slice(U,x)+c,U=x,b=0===l%2?!0:!1)}if(null!=p)for(k.length>U&&(v+=k.slice(U)),l=m+1;d.length>l;l+=1)v+=0===l%2?d[l]:"<"+d[l]+">";return v};var U=140,b=[o(65534),o(65279),o(65535),o(8234),o(8235),o(8236),o(8237),o(8238)];s.txt.getTweetLength=function(t,e){e||(e={short_url_length:22,short_url_length_https:23});var a=s.txt.getUnicodeTextLength(t),r=s.txt.extractUrlsWithIndices(t);s.txt.modifyIndicesFromUTF16ToUnicode(t,r);for(var n=0;r.length>n;n++)a+=r[n].indices[0]-r[n].indices[1],a+=r[n].url.toLowerCase().match(s.txt.regexen.urlHasHttps)?e.short_url_length_https:e.short_url_length;return a},s.txt.isInvalidTweet=function(t){if(!t)return"empty";if(s.txt.getTweetLength(t)>U)return"too_long";for(var e=0;b.length>e;e++)if(t.indexOf(b[e])>=0)return"invalid_characters";return!1},s.txt.isValidTweetText=function(t){return!s.txt.isInvalidTweet(t)},s.txt.isValidUsername=function(t){if(!t)return!1;var e=s.txt.extractMentions(t);return 1===e.length&&e[0]===t.slice(1)};var k=t(/^#{validMentionOrList}$/);if(s.txt.isValidList=function(t){var e=t.match(k);return!(!e||""!=e[1]||!e[4])},s.txt.isValidHashtag=function(t){if(!t)return!1;var e=s.txt.extractHashtags(t);return 1===e.length&&e[0]===t.slice(1)},s.txt.isValidUrl=function(t,e,a){if(null==e&&(e=!0),null==a&&(a=!0),!t)return!1;var r=t.match(s.txt.regexen.validateUrlUnencoded);if(!r||r[0]!==t)return!1;var n=r[1],l=r[2],o=r[3],c=r[4],h=r[5];return(!a||i(n,s.txt.regexen.validateUrlScheme)&&n.match(/^https?$/i))&&i(o,s.txt.regexen.validateUrlPath)&&i(c,s.txt.regexen.validateUrlQuery,!0)&&i(h,s.txt.regexen.validateUrlFragment,!0)?e&&i(l,s.txt.regexen.validateUrlUnicodeAuthority)||!e&&i(l,s.txt.regexen.validateUrlAuthority):!1},e!==void 0&&e.exports&&(e.exports=s.txt),"undefined"!=typeof window)if(window.twttr)for(var C in s)window.twttr[C]=s[C];else window.twttr=s})()},{}],"twitter-text":[function(t,e){e.exports=t("OczzTA")},{}]},{},[]),require("twitter-text");
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"twitter-text": "1.9.0"
}
}
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment