Note that you can add your own customized filter in a custom module : as an example, this could look like this to remove empty paragraphs :
<?php
namespace Drupal\your_module\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Drupal\filter\Annotation\Filter;
use Drupal\Core\Annotation\Translation;
/**
* Class FilterEmptyParagraphs
* @Filter(
* id = "filter_empty_paragraphs",
* title = @Translation("Filter empty paragraphs"),
* description = @Translation("Removes empty paragraphs."),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
* )
* @package Drupal\your_module\Plugin\Filter
*/
class FilterEmptyParagraphs extends FilterBase
{
/**
* Performs the filter processing.
*
* @param string $text
* The text string to be filtered.
* @param string $langcode
* The language code of the text to be filtered.
*
* @return \Drupal\filter\FilterProcessResult
* The filtered text, wrapped in a FilterProcessResult object, and possibly
* with associated assets, cacheability metadata and placeholders.
*
* @see \Drupal\filter\FilterProcessResult
*/
public function process($text, $langcode)
{
$regex = '@<p([^>]*)>\s*\n*\t*( )*\s*\n*\t*</p>@igm';
$text = preg_replace($regex, '', $text);
return new FilterProcessResult($text);
}
}
(regex not tested)
<p>
tag ... – Rubenxfd Oct 11 '17 at 15:03