src/constants/utils.js
/* Clean phrase of widowed words.
 * (avoid single word at last line.)
 */
Clean phrase of widowed words.
(avoid single word at last line.)
Clean phrase of widowed words . ( avoid single word at last line . )
function noWidows(phrase) {
  let words = phrase.trim().split(" ");
  if (words.length > 1) {
    const [last, penult] = words.slice(words.length - 2, words.length);
    words[words.length - 2] = `${penult}\u00a0${last}`;
    words[words.length - 2] = words[words.length - 2].replace(/\u00ad/g, "");
    words.pop();
  }
  return words.join(" ");
}
function noWidows ( phrase ) { let words = phrase . trim ( ) . split ( " " ) ; if ( words . length > 1 ) { const [ last , penult ] = words . slice ( words . length - 2 , words . length ) ; words [ words . length - 2 ] = ` ${ penult } \u00a0 ${ last } ` ; words [ words . length - 2 ] = words [ words . length - 2 ] . replace ( / \u00ad / g , "" ) ; words . pop ( ) ; } return words . join ( " " ) ; }
Clean phrase of widowed words.
Clean phrase of widowed words .
// Join the last two words with &nbsp; // remove soft-hyphen , if any // remove last word, since it was joined with a transparent space with the previous one.