<commit_before>.row
  .col-xs-12.col-sm-12
  h2.page-header
    | Logs
  '

  - if @log.is_a?(Hash)
      table.table.table-bordered
        thead
          tr
            th.col-xs-5.col-sm-4.col-md-3
              | Name
            th
              | Value
        tbody
         = render partial: 'endpoints/row', locals: {key: nil, content: @log, id: 1, parent_id: nil}
  - else
    p.h3
      | Error
    p.h4 = @log

javascript:
  $(function(){
    $(".table").treetable({ expandable: true });
    elements = $("tbody").children();
    elements.each(function () {
      if ($(this).attr('class').match(/branch/)) {
        id = $(this).attr('data-tt-id');
        if (id.match(/^\d+(_\d+){0,1}$/)) {
          $(".table").treetable('expandNode', id);
        }
      }
    });

    $("tr").each(function(i, element) {
      var tds = $(element).children('td');
      if (tds.length == 1) {
        return;
      }
      try {
        var json = JSON.stringify(JSON.parse(tds.eq(1).text()), null, "    ");
        if (json.match(/\{/)) {
          tds.eq(1).text('');
          tds.eq(1).append('<textarea class="form-control" rows="10" readonly>' + json + '</textarea>');
        }
      } catch (e) {
      }
    });
  });<commit_msg>support for the text of xml, tsv, csv and unexpected format<commit_after>.row
  .col-xs-12.col-sm-12
  h2.page-header
    | Logs
  '

  - if @log.is_a?(Hash)
      table.table.table-bordered
        thead
          tr
            th.col-xs-5.col-sm-4.col-md-3
              | Name
            th
              | Value
        tbody
         = render partial: 'endpoints/row', locals: {key: nil, content: @log, id: 1, parent_id: nil}
  - else
    p.h3
      | Error
    p.h4 = @log

javascript:
  $(function(){
    $(".table").treetable({ expandable: true });
    elements = $("tbody").children();
    elements.each(function () {
      if ($(this).attr('class').match(/branch/)) {
        id = $(this).attr('data-tt-id');
        if (id.match(/^\d+(_\d+){0,1}$/)) {
          $(".table").treetable('expandNode', id);
        }
      }
    });

    let JSON_REGEXP = /^[\{|\[](.*)\{|\[$/;
    let XML_REGEXP = /^<\?xml(.*)>/;
    $("tr td:first-child").each(function(i, bodyKey) {
      if (!$(bodyKey).text().match(/body/)) {
        return;
      }
      var formatText = "";
      try {
        var bodyValue = $(bodyKey).next();
        var text = bodyValue.text().trim();
        if (text.match(JSON_REGEXP)) {
          var json = JSON.stringify(JSON.parse(text), null, "    ");
          formatText = sanitize(json).replace(/[\n\r|\n|\r]/g, "<br/>").replace(/\t/, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\s/g, "&nbsp;");
        } else if (text.match(XML_REGEXP)) {
          var parser = new DOMParser();
          var xmlDocument = parser.parseFromString(text, "text/xml");
          var serializer = new XMLSerializer();
          var xml = serializer.serializeToString(xmlDocument);
          formatText = sanitize(xml).replace(/[\n\r|\n|\r]/g, "<br/>").replace(/\t/, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\s/g, "&nbsp;");
        } else {
          formatText = sanitize(text).replace(/[\n\r|\n|\r]/g, "<br/>").replace(/\t/, "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        bodyValue.empty().append('<p>' + formatText + '</p>');
      } catch (e) {
        formatText = sanitize(text).replace(/[\n\r|\n|\r]/g, "<br/>").replace(/\t/, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\s/g, "&nbsp;");
        bodyValue.empty().append('<p>' + formatText + '</p>');
      }
    });

    function sanitize(text) {
      return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
    }

  });
{'fraction_non_alphanumeric': 0.23183297180043383, 'fraction_numerical': 0.009219088937093275, 'mean_word_length': 2.001627339300244, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, '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': '4026039', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1287, 'n_words': 210}