<commit_before>function replaceHtml(htmlString, hashObject) {
  const filesArray = Object.keys(hashObject)
  let newHtmlString = htmlString
  
  function replaceSrc(file) {
    const srcAttributeDblQuote = `src="${file}"`
    const srcAttributeSingQuote = `src='${file}'`
    const hash = hashObject[file]
    const classAttribute = `class='${hash}'`
    
    while (newHtmlString.includes(srcAttributeDblQuote)) {
      newHtmlString = newHtmlString.replace(srcAttributeDblQuote, classAttribute)  
    }
    while (newHtmlString.includes(srcAttributeSingQuote)) {
      newHtmlString = newHtmlString.replace(srcAttributeSingQuote, classAttribute)  
    }
  }
  
  filesArray.forEach(replaceSrc)
  
  return newHtmlString  
}

module.exports = replaceHtml<commit_msg>Convert replaceHtml from replace to cheerio<commit_after>const cheerio = require('cheerio')

function replaceHtml(htmlString, hashObject) {
  const filesArray = Object.keys(hashObject)
  const $ = cheerio.load(htmlString)
  
  function replaceSrc(file) {
    let $elemArray = $(`[src="${file}"]`)
    
    $elemArray.forEach(elem => {
      elem.removeAttr('src')
      elem.addClass(hashObject[file])
    })
    
    $elemArray = $(`[src='${file}']`)
    
    $elemArray.forEach(elem => {
      elem.removeAttr('src')
      elem.addClass(hashObject[file])
    })
  }
  
  filesArray.forEach(replaceSrc)
  
  return $.html()  
}

module.exports = replaceHtml
{'fraction_non_alphanumeric': 0.12421052631578948, 'fraction_numerical': 0.0, 'mean_word_length': 3.951388888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6909175', 'n_tokens_mistral': 445, 'n_tokens_neox': 438, 'n_words': 71}