Skip to content

Instantly share code, notes, and snippets.

@imnotashrimp
Created November 16, 2018 05:39
Show Gist options
  • Save imnotashrimp/29943a47566c9adbd299e08a40e293bf to your computer and use it in GitHub Desktop.
Save imnotashrimp/29943a47566c9adbd299e08a40e293bf to your computer and use it in GitHub Desktop.
Jekyll snippets
{%- comment -%}
* This file goes in your Jekyll _includes/ folder. It prevents orphan words
* by replacing the last space in the string with a non-breaking space.
*
* Usage:
* Pass `str` (a string) to this include. Returns the string with last space
* replaced with ` `.
*
* Example:
* {%- include prevent_orphan_words.html str="You can call me Al." -%}
* Results in:
* "You can call me Al."
* {%- endcomment -%}
{{- include.str
| split: ""
| reverse
| join: ""
| replace_first: " ", ";psbn&"
| split: ""
| reverse
-}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment