Get excerpt from between excerpt tags or
first paragraph.

@param  string $content
@return string
437119
protected function getExcerpt($content)
    {
        // Check for excerpt tags
        $pattern = '#(\<\!\-\-\s?excerpt\s?\-\-\>)(.*)(\<\!\-\-\s?endexcerpt\s?\-\-\>)#si';
        if (preg_match($pattern, $content, $matches)) {
            return $matches[2];
        }

        // If all else get the content from the first paragraph
        return $this->description;
    }
1065433
public function parseJs($content)
    {
        $matches = $results = array();

        $pattern = '~[^\w]Gplcart\s*\.\s*text\s*\(\s*((?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+)\s*[,\)]~s';
        preg_match_all($pattern, $content, $matches);

        foreach ($matches[1] as $strings) {
            foreach ((array) $strings as $string) {
                $results[] = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($string, 1, -1)));
            }
        }

        return $results;
    }
1366128
private function detectMimeBySniffingContent(string $content): string
    {
        if (preg_match('/^\\{.*\\}$/is', $content)) {
            return 'application/json';
        }
        if (preg_match('/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/', $content)) {
            return 'application/x-www-form-urlencoded';
        }
        if (preg_match('/^<.*>$/s', $content)) {
            return 'text/xml';
        }

        return 'application/octet-stream';
    }
171683
public function tagElseif($tag, $content)
    {
        $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
        $condition = $this->parseCondition($condition);
        $parseStr  = '<?php elseif(' . $condition . '): ?>';

        return $parseStr;
    }
1267626
public function processContent(string $content): string
    {
        return Strings::replace($content, self::HEADLINE_PATTERN, function (array $result): string {
            $titleWithoutTags = strip_tags($result['title']);
            $headlineId = Strings::webalize($titleWithoutTags);
            $titleWithLink = Strings::match($result['title'], self::LINK_PATTERN);
            $titleHasLink = is_array($titleWithLink) ? count($titleWithLink) > 0 : false;

            // Title contains <a> element
            if ($result['title'] !== $titleWithoutTags && $titleHasLink) {
                return sprintf(
                    '<h%s id="%s">%s</h%s>',
                    $result['level'],
                    $headlineId,
                    $result['title'],
                    $result['level']
                );
            }

            return sprintf(
                '<h%s id="%s"><a href="#%s" class="heading-anchor">%s</a></h%s>',
                $result['level'],
                $headlineId,
                $headlineId,
                $result['title'],
                $result['level']
            );
        });
    }
903744
public function findPagesByContent($content)
    {
        $contentUids = array_merge($this->getContentsParentUids($content->getUid()), [$content->getUid()]);
        $contentUids = implode(', ', array_unique(array_map(function ($uid) {
            return '"'.$uid.'"';
        }, $contentUids)));

        $pageUids = $this->_em->getConnection()->executeQuery(
            sprintf('SELECT uid FROM page WHERE contentset IN (%s)', $contentUids)
        )->fetchAll(\PDO::FETCH_COLUMN);

        return $this->_em->createQueryBuilder('p')
            ->select('p')
            ->from('BackBee\NestedNode\Page', 'p')
            ->where('p._uid IN (:uids)')
            ->setParameter('uids', $pageUids)
            ->getQuery()
            ->getResult()
        ;
    }
1349698
public static function bb(&$content)
    {
        $content = preg_replace(array_flip(self::$_bbs), self::$_bbs, $content);

        return $content;
    }
1272176
public function parse($content)
	{
		$log = new Log;
		$description = [];
		$links = [];
		$matches = [];
		$bodyEnded = false;

		$line = current($content);
		while ($line !== false)
		{
			$line = ltrim($line);

			if (preg_match('/^#(?!#).+/', $line) === 1)
			{
				$log->setTitle($this->trimHashes($line));
			}
			elseif (preg_match('/^##(?!#).+/', $line) === 1)
			{
				$release = $this->parseRelease($content);
				$log->addRelease($release);
				$bodyEnded = true;
			}
			elseif (preg_match('/^\[(.+)\]: (.+)/', $line, $matches))
			{
				if (count($matches) >= 3)
				{
					$links[$matches[1]] = $matches[2];
				}
				$bodyEnded = true;
			}
			elseif ( ! $bodyEnded)
			{
				$description[] = $line;
			}

			$line = next($content);
		}

		$log->setDescription(implode("\n", $description));

		// Assign the releases their real links
		$this->assignLinks($log, $links);

		return $log;
	}
246386
public function escapeXmlContent($content)
    {
        if (is_object($content) || is_array($content)) {
            if (method_exists($content, 'getUuid')) {
                return $content->getUuid();
            }

            return 'ERROR: wrong data';
        }

        if (preg_match('/[<>{}"&]/', $content)) {
            $content = '<![CDATA[' . $content . ']]>';
        }

        return $content;
    }
387517
public function parse($content)
    {
        $processor = new Processor(new RegexParser(), $this->handlers);

        return $processor->process($content);
    }
687392
public function split( $content ) {

		if ( get_the_ID() === (int) $this->post_id ) {

			$content = str_replace( $this->original_media, '', $content );
			$content = wp_kses_post( $content );
		}

		return $content;
	}
519006
private function getContentData($content)
    {
        $res = [];
        $res['startStringPos'] = strpos($content, $this->startString) + strlen($this->startString);
        $res['endStringPos'] = strpos($content, $this->endString);
        $res['bundleList'] = substr($content, $res['startStringPos'], ($res['endStringPos'] - $res['startStringPos']));
        return $res;
    }
959930
public static function escapeAndMarkdown(?string $content): string
    {
        return $content ? C::getMarkdown()->text(Html::escape($content)) : (string) $content;
    }
917575
public function getNodes($content)
    {
        $items = array();
        $document = $this->createDocumentFromXML($content);
        $nodes = $document->getElementsByTagName('item');
        if ($nodes->length) {
            foreach ($nodes as $node) {
                try {
                    $item = $this->create($node);
                    $items[] = $item;
                } catch (\Exception $e) {
                    throw new RuntimeException($e->getMessage());
                }
            }
        }

        return $items;
    }
755869
public function parseLogBody($content)
    {
        $pattern      = "/^".self::STACK_TRACE_DIVIDER_PATTERN."/m";
        $parts        = array_map('ltrim', preg_split($pattern, $content));
        $context      = $parts[0];
        $stack_traces = (isset($parts[1])) ? $parts[1] : null;

        return compact('context', 'stack_traces');
    }
371636
public static function parseLines($content)
    {
        // Split by line
        $lines = explode("\n", $content);

        // Trim and convert to lowercase
        $lines = array_map('trim', $lines);
        $lines = array_map('strtolower', $lines);

        // Remove empty lines and comments
        $lines = array_filter($lines, function ($line) {
            return (0 === strlen($line) || '#' === $line[0]) ? false : $line;
        });

        return $lines;
    }
1014866
public function contentFormatter($content)
    {
        $new_content = '';
        $pattern_full = '{(\[raw\].*?\[/raw\])}is';
        $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
        $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

        foreach ($pieces as $piece) {
            if (preg_match($pattern_contents, $piece, $matches)) {
                $new_content .= $matches[1];
            } else {
                $new_content .= wpautop($piece);
            }
        }

        return $new_content;
    }