Typography Filter
22 sites
Security covered
This module automatically improves the typography of your content using the JoliTypo PHP library. You can enable it as a text filter within your text formats to apply these improvements directly to your content.
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
- Go to your text filters configuration page (
admin/config/content/formats); - Edit or create a filter, check the "Improve typography" filter;
- 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);