<commit_before>function convertDiff(name, table) {
  var ths = table.tHead.rows[0].cells;
  var lines = [
    "Index: " + name,
    "===================================================================",
    "--- " + ths[0].title,
    "+++ " + ths[1].title,
  ];
  var sepIndex = 0;
  var oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;

  for (var i = 0; i < table.tBodies.length; i++) {
    var tBody = table.tBodies[i];
    if (i == 0 || tBody.className == "skipped") {
      if (i > 0) {
        if (!oldOffset && oldLength) oldOffset = 1
        if (!newOffset && newLength) newOffset = 1
        lines[sepIndex] = lines[sepIndex]
          .replace("{1}", oldOffset).replace("{2}", oldLength)
          .replace("{3}", newOffset).replace("{4}", newLength);
      }
      sepIndex = lines.length;
      lines.push("@@ -{1},{2}, +{3},{4} @@");
      oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
      if (tBody.className == "skipped") continue;
    }
    for (var j = 0; j < tBody.rows.length; j++) {
      var cells = tBody.rows[j].cells;
      var oldLineNo = parseInt($(cells[0]).text());
      var newLineNo = parseInt($(cells[1]).text());
      var line = $(cells[2]).text();
      if (isNaN(oldLineNo)) {
        lines.push("+ " + line);
        newLength += 1;
      } else if (isNaN(newLineNo)) {
        lines.push("- " + line);
        oldLength += 1;
      } else {
        lines.push("  " + line);
        oldLength += 1;
        newLength += 1;
        if (!oldOffset) oldOffset = oldLineNo;
        if (!newOffset) newOffset = newLineNo;
      }
    }
  }

  if (!oldOffset && oldLength) oldOffset = 1
  if (!newOffset && newLength) newOffset = 1
  lines[sepIndex] = lines[sepIndex]
    .replace("{1}", oldOffset).replace("{2}", oldLength)
    .replace("{3}", newOffset).replace("{4}", newLength);

  return lines.join("\n");
}

$(document).ready(function() {
  $("div.diff h2").each(function() {
    var switcher = $("<span class='switch'></span>").prependTo(this);
    var name = $.trim($(this).text());
    var table = $(this).next().get(0);
    var pre = $("<pre></pre>").hide().insertAfter(table);
    $("<span>Tabular</span>").click(function() {
      $(pre).hide();
      $(table).show();
      $(this).addClass("active").siblings("span").removeClass("active");
      return false;
    }).addClass("active").appendTo(switcher);
    $("<span>Unified</span>").click(function() {<commit_msg>fix Unified diff display for side-by-side diffs (fixes #4754)<commit_after>function convertDiff(name, table) {
  var inline = table.className == 'inline';
  var ths = table.tHead.rows[0].cells;
  var lines = [
    "Index: " + name,
    "===================================================================",
    "--- " + (inline ? ths[0].title : $(ths[0]).find('a').text()),
    "+++ " + (inline ? ths[1].title : $(ths[1]).find('a').text()),
  ];
  var sepIndex = 0;
  var oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;

  for (var i = 0; i < table.tBodies.length; i++) {
    var tBody = table.tBodies[i];
    if (i == 0 || tBody.className == "skipped") {
      if (i > 0) {
        if (!oldOffset && oldLength) oldOffset = 1
        if (!newOffset && newLength) newOffset = 1
        lines[sepIndex] = lines[sepIndex]
          .replace("{1}", oldOffset).replace("{2}", oldLength)
          .replace("{3}", newOffset).replace("{4}", newLength);
      }
      sepIndex = lines.length;
      lines.push("@@ -{1},{2}, +{3},{4} @@");
      oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
      if (tBody.className == "skipped") continue;
    }
    var tmpLines = [];
    for (var j = 0; j < tBody.rows.length; j++) {
      var cells = tBody.rows[j].cells;
      var oldLineNo = parseInt($(cells[0]).text());
      var newLineNo = parseInt($(cells[inline ? 1 : 2]).text());
      if (tBody.className == 'unmod') {
        lines.push("  " + $(cells[inline ? 2 : 1]).text());
        oldLength += 1;
        newLength += 1;
        if (!oldOffset) oldOffset = oldLineNo;
        if (!newOffset) newOffset = newLineNo;
      } else {
        var oldLine;
        var newLine;
        if (inline) {
          oldLine = newLine = $(cells[2]).text();
        } else {
          oldLine = $(cells[1]).text();
          newLine = $(cells[3]).text();
        }
        if (!isNaN(oldLineNo)) {
          lines.push("- " + oldLine);
          oldLength += 1;
        }
        if (!isNaN(newLineNo)) {
          tmpLines.push("+ " + newLine);
          newLength += 1;
        }
      }
    }
    if (tmpLines.length > 0) {
      lines = lines.concat(tmpLines);
    }
  }

  if (!oldOffset && oldLength) oldOffset = 1
  if (!newOffset && newLength) newOffset = 1
  lines[sepIndex] = lines[sepIndex]
    .replace("{1}", oldOffset).replace("{2}", oldLength)
    .replace("{3}", newOffset).replace("{4}", newLength);

  return lines.join("\n");
}

$(document).ready(function() {
  $("div.diff h2").each(function() {
    var switcher = $("<span class='switch'></span>").prependTo(this);
    var name = $.trim($(this).text());
    var table = $(this).next().get(0);
    var pre = $("<pre></pre>").hide().insertAfter(table);
    $("<span>Tabular</span>").click(function() {
      $(pre).hide();
      $(table).show();
      $(this).addClass("active").siblings("span").removeClass("active");
      return false;
    }).addClass("active").appendTo(switcher);
    $("<span>Unified</span>").click(function() {
{'fraction_non_alphanumeric': 0.23072687224669602, 'fraction_numerical': 0.01725403817914831, 'mean_word_length': 2.7068027210884353, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, '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': '2309877', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1805, 'n_words': 376}