Resolves $content value.

@param  ContentSet $content
@param  array      $matches

@return mixed
8708
private function resolveContentSet(ContentSet $content, array $matches)
    {
        if ('ContentSet' === $matches[1]) {
            return $content->item($matches[3]);
        }

        $index = intval($matches[3]);
        $classname = AbstractClassContent::getFullClassname(str_replace('/', NAMESPACE_SEPARATOR, $matches[1]));

        foreach ($content as $subcontent) {
            if (get_class($subcontent) !== $classname) {
                continue;
            }

            if (0 === $index) {
                return $subcontent;
            }

            $index--;
        }

        return $content;
    }
951250
public static function cleanContent($content)
    {
        $content = self::stripControlCharacters($content);
        // remove Javascript
        $content = preg_replace('@<script[^>]*>.*?<\/script>@msi', '', $content);

        // remove internal CSS styles
        $content = preg_replace('@<style[^>]*>.*?<\/style>@msi', '', $content);

        // prevents concatenated words when stripping tags afterwards
        $content = str_replace(['<', '>'], [' <', '> '], $content);
        $content = static::stripTags($content);

        $content = str_replace(["\t", "\n", "\r", '&nbsp;'], ' ', $content);
        $content = self::stripUnicodeRanges($content);
        $content = preg_replace('/\s{2,}/', ' ', $content);
        $content = trim($content);

        return $content;
    }
440606
public function parse($content)
    {
        $this->parser
            ->setSafeMode(config('markdown.safe-mode', false))
            ->setUrlsLinked(config('markdown.urls', true))
            ->setMarkupEscaped(config('markdown.markups', true));

        if (config('markdown.xss', true)) {
            $content = preg_replace('/(\[.*\])\(javascript:.*\)/', '$1(#)', $content);
        }

        return $this->parser->text($content);
    }
195699
public function setContent($content)
    {
        $context = $this->_context;

        $context->content = (string)$content;

        return $this;
    }
1208135
public function createMissingValueSet(Content $content)
    {
        if ($content->getContentType() !== null && $content->getValueSet() === null)
        {
            $valueSet = new ValueSet();
            $this->em->persist($valueSet);

            $valueSet->setSchema($content->getContentType()->getSchema());
            $content->setValueSet($valueSet);

            $content = $this->save($content);
        }

        return $content;
    }
104853
public function contentTag($name, $content, array $options = array(), $escape = false)
    {
        if ($content instanceof \Closure) {
            ob_start();
            $tmpContent = $content();
            $content = ob_get_clean();
            if ($tmpContent !== null) {
                $content = $tmpContent;
                unset($tmpContent);
            }
        }
        return $this->_content_tag_string($name, $content, $options, $escape);
    }
469789
private function resetContent(Content $content, array $translatedContents)
    {
        foreach ($translatedContents as $lang => $translatedContent) {
            $this->updateTranslation($content, $translatedContent, $lang, true);
        }

        $this->updateTranslation($content, $translatedContents['en']);

        return $content;
    }
1188529
protected function _parseContent($content) {
        $output = array();
        $matches = array();
        $paramsString = implode('|', $this->_deployParams);
        $pattern = '/:?(?P<paramName>' . $paramsString
            . ')[,:]? [\'"](?P<paramValue>[^\'"]*)[\'"]/';

        if (!preg_match_all($pattern, $content, $matches)) {
            throw new Exception(
                "Could not extract deploy parameters from "
                . self::GENERIC_CONFIG_PATH
            );
        }

        foreach ($this->_deployParams as $p) {
            $indices = array_keys(
                array_filter(
                    $matches['paramName'], function ($pn) use ($p) {
                        return $pn === $p;
                    }
                )
            );
            if (!count($indices)) {
                continue;
            }
            $output[$p] = array_values(array_get_subset($matches['paramValue'], $indices));

            // For now: only treat the server param as array (since it's common for it to be an
            // array, in the case of a multi-server setup)
            if ($p !== 'server') {
                $output[$p] = $output[$p][0];
            }
        }

        // explode server into user and server parts
        if (!empty($output['server'])) {
            $output['server'] = array_map(
                function ($serverConfig) {
                    $bits = explode('@', $serverConfig, 2);
                    return array(
                    'user' => $bits[0],
                    'server' => $bits[1]
                    );
                }, $output['server']
            );
        }

        return $output;
    }
519785
protected function processUrlTag(string &$content): void
    {
        $pattern = $this->getTagPattern('url(\s+(.+?))?' . preg_quote($this->endTag, '/') . '(.+?)' . preg_quote($this->startTag . '/url', '/'));
        $content = preg_replace_callback($pattern, function ($match) {
            $matchName = $match[2];
            $matchPath = $match[3];
            $urlAsset = Application::$app->getService('urlAsset');
            if ($matchName == '') {
                return $urlAsset->getUrl($matchPath);
            } else {
                return $urlAsset->getUrl($matchPath, $matchName);
            }
        }, $content);
    }
560629
protected function detectFormatByContent($content)
    {
        if (preg_match('/^(\\{|\\[\\{).*(\\}|\\}\\])$/is', $content)) {
            return Client::FORMAT_JSON;
        }
        if (preg_match('/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/', $content)) {
            return Client::FORMAT_URLENCODED;
        }
        if (preg_match('/^<\?xml.*>$/s', $content)) {
            return Client::FORMAT_XML;
        }
        return null;
    }
1089875
public function closure($content = null)
    {
        $this->addNewToSequence("open");

        if (!empty($content)) {
            if ($content instanceof TokenSequencer) {
                $this->mergeSequence($content->getSequence());
            } elseif ($content instanceOf Token) {
                $this->addToSequence($content);
            } elseif (is_array($content)) {
                foreach ($content as $subContent) {
                    $this->addMixedContentToSequence($subContent);
                }
            } else {
                $this->val($content);
            }
        }

        $this->addNewToSequence("close");

        return $this;
    }
1226691
protected function getSelfMatchingValue(
        SimpleXMLElement $content,
        array $matches = [],
        ?string $alias = null
    ): array {
        $name = $matches[1];
        $key = $matches[2];
        $meta = $matches[3];

        $item = [];
        $uses = ($key == '@' ? $meta : "{$key},{$meta}");

        if (\is_null($alias)) {
            $alias = $name;
        }

        $collection = $this->getValue($content, \sprintf('%s[%s]', $name, $uses));

        foreach ((array) $collection as $collect) {
            $v = $collect[$meta];

            if ($key == '@') {
                $item[$alias][] = $v;
            } else {
                $item[$collect[$key]] = $v;
            }
        }

        return $item;
    }
1245078
protected function processPhpTag(string &$content): void
    {
        $pattern = $this->getTagPattern('php' . preg_quote($this->endTag, '/') . '(.+?)' . preg_quote($this->startTag . '/php', '/'));
        $content = preg_replace_callback($pattern, function ($match) {
            return '<?php ' . $match[1] . ' ?>';
        }, $content);
    }
148459
public function setContent($content)
    {
        if (!is_null($content)) {
            $content = (string) $content;
        }

        $this->content = $content;
        return $this;
    }
243126
static function FindContentGroup(Content $content)
    {
        $result = null;
        $currContent = $content;
        do
        {
            $result = $currContent->GetUserGroup();
            $currContent = ContentTreeUtil::ParentOf($currContent);
        } 
        while (!$result && $currContent);
        if ($result)
        {
            return $result;
        }
        return self::GetUpperContentGroup($content);
    }
1248738
protected function preProcessPostContent( $content ) {
		$content = apply_filters( 'the_content', $content );
		$content = str_ireplace( [ '<b></b>', '<i></i>', '<strong></strong>', '<em></em>' ], '', $content );
		$content = $this->fixAnnoyingCharacters( $content );
		$content = $this->tidy( $content );

		return $content;
	}
402354
public function fixString($content)
    {
        foreach ($this->_rules as $fixer) {
            $content = $fixer->fix($content, $this->stateBag);
        }

        return $content;
    }