Developed with love by KnpLabs Hire us for your project!
42

LiipHyphenatorBundle

by liip

Adds support for hyphenating long words using the Org_Heigl_Hyphenator library.

Introduction

Adds support for hyphenating long words using the Org_Heigl_Hyphenator library.

This bundle will add a Twig Extension for templates and a Hyphenator service.

Build Status

Installation

  1. Download the Bundle

    Open a command console, enter your project directory and execute the
    following command to download the latest stable version of this bundle:

    $ composer require liip/hyphenator-bundle
    

    This command requires you to have Composer installed globally, as explained
    in the installation chapter
    of the Composer documentation.

  2. Enable the Bundle

    Add the following line in the app/AppKernel.php file to enable this bundle only
    for the test environment:

    <?php
    // app/AppKernel.php
    
    // ...
    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            ..
    
            new Liip\HyphenatorBundle\LiipHyphenatorBundle(),
    
            return $bundles
        }
    
        // ...
    }
    
  3. Configure the bundle:

    The supported options for the Hyphenator with the defaults are:

    # app/config/config.yml
    liip_hyphenator:
        language: en
        hyphen: &shy;
        left_min: 2
        right_min: 2
        word_min: 6
        quality: highest # either the quality name, either the value of the constant
        no_hyphenate_string: ''
        custom_hyphen: --
        tokenizers: ['liip_hyphenator.tokenizer.whitespace', 'liip_hyphenator.tokenizer.puncuation']
        filters: ['liip_hyphenator.filter.simple']
    

    All settings are optional.

    For details about their meaning consult the Hyphenator library documentation.

Usage

This library adds a filter for twig templates that can be used like:

{{ "Somelongwordtohyphenate"|hyphenate }}

Alternatively the filter can be applied to an entire block:

{% filter hyphenate %}
...
Somelongwordtohyphenate
....
{% endfilter %}
Copyright (c) 2010-2011 Liip

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Merge pull request #8 from liip/update
    By lsmith77, 2 years ago
  • updated README and travis setup
    By lsmith77, 2 years ago
  • also test SF 2.3 and PHP 5.5
    By lsmith77, 3 years ago
  • updated composer and travis
    By lsmith77, 4 years ago
  • improved test bootstrap instructions
    By lsmith77, 4 years ago
  • also support symfony 2.2
    By lsmith77, 4 years ago
  • fixing composer
    By lsmith77, 4 years ago
  • added a composer.json
    By lsmith77, 4 years ago
  • fixed Configuration class
    By lsmith77, 5 years ago
  • Merge pull request #7 from dcastello/serviceproblem
    By fabian, 5 years ago
  • Updating WhitespaceTokenizer service
    By dcastello, 5 years ago
  • properly include twig in unit test setup
    By lsmith77, 5 years ago
  • ignore vendor dir for coverage
    By lsmith77, 5 years ago
  • adde code coverage
    By lsmith77, 5 years ago
  • made it possible to run the tests against a specific symfony version when testing locally
    By lsmith77, 5 years ago
  • fix colors support in the unit tests
    By lsmith77, 5 years ago
  • more test fixing
    By lsmith77, 5 years ago
  • fix tests
    By lsmith77, 5 years ago
  • s/Punktuation/Punctuation
    By lsmith77, 5 years ago
  • fix filter handling
    By lsmith77, 5 years ago
  • some more cleanups and support for tokenizer
    By lsmith77, 5 years ago
  • some more fixes for 2.0
    By lsmith77, 5 years ago
  • initial work to upgrade to hyphenator 2.0
    By lsmith77, 5 years ago
  • test against Symfony 2.0.6
    By lsmith77, 5 years ago
  • email notifciation
    By lsmith77, 5 years ago
  • travis tweaks
    By lsmith77, 5 years ago
  • add travis-ci status icon
    By lsmith77, 5 years ago
  • cosmetic tweaks
    By lsmith77, 5 years ago
  • minor tweak
    By lsmith77, 5 years ago
  • more travis-ci fixing
    By lsmith77, 5 years ago