heimrichhannot/contao-hyphenator-bundle

Word-Hyphenation for the contao content-management-system.

1.11.4 2023-09-06 14:00 UTC

README

A contao bundle that grants server-side hyphenation (thanks to vanderlee/phpSyllable). It does support headlines and paragraphs by default.

This module also handles line break exceptions, in order to keep words like company names together and prevent line break (see tl_page backend entity).

Options

To extend the functionality, all options can be adjusted within your localconfig.

Skip hyphenation

If you want to skip several tags from hyphenation simply add hyphen-none as css-class to the appropriate element or use the tl_page.hyphenation field.

You also can add tags to be skipped to your project configuration. See configuration reference below

Configuration reference

# Default configuration for extension with alias: "huh_hyphenator"
huh_hyphenator:
  
  # Add tags you want to be skipped from hyphenating, to array (string without <>)
  skip_tags: []

Line break exceptions

Hyphenator comes with line break exception handling. Simply add lineBreakExceptions on tl_page and prevent line break for connected word groups like:

  • Company Names (search: Heimrich & Hannot(?:\sGmbH)|Heimrich & Hannot(?:s)?, will be replaced to: <span class="text-nowrap">Heimrich&nbsp;&amp;&nbsp;Hannot&nbsp;GmbH</span>)
  • Prices and other units (search: (\d|€)(\s)(\w), replace: $1[nbsp]$3, Example: 160.000 m² -> 160.00<span class="text-nowrap">0&nbsp;m</span>², 167 Mio. € -> 16<span class="text-nowrap">7&nbsp;M</span>io.&nbsp;€)

As you can see, if you provide an replace pattern, than an regular expression will handle the replacement, otherwise if only an search pattern is provided, spaces will be protected with &nbsp;.

Requirements