<commit_before>function getNextParagraphId() {
  max = -1;
  paragraphs = jQuery('#article_body_ifr').contents().find('.article_comments');
  paragraphs.each(function(key, value) {
    value = jQuery(value).attr('data-macro-paragraph_id');
    if(value>max) max = parseInt(value);
  });
  return max+1;
}

function makeCommentable() {
  tinyMCE.activeEditor.focus();
  start = jQuery(tinyMCE.activeEditor.selection.getStart()).closest('p');
  end = jQuery(tinyMCE.activeEditor.selection.getEnd()).closest('p');

  //text = start.parent().children();
  text = jQuery('#article_body_ifr').contents().find('*');
  selection = text.slice(text.index(start), text.index(end)+1);

  hasTag = false;
  selection.each(function(key, value) {
    commentTag = jQuery(value).closest('.article_comments');
    if(commentTag.length) {
      commentTag.children().unwrap('<div class=\"article_comments\"/>');
      hasTag = true;
    }
  });

  if(!hasTag) {
    tags = start.siblings().add(start);
    tags = tags.slice(tags.index(start), tags.index(end)>=0?tags.index(end)+1:tags.index(start)+1);
    tags.wrapAll('<div class=\"macro article_comments\" data-macro=\"comment_paragraph_plugin/allow_comment\" data-macro-paragraph_id=\"'+getNextParagraphId()+'\"/>');

    contents = jQuery('#article_body_ifr').contents();
    lastP = contents.find('p.article_comments_last_paragraph');
    if(lastP.text().trim().length > 0) {
      lastP.removeClass('article_comments_last_paragraph');
    } else {
      lastP.remove();
    }
    lastDiv = contents.find('div.article_comments').last();
    if(lastDiv.next().length==0) {
      lastDiv.after("<p class='article_comments_last_paragraph'>&nbsp;</p>");
    }
  }
}
<commit_msg>Comments being created with all the paragraphs selected<commit_after>function makeCommentable() {
  paragraphsTxt=""
  jQuery('#article_body_ifr').contents().find('body').children('p').each(function( index ) {
      paragraphsTxt+='<p><div class="macro article_comments" data-macro="comment_paragraph_plugin/allow_comment" data-macro-paragraph_id="' + index + '">' + jQuery(this).html() + '</p></div>'
  });
  tinyMCE.activeEditor.setContent(paragraphsTxt)
}

{'fraction_non_alphanumeric': 0.1870967741935484, 'fraction_numerical': 0.003686635944700461, 'mean_word_length': 5.013850415512465, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '4225322', 'n_tokens_mistral': 701, 'n_tokens_neox': 692, 'n_words': 86}