private function incorporateLine(ContextInterface $context)
{
$cursor = new Cursor($context->getLine());
$context->getBlockCloser()->resetTip();
$context->setBlocksParsed(false);
$this->resetContainer($context, $cursor);
$context->getBlockCloser()->setLastMatchedContainer($context->getContainer());
// Check to see if we've hit 2nd blank line; if so break out of list:
if ($cursor->isBlank() && $context->getContainer()->endsWithBlankLine()) {
$this->breakOutOfLists($context, $context->getContainer());
}
$this->parseBlocks($context, $cursor);
// What remains at the offset is a text line. Add the text to the appropriate container.
// First check for a lazy paragraph continuation:
if ($this->isLazyParagraphContinuation($context, $cursor)) {
// lazy paragraph continuation
$context->getTip()->addLine($cursor->getRemainder());
return;
}
// not a lazy continuation
// finalize any blocks not matched
$context->getBlockCloser()->closeUnmatchedBlocks();
// Determine whether the last line is blank, updating parents as needed
$context->getContainer()->setLastLineBlank($cursor, $context->getLineNumber());
// Handle any remaining cursor contents
if ($context->getContainer()->isOpen()) {
$context->getContainer()->handleRemainingContents($context, $cursor);
} elseif (!$cursor->isBlank()) {
// Create paragraph container for line
$context->addBlock(new Paragraph());
$cursor->advanceToFirstNonSpace();
$context->getTip()->addLine($cursor->getRemainder());
}
}