Skip to content

Instantly share code, notes, and snippets.

@dleatherman
Created November 1, 2021 17:04
Show Gist options
  • Save dleatherman/62cecf4c37a673ed92644a12437a4b13 to your computer and use it in GitHub Desktop.
Save dleatherman/62cecf4c37a673ed92644a12437a4b13 to your computer and use it in GitHub Desktop.
This replaces last space with a non-breaking to prevent widows in text.
{% if content %}{% assign no_widows = content | split: '' | reverse | join: '' | replace_first: ' ', ';psbn&' | split: '' | reverse | join: '' %}{{ no_widows }}{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment