You are here

public function EmptyParagraphKiller::prepare in Empty paragraph killer 8

Prepares the text for processing.

Filters should not use the prepare method for anything other than escaping, because that would short-circuit the control the user has over the order in which filters are applied.

Parameters

string $text: The text string to be filtered.

string $langcode: The language code of the text to be filtered.

Return value

string The prepared, escaped text.

Overrides FilterBase::prepare

File

src/Plugin/Filter/EmptyParagraphKiller.php, line 21

Class

EmptyParagraphKiller
Plugin annotation @Filter( id = "emptyparagraphkiller", title = @Translation("Empty Paragraph filter"), description = @Translation("When entering more than one carriage return, only the first will be honored."), type =…

Namespace

Drupal\emptyparagraphkiller\Plugin\Filter

Code

public function prepare($text, $langcode) {
  return preg_replace('#<p[^>]*>(\\s|&nbsp;?)*</p>#', '[empty-para]', $text);
}