Find any virtual tags and render them

This function will pre-pend the tags to the content

@param string $text  The text to parse
488143
public function filter(&$text)
    {
        $scripts = $this->_parseTags($text);

        if($this->getTemplate()->decorator() == 'koowa') {
            $text = str_replace('<ktml:script>', $scripts, $text);
        } else  {
            $text = $scripts.$text;
        }
    }
601336
public function parse($text) {
        $this->text = $text;

        $data = array();
        $indcheck = array();

        $c = strlen($this->text);
        for ($i = 0; $i < $c; $i++) {
            $pos = array_search($this->text[$i], $this->keys);
            if ($pos === false) {
                // Search in extended?
                $extended = self::getExtendedVersion($this->text[$i]);
                if ($extended === false) {
                    throw new CINParseException('code93', 'The character \'' . $this->text[$i] . '\' is not allowed.');
                } else {
                    $extc = strlen($extended);
                    for ($j = 0; $j < $extc; $j++) {
                        $v = $extended[$j];
                        if ($v === '$') {
                            $indcheck[] = self::EXTENDED_1;
                            $data[] = $this->code[self::EXTENDED_1];
                        } elseif ($v === '%') {
                            $indcheck[] = self::EXTENDED_2;
                            $data[] = $this->code[self::EXTENDED_2];
                        } elseif ($v === '/') {
                            $indcheck[] = self::EXTENDED_3;
                            $data[] = $this->code[self::EXTENDED_3];
                        } elseif ($v === '+') {
                            $indcheck[] = self::EXTENDED_4;
                            $data[] = $this->code[self::EXTENDED_4];
                        } else {
                            $pos2 = array_search($v, $this->keys);
                            $indcheck[] = $pos2;
                            $data[] = $this->code[$pos2];
                        }
                    }
                }
            } else {
                $indcheck[] = $pos;
                $data[] = $this->code[$pos];
            }
        }

        $this->setData(array($indcheck, $data));
        $this->addDefaultLabel();
    }
631447
public function loadModelFromText($text)
    {
        $cfg = Config::newConfigFromText($text);

        $this->loadSection($cfg, 'r');
        $this->loadSection($cfg, 'p');
        $this->loadSection($cfg, 'e');
        $this->loadSection($cfg, 'm');

        $this->loadSection($cfg, 'g');
    }
332447
public function addText(string $text)
    {
        $contentConfig = [
            'text' => $text
        ];

        $contentItem = new ContentItem($contentConfig);

        $this->contentItems->addContentItemToCollection($contentItem);
    }
1124867
public function render($text)
    {
        $text = $this->config->onStart($text);

        $linesIterator = new \ArrayIterator(preg_split("/\015\012|\015|\012/", $text)); // we split the text at all line feeds
        $this->documentGenerator->clear();
        $this->errors = array();

        while ($linesIterator->valid()) {
            $line = $linesIterator->current();
            if ($line != '') {
                $blockGen = $this->parseBlock($linesIterator, $line, null);
                if (is_object($blockGen)) {
                    $this->documentGenerator->addBlock($blockGen);
                    continue;
                }
            }
            // no block found, we use a default block
            if (trim($line) == '') {
                $blockGenerator = new Generator\SingleLineBlock($this->documentGenerator->getConfig());
            } else {
                $inline = $this->inlineParser->parse($line);
                $blockGenerator = $this->documentGenerator->getDefaultBlock($inline);
                if (!$blockGenerator) {
                    $blockGenerator = new Generator\SingleLineBlock($this->documentGenerator->getConfig());
                    $blockGenerator->setLineAsString($inline);
                }
            }
            $this->documentGenerator->addBlock($blockGenerator);
            $this->nextLine($linesIterator);
        }

        $result = $this->documentGenerator->generate();

        if ($this->documentGenerator->getConfig()->generateHeaderFooter) {
            $result = $this->documentGenerator->generateHeader()
                     .$result
                     .$this->documentGenerator->generateFooter();
        }

        return $this->config->onParse($result);
    }
1118395
public function format($text)
    {
        preg_match_all(self::REGEX_PLACEHOLDER, $text, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            $uid = (int)$match[1];
            //meh, fix the following lines late
            $parent = $this->findParentFromDataUid($uid);
            $el = $this->findItemFromUid($uid);
            $node = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceNode')
                ->findOneBy(
                    array(
                        'parent' => $parent,
                        'name' => $el['name'],
                        'resourceType' => $this->resourceManager->getResourceTypeByName($el['type'])
                    )
                );

            if ($node) {
                $toReplace = $this->generateDisplayedUrlForTinyMce($node);
                $text = str_replace($match[0], $toReplace, $text);
            }
        }

        $event = $this->eventDispatcher->dispatch(
            'rich_text_format_event_import',
            'RichTextFormat',
            array($text)
        );

        return $event->getText();
    }
841591
public function addText($text)
    {
        $currentDescription = $this->project->getDescription();
        if ($currentDescription === null) {
            $this->project->setDescription($text);
        } else {
            $this->project->setDescription($currentDescription . $text);
        }
    }
114968
private function tag_get_name(string $text){
    if (
      ($this->mode === 'js') ||
      ($this->mode === 'vue')
    ){
      //preg_match('/\w+/', $text, $name, PREG_OFFSET_CAPTURE);
      preg_match('/[[:graph:]]+/', $text, $name, PREG_OFFSET_CAPTURE);
    }
    else if ( $this->mode === 'php' ){
      preg_match('/\$[a-z]+/', $text, $name, PREG_OFFSET_CAPTURE);
    }
    return $name;
  }
711619
static function parse($text)
    {
        $parser = new \Parsedown();

        $text = static::cleanLeadingSpace($text);

        return $parser->text($text);
    }
1209446
protected function parse_markdown( $text ) {
		static $markdown = null;

		if ( null === $markdown ) {
			$markdown = new Parsedown();
		}

		return $markdown->text( $text );
	}
113531
protected function _renderInlineTag($string)
    {
        $string = $this->engine->inlineParser->parse($string);
        // handling of carriage-returns inside paragraphs
        $string = (!$this->_firstLine) ? " $string" : $string;
        $this->_firstLine = false;
        return ($string);
    }
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]);
        }
    }
1053146
private function parse_tag(string $text){
		$res = [];
		$text = $this->clear_text($text);
		$tag_end = strpos($text, ' ');
		if ( $tag_end !== false ){
			// Get tag
			$res['tag'] = substr($text, 1, $tag_end - 1);
			if ( in_array($res['tag'], array_keys($this->tags)) ){
        if (
          $this->tag_has_text($res['tag']) &&
          ($text = substr($text, $tag_end + 1))
        ){
          $res['text'] = $this->clear_text($text);
        }
				else {
					// Get type
					if (
            $this->tag_has_type($res['tag']) &&
            ($type = $this->tag_get_type($text)) &&
            !empty($type[1])
          ){
						$res['type'] = $type[1][0];
					}
					// Get default value
					if (
            $this->tag_has_default($res['tag']) &&
            ($def = $this->tag_get_default($text)) &&
            !empty($def[1])
          ){
						$res['default'] = $def[1][0];
					}
					// Get name
					if ( isset($def[1]) ){
						$n = $def[0][1] + strlen($def[0][0]) + 1;
					}
					else if ( isset($type[1]) ){
						$n = $type[0][1] + strlen($type[0][0]) + 1;
					}
					else {
						$n = $tag_end + 1;
					}
					if (
            $this->tag_has_name($res['tag']) &&
						($name = $this->tag_get_name(substr($text, $n)))
					){
						$res['name'] = $this->clear_text($name[0][0]);
					}
					// Get description
					if ( isset($name[0]) ){
						$d = $n + $name[0][1] + strlen($name[0][0]) + 1;
					}
					else if ( isset($type[1]) ){
						$d = $type[0][1] + strlen($type[0][0]) + 1;
					}
          else {
						$d = $tag_end + 1;
					}
					if (
            $this->tag_has_desc($res['tag']) &&
            ($desc = substr($text, $d))
          ){
						$res['description'] = $this->clear_text($desc);
					}
				}

				return $res;
			}
		}
		return false;
	}
542611
protected function frame($text)
    {
        $line   = '+'.str_repeat('-', strlen($text) + 4).'+';
        $this->info($line);
        $this->info("|  $text  |");
        $this->info($line);
    }
853507
protected function parseShortnames($text)
	{
		$matchPos = strpos($text, ':');
		if ($matchPos === false)
		{
			return;
		}
		preg_match_all($this->shortnameRegexp, $text, $matches, PREG_OFFSET_CAPTURE, $matchPos);
		foreach ($matches[0] as list($alias, $tagPos))
		{
			$alias .= ':';
			$tagLen = strlen($alias);
			if (isset($this->parser->registeredVars['Emoji.aliases'][$alias]))
			{
				$hex = $this->getHexSequence($this->parser->registeredVars['Emoji.aliases'][$alias]);
				$this->addTag($tagPos, $tagLen, $hex);
			}
			elseif (preg_match('/^:[0-3][0-9a-f]{3,4}(?:-[0-9a-f]{4,5})*:$/', $alias))
			{
				$this->addTag($tagPos, $tagLen, substr($alias, 1, -1));
			}
		}
	}
586851
public static function parse($text) {
		
		self::setLineEndings();
		
		// set-up defaults
		$yaml     = array();
		$markdown = "";
		
		// read in the content
		// based on: https://github.com/mnapoli/FrontYAML/blob/master/src/Parser.php
		$lines = explode(PHP_EOL, $text);
		
		if (count($lines) <= 1) {
			$markdown = self::convertMarkdown($text);
			return array($yaml,$markdown);
		}
		
		if (rtrim($lines[0]) !== '---') {
			$markdown = self::convertMarkdown($text);
			return array($yaml,$markdown);
		}
		
		$head = array();
		unset($lines[0]);
		$i = 1;
		foreach ($lines as $line) {
			if ($line === '---') {
				break;
			}
			$head[] = $line;
			$i++;
		}
		
		$head = implode(PHP_EOL, $head);
		$body = implode(PHP_EOL, array_slice($lines, $i));
		
		$yaml     = self::convertYAML($head);
		$markdown = self::convertMarkdown($body);
		
		return array($yaml,$markdown);
		
	}
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);
            }
        }
    }