<commit_before>  // Install library in application.
  // see main-window-func.js, addLibraryToApp

  // 0. Read the index file to manipulate it
  var indexPath = APP_SETTINGS.getIndexFileFullPath(path)
  var html = FILEUTIL.readFileSync(indexPath)
  var scriptPath = `libs/${lib}/${lib}.js`
  var cssPath = `libs/${lib}/${lib}.css`

  // 1. Remove any existing reference in index.html
  cher = CHEERIO.load(html, { xmlMode: false })
  var element = cher('script').filter(function(i, el) {
        return cher(this).attr('src') === scriptPath
  })
  if (element.length > 0) {
    element.remove()
  }
  var element = cher('link').filter(function(i, el) {
        return cher(this).attr('href') === cssPath
  })
  if (element.length > 0) {
    element.remove()
  }

  // 2. Add a reference in index.html right before </body>
  // Note that we can't use <script blabla /> - it will fail
  cher('body').append(`
  <link rel="stylesheet" href="${cssPath}">
  <script src="${scriptPath}"></script>
`)

  // 3. Write index.html file back to disk
  FILEUTIL.writeFileSync(indexPath, cher.html())
  LOGGER.log("Added " + lib + " to " + path)<commit_msg>Moved MDL css to head<commit_after>  // Install library in application.
  // see main-window-func.js, addLibraryToApp

  // 0. Read the index file to manipulate it
  var indexPath = APP_SETTINGS.getIndexFileFullPath(path)
  var html = FILEUTIL.readFileSync(indexPath)
  var scriptPath = `libs/${lib}/${lib}.js`
  var cssPath = `libs/${lib}/${lib}.css`

  // 1. Remove any existing reference in index.html
  cher = CHEERIO.load(html, { xmlMode: false })
  var element = cher('script').filter(function(i, el) {
        return cher(this).attr('src') === scriptPath
  })
  if (element.length > 0) {
    element.remove()
  }
  var element = cher('link').filter(function(i, el) {
        return cher(this).attr('href') === cssPath
  })
  if (element.length > 0) {
    element.remove()
  }

  // 2. Add a reference in index.html right before </body>
  // Note that we can't use <script blabla /> - it will fail
  cher('head').append(`
  <link rel="stylesheet" href="${cssPath}">
`)
  cher('body').append(`
  <script src="${scriptPath}"></script>
`)

  // 3. Write index.html file back to disk
  FILEUTIL.writeFileSync(indexPath, cher.html())
  LOGGER.log("Added " + lib + " to " + path)
{'fraction_non_alphanumeric': 0.16659492036160137, 'fraction_numerical': 0.005165733964700818, 'mean_word_length': 3.352059925093633, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '4469562', 'n_tokens_mistral': 791, 'n_tokens_neox': 763, 'n_words': 202}