Replace <ktml:content> with the view content

@param string $text  The text to parse
@return void
3844
public function filter(&$text)
    {
        $matches = array();
        if(preg_match_all('#<ktml:content(.*)>#siU', $text, $matches))
        {
            foreach($matches[1] as $key => $match) {
                $text = str_replace($matches[0][$key], $this->getTemplate()->content(), $text);
            }
        }
    }
895829
public function setText(string $text): self
    {
        $text = trim($text);
        if ('' === $text) {
            throw new Exception('The text can not be empty');
        }

        $this->text = $text;

        return $this;
    }
275231
private function stripContent($text)
    {
        if ($this->convertBrToNewlines()) {
            $text = $this->brToNewline($text);
        }
        if ($this->stripTags()) {
            $text = strip_tags($text);
        }
        return $text;
    }
606074
protected function processIncludeTag(string &$content): void
    {
        $pattern = $this->getTagPattern('include\s+(.+?)');
        while (preg_match($pattern, $content) != 0) {
            $content = preg_replace_callback($pattern, function ($match) {
                $viewResult = new ViewResult($match[1]);
                return $viewResult->getTemplateSource();
            }, $content);
        }
    }
488820
private function parseLinks($text)
    {
        $offset = 0;
        $matches = array();
        // Extract all links from the text of the passage (if they exist)
        while (preg_match($this->links_pattern, $text, $matches, 0, $offset)) {
            switch ($matches[2]) {
                case '->':
                    $this->links[] = array('text' => trim($matches[1]), 'link' => trim($matches[3]));
                    $this->raw_links[] = $matches[0];
                    break;
                case '<-':
                case '|':
                    $this->links[] = array('text' => trim($matches[3]), 'link' => trim($matches[1]));
                    $this->raw_links[] = $matches[0];
                    break;
                default:
                    throw new \RuntimeException("Something that looked like a link could not be parsed.");
            }
            $offset = mb_stripos($text, $matches[0]) + mb_strlen($matches[0]);
        }
    }
889045
private function set_text($text)
    {
        if(!!$text)
        {
            if(!!$this->text)
            {
                if(!!is_array($this->text))
                {
                    $this->text[] = $text;
                }
                else
                {
                    $this->text = array($this->text,$text);
                }
            }
            else
            {
                $this->text = $text;
            }
        }

        return $this;
    }
98619
public function setText( $text ) {
    $this->textOriginal = $text;
    $this->text = preg_replace("/([^\w ]*)/iu", "", $text);
    return $this;
  }
440495
public function replaceAllInText($text)
    {
        $uriInfo = [];

        // Collects all µlink URIs present in the text and stores them
        // in an array keyed by their offset.
        foreach ($this->getURIPatterns() as $pattern) {
            $matches = [];

            if (preg_match_all($pattern, $text, $matches,  PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
                foreach ($matches as $match) {
                    list($uri, $offset) = $match[0];

                    $uriInfo[$offset] = [
                        'uri'   => $uri,
                        'type'  => $match['type'][0],
                        'id'    => $match['id'][0],
                    ];
                }
            }
        }

        // Sorts collected URIs by descending offset to start replacements
        // by the end of the text, ensuring in this way that the next offsets
        // will stay valid after each replacement.
        krsort($uriInfo);

        // Dispatches an event to allow some alterations of URIs information
        // before transform them in standard URLs.
        $event = new EntityLinkFilterEvent($uriInfo);
        $this->eventDispatcher->dispatch(EntityLinkFilterEvent::EVENT_BEFORE_FILTER, $event);

        // Replaces µlink URIs by standard URLs.
        foreach ($event->getURIInfo() as $offset => $info) {
            // Something inserted a new entry!?
            // Ok, just ignore it.
            if (!isset($uriInfo[$offset])) {
                continue;
            }
            // Something altered the original URI!?
            // Ok, just retrieve the text's version for the next.
            if ($info['uri'] !== $uriInfo[$offset]['uri']) {
                $info['uri'] = $uriInfo[$offset]['uri'];
            }

            try {
                $uri = url($this->getEntityPath($info['type'], $info['id']));
            } catch (\Exception $e) {
                $uri = '#'; // Silent fail for frontend
            }

            $text = substr_replace($text, $uri, $offset, strlen($info['uri']));
        }

        return $text;
    }
479417
protected function onSetText(string $text): void
    {
        parent::onSetText($text);

        $this->isInvalid = false;
        $this->value = null;

        if ($this->hasError()) {
            return;
        }

        if ($this->isEmpty()) {
            return;
        }

        try {
            $this->setValue(new \DateTimeImmutable($text));
        } catch (\Exception $exception) {
            $this->setError('Invalid value');
            $this->isInvalid = true;
        }
    }
88860
public function filter(&$text)
    {
        $text = str_replace(
            array_keys($this->_schemes),
            array_values($this->_schemes),
            $text);
    }
210577
protected function onFormatText(string &$text): void
    {
        $lines = preg_split("/\r\n|\n|\r/", $text);
        $result = [];

        $lastEmptyLinesCount = 0;
        $hasFoundNonEmptyLines = false;

        foreach ($lines as $line) {
            if (($this->textFormatOptions & TextFormatOptions::TRIM) !== 0) {
                $line = trim($line);
            }
            if (($this->textFormatOptions & TextFormatOptions::COMPACT) !== 0) {
                $line = preg_replace('/\s+/', ' ', $line);
            }

            if ($line === '') {
                if (($this->textFormatOptions & TextFormatOptions::COMPACT_LINES) !== 0 && $lastEmptyLinesCount > 0) {
                    continue;
                }
                if (($this->textFormatOptions & TextFormatOptions::TRIM_LINES) !== 0 && !$hasFoundNonEmptyLines) {
                    continue;
                }

                $lastEmptyLinesCount++;
            } else {
                $lastEmptyLinesCount = 0;
                $hasFoundNonEmptyLines = true;
            }

            $result[] = $line;
        }

        if (($this->textFormatOptions & TextFormatOptions::TRIM_LINES) !== 0 && $lastEmptyLinesCount > 0) {
            // Trim the last empty lines (we did not know until now that those were at the end).
            array_splice($result, -$lastEmptyLinesCount);
        }

        $text = implode("\r\n", $result);
    }
383981
public function heading($text) {
        $this->info('');
        $this->info('===================');
        $this->info($text);
        $this->info('===================');
        $this->info('');
    }
863490
private function tag_text($text)
	{
		if($this->current_tag instanceof Node_Container_Tag)
		{
			$accepted_children = $this->bbcodes[$this->current_tag->tag()]->accepted_children();

			if(!empty($accepted_children) && !in_array('text_node', $accepted_children))
				return;
		}

		$this->current_tag->add_child(new Node_Text($text));
	}
404636
public function setText($text)
	{
		if (!is_array($text) && !$text instanceof self) {
			$text = htmlspecialchars((string)$text, ENT_NOQUOTES, 'UTF-8');
		}

		return $this->setHtml($text);
	}
413013
public function modify(string $content, string $plainText = null)
    {
        $this->html = $content;
        $this->text = $plainText;
    }
1275934
public function seeInPageSource($text)
    {
        $this->assertThat(
            $this->webDriver->getPageSource(),
            new PageConstraint($text, $this->_getCurrentUri()),
            ''
        );
    }
368499
public function parse($text) {
        $this->setStartFromText($text);

        $this->text = '';
        $seq = '';

        $currentMode = $this->starting_text;

        // Here, we format correctly what the user gives.
        if (!is_array($text)) {
            $seq = $this->getSequence($text, $currentMode);
            $this->text = $text;
        } else {
            // This loop checks for UnknownText AND raises an exception if a character is not allowed in a table
            reset($text);
            while (list($key1, $val1) = each($text)) {     // We take each value
                if (!is_array($val1)) {                    // This is not a table
                    if (is_string($val1)) {                // If it's a string, parse as unknown
                        $seq .= $this->getSequence($val1, $currentMode);
                        $this->text .= $val1;
                    } else {
                        // it's the case of "array(ENCODING, 'text')"
                        // We got ENCODING in $val1, calling 'each' again will get 'text' in $val2
                        list($key2, $val2) = each($text);
                        $seq .= $this->{'setParse' . $this->METHOD[$val1]}($val2, $currentMode);
                        $this->text .= $val2;
                    }
                } else {                        // The method is specified
                    // $val1[0] = ENCODING
                    // $val1[1] = 'text'
                    $value = isset($val1[1]) ? $val1[1] : '';    // If data available
                    $seq .= $this->{'setParse' . $this->METHOD[$val1[0]]}($value, $currentMode);
                    $this->text .= $value;
                }
            }
        }

        if ($seq !== '') {
            $bitstream = $this->createBinaryStream($this->text, $seq);
            $this->setData($bitstream);
        }

        $this->addDefaultLabel();
    }