Created
November 16, 2018 05:39
-
-
Save imnotashrimp/29943a47566c9adbd299e08a40e293bf to your computer and use it in GitHub Desktop.
Jekyll snippets
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
{%- 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