Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Created December 19, 2022 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/a7cafb2eb67d402175e49185af6f100d to your computer and use it in GitHub Desktop.
Save nocodesupplyco/a7cafb2eb67d402175e49185af6f100d to your computer and use it in GitHub Desktop.
Fix Paragraph Runts With Nonbreaking Space
// Use or update ".no-runt" as the class that should be used on any element to fix runts within
$(".no-runt").each(function() {
var wordArray = $(this).text().split(" ");
if (wordArray.length > 1) {
wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1];
wordArray.pop();
$(this).html(wordArray.join(" "));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment