timnarr / hyphenate
Hyphenate is a Statamic addon providing a modifier to hyphenate strings based on the TeX-Hyphenation algorithm provided by the org_heigl/hyphenator package.
Fund package maintenance!
www.buymeacoffee.com/TimGr
Requires
- org_heigl/hyphenator: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.15
README
Hyphenate is a Statamic addon providing a modifier to hyphenate strings based on the TeX-Hyphenation algorithm provided by the org_heigl/hyphenator package.
The Hyphenate modifier will output a “soft hyphen” using the HTML entity ­
. This entity marks wehre the browser should break if necessary.
Install via Composer
composer require timnarr/hyphenate
Usage
{{ title | hyphenate }}
Read more about Statamic modifiers here https://statamic.dev/modifiers
Example
Let's assume we have a multilang page and a heading title
, which holds "Hyphenation" in english and "Silbentrennung" in german.
We output title
in your antlers file and use the hyphenate
modifier like this:
<h1>{{ title | hyphenate }}</h1>
And the final HTML output is:
<h1>Silben­tren­nung</h1> <h1>Hyphen­a­tion</h1>
Note
Frequent use of the hyphenate
modifier, especially on long texts, can affect your page performance and slow down your website. Please use in combination with caching!
License
MIT License © 2023-present Tim Grochowski