DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Configuration

Overview

To use the extension, the following steps are necessary:

  • Include the basic static template.
  • Create a pattern set in TYPO3, and fill it with patterns.
  • Use either the provided view helper or the stdWrap property to trigger hyphenation.
  • To make hyphenation work with CSS Styled Content, include the static template for your version of CSC. Include it after the static template from CSC.

Creating a pattern set

To create a pattern set, you first need a collection of hyphenation patterns. Currently only the pattern files from Hyphenator.js are supported. They may be downloaded here. Download the appropriate pattern set and save it to the fileadmin folder or some other storage.

Then go into the list module and create a new record of type "Hyphenation Patterns". It does not matter which page you use to store the record, as the storage PID is ignored for hyphenation patterns. The following options are available:

Field: Description:
Hide Hide this pattern set.
Name of pattern set The name of this pattern set - only used to make it easier for humans to identify.
Language The language this pattern set is for.
Additional word characters Additional characters that may make up a word. These characters are used to split up the texts to be hyphenated into words. The characters given here are merged with the characters given in the pattern file, if any (not all formats provide word characters). The characters "soft hyphen" (unicode 0xAD) and "zero width spacer" (unicode 0x200C) are always considered to be word characters.
Hyphen string The string to insert as a hyphen. You may use HTML entities here, they are replaced by their corresponding UTF8-characters in the output.
Minimal number of characters before first hyphen (lmin) Minimal number of characters that must occur before the first hyphen. This value may also be given in the pattern file. If it is given both in the record and the pattern file, the value from the record takes precedence.
Minimal number of characters after last hyphen (rmin) Same as lmin.
Hyphenation pattern file The file to read the hyphenation patterns from. Only files from Hyphenator.js (version >= 2.0.0) are supported at the moment.
Hyphenation pattern file format Format of the given pattern file. Determines which parse engine is used.

Applying hyphenation

There are two ways to apply hyphenation:

  • Use the stdWrap properties provided by this extension.
  • Use the view helper provided by this extension.

ViewHelper

The view helper is in the namespace NetzkoenigNkhyphenationViewHelpers, the namespace directive is this:

{namespace nk=Netzkoenig\Nkhyphenation\ViewHelpers}

After that, you may use the view helper like this:

<nk:hyphenate language="1">text to hyphenate</nk:hyphenate>

This view helper takes the following arguments:

Argument: Type: Description: Default:
language Integer The language of the text to be hyphenated. Is used to determine the pattern set that is used.
preserveHtmlTags Boolean Whether HTML tags should be preserved or not. true

stdWrap-Property

Generate the text you want to hyphenate, then stdWrap it with the hyphenation property defined. The following properties are available:

Property: Type: Description: Default:
hyphenate.language int/stdWrap Id of the language the input is in - used to determine the pattern set to use.  
hyphenate.preserveHtmlTags boolean/stdWrap Defines whether HTML tags should be respected or not. The value '1' signals to respect HTML tags, everything else makes the extension to disrespect them. 1 (preserve tags)
hyphenateBefore   Same as hyphenate, but applied as very first stdWrap processing step.  
hyphenateAfter   Same as hyphenate, but applied as very last stdWrap processing step (except debugging functions).  

Hyphenation for CSS Styled Content

There are static templates that enable hyphenation for CSS Styled Content. The used language is the language of the content element. Only the body texts of content elements are processed, the headlines are generally left alone.