<commit_before>var cheerio = require ( 'cheerio' );
var request = require ( 'request' );

var getSVGs = function getSVGs ( req , html , callback ) {
	var $     = cheerio.load ( html );
	var cache = {};
	
	var $imgs    = $ ( 'img[src*=".svg"]' );
	var promises = $imgs.length;
	
	$imgs.each ( function () {
		var $img   = $ ( this );
		var src    = $img.attr ( 'src' );
		var remote = src.startsWith ( 'http' ) || src.startsWith ( '//' );
		
		if ( ! cache.hasOwnProperty ( src.toString () ) ) {
			var url = remote ? src : req.protocol + '://' + req.headers.host + src;
			
			request ( url , function ( err , res , body ) {
				if ( ! err ) {
					cache[ src ] = body;
				}
				
				$img.parent ().append ( cache[ src ] );
				$img.remove ();
				
				promises --;
				if ( promises <= 0 ) {
					callback ( $.html () );
				}
			} );
		} else {
			$img.parent ().append ( cache[ src ] );
			$img.remove ();
			
			promises --;
			if ( promises <= 0 ) {
				callback ( $.html () );
			}
		}
	} );
};

var InlineSVG = function InlineSVG ( req , html , callback ) {
	getSVGs ( req , html , function ( parsedHtml ) {
		return callback ( parsedHtml );
	} );
};

module.exports = InlineSVG;<commit_msg>add ignore for svgs we don’t want converted<commit_after>var cheerio = require ( 'cheerio' );
var request = require ( 'request' );

var getSVGs = function getSVGs ( req , html , callback ) {
	var $     = cheerio.load ( html );
	var cache = {};
	
	var $imgs    = $ ( 'img[src*=".svg"]:not([data-convert-ignore])' );
	var promises = $imgs.length;
	
	$imgs.each ( function () {
		var $img   = $ ( this );
		var src    = $img.attr ( 'src' );
		var remote = src.startsWith ( 'http' ) || src.startsWith ( '//' );
		
		if ( ! cache.hasOwnProperty ( src.toString () ) ) {
			var url = remote ? src : req.protocol + '://' + req.headers.host + src;
			
			request ( url , function ( err , res , body ) {
				if ( ! err ) {
					cache[ src ] = body;
				}
				
				$img.parent ().append ( cache[ src ] );
				$img.remove ();
				
				promises --;
				if ( promises <= 0 ) {
					callback ( $.html () );
				}
			} );
		} else {
			$img.parent ().append ( cache[ src ] );
			$img.remove ();
			
			promises --;
			if ( promises <= 0 ) {
				callback ( $.html () );
			}
		}
	} );
};

var InlineSVG = function InlineSVG ( req , html , callback ) {
	getSVGs ( req , html , function ( parsedHtml ) {
		return callback ( parsedHtml );
	} );
};

module.exports = InlineSVG;
{'fraction_non_alphanumeric': 0.18492871690427698, 'fraction_numerical': 0.001629327902240326, 'mean_word_length': 2.2146596858638743, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6006521', 'n_tokens_mistral': 1018, 'n_tokens_neox': 854, 'n_words': 208}