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

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

public parse ( InlineParserContext $inlineContext ) : boolean
$inlineContext League\CommonMark\InlineParserContext
Результат boolean
    public function parse(InlineParserContext $inlineContext)
    {
        $inlineContext->getCursor()->advance();
        // Check previous inline for trailing spaces
        $spaces = 0;
        $lastInline = $inlineContext->getContainer()->lastChild();
        if ($lastInline && $lastInline instanceof Text) {
            $trimmed = rtrim($lastInline->getContent(), ' ');
            $spaces = strlen($lastInline->getContent()) - strlen($trimmed);
            if ($spaces) {
                $lastInline->setContent($trimmed);
            }
        }
        if ($spaces >= 2) {
            $inlineContext->getContainer()->appendChild(new Newline(Newline::HARDBREAK));
        } else {
            $inlineContext->getContainer()->appendChild(new Newline(Newline::SOFTBREAK));
        }
        return true;
    }