parisek / twig-typography
A Twig extension with typography filter
Installs: 1 686
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- mundschenk-at/php-typography: ^6.0
- symfony/yaml: ^5.0 || ^6.0 || ^7.0
- twig/twig: ^2.4 || ^3.0
README
Uses PHP-Typography library and exposes it as Twig Extension. See class-settings.php for possible options.
- Hyphenation — over 50 languages supported
- Space control, including:
- widow protection
- gluing values to units
- forced internal wrapping of long URLs & email addresses
- Intelligent character replacement, including smart handling of:
- quote marks (‘single’, “double”)
- dashes ( – )
- ellipses (…)
- trademarks, copyright & service marks (™ ©)
- math symbols (5×5×5=53)
- fractions (1⁄16)
- ordinal suffixes (1st, 2nd)
- CSS hooks for styling:
- ampersands,
- uppercase words,
- numbers,
- initial quotes & guillemets.
Installation
Twig Typography Extension can be easily installed using composer
composer require parisek/twig-typography
Usage
$twig = new Twig_Environment($loader); $twig->addExtension(new Parisek\Twig\TypographyExtension(__DIR__ . '/typography.yml'));
Template
{{ title|typography }}
<h1>{{ "Lorem Ipsum"|typography }}</h1>
{{ title|typography({'set_dewidow': FALSE}) }}
{% typography %} <h1>Lorem Ipsum</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ullamcorper semper nunc, a hendrerit leo auctor ultricies. </p> {% endtypography %}