<?phpdeclare(strict_types=1);
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/namespaceLeague\CommonMark\Extension\CommonMark\Parser\Block;
useLeague\CommonMark\Node\Block\Paragraph;
useLeague\CommonMark\Parser\Block\BlockStart;
useLeague\CommonMark\Parser\Block\BlockStartParserInterface;
useLeague\CommonMark\Parser\Cursor;
useLeague\CommonMark\Parser\MarkdownParserStateInterface;
finalclassIndentedCodeStartParserimplementsBlockStartParserInterface{
publicfunctiontryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart{
if (! $cursor->isIndented()) {
returnBlockStart::none();
}
if ($parserState->getActiveBlockParser()->getBlock() instanceof Paragraph) {
returnBlockStart::none();
}
if ($cursor->isBlank()) {
returnBlockStart::none();
}
$cursor->advanceBy(Cursor::INDENT_LEVEL, true);
returnBlockStart::of(newIndentedCodeParser())->at($cursor);
}
}