Find any virtual tags and render them

This function will pre-pend the tags to the content

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

        if($this->getTemplate()->decorator() == 'koowa') {
            $text = str_replace('<ktml:meta>', $meta, $text);
        } else  {
            $text = $meta.$text;
        }
    }
717085
public function filter(&$text)
    {
        $matches = array();
        if(preg_match_all('#<ktml:markdown>(.*)<\/ktml:markdown>#siU', $text, $matches))
        {
            $engine = $this->getObject('template.engine.factory')
                ->createEngine('markdown', array('template' => $this->getTemplate()));

            foreach($matches[1] as $key => $match)
            {
                $html = $engine->loadString($matches[1][$key])->render();
                $text = str_replace($matches[0][$key], $html, $text);
            }
        }
    }
725094
protected function parseUnicode($text)
	{
		if (strpos($text, "\xE2") === false && strpos($text, "\xEF") === false && strpos($text, "\xF0") === false)
		{
			return;
		}
		preg_match_all($this->unicodeRegexp, $text, $matches, PREG_OFFSET_CAPTURE);
		foreach ($matches[0] as list($emoji, $tagPos))
		{
			$this->addTag($tagPos, strlen($emoji), $this->getHexSequence($emoji));
		}
	}
1272664
public function parse(string $text) : string
    {
        if ($text === '')
            throw new ParseException($this, $text, 0, self::NO_EMPTY);
        return $text;
    }
711619
static function parse($text)
    {
        $parser = new \Parsedown();

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

        return $parser->text($text);
    }
738707
protected function parse($text) {
        // Build tree structure
        $in = array();
        for ($ptr=0,$len=strlen($text),$tree=array(),$node=&$tree,
            $stack=array(),$depth=0,$tmp='';$ptr<$len;)
            if (preg_match('/^@(end)?('.$this->tags.')\b(.*)/i', substr($text,$ptr),$match)) {
                $single = substr($match[3], strlen($match[3])-1)==='@';
                !$single || $match[3] = substr($match[3], 0, strlen($match[3])-1);
                if (strlen($tmp))
                    $node[] = $tmp;
                // Element node
                if ($match[1]) {
                    if ($in) {
                        // in element
                        for ($i=count($in)-1; $i > -1 ; --$i)
                            $in[$i][1] = array_pop($node);
                        $node['@in'] = $in;
                        $in = array();
                    }
                    // Find matching start tag
                    $save  = $depth;
                    $found = false;
                    while ($depth>0) {
                        $depth--;
                        foreach ($stack[$depth] as $item)
                            if (is_array($item) && isset($item[$match[2]])) {
                                // Start tag found
                                $found = true;
                                break 2;
                            }
                    }
                    if (!$found)
                        // Unbalanced tag
                        $depth = $save;
                    $node =& $stack[$depth];
                }
                elseif ($this->intag($match[2])) {
                    $in[] = array($match[2], '@attrib'=>$this->parseAttrib($match[3]), '');
                }
                else {
                    // Start tag
                    $stack[$depth]   =& $node;
                    $node            =& $node[][$match[2]];
                    $node['@attrib'] = $this->parseAttrib($match[3]);
                    if ($single)
                        // single
                        $node =& $stack[$depth];
                    else
                        $depth++;
                }
                $tmp = '';
                $ptr += strlen($match[0]);
            }
            else {
                // Text node
                $tmp .= substr($text,$ptr,1);
                $ptr++;
            }
        if (strlen($tmp))
            // Append trailing text
            $node[] = $tmp;
        // Break references
        unset($node, $stack);

        return $tree;
    }
708756
public function parseAttributes(string $text): array
    {
        $atts = [];
        $patterns = implode('|', [
            '([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)', // attribute="value"
            '([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)', // attribute='value'
            '([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)', // attribute=value
            '"([^"]*)"(?:\s|$)', // "attribute"
            '\'([^\']*)\'(?:\s|$)', // 'attribute'
            '(\S+)(?:\s|$)', // attribute
        ]);
        $pattern = "/{$patterns}/";
        $text = preg_replace("/[\x{00a0}\x{200b}]+/u", ' ', $text);
        if (preg_match_all($pattern, (string) $text, $match, PREG_SET_ORDER)) {

            // Reject any unclosed HTML elements
            foreach ($this->generateAttributes($match) as $att => $value) {
                if ($value !== true && strpos((string) $value, '<') !== false) {
                    if (preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', (string) $value) !== 1) {
                        $value = '';
                    }
                }
                $atts[$att] = $value;
            }
        }

        return $atts;
    }
411097
function &_getInlineTags($text)
    {
        $return = NULL;
        $tagStrings = preg_split('/{(@.+)}/sU', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        if ($tagStrings) {
            $inlineTags = NULL;
            $phpdoctor =& $this->_root->phpdoctor();
            foreach ($tagStrings as $tag) {
                if (substr($tag, 0, 1) == '@') {
                    $pos = strpos($tag, ' ');
                    if ($pos !== FALSE) {
                        $name = trim(substr($tag, 0, $pos));
                        $text = trim(substr($tag, $pos + 1));
                    } else {
                        $name = $tag;
                        $text = NULL;
                    }
                } else {
                    $name = '@text';
                    $text = $tag;
                }
                $data = NULL;
                $inlineTag =& $phpdoctor->createTag($name, $text, $data, $this->_root);
                $inlineTag->setParent($this->_parent);
                $inlineTags[] = $inlineTag;
            }
            $return =& $inlineTags;
        }

        return $return;
    }
632461
public function render($text)
    {
        $response = new ImageResponse('image/png');
        $response->send();

        $image = $this->generate($text);

        imagepng($image);
        imagedestroy($image);
    }
1094582
public function addRaw($text)
	{
		$this->response[] = array(
			'message' => $text
		);

		if ($this->isInteractive())
		{
			$this->render(true);
		}
	}
946915
public function embedTags(string $text): string
    {
        if (strpos($text, '#') !== false) {
            $text = strtr($text, $this->getTags($text));
        }

        return $text;
    }
124217
public function render($text)
    {
        $text = trim(str_replace(array("\r\n", "\r"), "\n", $text), "\n");

        foreach ($this->rules as $regex => $replacement) {
            if (is_callable($replacement)) {
                $text = preg_replace_callback($regex, $replacement, $text);
            } else {
                $text = preg_replace($regex, $replacement, $text);
            }
        }

        return trim($text);
    }
633509
private function _checkReplacements($text) {
		if ($this->_isActive('checkReplacements')) {
			$key = strtolower($text);
			if (array_key_exists($key, $this->_replacements)) {
				$msg = $this->_getMessage('REPLACED', $this->_replacements[$key]['old'], $this->_replacements[$key]['new']);
				$this->_writeError('checkReplacements', $msg);
			}
		}
	}
53510
public function filter(&$text)
    {
        $pattern = '~
            <ktml:(?:script|style) # match ktml:script and ktml:style tags
            [^(?:src=)]+           # anything before src=
            src="                  # match the link
              ((?:media://|assets://)           # starts with media:// or assets://
              (?:koowa/)?            # may or may not be in koowa/ folder
              (?:com_([^/]+)/|js/|css/|scss/) # either has package name (com_foo) or in framework
              [^"]+)"                # match the rest of the link
             (.*)/>
        ~siUx';

        // Hold a list of already processed URLs
        $processed = array();

        if(preg_match_all($pattern, $text, $matches, PREG_SET_ORDER))
        {
            foreach ($matches as $match)
            {
                $version = $this->_getVersion(!empty($match[2]) ? $match[2] : 'koowa');

                if ($version)
                {
                    $url = $match[1];

                    if (!in_array($url, $processed))
                    {
                        $processed[] = $url;

                        $version = substr(md5($version), 0, 8);
                        $suffix  = strpos($url, '?') === false ? '?'.$version : '&'.$version;
                        $text    = str_replace($url, $url.$suffix, $text);
                    }


                }
            }
        }
    }
660569
public function parse($text) {
        $this->text = $text;
        $this->checksumValue = false; // Reset checksumValue
        $this->validate();

        parent::parse($text);

        $this->addDefaultLabel();
    }
1066206
static function removeHtmlTag($text)
    {

        $text = htmlspecialchars_decode($text);
        $text = html_entity_decode($text);
        $text = strip_tags($text);
        return $text;

    }
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);
		
	}