League\CommonMark\Inline\Parser\BacktickParser::parse PHP Метод

parse() публичный Метод

public parse ( InlineParserContext $inlineContext ) : boolean
$inlineContext League\CommonMark\InlineParserContext
Результат boolean
    public function parse(InlineParserContext $inlineContext)
    {
        $cursor = $inlineContext->getCursor();
        $ticks = $cursor->match('/^`+/');
        if ($ticks === '') {
            return false;
        }
        $previousState = $cursor->saveState();
        while ($matchingTicks = $cursor->match('/`+/m')) {
            if ($matchingTicks === $ticks) {
                $code = mb_substr($cursor->getLine(), $previousState->getCurrentPosition(), $cursor->getPosition() - $previousState->getCurrentPosition() - strlen($ticks), 'utf-8');
                $c = preg_replace(RegexHelper::REGEX_WHITESPACE, ' ', $code);
                $inlineContext->getContainer()->appendChild(new Code(trim($c)));
                return true;
            }
        }
        // If we got here, we didn't match a closing backtick sequence
        $cursor->restoreState($previousState);
        $inlineContext->getContainer()->appendChild(new Text($ticks));
        return true;
    }