You are here

public function XBBCodeParser::parse in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Parser/XBBCodeParser.php \Drupal\xbbcode\Parser\XBBCodeParser::parse()

Parse a text and build an element tree.

Parameters

string $text: The source text.

Return value

\Drupal\xbbcode\Parser\Tree\NodeElementInterface The element representing the root of the tree.

Overrides ParserInterface::parse

File

src/Parser/XBBCodeParser.php, line 37

Class

XBBCodeParser
The standard XBBCode parser.

Namespace

Drupal\xbbcode\Parser

Code

public function parse(string $text) : NodeElementInterface {
  $tokens = static::tokenize($text, $this->processors);
  $tokens = static::validateTokens($tokens);
  $tree = static::buildTree($text, $tokens);
  if ($this->processors) {
    static::decorateTree($tree, $this->processors);
  }
  return $tree;
}