<commit_before>$(document).ready(function(){
  function split(val) {
    return val.split(/,\s*/);
  }

  function extractLast( term ) {
    return split(term).pop();
  }
 
  $('.tags-input')
  .autocomplete({
    source: function( request, response ) {
      response( $.ui.autocomplete.filter(
        availableTags, extractLast( request.term ) ) );
    },
    select: function(event,ui){
      var terms = split($('.tags-list').html());
      var lastInput = terms[terms.length-1];
      if (availableTags.indexOf(lastInput) === -1){ terms.pop(); }
      terms.push(ui.item.value);
      this.value = terms.join(",");
      $('.tags-list').html(this.value);
    }, 
    open: function() {
      $('.ui-menu').width('42%');
    }  
  });

});<commit_msg>Display tags list as blocks<commit_after>$(document).ready(function(){
 function split(val) {
    if (val){
      var arr = [];
      $.parseHTML(val).forEach(function(elem){
        arr.push($(elem).html());
      });
      return arr;
    } else {
      return val;
    }

  }

  function extract(val){
    return val.split(/,\s*/)
  }

  function extractLast( term ) {
    return extract(term).pop();
  }
  var divJoin = '</div><div class="tag">'
 
  $('.tags-input')
  .autocomplete({
    source: function( request, response ) {
      response( $.ui.autocomplete.filter(
        availableTags, extractLast( request.term ) ) );
    },
    select: function(event,ui){
      var terms = split($('.tags-list').html()) || []; 
      var lastInput = terms[terms.length-1];
      if (availableTags.indexOf(lastInput) === -1){
        terms.pop();
      }
      terms.push(ui.item.value);
      this.value = '<div class="tag">' + terms.join(divJoin) + '</div>';
      $('.tags-list').html(this.value);
    }, 
    open: function() {
      $('.ui-menu').width('42%');
    }  
  });

});
{'fraction_non_alphanumeric': 0.20631464344039194, 'fraction_numerical': 0.004354926510615134, 'mean_word_length': 2.541425818882466, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5880259', 'n_tokens_mistral': 608, 'n_tokens_neox': 589, 'n_words': 104}