Neos Eel Helper package for hyphenating Text
This package is licensed under the MIT license, please view the LICENSE file.
Since automatic hyphenation support by browsers can be described as inconsistent at best and might lead to techincally correct but ugly results, this package provides an Eel helper, which can hyphenate text with soft-hyphens (
&:shy;) in a consistent and configurable manner.
The Eel helper calls a node.js CLI app, which uses the Hypher node module and hyphenation pattern files to do the initial hyphenation.
Once a word is hyphenated, the result is cached and the word will be served from the cache instead of calling the node.js app every time it occurs.
Install the package:
composer require punktde/neos-hyphenation
Install the node.js app and its dependencies:
Please make sure you have node.js (this app is tested on node.js 8.0.0 and newer) and npm installed.
Navigate to the
index.js file has its executability flag set:
cd Resources/Private/Library npm install #if necessary chmod +x index.js
Configure caching in your project:
You might specify a different cache backend and cache lifetime in the
The first page hit will be very slow, but once most of the long words are in the cache, it will be quite performant.
This package provides the Eel Helper
Hyphenation.hyphenateText(string <text>), which takes a string as an argument and returns a hyphenated version of this string.
Minimum word length and padding:
Users can configure a minimum padding at
Settings.yaml file. This is an offset which is applied from both ends of the word wherein no hyphenation can occur. Adjust this to ensure a nice and consistent look of the text, e.g. avoiding linebreaks after just one syllable which might look a bit silly in long words.
To save resources, the Eel Helper will only call hyphenation on words which are at least twice as long as the minimum padding, since only those are eligible for hyphenation in the first place.
The default value is
Language/pattern file used for hyphenation:
The pattern file can be specified in the
Resources/Private/Library/package.json file or by running
npm install --save <pattern file package> in the
Resources/Private/Library directory. Furthermore, it needs to be specified in the
index.js app in line 4:
var language = require('<language package name>'); //replace <language package name> with the "name" from the language package's package.json file
npm install in the Library directory afterwards.
The default language package is german.