<commit_before>var fs = require('fs');
var cheerio = require('cheerio');
var file = process.argv[2];

fs.readFile(file, function processTemplates (err, contents) {
  $ = cheerio.load(contents, {
          xmlMode: true
        });

  //function to replace element, keeping innerHtml & attributes
  function replaceEl (selector, newTag) {
    selector.each(function(){
      var myAttr = $(this).attr();
      var myHtml = $(this).html();
      $(this).replaceWith(function(){
          return $(newTag).html(myHtml).attr(myAttr);
      });
    });
  }

  //selections
  var ems = $("span[class='spanitaliccharactersital']");
  var strongs = $("span[class='spanboldfacecharactersbf']");
  var sups = $("span[class='spansuperscriptcharacterssup']");
  var subs = $("span[class='spansubscriptcharacterssub']");
  var scitals = $("span[class='spansmcapitalscital']"); 
  var scbolds = $("span[class='spansmcapboldscbold']");
  var italbems = $("span[class='spanbolditalbem']");
  //call replaceEl to replace selected span elements with formatting tags
  replaceEl (ems, "<em/>");
  replaceEl (strongs, "<strong/>");
  replaceEl (sups, "<sup/>");
  replaceEl (subs, "<sub/>");
  //these two spans require nested tags, wrapping existing span (wth appropriate class) with new tag
  scitals.each(function(){
    $(this).wrap("<em/>");
  });
  scbolds.each(function(){
    $(this).wrap("<strong/>");
  });
  //this span requires an element be replaced and wrapped, same function as above + this.wrap
  italbems.each(function(){
    var myAttr = $(this).attr();
    var myHtml = $(this).html();
    $(this).wrap("<strong/>");
    $(this).replaceWith(function(){
        return $("<em/>").html(myHtml).attr(myAttr);
    });
  });

  // support for inline images
  $('span.Illustrationholderinlineilli').each(function () {
    var mytext = $(this).text().trim();
    var el = $('<img class="illustrationholderinlineilli" src="images/' + mytext + '"></img>');
    $(this).empty();
    $(this).append(el);
  });

  var output = $.html();
    fs.writeFile(file, output, function(err) {
	    if(err) {
	        return console.log(err);
	    }

      console.log("Processing instructions have been evaluated!");
	});
});<commit_msg>adjusting img src syntax<commit_after>var fs = require('fs');
var cheerio = require('cheerio');
var file = process.argv[2];

fs.readFile(file, function processTemplates (err, contents) {
  $ = cheerio.load(contents, {
          xmlMode: true
        });

  //function to replace element, keeping innerHtml & attributes
  function replaceEl (selector, newTag) {
    selector.each(function(){
      var myAttr = $(this).attr();
      var myHtml = $(this).html();
      $(this).replaceWith(function(){
          return $(newTag).html(myHtml).attr(myAttr);
      });
    });
  }

  //selections
  var ems = $("span[class='spanitaliccharactersital']");
  var strongs = $("span[class='spanboldfacecharactersbf']");
  var sups = $("span[class='spansuperscriptcharacterssup']");
  var subs = $("span[class='spansubscriptcharacterssub']");
  var scitals = $("span[class='spansmcapitalscital']"); 
  var scbolds = $("span[class='spansmcapboldscbold']");
  var italbems = $("span[class='spanbolditalbem']");
  //call replaceEl to replace selected span elements with formatting tags
  replaceEl (ems, "<em/>");
  replaceEl (strongs, "<strong/>");
  replaceEl (sups, "<sup/>");
  replaceEl (subs, "<sub/>");
  //these two spans require nested tags, wrapping existing span (wth appropriate class) with new tag
  scitals.each(function(){
    $(this).wrap("<em/>");
  });
  scbolds.each(function(){
    $(this).wrap("<strong/>");
  });
  //this span requires an element be replaced and wrapped, same function as above + this.wrap
  italbems.each(function(){
    var myAttr = $(this).attr();
    var myHtml = $(this).html();
    $(this).wrap("<strong/>");
    $(this).replaceWith(function(){
        return $("<em/>").html(myHtml).attr(myAttr);
    });
  });

  // support for inline images
  $('span.Illustrationholderinlineilli').each(function () {
    var mytext = $(this).text().trim();
    var el = $('<img src="images/' + mytext + '"></img>');
    $(this).empty();
    $(this).append(el);
  });

  var output = $.html();
    fs.writeFile(file, output, function(err) {
	    if(err) {
	        return console.log(err);
	    }

      console.log("Processing instructions have been evaluated!");
	});
});
{'fraction_non_alphanumeric': 0.19232515894641236, 'fraction_numerical': 0.00045413260672116256, 'mean_word_length': 3.782844733984799, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '781369', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1364, 'n_words': 316}