Last active
September 7, 2017 15:09
-
-
Save willbroderick/390d8a9f733609fef1a135687cfa0ea2 to your computer and use it in GitHub Desktop.
Prevent a line-break before the last word in a passage of text, to aid typography
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This will turn "I eat lots of poached eggs" into "I eat lots of poached eggs" | |
* | |
* So this: | |
* | I eat lots of poached | | |
* | eggs | |
* | |
* Becomes: | |
* | I eat lots of | | |
* | poached eggs | | |
*/ | |
$('.menu a').each(function(){ | |
var text = $(this).text(); | |
text = text.replace(/([^\s]{1,8}) ([^\s]{1,16})$/, '$1 $2'); | |
$(this).text(text); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment