function reflowText (text, width, gfm) {
      // Hard break was inserted by Renderer.prototype.br or is
      // <br /> when gfm is true
      var splitRe = gfm ? HARD_RETURN_GFM_RE : HARD_RETURN_RE,
          sections = text.split(splitRe),
          reflowed = [];
    
      sections.forEach(function (section) {
        var words = section.split(/[ \t\n]+/),
            column = 0,
            nextText = '';
    
        words.forEach(function (word) {
          var addOne = column != 0;
          if ((column + textLength(word) + addOne) > width) {
            nextText += '\n';
            column = 0;
          } else if (addOne) {
            nextText += " ";
            column += 1;
          }
          nextText += word;
          column += textLength(word);
        });
        reflowed.push(nextText);
      });
      return reflowed.join('\n');
    }
function reflowText (text, width, gfm) {
      // Hard break was inserted by Renderer.prototype.br or is
      // <br /> when gfm is true
      var splitRe = gfm ? HARD_RETURN_GFM_RE : HARD_RETURN_RE,
          sections = text.split(splitRe),
          reflowed = [];
    
      sections.forEach(function (section) {
        var words = section.split(/[ \t\n]+/),
            column = 0,
            nextText = '';
    
        words.forEach(function (word) {
          var addOne = column != 0;
          if ((column + textLength(word) + addOne) > width) {
            nextText += '\n';
            column = 0;
          } else if (addOne) {
            nextText += " ";
            column += 1;
          }
          nextText += word;
          column += textLength(word);
        });
        reflowed.push(nextText);
      });
      return reflowed.join('\n');
    }
function reflowText ( text , width , gfm ) { // Hard break was inserted by Renderer.prototype.br or is // <br /> when gfm is true var splitRe = gfm ? HARD_RETURN_GFM_RE : HARD_RETURN_RE , sections = text . split ( splitRe ) , reflowed = [ ] ; sections . forEach ( function ( section ) { var words = section . split ( / [ \t\n]+ / ) , column = 0 , nextText = '' ; words . forEach ( function ( word ) { var addOne = column != 0 ; if ( ( column + textLength ( word ) + addOne ) > width ) { nextText += '\n' ; column = 0 ; } else if ( addOne ) { nextText += " " ; column += 1 ; } nextText += word ; column += textLength ( word ) ; } ) ; reflowed . push ( nextText ) ; } ) ; return reflowed . join ( '\n' ) ; }
Munge \n's and spaces in "text" so that the number of characters between \n's is less than or equal to "width".
Munge \ n s and spaces in text so that the number of characters between \ n s is less than or equal to width .