_filter_autop example

// Bug 3097338, paragraphs were appearing around drupalmedia tags.       '<drupal-media data-caption=" " data-entity-type="media" data-entity-uuid="dbb16f97-cd11-4357-acde-cd09e19e312b"></drupal-media>' => [
        '<p><drupal-media data-caption=" " data-entity-type="media" data-entity-uuid="dbb16f97-cd11-4357-acde-cd09e19e312b"></drupal-media></p>' => FALSE,
      ],
    ];
    // cSpell:enable     $this->assertFilteredString($filter$tests);

    // Very long string hitting PCRE limits.     $limit = max(ini_get('pcre.backtrack_limit')ini_get('pcre.recursion_limit'));
    $source = $this->randomMachineName($limit);
    $result = _filter_autop($source);
    $this->assertEquals($result, '<p>' . $source . "</p>\n", 'Line break filter can process very long strings.');
  }

  /** * Tests filter settings, defaults, access restrictions and similar. * * @todo This is for functions like filter_filter and check_markup, whose * functionality is not completely focused on filtering. Some ideas: * restricting formats according to user permissions, proper cache * handling, defaults -- allowed tags/attributes/protocols. * * @todo It is possible to add script, iframe etc. to allowed tags, but this * makes HTML filter completely ineffective. * * @todo Class, id, name and xmlns should be added to the list of forbidden * attributes, or, better yet, use an allowed attribute list. */

class FilterAutoP extends FilterBase {

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    return new FilterProcessResult(_filter_autop($text));
  }

  /** * {@inheritdoc} */
  public function tips($long = FALSE) {
    if ($long) {
      return $this->t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple of blank lines.');
    }
    else {
      return $this->t('Lines and paragraphs break automatically.');
    }
Home | Imprint | This part of the site doesn't use cookies.