League\CommonMark\DocParser::resetContainer PHP Method

resetContainer() private method

Sets the container to the last open child (or its parent)
private resetContainer ( League\CommonMark\ContextInterface $context, Cursor $cursor )
$context League\CommonMark\ContextInterface
$cursor Cursor
    private function resetContainer(ContextInterface $context, Cursor $cursor)
    {
        $context->setContainer($context->getDocument());
        while ($context->getContainer()->hasChildren()) {
            $lastChild = $context->getContainer()->lastChild();
            if (!$lastChild->isOpen()) {
                break;
            }
            $context->setContainer($lastChild);
            if (!$context->getContainer()->matchesNextLine($cursor)) {
                $context->setContainer($context->getContainer()->parent());
                // back up to the last matching block
                break;
            }
        }
    }