Overview

Text filter to automatically improve typography of your content. It relies on the JoliTypo PHP library.

How to use

As a filter in editor

  1. Go to your text filters configuration page (admin/config/content/formats);
  2. Edit or create a filter, check the "Improve typography" filter;
  3. Enable necessary filter types and save the configuration.

As a service

To process HTML content:

// Parameters: only $content is required, other parameters have default values.
$content = '<div>Some <p>text</p></div>';
$rules = ['CurlyQuote', 'Dash'];
$locale = 'en';
$protected_tags = '<p>';
// Process.
$result = \Drupal::service('typography_filter.manager')->fix($content, $rules, $locale, $protected_tags);

To process non-HTML content:

// Parameters: only $content is required, $rules parameter has default value.
$content = 'Some text';
$rules = ['CurlyQuote', 'Dash'];
// Process.
$result = \Drupal::service('typography_filter.manager')->fixString($content, $rules);
Supporting organizations: 
paid contribution time (up to version 8.x-1.0)

Project information

Releases