You are here

public function XBBCodeFilter::process in Extensible BBCode 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::process()
  2. 4.0.x src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::process()

Performs the filter processing.

Parameters

string $text: The text string to be filtered.

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

Return value

\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.

Overrides FilterInterface::process

See also

\Drupal\filter\FilterProcessResult

File

src/Plugin/Filter/XBBCodeFilter.php, line 125
Contains Drupal\xbbcode\Plugin\Filter\XBBCodeFilter.

Class

XBBCodeFilter
Provides a filter that converts BBCode to HTML.

Namespace

Drupal\xbbcode\Plugin\Filter

Code

public function process($text, $langcode) {
  $tree = $this
    ->buildTree($text);
  $output = $this
    ->renderTree($tree->content);

  // The core AutoP filter breaks inline tags that span multiple paragraphs.
  // Since there is no advantage in using <p></p> tags, this filter uses
  // ordinary <br /> tags which are usable inside inline tags.
  if ($this->settings['linebreaks']) {
    $output = nl2br($output);
  }
  return new FilterProcessResult($output);
}