typography_filter
20 sites
Security covered
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);