Hanging Conjunctions Filter Guide

Last updated on
15 June 2019

Problem/Motivation

Dangling conjunctions, also known as orphans, are a typographical error in the Polish language. They are single-letter words left at the end of a line. This rule applies to, for example, conjunctions and prepositions.

Functionality

This module provides a text filter that moves dangling conjunctions from the end of each line. It contains its own set of words specific for Polish typography. It automatically adds a non-breaking space to the text where necessary.

This module skip ignore tags (a|script|style|code|pre) and add a non-breaking space to the text where necessary. No attributes are processed.

Configuration

  1. Go to 'Text formats and editors' on the page '/admin/config/content/formats'.
  2. Add a new text format or edit an existing one.
  3. In the chosen text format, select the 'Hanging Conjunctions Filter' option.
  4. Change its order on the list. It should be after other filters that need to be processed before.
  5. Click on the 'Save configuration' button.

Notice: The Hanging Conjunctions Filter should be triggered after the 'Correct faulty and chopped off HTML' or 'No Non-breaking Space Filter' if they are selected.

API and extending a module

By default this filter is only for Polish language. Allows to add terms for any languages.

/**
 * Add terms for any languages.
 *
 * @param array $terms
 *   An associated array of key langcode and array of terms.
 */
function hook_hanging_conjunction_filter_terms_alter(array &$terms) {
  // Add an additional terms for the Polish language.
  array_push($terms['pl'], 'xyz');

  // Add terms for the Czech language.
  $terms['cs'] = [
    '[a-z]',
  ];
}

Help improve this page

Page status: No known problems

You can: