<commit_before>/**
 * Linky++ v0.2.1
 * 
 * @link		https://github.com/AnSavvides/jquery.linky
 * @link		https://github.com/MarQuisKnox/jquery.linky
 * @license		MIT
 *
 * @copyright	2013 - 2015 <NAME> et al
 * @copyright	2014 - 2015 <NAME>
*/

(function($) {

    'use strict';

    $.fn.linky = function(options) {
        return this.each( function() {
            var $el					= $(this);
            var linkifiedContent	= _linkify( $el, options );

            $el.html( linkifiedContent );
        });
    };

    function _linkify( $el, options ) {
        var links = {
                local: {
                    baseUrl: BASEURL + "/",
                    hashtagSearchUrl: "search/",
                    target: '_self'
                },        		
                twitter: {
                    baseUrl: "https://twitter.com/",
                    hashtagSearchUrl: "search?q=",
                    target: '_blank'
                },
                instagram: {
                    baseUrl: "http://instagram.com/",
                    hashtagSearchUrl: null,
                    target: '_blank'
                },
                github: {
                    baseUrl: "https://github.com/",
                    hashtagSearchUrl: null,
                    target: '_blank'
                }
            },
            defaultOptions = {
                mentions: true,
                hashtags: false,
                urls: true,
                linkTo: 'local',
                target: '_blank',
                scheme: 'http://'
            },
            extendedOptions = $.extend(defaultOptions, options),
            elContent = $el.html(),

            // @link	http://snipplr.com/view/68530/regular-expression-for-matching-urls-with-or-without-https
            urlRegEx = /(?:(?:http|https):\/\/)?([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi,
            matches;

            // Linkifying URLs
            if ( extendedOptions.urls ) {
                matches = elContent.match( urlRegEx );
                if ( matches ) {
                    elContent = _linkifyUrls( matches, $el, extendedOptions );
                }
            }

            // Linkifying mentions
            if (extendedOptions.mentions) {
                elContent = _linkifyMentions(elContent, links[extendedOptions.linkTo].baseUrl);
            }

            // Linkifying hashtags
            if (extendedOptions.hashtags) {
                elContent = _linkifyHashtags(elContent, links[extendedOptions.linkTo]);
            }

        return elContent;
    }
    
    function _hasScheme( url ) {
    	var regEx = /ed2k|ftp|http|https|news|nntp/;
    	if( url.match( regEx ) ) {
    		return true;
    	}
    	
    	return false;
    }
    
    function _isEmbed( url ) {
    	// check for Dailymotion embed
    	var isDailymotionEmbed	= url.match( /dailymotion\.com\/embed/ig );
    	isDailymotionEmbed		= ( isDailymotionEmbed !== null ) ? true : false;
    	
    	if( isDailymotionEmbed ) {
    		return true;
    	}
    	    	
    	// check for Vimeo embed
    	var isVimeoEmbed	= url.match( /player\.vimeo\.com\/video/ig );
    	isVimeoEmbed		= ( isVimeoEmbed !== null ) ? true : false;
    	
    	if( isVimeoEmbed ) {
    		return true;
    	}    	
    	
    	// check for YouTube embed
    	var isYouTubeEmbed      = url.match( /youtube\.com\/embed/ig );
    	var isYouTubeAltEmbed   = url.match( /youtube\-nocookie\.com\/embed/ig );
    	isYouTubeEmbed          = ( isYouTubeEmbed !== null || isYouTubeAltEmbed !== null ) ? true : false;
    	
    	if( isYouTubeEmbed ) {
    		return true;
    	}
    	
    	return false;
    }    

    function _linkifyUrls( matches, $el, linkObj ) {
        
    	var elContent = $el.html();
        $.each( matches, function( index, value ) {
        	
        	// check if embed
        	var isEmbed = _isEmbed( value );
        	
        	// check for scheme
        	var scheme = ( _hasScheme( value ) ) ? '' : linkObj.scheme;        	
        	
        	       
            if ( !isEmbed && $el.find('a[href="' + scheme + this + '"]').length === 0 ) {
                elContent = elContent.replace( this, '<a class="linkified" href="' + scheme + this + '" target="'+ linkObj.target +'">' + this + '</a>' );
            }
            
        });

        return elContent;
    }

    // Find any mentions (e.g. @andreassavvides) and turn them into links that<commit_msg>FIXED:  SoundCloud embed code detection<commit_after>/**
 * Linky++ v0.2.2
 * 
 * @link		https://github.com/AnSavvides/jquery.linky
 * @link		https://github.com/MarQuisKnox/jquery.linky
 * @license		MIT <http://en.wikipedia.org/wiki/MIT_License>
 *
 * @copyright	2013 - 2015 <NAME> et al
 * @copyright	2014 - 2015 <NAME>
*/

(function($) {

    'use strict';

    $.fn.linky = function(options) {
        return this.each( function() {
            var $el					= $(this);
            var linkifiedContent	= _linkify( $el, options );

            $el.html( linkifiedContent );
        });
    };

    function _linkify( $el, options ) {
        var links = {
                local: {
                    baseUrl: BASEURL + "/",
                    hashtagSearchUrl: "search/",
                    target: '_self'
                },        		
                twitter: {
                    baseUrl: "https://twitter.com/",
                    hashtagSearchUrl: "search?q=",
                    target: '_blank'
                },
                instagram: {
                    baseUrl: "http://instagram.com/",
                    hashtagSearchUrl: null,
                    target: '_blank'
                },
                github: {
                    baseUrl: "https://github.com/",
                    hashtagSearchUrl: null,
                    target: '_blank'
                }
            },
            defaultOptions = {
                mentions: true,
                hashtags: false,
                urls: true,
                linkTo: 'local',
                target: '_blank',
                scheme: 'http://'
            },
            extendedOptions = $.extend(defaultOptions, options),
            elContent = $el.html(),

            // @link	http://snipplr.com/view/68530/regular-expression-for-matching-urls-with-or-without-https
            urlRegEx = /(?:(?:http|https):\/\/)?([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi,
            matches;

            // Linkifying URLs
            if ( extendedOptions.urls ) {
                matches = elContent.match( urlRegEx );
                if ( matches ) {
                    elContent = _linkifyUrls( matches, $el, extendedOptions );
                }
            }

            // Linkifying mentions
            if (extendedOptions.mentions) {
                elContent = _linkifyMentions(elContent, links[extendedOptions.linkTo].baseUrl);
            }

            // Linkifying hashtags
            if (extendedOptions.hashtags) {
                elContent = _linkifyHashtags(elContent, links[extendedOptions.linkTo]);
            }

        return elContent;
    }
    
    function _hasScheme( url ) {
    	var regEx = /ed2k|ftp|http|https|news|nntp/;
    	if( url.match( regEx ) ) {
    		return true;
    	}
    	
    	return false;
    }
    
    function _isEmbed( url ) {
    	
    	// check for Dailymotion embed
    	var isDailymotionEmbed	= url.match( /dailymotion\.com\/embed/ig );
    	isDailymotionEmbed		= ( isDailymotionEmbed !== null ) ? true : false;
    	
    	if( isDailymotionEmbed ) {
    		return true;
    	}
    	
    	// check for SoundCloud embed
    	var isSoundCloudEmbed	= url.match( /w\.soundcloud\.com\/player/ig );
    	isSoundCloudEmbed		= ( isSoundCloudEmbed !== null ) ? true : false;
    	
    	if( isSoundCloudEmbed ) {
    		return true;
    	}    	
    	    	
    	// check for Vimeo embed
    	var isVimeoEmbed	= url.match( /player\.vimeo\.com\/video/ig );
    	isVimeoEmbed		= ( isVimeoEmbed !== null ) ? true : false;
    	
    	if( isVimeoEmbed ) {
    		return true;
    	}    	
    	
    	// check for YouTube embed
    	var isYouTubeEmbed      = url.match( /youtube\.com\/embed/ig );
    	var isYouTubeAltEmbed   = url.match( /youtube\-nocookie\.com\/embed/ig );
    	isYouTubeEmbed          = ( isYouTubeEmbed !== null || isYouTubeAltEmbed !== null ) ? true : false;
    	
    	if( isYouTubeEmbed ) {
    		return true;
    	}
    	
    	return false;
    	
    }    

    function _linkifyUrls( matches, $el, linkObj ) {
        
    	var elContent = $el.html();
        $.each( matches, function( index, value ) {
        	
        	// check if embed
        	var isEmbed = _isEmbed( value );
        	
        	// check for scheme
        	var scheme = ( _hasScheme( value ) ) ? '' : linkObj.scheme;        	
        	
        	       
            if ( !isEmbed && $el.find('a[href="' + scheme + this + '"]').length === 0 ) {
                elContent = elContent.replace( this, '<a class="linkified" href="' + scheme + this + '" target="'+ linkObj.target +'">' + this + '</a>' );
            }
            
        });

        return elContent;
    }

    // Find any mentions (e.g. @andreassavvides) and turn them into links that
{'fraction_non_alphanumeric': 0.13225911106304747, 'fraction_numerical': 0.007786309073212934, 'mean_word_length': 1.3859649122807018, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2705858', 'n_tokens_mistral': 3032, 'n_tokens_neox': 2809, 'n_words': 539}