Merge 2 line in each paragraph in string of caption

Comments

2 comments

  • Rainer Grabowski
    var arr = (@Text +"\n").replace(/\n\n/g,"\n").split(/^\d\n/gm);
    result = [];
    cnt = 0;
    for(i = 1; i < arr.length; i++){
         arr2 = arr[i].split("\n")
         len = arr2.length
         if(len > 3){
             e = [];
             for(j = 0; j < arr2.length; j++){
                 if(j == 0){
                    e.push(i + "\n" + arr2[j] + "\n")
                } else {
                   e.push( arr2[j]);
                }
           }
           e = e.join("");
     } else {
           e = i + "\n" + arr[i];
      }
    result.push(e);
    }
    result.join("\n").replace(/\n/g,"\n\n")

    But be careful because of possible HTML tags or additional line breaks in the original text. That can destroy the result. 

    Rainer

    0
    Comment actions Permalink
  • Admin BVOT

    Thank you for your reply.

    My site dont work

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk